File indexing completed on 2025-01-05 03:58:59

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 "digikam_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 DIGIKAM_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         Satellite,
0147 
0148         /*
0149          * Start of OpenStreetMap categories
0150          */
0151 
0152         PlaceCity, // please keep order (used in for loops)
0153         PlaceCityCapital,
0154         PlaceCityNationalCapital,
0155         PlaceSuburb,
0156         PlaceHamlet,
0157         PlaceLocality,
0158         PlaceTown,
0159         PlaceTownCapital,
0160         PlaceTownNationalCapital,
0161         PlaceVillage,
0162         PlaceVillageCapital,
0163         PlaceVillageNationalCapital, // please keep order (used in for loops)
0164 
0165         NaturalWater,
0166         NaturalReef,
0167         NaturalWood,
0168         NaturalBeach,
0169         NaturalWetland,
0170         NaturalGlacier,
0171         NaturalIceShelf,
0172         NaturalScrub,
0173         NaturalCliff,
0174         NaturalHeath,
0175 
0176         HighwayTrafficSignals,
0177         HighwayElevator,
0178 
0179         // OpenStreetMap highways
0180         HighwaySteps, // please keep order (used in for loops)
0181         HighwayUnknown,
0182         HighwayPath,
0183         HighwayFootway,
0184         HighwayTrack,
0185         HighwayPedestrian,
0186         HighwayCorridor,
0187         HighwayCycleway,
0188         HighwayService,
0189         HighwayRoad,
0190         HighwayResidential,
0191         HighwayLivingStreet,
0192         HighwayUnclassified,
0193         HighwayTertiaryLink,
0194         HighwayTertiary,
0195         HighwaySecondaryLink,
0196         HighwaySecondary,
0197         HighwayPrimaryLink,
0198         HighwayPrimary,
0199         HighwayRaceway,
0200         HighwayTrunkLink,
0201         HighwayTrunk,
0202         HighwayMotorwayLink,
0203         HighwayMotorway, // please keep order (used in for loops)
0204 
0205         //OSM building
0206         Building,
0207 
0208         // OpenStreetMap category Accommodation
0209         AccomodationCamping,
0210         AccomodationHostel,
0211         AccomodationHotel,
0212         AccomodationMotel,
0213         AccomodationYouthHostel,
0214         AccomodationGuestHouse,
0215 
0216         // OpenStreetMap category Education
0217         EducationCollege,
0218         EducationSchool,
0219         EducationUniversity,
0220 
0221         // OpenStreetMap category Food
0222         FoodBar,
0223         FoodBiergarten,
0224         FoodCafe,
0225         FoodFastFood,
0226         FoodPub,
0227         FoodRestaurant,
0228 
0229         // OpenStreetMap category Health
0230         HealthDentist,
0231         HealthDoctors,
0232         HealthHospital,
0233         HealthPharmacy,
0234         HealthVeterinary,
0235 
0236         // OpenStreetMap category Money
0237         MoneyAtm,
0238         MoneyBank,
0239 
0240         // OpenStreetMap category Amenity
0241         AmenityLibrary,
0242         AmenityKindergarten, ///< @since 0.26.0
0243         AmenityEmbassy,
0244         AmenityEmergencyPhone,
0245         AmenityMountainRescue,
0246         AmenityCommunityCentre,
0247         AmenityCinema,
0248         AmenityFountain,
0249         AmenityNightClub,
0250         AmenityBench,
0251         AmenityCourtHouse,
0252         AmenityFireStation,
0253         AmenityHuntingStand,
0254         AmenityPolice,
0255         AmenityPostBox,
0256         AmenityPostOffice,
0257         AmenityPrison,
0258         AmenityRecycling,
0259         AmenityShelter, ///< @since 0.26.0
0260         AmenityTelephone,
0261         AmenityTheatre,
0262         AmenityToilets,
0263         AmenityTownHall,
0264         AmenityWasteBasket,
0265         AmenityDrinkingWater,
0266         AmenityGraveyard,
0267         AmenityChargingStation,
0268         AmenityCarWash,
0269         AmenitySocialFacility,
0270 
0271         // OpenStreetMap category Barrier
0272         BarrierCityWall,
0273         BarrierGate,
0274         BarrierLiftGate,
0275         BarrierWall,
0276 
0277         NaturalPeak,
0278         NaturalVolcano,
0279         NaturalTree,
0280         NaturalCave,
0281 
0282         // OpenStreetMap category Shopping
0283         ShopBeverages, // please keep order (used in for loops)
0284         ShopHifi,
0285         ShopSupermarket,
0286         ShopAlcohol,
0287         ShopBakery,
0288         ShopButcher,
0289         ShopConfectionery,
0290         ShopConvenience,
0291         ShopGreengrocer,
0292         ShopSeafood,
0293         ShopDepartmentStore,
0294         ShopKiosk,
0295         ShopBag,
0296         ShopClothes,
0297         ShopFashion,
0298         ShopJewelry,
0299         ShopShoes,
0300         ShopVarietyStore,
0301         ShopBeauty,
0302         ShopChemist,
0303         ShopCosmetics,
0304         ShopHairdresser,
0305         ShopOptician,
0306         ShopPerfumery,
0307         ShopDoitYourself,
0308         ShopFlorist,
0309         ShopHardware,
0310         ShopFurniture,
0311         ShopElectronics,
0312         ShopMobilePhone,
0313         ShopBicycle,
0314         ShopCar,
0315         ShopCarRepair,
0316         ShopCarParts,
0317         ShopMotorcycle,
0318         ShopOutdoor,
0319         ShopSports,
0320         ShopCopy,
0321         ShopArt,
0322         ShopMusicalInstrument,
0323         ShopPhoto,
0324         ShopBook,
0325         ShopGift,
0326         ShopStationery,
0327         ShopLaundry,
0328         ShopPet,
0329         ShopToys,
0330         ShopTravelAgency,
0331         ShopDeli,
0332         ShopTobacco,
0333         ShopTea,
0334         ShopComputer,
0335         ShopGardenCentre,
0336         Shop, // please keep order (used in for loops)
0337 
0338         ManmadeBridge,
0339         ManmadeLighthouse,
0340         ManmadePier,
0341         ManmadeWaterTower,
0342         ManmadeWindMill,
0343         ManmadeCommunicationsTower,
0344 
0345         // OpenStreetMap category Tourist
0346         TourismArtwork,
0347         TourismAttraction,
0348         TourismInformation,
0349         TourismMuseum,
0350         TourismThemePark,
0351         TourismViewPoint,
0352         TourismZoo,
0353         TourismAlpineHut,
0354         TourismWildernessHut,
0355 
0356         // OpenStreetMap category Historic
0357         HistoricArchaeologicalSite,
0358         HistoricCastle,
0359         HistoricMemorial,
0360         HistoricMonument,
0361         HistoricRuins,
0362 
0363         // OpenStreetMap category Transport
0364         TransportAerodrome,
0365         TransportHelipad,
0366         TransportAirportTerminal,
0367         TransportAirportGate, ///< @since 0.26.0
0368         TransportAirportRunway, ///< @since 0.26.0
0369         TransportAirportTaxiway, ///< @since 0.26.0
0370         TransportAirportApron, ///< @since 0.26.0
0371         TransportBusStation,
0372         TransportBusStop,
0373         TransportCarShare,
0374         TransportFuel,
0375         TransportParking,
0376         TransportParkingSpace,
0377         TransportPlatform,
0378         TransportRentalBicycle,
0379         TransportRentalCar,
0380         TransportRentalSki,
0381         TransportTaxiRank,
0382         TransportTrainStation,
0383         TransportTramStop,
0384         TransportBicycleParking,
0385         TransportMotorcycleParking,
0386         TransportSubwayEntrance,
0387         TransportSpeedCamera,
0388 
0389         // OpenStreetMap category religion
0390         ReligionPlaceOfWorship,
0391         ReligionBahai,
0392         ReligionBuddhist,
0393         ReligionChristian,
0394         ReligionMuslim,
0395         ReligionHindu,
0396         ReligionJain,
0397         ReligionJewish,
0398         ReligionShinto,
0399         ReligionSikh,
0400         ReligionTaoist,
0401 
0402         // OpenStreetMap category Leisure
0403         LeisureGolfCourse,
0404         LeisureMarina, ///< @since 0.26.0
0405         LeisureWaterPark,
0406         LeisurePark,
0407         LeisurePlayground,
0408         LeisurePitch,
0409         LeisureSportsCentre,
0410         LeisureStadium,
0411         LeisureTrack,
0412         LeisureSwimmingPool,
0413         LeisureMinigolfCourse,
0414 
0415         LanduseAllotments,
0416         LanduseBasin,
0417         LanduseCemetery,
0418         LanduseCommercial,
0419         LanduseConstruction,
0420         LanduseFarmland,
0421         LanduseFarmyard,
0422         LanduseGarages,
0423         LanduseGrass,
0424         LanduseIndustrial,
0425         LanduseLandfill,
0426         LanduseMeadow,
0427         LanduseMilitary,
0428         LanduseQuarry,
0429         LanduseRailway,
0430         LanduseReservoir,
0431         LanduseResidential,
0432         LanduseRetail,
0433         LanduseOrchard,
0434         LanduseVineyard,
0435 
0436         RailwayRail, // please keep order (used in for loops)
0437         RailwayNarrowGauge,
0438         RailwayTram,
0439         RailwayLightRail,
0440         RailwayAbandoned,
0441         RailwaySubway,
0442         RailwayPreserved,
0443         RailwayMiniature,
0444         RailwayConstruction,
0445         RailwayMonorail,
0446         RailwayFunicular, // please keep order (used in for loops)
0447 
0448         // OpenStreetMap category Power
0449         PowerTower,
0450 
0451         // OpenStreetMap category Aerialway
0452         AerialwayStation,
0453         AerialwayPylon, // node only
0454         // below please keep order (used in for loops)
0455         AerialwayCableCar,
0456         AerialwayGondola,
0457         AerialwayChairLift,
0458         AerialwayMixedLift,
0459         AerialwayDragLift,
0460         AerialwayTBar,
0461         AerialwayJBar,
0462         AerialwayPlatter,
0463         AerialwayRopeTow,
0464         AerialwayMagicCarpet,
0465         AerialwayZipLine,
0466         AerialwayGoods, // please keep order (used in for loops)
0467 
0468         // OpenStreetMap category Piste
0469         PisteDownhill,
0470         PisteNordic,
0471         PisteSkitour,
0472         PisteSled,
0473         PisteHike,
0474         PisteSleigh,
0475         PisteIceSkate,
0476         PisteSnowPark,
0477         PistePlayground,
0478         PisteSkiJump,
0479 
0480         // Waterways
0481         WaterwayCanal, // please keep order (used in for loops)
0482         WaterwayDitch,
0483         WaterwayDrain,
0484         WaterwayRiver,
0485         WaterwayWeir,
0486         WaterwayStream, // please keep order (used in for loops)
0487 
0488         CrossingSignals, // pedestrian vs highway crossing with traffic signals
0489         CrossingIsland, // pedestrian vs highway crossing with a traffic island
0490         CrossingZebra, // pedestrian vs highway zebra crossing
0491         CrossingRailway, // pedestrian or highway vs railway crossing
0492 
0493         //Admin level tags for depicting boundary
0494         AdminLevel1, // please keep order (used in for loops)
0495         AdminLevel2,
0496         AdminLevel3,
0497         AdminLevel4,
0498         AdminLevel5,
0499         AdminLevel6,
0500         AdminLevel7,
0501         AdminLevel8,
0502         AdminLevel9,
0503         AdminLevel10,
0504         AdminLevel11, // please keep order (used in for loops)
0505 
0506         BoundaryMaritime,
0507 
0508         IndoorDoor,
0509         IndoorWall,
0510         IndoorRoom,
0511 
0512         //Custom OSM Tags
0513         Landmass,
0514         UrbanArea,
0515         InternationalDateLine,
0516         Bathymetry, ///< @since 0.26.0
0517 
0518         // Important: Make sure that this is always the last
0519         // item and just use it to specify the array size
0520         LastIndex
0521 
0522     };
0523 
0524     /**
0525      * Return the symbol index of the placemark.
0526      */
0527     GeoDataVisualCategory visualCategory() const;
0528 
0529     /**
0530      * Sets the symbol @p category of the placemark.
0531      * @param index  the new category to be used.
0532      */
0533     void setVisualCategory(GeoDataVisualCategory index);
0534 
0535     /**
0536      * Return the coordinates of the placemark at time @p dateTime as a GeoDataCoordinates
0537      *
0538      * The @p dateTime parameter should be used if the placemark geometry() is a
0539      * GeoDataTrack and thus contains several coordinates associated with a date and time.
0540      *
0541      * The @p iconAtCoordinates boolean is set to true if an icon should be drawn to
0542      * represent the placemark at these coordinates as described in
0543      * https://code.google.com/apis/kml/documentation/kmlreference.html#placemark,
0544      * it is set to false otherwise.
0545      *
0546      * @see GeoDataTrack::GeoDataTrack
0547      */
0548     GeoDataCoordinates coordinate( const QDateTime &dateTime = QDateTime(), bool *iconAtCoordinates = nullptr ) const;
0549 
0550     /**
0551      * The geometry of the GeoDataPlacemark is to be rendered to the marble map
0552      * along with the icon at the coordinate associated with this Placemark.
0553      * @return a pointer to the current Geometry object
0554      */
0555     GeoDataGeometry* geometry();
0556     const GeoDataGeometry* geometry() const;
0557 
0558     /**
0559      * @brief displays the name of a place in the locale language of the user
0560      */
0561     QString displayName() const;
0562 
0563     /**
0564      * @since 0.26.0
0565      */
0566     QString categoryName() const;
0567 
0568     /**
0569      * Return the coordinates of the placemark as @p longitude,
0570      * @p latitude and @p altitude.
0571      */
0572     void coordinate( qreal &longitude, qreal &latitude, qreal &altitude ) const;
0573 
0574     /**
0575       * Quick, safe accessor to the placemark's OsmPlacemarkData stored within it's
0576       * ExtendedData. If the extendedData does not contain osmData, the function
0577       * inserts a default-constructed one, and returns a reference to it.
0578       */
0579     OsmPlacemarkData &osmData();
0580     const OsmPlacemarkData &osmData() const;
0581 
0582     void setOsmData( const OsmPlacemarkData &osmData );
0583     bool hasOsmData() const;
0584     /**
0585      * @since 0.26.0
0586      */
0587     void clearOsmData();
0588 
0589     /**
0590      * Set the coordinate of the placemark in @p longitude and
0591      * @p latitude.
0592      */
0593     void setCoordinate( qreal longitude, qreal latitude, qreal altitude = 0,
0594                         GeoDataCoordinates::Unit _unit = GeoDataCoordinates::Radian );
0595 
0596     /**
0597     * Set the coordinate of the placemark with an @p GeoDataPoint.
0598     */
0599     void setCoordinate( const GeoDataCoordinates &coordinate );
0600 
0601     /**
0602      * Sets the current Geometry of this Placemark. @see geometry() and the class
0603      * overview for description of the geometry concept. The geometry can be set
0604      * to any @see GeoDataGeometry like @see GeoDataPoint,@see GeoDataLineString,
0605      * @see GeoDataLinearRing and @see GeoDataMultiGeometry
0606      */
0607     void setGeometry( GeoDataGeometry *entry );
0608 
0609     /**
0610      * Return the area size of the feature in square km.
0611      *
0612      * FIXME: Once we make Marble more area-aware we need to
0613      * move this into the GeoDataArea class which will get
0614      * inherited from GeoDataPlacemark (or GeoDataFeature).
0615      */
0616     qreal area() const;
0617 
0618     /**
0619      * Set the area size of the feature in square km.
0620      */
0621     void setArea( qreal area );
0622 
0623     /**
0624      * Return the population of the placemark.
0625      */
0626     qint64 population() const;
0627     /**
0628      * Sets the @p population of the placemark.
0629      * @param  population  the new population value
0630      */
0631     void setPopulation( qint64 population );
0632 
0633     /**
0634      * Return the state of the placemark.
0635      */
0636     const QString state() const;
0637 
0638     /**
0639      * Set the state @p state of the placemark.
0640      */
0641     void setState( const QString &state );
0642 
0643     /**
0644      * Return the country code of the placemark.
0645      */
0646     const QString countryCode() const;
0647 
0648     /**
0649      * Set the country @p code of the placemark.
0650      */
0651     void setCountryCode( const QString &code );
0652 
0653     /**
0654      * Returns whether balloon is visible or not
0655      */
0656     bool isBalloonVisible() const;
0657 
0658     /**
0659      * Set visibility of the balloon
0660      */
0661     void setBalloonVisible( bool visible );
0662 
0663     /**
0664      * Serialize the Placemark to a data stream. This is a binary serialisation
0665      * and is deserialised using @see unpack()
0666      * @param stream the QDataStream to serialise object to.
0667      */
0668     void pack( QDataStream& stream ) const override;
0669 
0670     /**
0671      * Serialise this Placemark to a XML stream writer @see QXmlStreamWriter in
0672      * the Qt documentation for more info. This will output the XML
0673      * representation of this Placemark. The default XML format is KML, to have
0674      * other formats supported you need to create a subclass and override this
0675      * method.
0676      * @param stream the XML Stream Reader to output to.
0677      */
0678     virtual QXmlStreamWriter& pack( QXmlStreamWriter& stream ) const;
0679 
0680     virtual QXmlStreamWriter& operator <<( QXmlStreamWriter& stream ) const;
0681 
0682     /**
0683      * Deserialize the Placemark from a data stream. This has the opposite effect
0684      * from @see pack()
0685      * @param stream the QDataStream to deserialise from.
0686      */
0687     void unpack( QDataStream& stream ) override;
0688 
0689     /**
0690      * Returns GeoDataLookAt object if lookAt is setup earlier
0691      * otherwise It will convert GeoDataCoordinates of Placemark
0692      * to GeoDataLookAt with range equals to altitude of
0693      * GeoDataCoordinate
0694      */
0695     const GeoDataLookAt *lookAt() const;
0696     GeoDataLookAt *lookAt();
0697 
0698     static bool placemarkLayoutOrderCompare(const GeoDataPlacemark *a, const GeoDataPlacemark* b);
0699 
0700  private:
0701     Q_DECLARE_PRIVATE(GeoDataPlacemark)
0702 };
0703 
0704 }
0705 
0706 #endif