Commit 72b2815f authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Provide a render preference for osm placemarks

The visual category now decides which one to render in case several
placemarks collide on screen.
parent 0d28f009
......@@ -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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment