summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-06 15:01:12 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-06 15:01:12 (GMT)
commit72b2815f5d8b8c895d178ee27d0596e9c4edd7df (patch)
treeab944d2d692584ac4b126f6495945492967dc0d7
parent0d28f0098791d922c4ca8a68cbaec48b9be41eed (diff)
Provide a render preference for osm placemarks
The visual category now decides which one to render in case several placemarks collide on screen.
-rw-r--r--src/plugins/runner/osm/OsmNode.cpp242
-rw-r--r--src/plugins/runner/osm/OsmNode.h6
-rw-r--r--src/plugins/runner/osm/OsmRelation.cpp3
-rw-r--r--src/plugins/runner/osm/OsmWay.cpp3
4 files changed, 219 insertions, 35 deletions
diff --git a/src/plugins/runner/osm/OsmNode.cpp b/src/plugins/runner/osm/OsmNode.cpp
index 5dd1980..68bbff3 100644
--- a/src/plugins/runner/osm/OsmNode.cpp
+++ b/src/plugins/runner/osm/OsmNode.cpp
@@ -22,6 +22,9 @@
namespace Marble {
+QHash<GeoDataPlacemark::GeoDataVisualCategory, qint64> OsmNode::m_popularities;
+QHash<GeoDataPlacemark::GeoDataVisualCategory, int> OsmNode::m_zoomLevels;
+
void OsmNode::parseCoordinates(const QXmlStreamAttributes &attributes)
{
qreal const lon = attributes.value(QLatin1String("lon")).toDouble();
@@ -65,39 +68,8 @@ void OsmNode::create(GeoDataDocument *document) const
int const zoomLevel = m_osmData.tagValue(QLatin1String("marbleZoomLevel")).toInt();
placemark->setZoomLevel(zoomLevel);
} else {
- switch (category) {
- case GeoDataPlacemark::PlaceCity:
- case GeoDataPlacemark::PlaceCityCapital:
- placemark->setZoomLevel(9);
- break;
- case GeoDataPlacemark::PlaceSuburb:
- placemark->setZoomLevel(13);
- break;
- case GeoDataPlacemark::PlaceHamlet:
- placemark->setZoomLevel(15);
- break;
- case GeoDataPlacemark::PlaceLocality:
- placemark->setZoomLevel(15);
- break;
- case GeoDataPlacemark::PlaceTown:
- case GeoDataPlacemark::PlaceTownCapital:
- placemark->setZoomLevel(11);
- break;
- case GeoDataPlacemark::PlaceVillage:
- case GeoDataPlacemark::PlaceVillageCapital:
- placemark->setZoomLevel(13);
- break;
- case GeoDataPlacemark::NaturalPeak:
- placemark->setZoomLevel(11);
- break;
- case GeoDataPlacemark::AmenityBench:
- case GeoDataPlacemark::AmenityWasteBasket:
- placemark->setZoomLevel(19);
- break;
- default:
- placemark->setZoomLevel(18);
- break;
- }
+ placemark->setZoomLevel(zoomLevelFor(category, 18));
+ placemark->setPopularity(popularityFor(category, 100));
}
if (category >= GeoDataPlacemark::PlaceCity && category <= GeoDataPlacemark::PlaceVillageCapital) {
@@ -128,6 +100,210 @@ int OsmNode::populationIndex(qint64 population) const
return popidx;
}
+int OsmNode::zoomLevelFor(GeoDataPlacemark::GeoDataVisualCategory category, int defaultValue)
+{
+ if (m_zoomLevels.isEmpty()) {
+ m_zoomLevels[GeoDataPlacemark::PlaceCityCapital] = 9;
+ m_zoomLevels[GeoDataPlacemark::PlaceCity] = 9;
+
+ m_zoomLevels[GeoDataPlacemark::PlaceTownCapital] = 11;
+ m_zoomLevels[GeoDataPlacemark::PlaceTown] = 11;
+ m_zoomLevels[GeoDataPlacemark::NaturalPeak] = 11;
+
+ m_zoomLevels[GeoDataPlacemark::PlaceSuburb] = 13;
+ m_zoomLevels[GeoDataPlacemark::PlaceVillageCapital] = 13;
+ m_zoomLevels[GeoDataPlacemark::PlaceVillage] = 13;
+
+ m_zoomLevels[GeoDataPlacemark::PlaceHamlet] = 15;
+ m_zoomLevels[GeoDataPlacemark::HealthHospital] = 15;
+ m_zoomLevels[GeoDataPlacemark::PlaceLocality] = 15;
+
+ m_zoomLevels[GeoDataPlacemark::AmenityBench] = 19;
+ m_zoomLevels[GeoDataPlacemark::AmenityWasteBasket] = 19;
+ m_zoomLevels[GeoDataPlacemark::PowerTower] = 19;
+ }
+
+ return m_zoomLevels.value(category, defaultValue);
+}
+
+qint64 OsmNode::popularityFor(GeoDataPlacemark::GeoDataVisualCategory category, qint64 defaultValue)
+{
+ if (m_popularities.isEmpty()) {
+
+ QVector<GeoDataPlacemark::GeoDataVisualCategory> popularities;
+ popularities << GeoDataPlacemark::PlaceCityCapital;
+ popularities << GeoDataPlacemark::PlaceTownCapital;
+ popularities << GeoDataPlacemark::PlaceCity;
+ popularities << GeoDataPlacemark::PlaceTown;
+ popularities << GeoDataPlacemark::PlaceSuburb;
+ popularities << GeoDataPlacemark::PlaceVillageCapital;
+ popularities << GeoDataPlacemark::PlaceVillage;
+ popularities << GeoDataPlacemark::PlaceHamlet;
+ popularities << GeoDataPlacemark::PlaceLocality;
+
+ popularities << GeoDataPlacemark::AmenityEmergencyPhone;
+ popularities << GeoDataPlacemark::HealthHospital;
+ popularities << GeoDataPlacemark::AmenityToilets;
+ popularities << GeoDataPlacemark::MoneyAtm;
+
+ popularities << GeoDataPlacemark::NaturalPeak;
+
+ popularities << GeoDataPlacemark::AccomodationHotel;
+ popularities << GeoDataPlacemark::AccomodationMotel;
+ popularities << GeoDataPlacemark::AccomodationGuestHouse;
+ popularities << GeoDataPlacemark::AccomodationYouthHostel;
+ popularities << GeoDataPlacemark::AccomodationHostel;
+ popularities << GeoDataPlacemark::AccomodationCamping;
+
+ popularities << GeoDataPlacemark::HealthDentist;
+ popularities << GeoDataPlacemark::HealthDoctors;
+ popularities << GeoDataPlacemark::HealthPharmacy;
+ popularities << GeoDataPlacemark::HealthVeterinary;
+
+ popularities << GeoDataPlacemark::AmenityLibrary;
+ popularities << GeoDataPlacemark::EducationCollege;
+ popularities << GeoDataPlacemark::EducationSchool;
+ popularities << GeoDataPlacemark::EducationUniversity;
+
+ popularities << GeoDataPlacemark::FoodBar;
+ popularities << GeoDataPlacemark::FoodBiergarten;
+ popularities << GeoDataPlacemark::FoodCafe;
+ popularities << GeoDataPlacemark::FoodFastFood;
+ popularities << GeoDataPlacemark::FoodPub;
+ popularities << GeoDataPlacemark::FoodRestaurant;
+
+ popularities << GeoDataPlacemark::MoneyBank;
+
+ popularities << GeoDataPlacemark::AmenityArchaeologicalSite;
+ popularities << GeoDataPlacemark::AmenityEmbassy;
+ popularities << GeoDataPlacemark::AmenityWaterPark;
+ popularities << GeoDataPlacemark::AmenityCommunityCentre;
+ popularities << GeoDataPlacemark::AmenityFountain;
+ popularities << GeoDataPlacemark::AmenityNightClub;
+ popularities << GeoDataPlacemark::AmenityCourtHouse;
+ popularities << GeoDataPlacemark::AmenityFireStation;
+ popularities << GeoDataPlacemark::AmenityHuntingStand;
+ popularities << GeoDataPlacemark::AmenityPolice;
+ popularities << GeoDataPlacemark::AmenityPostBox;
+ popularities << GeoDataPlacemark::AmenityPostOffice;
+ popularities << GeoDataPlacemark::AmenityPrison;
+ popularities << GeoDataPlacemark::AmenityRecycling;
+ popularities << GeoDataPlacemark::AmenityTelephone;
+ popularities << GeoDataPlacemark::AmenityTownHall;
+ popularities << GeoDataPlacemark::AmenityDrinkingWater;
+ popularities << GeoDataPlacemark::AmenityGraveyard;
+
+ popularities << GeoDataPlacemark::ManmadeBridge;
+ popularities << GeoDataPlacemark::ManmadeLighthouse;
+ popularities << GeoDataPlacemark::ManmadePier;
+ popularities << GeoDataPlacemark::ManmadeWaterTower;
+ popularities << GeoDataPlacemark::ManmadeWindMill;
+ popularities << GeoDataPlacemark::TouristAttraction;
+ popularities << GeoDataPlacemark::TouristCastle;
+ popularities << GeoDataPlacemark::TouristCinema;
+ popularities << GeoDataPlacemark::TouristInformation;
+ popularities << GeoDataPlacemark::TouristMonument;
+ popularities << GeoDataPlacemark::TouristMuseum;
+ popularities << GeoDataPlacemark::TouristRuin;
+ popularities << GeoDataPlacemark::TouristTheatre;
+ popularities << GeoDataPlacemark::TouristThemePark;
+ popularities << GeoDataPlacemark::TouristViewPoint;
+ popularities << GeoDataPlacemark::TouristZoo;
+ popularities << GeoDataPlacemark::TouristAlpineHut;
+ popularities << GeoDataPlacemark::TransportAerodrome;
+ popularities << GeoDataPlacemark::TransportHelipad;
+ popularities << GeoDataPlacemark::TransportAirportTerminal;
+ popularities << GeoDataPlacemark::TransportBusStation;
+ popularities << GeoDataPlacemark::TransportBusStop;
+ popularities << GeoDataPlacemark::TransportCarShare;
+ popularities << GeoDataPlacemark::TransportFuel;
+ popularities << GeoDataPlacemark::TransportParking;
+ popularities << GeoDataPlacemark::TransportParkingSpace;
+ popularities << GeoDataPlacemark::TransportPlatform;
+ popularities << GeoDataPlacemark::TransportRentalBicycle;
+ popularities << GeoDataPlacemark::TransportRentalCar;
+ popularities << GeoDataPlacemark::TransportTaxiRank;
+ popularities << GeoDataPlacemark::TransportTrainStation;
+ popularities << GeoDataPlacemark::TransportTramStop;
+ popularities << GeoDataPlacemark::TransportBicycleParking;
+ popularities << GeoDataPlacemark::TransportMotorcycleParking;
+ popularities << GeoDataPlacemark::TransportSubwayEntrance;
+
+ popularities << GeoDataPlacemark::ShopBeverages;
+ popularities << GeoDataPlacemark::ShopHifi;
+ popularities << GeoDataPlacemark::ShopSupermarket;
+ popularities << GeoDataPlacemark::ShopAlcohol;
+ popularities << GeoDataPlacemark::ShopBakery;
+ popularities << GeoDataPlacemark::ShopButcher;
+ popularities << GeoDataPlacemark::ShopConfectionery;
+ popularities << GeoDataPlacemark::ShopConvenience;
+ popularities << GeoDataPlacemark::ShopGreengrocer;
+ popularities << GeoDataPlacemark::ShopSeafood;
+ popularities << GeoDataPlacemark::ShopDepartmentStore;
+ popularities << GeoDataPlacemark::ShopKiosk;
+ popularities << GeoDataPlacemark::ShopBag;
+ popularities << GeoDataPlacemark::ShopClothes;
+ popularities << GeoDataPlacemark::ShopFashion;
+ popularities << GeoDataPlacemark::ShopJewelry;
+ popularities << GeoDataPlacemark::ShopShoes;
+ popularities << GeoDataPlacemark::ShopVarietyStore;
+ popularities << GeoDataPlacemark::ShopBeauty;
+ popularities << GeoDataPlacemark::ShopChemist;
+ popularities << GeoDataPlacemark::ShopCosmetics;
+ popularities << GeoDataPlacemark::ShopHairdresser;
+ popularities << GeoDataPlacemark::ShopOptician;
+ popularities << GeoDataPlacemark::ShopPerfumery;
+ popularities << GeoDataPlacemark::ShopDoitYourself;
+ popularities << GeoDataPlacemark::ShopFlorist;
+ popularities << GeoDataPlacemark::ShopHardware;
+ popularities << GeoDataPlacemark::ShopFurniture;
+ popularities << GeoDataPlacemark::ShopElectronics;
+ popularities << GeoDataPlacemark::ShopMobilePhone;
+ popularities << GeoDataPlacemark::ShopBicycle;
+ popularities << GeoDataPlacemark::ShopCar;
+ popularities << GeoDataPlacemark::ShopCarRepair;
+ popularities << GeoDataPlacemark::ShopCarParts;
+ popularities << GeoDataPlacemark::ShopMotorcycle;
+ popularities << GeoDataPlacemark::ShopOutdoor;
+ popularities << GeoDataPlacemark::ShopMusicalInstrument;
+ popularities << GeoDataPlacemark::ShopPhoto;
+ popularities << GeoDataPlacemark::ShopBook;
+ popularities << GeoDataPlacemark::ShopGift;
+ popularities << GeoDataPlacemark::ShopStationery;
+ popularities << GeoDataPlacemark::ShopLaundry;
+ popularities << GeoDataPlacemark::ShopPet;
+ popularities << GeoDataPlacemark::ShopToys;
+ popularities << GeoDataPlacemark::ShopTravelAgency;
+ popularities << GeoDataPlacemark::Shop;
+
+ popularities << GeoDataPlacemark::LeisureGolfCourse;
+ popularities << GeoDataPlacemark::LeisurePark;
+ popularities << GeoDataPlacemark::LeisurePlayground;
+ popularities << GeoDataPlacemark::LeisurePitch;
+ popularities << GeoDataPlacemark::LeisureSportsCentre;
+ popularities << GeoDataPlacemark::LeisureStadium;
+ popularities << GeoDataPlacemark::LeisureTrack;
+ popularities << GeoDataPlacemark::LeisureSwimmingPool;
+
+ popularities << GeoDataPlacemark::HighwayTrafficSignals;
+ popularities << GeoDataPlacemark::BarrierGate;
+ popularities << GeoDataPlacemark::BarrierLiftGate;
+ popularities << GeoDataPlacemark::AmenityBench;
+ popularities << GeoDataPlacemark::NaturalTree;
+ popularities << GeoDataPlacemark::AmenityWasteBasket;
+ popularities << GeoDataPlacemark::PowerTower;
+
+ int const offset = 10;
+ int value = defaultValue + offset * popularities.size();
+ for (auto popularity: popularities) {
+ m_popularities[popularity] = value;
+ value -= offset;
+ }
+ }
+
+ return m_popularities.value(category, defaultValue);
+}
+
const GeoDataCoordinates &OsmNode::coordinates() const
{
return m_coordinates;
diff --git a/src/plugins/runner/osm/OsmNode.h b/src/plugins/runner/osm/OsmNode.h
index f5b00a5..5f89ff2 100644
--- a/src/plugins/runner/osm/OsmNode.h
+++ b/src/plugins/runner/osm/OsmNode.h
@@ -12,6 +12,7 @@
#define MARBLE_OSMNODE
#include <osm/OsmPlacemarkData.h>
+#include <GeoDataPlacemark.h>
#include <QString>
@@ -32,11 +33,16 @@ public:
void create(GeoDataDocument* document) const;
+ static int zoomLevelFor(GeoDataPlacemark::GeoDataVisualCategory category, int defaultValue);
+ static qint64 popularityFor(GeoDataPlacemark::GeoDataVisualCategory category, qint64 defaultValue);
+
private:
int populationIndex(qint64 population) const;
OsmPlacemarkData m_osmData;
GeoDataCoordinates m_coordinates;
+ static QHash<GeoDataPlacemark::GeoDataVisualCategory, qint64> m_popularities;
+ static QHash<GeoDataPlacemark::GeoDataVisualCategory, int> m_zoomLevels;
};
typedef QHash<qint64,OsmNode> OsmNodes;
diff --git a/src/plugins/runner/osm/OsmRelation.cpp b/src/plugins/runner/osm/OsmRelation.cpp
index d2a879c..272d648 100644
--- a/src/plugins/runner/osm/OsmRelation.cpp
+++ b/src/plugins/runner/osm/OsmRelation.cpp
@@ -144,7 +144,8 @@ void OsmRelation::create(GeoDataDocument *document, OsmWays &ways, const OsmNode
placemark->setName(m_osmData.tagValue(QStringLiteral("name")));
placemark->setVisualCategory(outerCategory);
placemark->setStyle( GeoDataStyle::Ptr() );
- placemark->setZoomLevel(17);
+ placemark->setZoomLevel(OsmNode::zoomLevelFor(outerCategory, 17));
+ placemark->setPopularity(OsmNode::popularityFor(outerCategory, 100));
placemark->setVisible(outerCategory != GeoDataPlacemark::None);
placemark->setGeometry(polygon);
if (hasMultipleOuterRings) {
diff --git a/src/plugins/runner/osm/OsmWay.cpp b/src/plugins/runner/osm/OsmWay.cpp
index 035d582..3055ce0 100644
--- a/src/plugins/runner/osm/OsmWay.cpp
+++ b/src/plugins/runner/osm/OsmWay.cpp
@@ -74,7 +74,8 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint6
placemark->setName(m_osmData.tagValue(QStringLiteral("ref")));
}
placemark->setOsmData(osmData);
- placemark->setZoomLevel(17);
+ placemark->setZoomLevel(OsmNode::zoomLevelFor(placemark->visualCategory(), 17));
+ placemark->setPopularity(OsmNode::popularityFor(placemark->visualCategory(), 100));
placemark->setVisible(placemark->visualCategory() != GeoDataPlacemark::None);
document->append(placemark);