File indexing completed on 2024-05-12 03:50:16

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org>
0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
0005 // SPDX-FileCopyrightText: 2008-2009 Patrick Spendrin <ps_ml@gmx.de>
0006 //
0007 
0008 
0009 #ifndef MARBLE_GEODATAPLACEMARK_H
0010 #define MARBLE_GEODATAPLACEMARK_H
0011 
0012 
0013 #include <QDateTime>
0014 
0015 #include "GeoDataCoordinates.h"
0016 #include "GeoDataFeature.h"
0017 
0018 #include "geodata_export.h"
0019 
0020 class QXmlStreamWriter;
0021 
0022 namespace Marble
0023 {
0024 
0025 class GeoDataPlacemarkPrivate;
0026 class OsmPlacemarkData;
0027 class GeoDataLookAt;
0028 class GeoDataPolygon;
0029 class GeoDataGeometry;
0030 
0031 /**
0032  * @short a class representing a point of interest on the map
0033  *
0034  * This class represents a point of interest, e.g. a city or a
0035  * mountain.  It is filled with data by the KML or GPX loader and the
0036  * PlacemarkModel makes use of it.
0037  *
0038  * A Placemark can have an associated geometry which will be rendered to the map
0039  * along with the placemark's point icon. If you would like to render more than
0040  * one geometry for any one placemark than use @see setGeometry() to set add a
0041  * @see MultiGeometry.
0042  *
0043  * This is more or less only a GeoDataFeature with a geographic
0044  * position and a country code attached to it.  The country code is
0045  * not provided in a KML file.
0046  */
0047 
0048 class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature
0049 {
0050  public:
0051     /**
0052      * Create a new placemark.
0053      */
0054     GeoDataPlacemark();
0055 
0056     /**
0057      * Create a new placemark from existing placemark @p placemark
0058      */
0059     GeoDataPlacemark( const GeoDataPlacemark& placemark );
0060 
0061     /**
0062      * Create a new placemark with the given @p name.
0063      */
0064     explicit GeoDataPlacemark( const QString &name );
0065 
0066     /**
0067     * Delete the placemark
0068     */
0069     ~GeoDataPlacemark() override;
0070 
0071     GeoDataPlacemark &operator=( const GeoDataPlacemark &other );
0072 
0073     /**
0074     * Equality operators.
0075     */
0076     bool operator==( const GeoDataPlacemark& other ) const;
0077     bool operator!=( const GeoDataPlacemark& other ) const;
0078 
0079     const char* nodeType() const override;
0080 
0081     GeoDataFeature * clone() const override;
0082 
0083     /**
0084      * @brief  A categorization of a placemark as defined by ...FIXME.
0085      * There is an additional osm tag mapping to GeoDataVisualCategory
0086      * in OsmPlacemarkData
0087      */
0088     enum GeoDataVisualCategory {
0089         None,
0090         Default,
0091         Unknown,
0092 
0093         // The order of the cities needs to stay fixed as the
0094         // algorithms rely on that.
0095         SmallCity,
0096         SmallCountyCapital,
0097         SmallStateCapital,
0098         SmallNationCapital,
0099         MediumCity,
0100         MediumCountyCapital,
0101         MediumStateCapital,
0102         MediumNationCapital,
0103         BigCity,
0104         BigCountyCapital,
0105         BigStateCapital,
0106         BigNationCapital,
0107         LargeCity,
0108         LargeCountyCapital,
0109         LargeStateCapital,
0110         LargeNationCapital,
0111         Nation,
0112 
0113         // Terrain
0114         Mountain,
0115         Volcano,
0116         Mons,                    // m
0117         Valley,                  // v
0118         Continent,
0119         Ocean,
0120         OtherTerrain,            // o
0121 
0122         // Space Terrain
0123         Crater,                  // c
0124         Mare,                    // a
0125 
0126         // Places of Interest
0127         GeographicPole,
0128         MagneticPole,
0129         ShipWreck,
0130         AirPort,
0131         Observatory,
0132 
0133         // Military
0134         MilitaryDangerArea,
0135 
0136         // Runners
0137         OsmSite,
0138         Coordinate,
0139 
0140         // Planets
0141         MannedLandingSite,       // h
0142         RoboticRover,            // r
0143         UnmannedSoftLandingSite, // u
0144         UnmannedHardLandingSite, // i
0145 
0146         Bookmark,
0147 
0148         Satellite,
0149 
0150         /*
0151          * Start of OpenStreetMap categories
0152          */
0153 
0154         PlaceCity, // please keep order (used in for loops)
0155         PlaceCityCapital,
0156         PlaceCityNationalCapital,
0157         PlaceSuburb,
0158         PlaceHamlet,
0159         PlaceLocality,
0160         PlaceTown,
0161         PlaceTownCapital,
0162         PlaceTownNationalCapital,
0163         PlaceVillage,
0164         PlaceVillageCapital,
0165         PlaceVillageNationalCapital, // please keep order (used in for loops)
0166 
0167         NaturalWater,
0168         NaturalReef,
0169         NaturalWood,
0170         NaturalBeach,
0171         NaturalWetland,
0172         NaturalGlacier,
0173         NaturalIceShelf,
0174         NaturalScrub,
0175         NaturalCliff,
0176         NaturalHeath,
0177 
0178         HighwayTrafficSignals,
0179         HighwayElevator,
0180 
0181         // OpenStreetMap highways
0182         HighwaySteps, // please keep order (used in for loops)
0183         HighwayUnknown,
0184         HighwayPath,
0185         HighwayFootway,
0186         HighwayTrack,
0187         HighwayPedestrian,
0188         HighwayCorridor,
0189         HighwayCycleway,
0190         HighwayService,
0191         HighwayRoad,
0192         HighwayResidential,
0193         HighwayLivingStreet,
0194         HighwayUnclassified,
0195         HighwayTertiaryLink,
0196         HighwayTertiary,
0197         HighwaySecondaryLink,
0198         HighwaySecondary,
0199         HighwayPrimaryLink,
0200         HighwayPrimary,
0201         HighwayRaceway,
0202         HighwayTrunkLink,
0203         HighwayTrunk,
0204         HighwayMotorwayLink,
0205         HighwayMotorway, // please keep order (used in for loops)
0206 
0207         //OSM building
0208         Building,
0209 
0210         // OpenStreetMap category Accommodation
0211         AccomodationCamping,
0212         AccomodationHostel,
0213         AccomodationHotel,
0214         AccomodationMotel,
0215         AccomodationYouthHostel,
0216         AccomodationGuestHouse,
0217 
0218         // OpenStreetMap category Education
0219         EducationCollege,
0220         EducationSchool,
0221         EducationUniversity,
0222 
0223         // OpenStreetMap category Food
0224         FoodBar,
0225         FoodBiergarten,
0226         FoodCafe,
0227         FoodFastFood,
0228         FoodPub,
0229         FoodRestaurant,
0230 
0231         // OpenStreetMap category Health
0232         HealthDentist,
0233         HealthDoctors,
0234         HealthHospital,
0235         HealthPharmacy,
0236         HealthVeterinary,
0237 
0238         // OpenStreetMap category Money
0239         MoneyAtm,
0240         MoneyBank,
0241 
0242         // OpenStreetMap category Amenity
0243         AmenityLibrary,
0244         AmenityKindergarten, ///< @since 0.26.0
0245         AmenityEmbassy,
0246         AmenityEmergencyPhone,
0247         AmenityMountainRescue,
0248         AmenityCommunityCentre,
0249         AmenityCinema,
0250         AmenityFountain,
0251         AmenityNightClub,
0252         AmenityBench,
0253         AmenityCourtHouse,
0254         AmenityFireStation,
0255         AmenityHuntingStand,
0256         AmenityPolice,
0257         AmenityPostBox,
0258         AmenityPostOffice,
0259         AmenityPrison,
0260         AmenityRecycling,
0261         AmenityShelter, ///< @since 0.26.0
0262         AmenityTelephone,
0263         AmenityTheatre,
0264         AmenityToilets,
0265         AmenityTownHall,
0266         AmenityWasteBasket,
0267         AmenityDrinkingWater,
0268         AmenityGraveyard,
0269         AmenityChargingStation,
0270         AmenityCarWash,
0271         AmenitySocialFacility,
0272 
0273         // OpenStreetMap category Barrier
0274         BarrierCityWall,
0275         BarrierGate,
0276         BarrierLiftGate,
0277         BarrierWall,
0278 
0279         NaturalPeak,
0280         NaturalVolcano,
0281         NaturalTree,
0282         NaturalCave,
0283 
0284         // OpenStreetMap category Shopping
0285         ShopBeverages, // please keep order (used in for loops)
0286         ShopHifi,
0287         ShopSupermarket,
0288         ShopAlcohol,
0289         ShopBakery,
0290         ShopButcher,
0291         ShopConfectionery,
0292         ShopConvenience,
0293         ShopGreengrocer,
0294         ShopSeafood,
0295         ShopDepartmentStore,
0296         ShopKiosk,
0297         ShopBag,
0298         ShopClothes,
0299         ShopFashion,
0300         ShopJewelry,
0301         ShopShoes,
0302         ShopVarietyStore,
0303         ShopBeauty,
0304         ShopChemist,
0305         ShopCosmetics,
0306         ShopHairdresser,
0307         ShopOptician,
0308         ShopPerfumery,
0309         ShopDoitYourself,
0310         ShopFlorist,
0311         ShopHardware,
0312         ShopFurniture,
0313         ShopElectronics,
0314         ShopMobilePhone,
0315         ShopBicycle,
0316         ShopCar,
0317         ShopCarRepair,
0318         ShopCarParts,
0319         ShopMotorcycle,
0320         ShopOutdoor,
0321         ShopSports,
0322         ShopCopy,
0323         ShopArt,
0324         ShopMusicalInstrument,
0325         ShopPhoto,
0326         ShopBook,
0327         ShopGift,
0328         ShopStationery,
0329         ShopLaundry,
0330         ShopPet,
0331         ShopToys,
0332         ShopTravelAgency,
0333         ShopDeli,
0334         ShopTobacco,
0335         ShopTea,
0336         ShopComputer,
0337         ShopGardenCentre,
0338         Shop, // please keep order (used in for loops)
0339 
0340         ManmadeBridge,
0341         ManmadeLighthouse,
0342         ManmadePier,
0343         ManmadeWaterTower,
0344         ManmadeWindMill,
0345         ManmadeCommunicationsTower,
0346 
0347         // OpenStreetMap category Tourist
0348         TourismArtwork,
0349         TourismAttraction,
0350         TourismInformation,
0351         TourismMuseum,
0352         TourismThemePark,
0353         TourismViewPoint,
0354         TourismZoo,
0355         TourismAlpineHut,
0356         TourismWildernessHut,
0357 
0358         // OpenStreetMap category Historic
0359         HistoricArchaeologicalSite,
0360         HistoricCastle,
0361         HistoricMemorial,
0362         HistoricMonument,
0363         HistoricRuins,
0364 
0365         // OpenStreetMap category Transport
0366         TransportAerodrome,
0367         TransportHelipad,
0368         TransportAirportTerminal,
0369         TransportAirportGate, ///< @since 0.26.0
0370         TransportAirportRunway, ///< @since 0.26.0
0371         TransportAirportTaxiway, ///< @since 0.26.0
0372         TransportAirportApron, ///< @since 0.26.0
0373         TransportBusStation,
0374         TransportBusStop,
0375         TransportCarShare,
0376         TransportFuel,
0377         TransportParking,
0378         TransportParkingSpace,
0379         TransportPlatform,
0380         TransportRentalBicycle,
0381         TransportRentalCar,
0382         TransportRentalSki,
0383         TransportTaxiRank,
0384         TransportTrainStation,
0385         TransportTramStop,
0386         TransportBicycleParking,
0387         TransportMotorcycleParking,
0388         TransportSubwayEntrance,
0389         TransportSpeedCamera,
0390 
0391         // OpenStreetMap category religion
0392         ReligionPlaceOfWorship,
0393         ReligionBahai,
0394         ReligionBuddhist,
0395         ReligionChristian,
0396         ReligionMuslim,
0397         ReligionHindu,
0398         ReligionJain,
0399         ReligionJewish,
0400         ReligionShinto,
0401         ReligionSikh,
0402         ReligionTaoist,
0403 
0404         // OpenStreetMap category Leisure
0405         LeisureGolfCourse,
0406         LeisureMarina, ///< @since 0.26.0
0407         LeisureWaterPark,
0408         LeisurePark,
0409         LeisurePlayground,
0410         LeisurePitch,
0411         LeisureSportsCentre,
0412         LeisureStadium,
0413         LeisureTrack,
0414         LeisureSwimmingPool,
0415         LeisureMinigolfCourse,
0416 
0417         LanduseAllotments,
0418         LanduseBasin,
0419         LanduseCemetery,
0420         LanduseCommercial,
0421         LanduseConstruction,
0422         LanduseFarmland,
0423         LanduseFarmyard,
0424         LanduseGarages,
0425         LanduseGrass,
0426         LanduseIndustrial,
0427         LanduseLandfill,
0428         LanduseMeadow,
0429         LanduseMilitary,
0430         LanduseQuarry,
0431         LanduseRailway,
0432         LanduseReservoir,
0433         LanduseResidential,
0434         LanduseRetail,
0435         LanduseOrchard,
0436         LanduseVineyard,
0437 
0438         RailwayRail, // please keep order (used in for loops)
0439         RailwayNarrowGauge,
0440         RailwayTram,
0441         RailwayLightRail,
0442         RailwayAbandoned,
0443         RailwaySubway,
0444         RailwayPreserved,
0445         RailwayMiniature,
0446         RailwayConstruction,
0447         RailwayMonorail,
0448         RailwayFunicular, // please keep order (used in for loops)
0449 
0450         // OpenStreetMap category Power
0451         PowerTower,
0452 
0453         // OpenStreetMap category Aerialway
0454         AerialwayStation,
0455         AerialwayPylon, // node only
0456         // below please keep order (used in for loops)
0457         AerialwayCableCar,
0458         AerialwayGondola,
0459         AerialwayChairLift,
0460         AerialwayMixedLift,
0461         AerialwayDragLift,
0462         AerialwayTBar,
0463         AerialwayJBar,
0464         AerialwayPlatter,
0465         AerialwayRopeTow,
0466         AerialwayMagicCarpet,
0467         AerialwayZipLine,
0468         AerialwayGoods, // please keep order (used in for loops)
0469 
0470         // OpenStreetMap category Piste
0471         PisteDownhill,
0472         PisteNordic,
0473         PisteSkitour,
0474         PisteSled,
0475         PisteHike,
0476         PisteSleigh,
0477         PisteIceSkate,
0478         PisteSnowPark,
0479         PistePlayground,
0480         PisteSkiJump,
0481 
0482         // Waterways
0483         WaterwayCanal, // please keep order (used in for loops)
0484         WaterwayDitch,
0485         WaterwayDrain,
0486         WaterwayRiver,
0487         WaterwayWeir,
0488         WaterwayStream, // please keep order (used in for loops)
0489 
0490         CrossingSignals, // pedestrian vs highway crossing with traffic signals
0491         CrossingIsland, // pedestrian vs highway crossing with a traffic island
0492         CrossingZebra, // pedestrian vs highway zebra crossing
0493         CrossingRailway, // pedestrian or highway vs railway crossing
0494 
0495         //Admin level tags for depicting boundary
0496         AdminLevel1, // please keep order (used in for loops)
0497         AdminLevel2,
0498         AdminLevel3,
0499         AdminLevel4,
0500         AdminLevel5,
0501         AdminLevel6,
0502         AdminLevel7,
0503         AdminLevel8,
0504         AdminLevel9,
0505         AdminLevel10,
0506         AdminLevel11, // please keep order (used in for loops)
0507 
0508         BoundaryMaritime,
0509 
0510         IndoorDoor,
0511         IndoorWall,
0512         IndoorRoom,
0513 
0514         //Custom OSM Tags
0515         Landmass,
0516         UrbanArea,
0517         InternationalDateLine,
0518         Bathymetry, ///< @since 0.26.0
0519 
0520         // Important: Make sure that this is always the last
0521         // item and just use it to specify the array size
0522         LastIndex
0523 
0524     };
0525 
0526     /**
0527      * Return the symbol index of the placemark.
0528      */
0529     GeoDataVisualCategory visualCategory() const;
0530 
0531     /**
0532      * Sets the symbol @p category of the placemark.
0533      * @param index  the new category to be used.
0534      */
0535     void setVisualCategory(GeoDataVisualCategory index);
0536 
0537     /**
0538      * Return the coordinates of the placemark at time @p dateTime as a GeoDataCoordinates
0539      *
0540      * The @p dateTime parameter should be used if the placemark geometry() is a
0541      * GeoDataTrack and thus contains several coordinates associated with a date and time.
0542      *
0543      * The @p iconAtCoordinates boolean is set to true if an icon should be drawn to
0544      * represent the placemark at these coordinates as described in
0545      * https://code.google.com/apis/kml/documentation/kmlreference.html#placemark,
0546      * it is set to false otherwise.
0547      *
0548      * @see GeoDataTrack::GeoDataTrack
0549      */
0550     GeoDataCoordinates coordinate( const QDateTime &dateTime = QDateTime(), bool *iconAtCoordinates = nullptr ) const;
0551 
0552     /**
0553      * The geometry of the GeoDataPlacemark is to be rendered to the marble map
0554      * along with the icon at the coordinate associated with this Placemark.
0555      * @return a pointer to the current Geometry object
0556      */
0557     GeoDataGeometry* geometry();
0558     const GeoDataGeometry* geometry() const;
0559 
0560     /**
0561      * @brief displays the name of a place in the locale language of the user
0562      */
0563     QString displayName() const;
0564 
0565     /**
0566      * @since 0.26.0
0567      */
0568     QString categoryName() const;
0569 
0570     /**
0571      * Return the coordinates of the placemark as @p longitude,
0572      * @p latitude and @p altitude.
0573      */
0574     void coordinate( qreal &longitude, qreal &latitude, qreal &altitude ) const;
0575 
0576     /**
0577       * Quick, safe accessor to the placemark's OsmPlacemarkData stored within it's
0578       * ExtendedData. If the extendedData does not contain osmData, the function
0579       * inserts a default-constructed one, and returns a reference to it.
0580       */
0581     OsmPlacemarkData &osmData();
0582     const OsmPlacemarkData &osmData() const;
0583 
0584     void setOsmData( const OsmPlacemarkData &osmData );
0585     bool hasOsmData() const;
0586     /**
0587      * @since 0.26.0
0588      */
0589     void clearOsmData();
0590 
0591     /**
0592      * Set the coordinate of the placemark in @p longitude and
0593      * @p latitude.
0594      */
0595     void setCoordinate( qreal longitude, qreal latitude, qreal altitude = 0,
0596                         GeoDataCoordinates::Unit _unit = GeoDataCoordinates::Radian );
0597 
0598     /**
0599     * Set the coordinate of the placemark with an @p GeoDataPoint.
0600     */
0601     void setCoordinate( const GeoDataCoordinates &coordinate );
0602 
0603     /**
0604      * Sets the current Geometry of this Placemark. @see geometry() and the class 
0605      * overview for description of the geometry concept. The geometry can be set 
0606      * to any @see GeoDataGeometry like @see GeoDataPoint,@see GeoDataLineString,
0607      * @see GeoDataLinearRing and @see GeoDataMultiGeometry
0608      */
0609     void setGeometry( GeoDataGeometry *entry );
0610 
0611     /**
0612      * Return the area size of the feature in square km.
0613      *
0614      * FIXME: Once we make Marble more area-aware we need to 
0615      * move this into the GeoDataArea class which will get
0616      * inherited from GeoDataPlacemark (or GeoDataFeature).
0617      */
0618     qreal area() const;
0619 
0620     /**
0621      * Set the area size of the feature in square km.
0622      */
0623     void setArea( qreal area );
0624 
0625     /**
0626      * Return the population of the placemark.
0627      */
0628     qint64 population() const;
0629     /**
0630      * Sets the @p population of the placemark.
0631      * @param  population  the new population value
0632      */
0633     void setPopulation( qint64 population );
0634 
0635     /**
0636      * Return the state of the placemark.
0637      */
0638     const QString state() const;
0639 
0640     /**
0641      * Set the state @p state of the placemark.
0642      */
0643     void setState( const QString &state );
0644 
0645     /**
0646      * Return the country code of the placemark.
0647      */
0648     const QString countryCode() const;
0649 
0650     /**
0651      * Set the country @p code of the placemark.
0652      */
0653     void setCountryCode( const QString &code );
0654 
0655     /**
0656      * Returns whether balloon is visible or not
0657      */
0658     bool isBalloonVisible() const;
0659 
0660     /**
0661      * Set visibility of the balloon
0662      */
0663     void setBalloonVisible( bool visible );
0664 
0665     /**
0666      * Serialize the Placemark to a data stream. This is a binary serialisation
0667      * and is deserialised using @see unpack()
0668      * @param stream the QDataStream to serialise object to.
0669      */
0670     void pack( QDataStream& stream ) const override;
0671 
0672     /**
0673      * Serialise this Placemark to a XML stream writer @see QXmlStreamWriter in
0674      * the Qt documentation for more info. This will output the XML
0675      * representation of this Placemark. The default XML format is KML, to have
0676      * other formats supported you need to create a subclass and override this
0677      * method.
0678      * @param stream the XML Stream Reader to output to.
0679      */
0680     virtual QXmlStreamWriter& pack( QXmlStreamWriter& stream ) const;
0681 
0682     virtual QXmlStreamWriter& operator <<( QXmlStreamWriter& stream ) const;
0683 
0684     /**
0685      * Deserialize the Placemark from a data stream. This has the opposite effect
0686      * from @see pack()
0687      * @param stream the QDataStream to deserialise from.
0688      */
0689     void unpack( QDataStream& stream ) override;
0690 
0691     /**
0692      * Returns GeoDataLookAt object if lookAt is setup earlier
0693      * otherwise It will convert GeoDataCoordinates of Placemark
0694      * to GeoDataLookAt with range equals to altitude of
0695      * GeoDataCoordinate
0696      */
0697     const GeoDataLookAt *lookAt() const;
0698     GeoDataLookAt *lookAt();
0699 
0700     static bool placemarkLayoutOrderCompare(const GeoDataPlacemark *a, const GeoDataPlacemark* b);
0701 
0702  private:
0703     Q_DECLARE_PRIVATE(GeoDataPlacemark)
0704 };
0705 
0706 }
0707 
0708 #endif