Marble

GeoDataPlacemark.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2007 Inge Wallin <[email protected]>
5 // SPDX-FileCopyrightText: 2008-2009 Patrick Spendrin <[email protected]>
6 //
7 
8 
9 #ifndef MARBLE_GEODATAPLACEMARK_H
10 #define MARBLE_GEODATAPLACEMARK_H
11 
12 
13 #include <QDateTime>
14 
15 #include "GeoDataCoordinates.h"
16 #include "GeoDataFeature.h"
17 
18 #include "geodata_export.h"
19 
20 class QXmlStreamWriter;
21 
22 namespace Marble
23 {
24 
25 class GeoDataPlacemarkPrivate;
26 class OsmPlacemarkData;
27 class GeoDataLookAt;
28 class GeoDataPolygon;
29 class GeoDataGeometry;
30 
31 /**
32  * @short a class representing a point of interest on the map
33  *
34  * This class represents a point of interest, e.g. a city or a
35  * mountain. It is filled with data by the KML or GPX loader and the
36  * PlacemarkModel makes use of it.
37  *
38  * A Placemark can have an associated geometry which will be rendered to the map
39  * along with the placemark's point icon. If you would like to render more than
40  * one geometry for any one placemark than use @see setGeometry() to set add a
41  * @see MultiGeometry.
42  *
43  * This is more or less only a GeoDataFeature with a geographic
44  * position and a country code attached to it. The country code is
45  * not provided in a KML file.
46  */
47 
48 class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature
49 {
50  public:
51  /**
52  * Create a new placemark.
53  */
55 
56  /**
57  * Create a new placemark from existing placemark @p placemark
58  */
59  GeoDataPlacemark( const GeoDataPlacemark& placemark );
60 
61  /**
62  * Create a new placemark with the given @p name.
63  */
64  explicit GeoDataPlacemark( const QString &name );
65 
66  /**
67  * Delete the placemark
68  */
69  ~GeoDataPlacemark() override;
70 
71  GeoDataPlacemark &operator=( const GeoDataPlacemark &other );
72 
73  /**
74  * Equality operators.
75  */
76  bool operator==( const GeoDataPlacemark& other ) const;
77  bool operator!=( const GeoDataPlacemark& other ) const;
78 
79  const char* nodeType() const override;
80 
81  GeoDataFeature * clone() const override;
82 
83  /**
84  * @brief A categorization of a placemark as defined by ...FIXME.
85  * There is an additional osm tag mapping to GeoDataVisualCategory
86  * in OsmPlacemarkData
87  */
89  None,
90  Default,
91  Unknown,
92 
93  // The order of the cities needs to stay fixed as the
94  // algorithms rely on that.
95  SmallCity,
96  SmallCountyCapital,
97  SmallStateCapital,
98  SmallNationCapital,
99  MediumCity,
100  MediumCountyCapital,
101  MediumStateCapital,
102  MediumNationCapital,
103  BigCity,
104  BigCountyCapital,
105  BigStateCapital,
106  BigNationCapital,
107  LargeCity,
108  LargeCountyCapital,
109  LargeStateCapital,
110  LargeNationCapital,
111  Nation,
112 
113  // Terrain
114  Mountain,
115  Volcano,
116  Mons, // m
117  Valley, // v
118  Continent,
119  Ocean,
120  OtherTerrain, // o
121 
122  // Space Terrain
123  Crater, // c
124  Mare, // a
125 
126  // Places of Interest
127  GeographicPole,
128  MagneticPole,
129  ShipWreck,
130  AirPort,
131  Observatory,
132 
133  // Military
134  MilitaryDangerArea,
135 
136  // Runners
137  OsmSite,
138  Coordinate,
139 
140  // Planets
141  MannedLandingSite, // h
142  RoboticRover, // r
143  UnmannedSoftLandingSite, // u
144  UnmannedHardLandingSite, // i
145 
146  Bookmark,
147 
148  Satellite,
149 
150  /*
151  * Start of OpenStreetMap categories
152  */
153 
154  PlaceCity, // please keep order (used in for loops)
155  PlaceCityCapital,
156  PlaceCityNationalCapital,
157  PlaceSuburb,
158  PlaceHamlet,
159  PlaceLocality,
160  PlaceTown,
161  PlaceTownCapital,
162  PlaceTownNationalCapital,
163  PlaceVillage,
164  PlaceVillageCapital,
165  PlaceVillageNationalCapital, // please keep order (used in for loops)
166 
167  NaturalWater,
168  NaturalReef,
169  NaturalWood,
170  NaturalBeach,
171  NaturalWetland,
172  NaturalGlacier,
173  NaturalIceShelf,
174  NaturalScrub,
175  NaturalCliff,
176  NaturalHeath,
177 
178  HighwayTrafficSignals,
179  HighwayElevator,
180 
181  // OpenStreetMap highways
182  HighwaySteps, // please keep order (used in for loops)
183  HighwayUnknown,
184  HighwayPath,
185  HighwayFootway,
186  HighwayTrack,
187  HighwayPedestrian,
188  HighwayCorridor,
189  HighwayCycleway,
190  HighwayService,
191  HighwayRoad,
192  HighwayResidential,
193  HighwayLivingStreet,
194  HighwayUnclassified,
195  HighwayTertiaryLink,
196  HighwayTertiary,
197  HighwaySecondaryLink,
198  HighwaySecondary,
199  HighwayPrimaryLink,
200  HighwayPrimary,
201  HighwayRaceway,
202  HighwayTrunkLink,
203  HighwayTrunk,
204  HighwayMotorwayLink,
205  HighwayMotorway, // please keep order (used in for loops)
206 
207  //OSM building
208  Building,
209 
210  // OpenStreetMap category Accommodation
211  AccomodationCamping,
212  AccomodationHostel,
213  AccomodationHotel,
214  AccomodationMotel,
215  AccomodationYouthHostel,
216  AccomodationGuestHouse,
217 
218  // OpenStreetMap category Education
219  EducationCollege,
220  EducationSchool,
221  EducationUniversity,
222 
223  // OpenStreetMap category Food
224  FoodBar,
225  FoodBiergarten,
226  FoodCafe,
227  FoodFastFood,
228  FoodPub,
229  FoodRestaurant,
230 
231  // OpenStreetMap category Health
232  HealthDentist,
233  HealthDoctors,
234  HealthHospital,
235  HealthPharmacy,
236  HealthVeterinary,
237 
238  // OpenStreetMap category Money
239  MoneyAtm,
240  MoneyBank,
241 
242  // OpenStreetMap category Amenity
243  AmenityLibrary,
244  AmenityKindergarten, ///< @since 0.26.0
245  AmenityEmbassy,
246  AmenityEmergencyPhone,
247  AmenityMountainRescue,
248  AmenityCommunityCentre,
249  AmenityCinema,
250  AmenityFountain,
251  AmenityNightClub,
252  AmenityBench,
253  AmenityCourtHouse,
254  AmenityFireStation,
255  AmenityHuntingStand,
256  AmenityPolice,
257  AmenityPostBox,
258  AmenityPostOffice,
259  AmenityPrison,
260  AmenityRecycling,
261  AmenityShelter, ///< @since 0.26.0
262  AmenityTelephone,
263  AmenityTheatre,
264  AmenityToilets,
265  AmenityTownHall,
266  AmenityWasteBasket,
267  AmenityDrinkingWater,
268  AmenityGraveyard,
269  AmenityChargingStation,
270  AmenityCarWash,
271  AmenitySocialFacility,
272 
273  // OpenStreetMap category Barrier
274  BarrierCityWall,
275  BarrierGate,
276  BarrierLiftGate,
277  BarrierWall,
278 
279  NaturalPeak,
280  NaturalVolcano,
281  NaturalTree,
282  NaturalCave,
283 
284  // OpenStreetMap category Shopping
285  ShopBeverages, // please keep order (used in for loops)
286  ShopHifi,
287  ShopSupermarket,
288  ShopAlcohol,
289  ShopBakery,
290  ShopButcher,
291  ShopConfectionery,
292  ShopConvenience,
293  ShopGreengrocer,
294  ShopSeafood,
295  ShopDepartmentStore,
296  ShopKiosk,
297  ShopBag,
298  ShopClothes,
299  ShopFashion,
300  ShopJewelry,
301  ShopShoes,
302  ShopVarietyStore,
303  ShopBeauty,
304  ShopChemist,
305  ShopCosmetics,
306  ShopHairdresser,
307  ShopOptician,
308  ShopPerfumery,
309  ShopDoitYourself,
310  ShopFlorist,
311  ShopHardware,
312  ShopFurniture,
313  ShopElectronics,
314  ShopMobilePhone,
315  ShopBicycle,
316  ShopCar,
317  ShopCarRepair,
318  ShopCarParts,
319  ShopMotorcycle,
320  ShopOutdoor,
321  ShopSports,
322  ShopCopy,
323  ShopArt,
324  ShopMusicalInstrument,
325  ShopPhoto,
326  ShopBook,
327  ShopGift,
328  ShopStationery,
329  ShopLaundry,
330  ShopPet,
331  ShopToys,
332  ShopTravelAgency,
333  ShopDeli,
334  ShopTobacco,
335  ShopTea,
336  ShopComputer,
337  ShopGardenCentre,
338  Shop, // please keep order (used in for loops)
339 
340  ManmadeBridge,
341  ManmadeLighthouse,
342  ManmadePier,
343  ManmadeWaterTower,
344  ManmadeWindMill,
345  ManmadeCommunicationsTower,
346 
347  // OpenStreetMap category Tourist
348  TourismArtwork,
349  TourismAttraction,
350  TourismInformation,
351  TourismMuseum,
352  TourismThemePark,
353  TourismViewPoint,
354  TourismZoo,
355  TourismAlpineHut,
356  TourismWildernessHut,
357 
358  // OpenStreetMap category Historic
359  HistoricArchaeologicalSite,
360  HistoricCastle,
361  HistoricMemorial,
362  HistoricMonument,
363  HistoricRuins,
364 
365  // OpenStreetMap category Transport
366  TransportAerodrome,
367  TransportHelipad,
368  TransportAirportTerminal,
369  TransportAirportGate, ///< @since 0.26.0
370  TransportAirportRunway, ///< @since 0.26.0
371  TransportAirportTaxiway, ///< @since 0.26.0
372  TransportAirportApron, ///< @since 0.26.0
373  TransportBusStation,
374  TransportBusStop,
375  TransportCarShare,
376  TransportFuel,
377  TransportParking,
378  TransportParkingSpace,
379  TransportPlatform,
380  TransportRentalBicycle,
381  TransportRentalCar,
382  TransportRentalSki,
383  TransportTaxiRank,
384  TransportTrainStation,
385  TransportTramStop,
386  TransportBicycleParking,
387  TransportMotorcycleParking,
388  TransportSubwayEntrance,
389  TransportSpeedCamera,
390 
391  // OpenStreetMap category religion
392  ReligionPlaceOfWorship,
393  ReligionBahai,
394  ReligionBuddhist,
395  ReligionChristian,
396  ReligionMuslim,
397  ReligionHindu,
398  ReligionJain,
399  ReligionJewish,
400  ReligionShinto,
401  ReligionSikh,
402  ReligionTaoist,
403 
404  // OpenStreetMap category Leisure
405  LeisureGolfCourse,
406  LeisureMarina, ///< @since 0.26.0
407  LeisureWaterPark,
408  LeisurePark,
409  LeisurePlayground,
410  LeisurePitch,
411  LeisureSportsCentre,
412  LeisureStadium,
413  LeisureTrack,
414  LeisureSwimmingPool,
415  LeisureMinigolfCourse,
416 
417  LanduseAllotments,
418  LanduseBasin,
419  LanduseCemetery,
420  LanduseCommercial,
421  LanduseConstruction,
422  LanduseFarmland,
423  LanduseFarmyard,
424  LanduseGarages,
425  LanduseGrass,
426  LanduseIndustrial,
427  LanduseLandfill,
428  LanduseMeadow,
429  LanduseMilitary,
430  LanduseQuarry,
431  LanduseRailway,
432  LanduseReservoir,
433  LanduseResidential,
434  LanduseRetail,
435  LanduseOrchard,
436  LanduseVineyard,
437 
438  RailwayRail, // please keep order (used in for loops)
439  RailwayNarrowGauge,
440  RailwayTram,
441  RailwayLightRail,
442  RailwayAbandoned,
443  RailwaySubway,
444  RailwayPreserved,
445  RailwayMiniature,
446  RailwayConstruction,
447  RailwayMonorail,
448  RailwayFunicular, // please keep order (used in for loops)
449 
450  // OpenStreetMap category Power
451  PowerTower,
452 
453  // OpenStreetMap category Aerialway
454  AerialwayStation,
455  AerialwayPylon, // node only
456  // below please keep order (used in for loops)
457  AerialwayCableCar,
458  AerialwayGondola,
459  AerialwayChairLift,
460  AerialwayMixedLift,
461  AerialwayDragLift,
462  AerialwayTBar,
463  AerialwayJBar,
464  AerialwayPlatter,
465  AerialwayRopeTow,
466  AerialwayMagicCarpet,
467  AerialwayZipLine,
468  AerialwayGoods, // please keep order (used in for loops)
469 
470  // OpenStreetMap category Piste
471  PisteDownhill,
472  PisteNordic,
473  PisteSkitour,
474  PisteSled,
475  PisteHike,
476  PisteSleigh,
477  PisteIceSkate,
478  PisteSnowPark,
479  PistePlayground,
480  PisteSkiJump,
481 
482  // Waterways
483  WaterwayCanal, // please keep order (used in for loops)
484  WaterwayDitch,
485  WaterwayDrain,
486  WaterwayRiver,
487  WaterwayWeir,
488  WaterwayStream, // please keep order (used in for loops)
489 
490  CrossingSignals, // pedestrian vs highway crossing with traffic signals
491  CrossingIsland, // pedestrian vs highway crossing with a traffic island
492  CrossingZebra, // pedestrian vs highway zebra crossing
493  CrossingRailway, // pedestrian or highway vs railway crossing
494 
495  //Admin level tags for depicting boundary
496  AdminLevel1, // please keep order (used in for loops)
497  AdminLevel2,
498  AdminLevel3,
499  AdminLevel4,
500  AdminLevel5,
501  AdminLevel6,
502  AdminLevel7,
503  AdminLevel8,
504  AdminLevel9,
505  AdminLevel10,
506  AdminLevel11, // please keep order (used in for loops)
507 
508  BoundaryMaritime,
509 
510  IndoorDoor,
511  IndoorWall,
512  IndoorRoom,
513 
514  //Custom OSM Tags
515  Landmass,
516  UrbanArea,
517  InternationalDateLine,
518  Bathymetry, ///< @since 0.26.0
519 
520  // Important: Make sure that this is always the last
521  // item and just use it to specify the array size
522  LastIndex
523 
524  };
525 
526  /**
527  * Return the symbol index of the placemark.
528  */
529  GeoDataVisualCategory visualCategory() const;
530 
531  /**
532  * Sets the symbol @p category of the placemark.
533  * @param index the new category to be used.
534  */
535  void setVisualCategory(GeoDataVisualCategory index);
536 
537  /**
538  * Return the coordinates of the placemark at time @p dateTime as a GeoDataCoordinates
539  *
540  * The @p dateTime parameter should be used if the placemark geometry() is a
541  * GeoDataTrack and thus contains several coordinates associated with a date and time.
542  *
543  * The @p iconAtCoordinates boolean is set to true if an icon should be drawn to
544  * represent the placemark at these coordinates as described in
545  * https://code.google.com/apis/kml/documentation/kmlreference.html#placemark,
546  * it is set to false otherwise.
547  *
548  * @see GeoDataTrack::GeoDataTrack
549  */
550  GeoDataCoordinates coordinate( const QDateTime &dateTime = QDateTime(), bool *iconAtCoordinates = nullptr ) const;
551 
552  /**
553  * The geometry of the GeoDataPlacemark is to be rendered to the marble map
554  * along with the icon at the coordinate associated with this Placemark.
555  * @return a pointer to the current Geometry object
556  */
557  GeoDataGeometry* geometry();
558  const GeoDataGeometry* geometry() const;
559 
560  /**
561  * @brief displays the name of a place in the locale language of the user
562  */
563  QString displayName() const;
564 
565  /**
566  * @since 0.26.0
567  */
568  QString categoryName() const;
569 
570  /**
571  * Return the coordinates of the placemark as @p longitude,
572  * @p latitude and @p altitude.
573  */
574  void coordinate( qreal &longitude, qreal &latitude, qreal &altitude ) const;
575 
576  /**
577  * Quick, safe accessor to the placemark's OsmPlacemarkData stored within it's
578  * ExtendedData. If the extendedData does not contain osmData, the function
579  * inserts a default-constructed one, and returns a reference to it.
580  */
581  OsmPlacemarkData &osmData();
582  const OsmPlacemarkData &osmData() const;
583 
584  void setOsmData( const OsmPlacemarkData &osmData );
585  bool hasOsmData() const;
586  /**
587  * @since 0.26.0
588  */
589  void clearOsmData();
590 
591  /**
592  * Set the coordinate of the placemark in @p longitude and
593  * @p latitude.
594  */
595  void setCoordinate( qreal longitude, qreal latitude, qreal altitude = 0,
596  GeoDataCoordinates::Unit _unit = GeoDataCoordinates::Radian );
597 
598  /**
599  * Set the coordinate of the placemark with an @p GeoDataPoint.
600  */
601  void setCoordinate( const GeoDataCoordinates &coordinate );
602 
603  /**
604  * Sets the current Geometry of this Placemark. @see geometry() and the class
605  * overview for description of the geometry concept. The geometry can be set
606  * to any @see GeoDataGeometry like @see GeoDataPoint,@see GeoDataLineString,
607  * @see GeoDataLinearRing and @see GeoDataMultiGeometry
608  */
609  void setGeometry( GeoDataGeometry *entry );
610 
611  /**
612  * Return the area size of the feature in square km.
613  *
614  * FIXME: Once we make Marble more area-aware we need to
615  * move this into the GeoDataArea class which will get
616  * inherited from GeoDataPlacemark (or GeoDataFeature).
617  */
618  qreal area() const;
619 
620  /**
621  * Set the area size of the feature in square km.
622  */
623  void setArea( qreal area );
624 
625  /**
626  * Return the population of the placemark.
627  */
628  qint64 population() const;
629  /**
630  * Sets the @p population of the placemark.
631  * @param population the new population value
632  */
633  void setPopulation( qint64 population );
634 
635  /**
636  * Return the state of the placemark.
637  */
638  const QString state() const;
639 
640  /**
641  * Set the state @p state of the placemark.
642  */
643  void setState( const QString &state );
644 
645  /**
646  * Return the country code of the placemark.
647  */
648  const QString countryCode() const;
649 
650  /**
651  * Set the country @p code of the placemark.
652  */
653  void setCountryCode( const QString &code );
654 
655  /**
656  * Returns whether balloon is visible or not
657  */
658  bool isBalloonVisible() const;
659 
660  /**
661  * Set visibility of the balloon
662  */
663  void setBalloonVisible( bool visible );
664 
665  /**
666  * Serialize the Placemark to a data stream. This is a binary serialisation
667  * and is deserialised using @see unpack()
668  * @param stream the QDataStream to serialise object to.
669  */
670  void pack( QDataStream& stream ) const override;
671 
672  /**
673  * Serialise this Placemark to a XML stream writer @see QXmlStreamWriter in
674  * the Qt documentation for more info. This will output the XML
675  * representation of this Placemark. The default XML format is KML, to have
676  * other formats supported you need to create a subclass and override this
677  * method.
678  * @param stream the XML Stream Reader to output to.
679  */
680  virtual QXmlStreamWriter& pack( QXmlStreamWriter& stream ) const;
681 
682  virtual QXmlStreamWriter& operator <<( QXmlStreamWriter& stream ) const;
683 
684  /**
685  * Deserialize the Placemark from a data stream. This has the opposite effect
686  * from @see pack()
687  * @param stream the QDataStream to deserialise from.
688  */
689  void unpack( QDataStream& stream ) override;
690 
691  /**
692  * Returns GeoDataLookAt object if lookAt is setup earlier
693  * otherwise It will convert GeoDataCoordinates of Placemark
694  * to GeoDataLookAt with range equals to altitude of
695  * GeoDataCoordinate
696  */
697  const GeoDataLookAt *lookAt() const;
698  GeoDataLookAt *lookAt();
699 
700  static bool placemarkLayoutOrderCompare(const GeoDataPlacemark *a, const GeoDataPlacemark* b);
701 
702  private:
703  Q_DECLARE_PRIVATE(GeoDataPlacemark)
704 };
705 
706 }
707 
708 #endif
A 3d point representation.
A base class for all geodata features.
A base class for all geodata features.
GeoDataVisualCategory
A categorization of a placemark as defined by ...FIXME.
Binds a QML item to a specific geodetic location in screen coordinates.
This class is used to encapsulate the osm data fields kept within a placemark's extendedData.
a class representing a point of interest on the map
Unit
enum used constructor to specify the units used
Represents a coordinate with the properties of a name and coordinates.
Definition: Coordinate.h:18
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Nov 30 2023 04:11:40 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.