OsmPresetLibrary.cpp 39.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2015    Marius-Valeriu Stanciu <stanciumarius94@gmail.com>
//

#include "OsmPresetLibrary.h"

#include "GeoDataTypes.h"
#include "GeoDataFeature.h"
#include "GeoDataPlacemark.h"
#include "GeoDataStyle.h"
#include "OsmPlacemarkData.h"

#include <QMap>

namespace Marble
{

QMap<OsmPresetLibrary::OsmTag, GeoDataFeature::GeoDataVisualCategory> OsmPresetLibrary::s_visualCategories;
QList<OsmPresetLibrary::OsmTag> OsmPresetLibrary::s_additionalOsmTags;
26
QSet<QString> OsmPresetLibrary::s_areaTags;
27
28
29
30

void OsmPresetLibrary::initializeOsmVisualCategories()
{
    // Only initialize the map once
31
    if( !s_visualCategories.isEmpty() ) {
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
        return;
    }

    s_visualCategories[ OsmTag( "admin_level", "1" ) ]              = GeoDataFeature::OtherTerrain;
    s_visualCategories[ OsmTag( "admin_level", "2" ) ]              = GeoDataFeature::OtherTerrain;
    s_visualCategories[ OsmTag( "admin_level", "3" ) ]              = GeoDataFeature::OtherTerrain;
    s_visualCategories[ OsmTag( "admin_level", "4" ) ]              = GeoDataFeature::OtherTerrain;
    s_visualCategories[ OsmTag( "admin_level", "5" ) ]              = GeoDataFeature::OtherTerrain;
    s_visualCategories[ OsmTag( "admin_level", "6" ) ]              = GeoDataFeature::OtherTerrain;
    s_visualCategories[ OsmTag( "admin_level", "7" ) ]              = GeoDataFeature::OtherTerrain;
    s_visualCategories[ OsmTag( "admin_level", "8" ) ]              = GeoDataFeature::OtherTerrain;

    s_visualCategories[ OsmTag( "amenity", "restaurant" ) ]         = GeoDataFeature::FoodRestaurant;
    s_visualCategories[ OsmTag( "amenity", "fast_food" ) ]          = GeoDataFeature::FoodFastFood;
    s_visualCategories[ OsmTag( "amenity", "pub" ) ]                = GeoDataFeature::FoodPub;
    s_visualCategories[ OsmTag( "amenity", "bar" ) ]                = GeoDataFeature::FoodBar;
    s_visualCategories[ OsmTag( "amenity", "cafe" ) ]               = GeoDataFeature::FoodCafe;
    s_visualCategories[ OsmTag( "amenity", "biergarten" ) ]         = GeoDataFeature::FoodBiergarten;
    s_visualCategories[ OsmTag( "amenity", "school" ) ]             = GeoDataFeature::EducationSchool;
    s_visualCategories[ OsmTag( "amenity", "college" ) ]            = GeoDataFeature::EducationCollege;
    s_visualCategories[ OsmTag( "amenity", "library" ) ]            = GeoDataFeature::AmenityLibrary;
    s_visualCategories[ OsmTag( "amenity", "university" ) ]         = GeoDataFeature::EducationUniversity;
    s_visualCategories[ OsmTag( "amenity", "bus_station" ) ]        = GeoDataFeature::TransportBusStation;
    s_visualCategories[ OsmTag( "amenity", "car_sharing" ) ]        = GeoDataFeature::TransportCarShare;
    s_visualCategories[ OsmTag( "amenity", "fuel" ) ]               = GeoDataFeature::TransportFuel;
    s_visualCategories[ OsmTag( "amenity", "parking" ) ]            = GeoDataFeature::TransportParking;
58
    s_visualCategories[ OsmTag( "amenity", "parking_space" ) ]      = GeoDataFeature::TransportParkingSpace;
59
    s_visualCategories[ OsmTag( "amenity", "atm" ) ]                = GeoDataFeature::MoneyAtm;
60
    s_visualCategories[ OsmTag( "amenity", "bank" ) ]               = GeoDataFeature::MoneyBank;
61

Torsten Rahn's avatar
Torsten Rahn committed
62
    s_visualCategories[ OsmTag( "historic", "archaeological_site" ) ] = GeoDataFeature::AmenityArchaeologicalSite;
63
    s_visualCategories[ OsmTag( "amenity", "embassy" ) ]            = GeoDataFeature::AmenityEmbassy;
Torsten Rahn's avatar
Torsten Rahn committed
64
65
    s_visualCategories[ OsmTag( "emergency", "phone" ) ]            = GeoDataFeature::AmenityEmergencyPhone;
    s_visualCategories[ OsmTag( "leisure", "water_park" ) ]         = GeoDataFeature::AmenityWaterPark;
66
    s_visualCategories[ OsmTag( "amenity", "community_centre" ) ]   = GeoDataFeature::AmenityCommunityCentre;
Torsten Rahn's avatar
Torsten Rahn committed
67
    s_visualCategories[ OsmTag( "amenity", "fountain" ) ]           = GeoDataFeature::AmenityFountain;
68
    s_visualCategories[ OsmTag( "amenity", "nightclub" ) ]          = GeoDataFeature::AmenityNightClub;
69
70
    s_visualCategories[ OsmTag( "amenity", "bench" ) ]              = GeoDataFeature::AmenityBench;
    s_visualCategories[ OsmTag( "amenity", "courthouse" ) ]         = GeoDataFeature::AmenityCourtHouse;
Torsten Rahn's avatar
Torsten Rahn committed
71
    s_visualCategories[ OsmTag( "amenity", "fire_station" ) ]       = GeoDataFeature::AmenityFireStation;
72
73
74
75
76
77
78
79
80
81
    s_visualCategories[ OsmTag( "amenity", "hunting_stand" ) ]      = GeoDataFeature::AmenityHuntingStand;
    s_visualCategories[ OsmTag( "amenity", "police" ) ]             = GeoDataFeature::AmenityPolice;
    s_visualCategories[ OsmTag( "amenity", "post_box" ) ]           = GeoDataFeature::AmenityPostBox;
    s_visualCategories[ OsmTag( "amenity", "post_office" ) ]        = GeoDataFeature::AmenityPostOffice;
    s_visualCategories[ OsmTag( "amenity", "prison" ) ]             = GeoDataFeature::AmenityPrison;
    s_visualCategories[ OsmTag( "amenity", "recycling" ) ]          = GeoDataFeature::AmenityRecycling;
    s_visualCategories[ OsmTag( "amenity", "telephone" ) ]          = GeoDataFeature::AmenityTelephone;
    s_visualCategories[ OsmTag( "amenity", "toilets" ) ]            = GeoDataFeature::AmenityToilets;
    s_visualCategories[ OsmTag( "amenity", "townhall" ) ]           = GeoDataFeature::AmenityTownHall;
    s_visualCategories[ OsmTag( "amenity", "waste_basket" ) ]       = GeoDataFeature::AmenityWasteBasket;
82
    s_visualCategories[ OsmTag( "amenity", "drinking_water" ) ]     = GeoDataFeature::AmenityDrinkingWater;
83
    s_visualCategories[ OsmTag( "amenity", "graveyard" ) ]          = GeoDataFeature::AmenityGraveyard;
84
85

    s_visualCategories[ OsmTag( "amenity", "dentist" ) ]            = GeoDataFeature::HealthDentist;
86
87
88
    s_visualCategories[ OsmTag( "amenity", "pharmacy" ) ]           = GeoDataFeature::HealthPharmacy;
    s_visualCategories[ OsmTag( "amenity", "hospital" ) ]           = GeoDataFeature::HealthHospital;
    s_visualCategories[ OsmTag( "amenity", "doctors" ) ]            = GeoDataFeature::HealthDoctors;
89
90
    s_visualCategories[ OsmTag( "amenity", "veterinary" ) ]         = GeoDataFeature::HealthVeterinary;

91
    s_visualCategories[ OsmTag( "amenity", "cinema" ) ]             = GeoDataFeature::TouristCinema;
Torsten Rahn's avatar
Torsten Rahn committed
92
    s_visualCategories[ OsmTag( "tourism", "information" ) ]        = GeoDataFeature::TouristInformation;
93
94
95
    s_visualCategories[ OsmTag( "amenity", "theatre" ) ]            = GeoDataFeature::TouristTheatre;
    s_visualCategories[ OsmTag( "amenity", "place_of_worship" ) ]   = GeoDataFeature::ReligionPlaceOfWorship;

96
    s_visualCategories[ OsmTag( "natural", "peak" ) ]               = GeoDataFeature::NaturalPeak;
97
    s_visualCategories[ OsmTag( "natural", "tree" ) ]               = GeoDataFeature::NaturalTree;
98

99
100
101
102
103
    s_visualCategories[ OsmTag( "shop", "beverages" ) ]             = GeoDataFeature::ShopBeverages;
    s_visualCategories[ OsmTag( "shop", "hifi" ) ]                  = GeoDataFeature::ShopHifi;
    s_visualCategories[ OsmTag( "shop", "supermarket" ) ]           = GeoDataFeature::ShopSupermarket;
    s_visualCategories[ OsmTag( "shop", "alcohol" ) ]               = GeoDataFeature::ShopAlcohol;
    s_visualCategories[ OsmTag( "shop", "bakery" ) ]                = GeoDataFeature::ShopBakery;
104
    s_visualCategories[ OsmTag( "shop", "butcher" ) ]               = GeoDataFeature::ShopButcher;
105
106
107
108
    s_visualCategories[ OsmTag( "shop", "confectionery" ) ]         = GeoDataFeature::ShopConfectionery;
    s_visualCategories[ OsmTag( "shop", "convenience" ) ]           = GeoDataFeature::ShopConvenience;
    s_visualCategories[ OsmTag( "shop", "greengrocer" ) ]           = GeoDataFeature::ShopGreengrocer;
    s_visualCategories[ OsmTag( "shop", "seafood" ) ]               = GeoDataFeature::ShopSeafood;
109
    s_visualCategories[ OsmTag( "shop", "department_store" ) ]      = GeoDataFeature::ShopDepartmentStore;
110
    s_visualCategories[ OsmTag( "shop", "kiosk" ) ]                 = GeoDataFeature::ShopKiosk;
Torsten Rahn's avatar
Torsten Rahn committed
111
    s_visualCategories[ OsmTag( "shop", "bag" ) ]                   = GeoDataFeature::ShopBag;
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
    s_visualCategories[ OsmTag( "shop", "clothes" ) ]               = GeoDataFeature::ShopClothes;
    s_visualCategories[ OsmTag( "shop", "fashion" ) ]               = GeoDataFeature::ShopFashion;
    s_visualCategories[ OsmTag( "shop", "jewelry" ) ]               = GeoDataFeature::ShopJewelry;
    s_visualCategories[ OsmTag( "shop", "shoes" ) ]                 = GeoDataFeature::ShopShoes;
    s_visualCategories[ OsmTag( "shop", "variety_store" ) ]         = GeoDataFeature::ShopVarietyStore;
    s_visualCategories[ OsmTag( "shop", "beauty" ) ]                = GeoDataFeature::ShopBeauty;
    s_visualCategories[ OsmTag( "shop", "chemist" ) ]               = GeoDataFeature::ShopChemist;
    s_visualCategories[ OsmTag( "shop", "cosmetics" ) ]             = GeoDataFeature::ShopCosmetics;
    s_visualCategories[ OsmTag( "shop", "hairdresser" ) ]           = GeoDataFeature::ShopHairdresser;
    s_visualCategories[ OsmTag( "shop", "optician" ) ]              = GeoDataFeature::ShopOptician;
    s_visualCategories[ OsmTag( "shop", "perfumery" ) ]             = GeoDataFeature::ShopPerfumery;
    s_visualCategories[ OsmTag( "shop", "doityourself" ) ]          = GeoDataFeature::ShopDoitYourself;
    s_visualCategories[ OsmTag( "shop", "florist" ) ]               = GeoDataFeature::ShopFlorist;
    s_visualCategories[ OsmTag( "shop", "hardware" ) ]              = GeoDataFeature::ShopHardware;
    s_visualCategories[ OsmTag( "shop", "furniture" ) ]             = GeoDataFeature::ShopFurniture;
    s_visualCategories[ OsmTag( "shop", "electronics" ) ]           = GeoDataFeature::ShopElectronics;
    s_visualCategories[ OsmTag( "shop", "mobile_phone" ) ]          = GeoDataFeature::ShopMobilePhone;
    s_visualCategories[ OsmTag( "shop", "bicycle" ) ]               = GeoDataFeature::ShopBicycle;
    s_visualCategories[ OsmTag( "shop", "car" ) ]                   = GeoDataFeature::ShopCar;
    s_visualCategories[ OsmTag( "shop", "car_repair" ) ]            = GeoDataFeature::ShopCarRepair;
    s_visualCategories[ OsmTag( "shop", "car_parts" ) ]             = GeoDataFeature::ShopCarParts;
    s_visualCategories[ OsmTag( "shop", "motorcycle" ) ]            = GeoDataFeature::ShopMotorcycle;
Torsten Rahn's avatar
Torsten Rahn committed
134
    s_visualCategories[ OsmTag( "shop", "outdoor" ) ]               = GeoDataFeature::ShopOutdoor;
135
136
137
138
139
140
141
142
143
144
    s_visualCategories[ OsmTag( "shop", "musical_instrument" ) ]    = GeoDataFeature::ShopMusicalInstrument;
    s_visualCategories[ OsmTag( "shop", "photo" ) ]                 = GeoDataFeature::ShopPhoto;
    s_visualCategories[ OsmTag( "shop", "books" ) ]                 = GeoDataFeature::ShopBook;
    s_visualCategories[ OsmTag( "shop", "gift" ) ]                  = GeoDataFeature::ShopGift;
    s_visualCategories[ OsmTag( "shop", "stationery" ) ]            = GeoDataFeature::ShopStationery;
    s_visualCategories[ OsmTag( "shop", "laundry" ) ]               = GeoDataFeature::ShopLaundry;
    s_visualCategories[ OsmTag( "shop", "pet" ) ]                   = GeoDataFeature::ShopPet;
    s_visualCategories[ OsmTag( "shop", "toys" ) ]                  = GeoDataFeature::ShopToys;
    s_visualCategories[ OsmTag( "shop", "travel_agency" ) ]         = GeoDataFeature::ShopTravelAgency;

145
146
147
148
149
150
    // Default for all other shops
    foreach(const QString &value, shopValues() ) {
        s_visualCategories[ OsmTag( "shop", value ) ]               = GeoDataFeature::Shop;
    }


151
    s_visualCategories[ OsmTag( "man_made", "bridge" ) ]            = GeoDataFeature::ManmadeBridge;
152
    s_visualCategories[ OsmTag( "man_made", "lighthouse" ) ]        = GeoDataFeature::ManmadeLighthouse;
Torsten Rahn's avatar
Torsten Rahn committed
153
    s_visualCategories[ OsmTag( "man_made", "pier" ) ]              = GeoDataFeature::ManmadePier;
154
    s_visualCategories[ OsmTag( "man_made", "water_tower" ) ]       = GeoDataFeature::ManmadeWaterTower;
Torsten Rahn's avatar
Torsten Rahn committed
155
    s_visualCategories[ OsmTag( "man_made", "windmill" ) ]          = GeoDataFeature::ManmadeWindMill;
156
157
158
159
160

    s_visualCategories[ OsmTag( "religion", "" ) ]                  = GeoDataFeature::ReligionPlaceOfWorship;
    s_visualCategories[ OsmTag( "religion", "bahai" ) ]             = GeoDataFeature::ReligionBahai;
    s_visualCategories[ OsmTag( "religion", "buddhist" ) ]          = GeoDataFeature::ReligionBuddhist;
    s_visualCategories[ OsmTag( "religion", "christian" ) ]         = GeoDataFeature::ReligionChristian;
161
    s_visualCategories[ OsmTag( "religion", "muslim" ) ]            = GeoDataFeature::ReligionMuslim;
162
163
164
165
166
167
    s_visualCategories[ OsmTag( "religion", "hindu" ) ]             = GeoDataFeature::ReligionHindu;
    s_visualCategories[ OsmTag( "religion", "jain" ) ]              = GeoDataFeature::ReligionJain;
    s_visualCategories[ OsmTag( "religion", "jewish" ) ]            = GeoDataFeature::ReligionJewish;
    s_visualCategories[ OsmTag( "religion", "shinto" ) ]            = GeoDataFeature::ReligionShinto;
    s_visualCategories[ OsmTag( "religion", "sikh" ) ]              = GeoDataFeature::ReligionSikh;

Torsten Rahn's avatar
Torsten Rahn committed
168
    s_visualCategories[ OsmTag( "historic", "memorial" ) ]          = GeoDataFeature::TouristAttraction;
169
170
171
172
173
    s_visualCategories[ OsmTag( "tourism", "attraction" ) ]         = GeoDataFeature::TouristAttraction;
    s_visualCategories[ OsmTag( "tourism", "camp_site" ) ]          = GeoDataFeature::AccomodationCamping;
    s_visualCategories[ OsmTag( "tourism", "hostel" ) ]             = GeoDataFeature::AccomodationHostel;
    s_visualCategories[ OsmTag( "tourism", "hotel" ) ]              = GeoDataFeature::AccomodationHotel;
    s_visualCategories[ OsmTag( "tourism", "motel" ) ]              = GeoDataFeature::AccomodationMotel;
Torsten Rahn's avatar
Torsten Rahn committed
174
    s_visualCategories[ OsmTag( "tourism", "guest_house" ) ]        = GeoDataFeature::AccomodationGuestHouse;
175
176
177
178
    s_visualCategories[ OsmTag( "tourism", "museum" ) ]             = GeoDataFeature::TouristMuseum;
    s_visualCategories[ OsmTag( "tourism", "theme_park" ) ]         = GeoDataFeature::TouristThemePark;
    s_visualCategories[ OsmTag( "tourism", "viewpoint" ) ]          = GeoDataFeature::TouristViewPoint;
    s_visualCategories[ OsmTag( "tourism", "zoo" ) ]                = GeoDataFeature::TouristZoo;
Dennis Nienhüser's avatar
Dennis Nienhüser committed
179
    s_visualCategories[ OsmTag( "tourism", "alpine_hut" ) ]         = GeoDataFeature::TouristAlpineHut;
180

181
182
    s_visualCategories[ OsmTag( "barrier", "gate" ) ]               = GeoDataFeature::BarrierGate;
    s_visualCategories[ OsmTag( "barrier", "lift_gate" ) ]           = GeoDataFeature::BarrierLiftGate;
183
    s_visualCategories[ OsmTag( "barrier", "wall" ) ]               = GeoDataFeature::BarrierWall;
184
185
186
187
188
189

    s_visualCategories[ OsmTag( "historic", "castle" ) ]            = GeoDataFeature::TouristCastle;
    s_visualCategories[ OsmTag( "historic", "fort" ) ]              = GeoDataFeature::TouristCastle;
    s_visualCategories[ OsmTag( "historic", "monument" ) ]          = GeoDataFeature::TouristMonument;
    s_visualCategories[ OsmTag( "historic", "ruins" ) ]             = GeoDataFeature::TouristRuin;

190
191
    s_visualCategories[ OsmTag( "highway", "traffic_signals" ) ]    = GeoDataFeature::HighwayTrafficSignals;

192
193
    s_visualCategories[ OsmTag( "highway", "unknown" ) ]            = GeoDataFeature::HighwayUnknown;
    s_visualCategories[ OsmTag( "highway", "steps" ) ]              = GeoDataFeature::HighwaySteps;
194
    s_visualCategories[ OsmTag( "highway", "footway" ) ]            = GeoDataFeature::HighwayFootway;
Dennis Nienhüser's avatar
Dennis Nienhüser committed
195
    s_visualCategories[ OsmTag( "highway", "cycleway" ) ]           = GeoDataFeature::HighwayCycleway;
196
197
198
199
    s_visualCategories[ OsmTag( "highway", "path" ) ]               = GeoDataFeature::HighwayPath;
    s_visualCategories[ OsmTag( "highway", "track" ) ]              = GeoDataFeature::HighwayTrack;
    s_visualCategories[ OsmTag( "highway", "pedestrian" ) ]         = GeoDataFeature::HighwayPedestrian;
    s_visualCategories[ OsmTag( "highway", "service" ) ]            = GeoDataFeature::HighwayService;
200
201
    s_visualCategories[ OsmTag( "highway", "living_street" ) ]      = GeoDataFeature::HighwayLivingStreet;
    s_visualCategories[ OsmTag( "highway", "unclassified" ) ]       = GeoDataFeature::HighwayUnclassified;
202
    s_visualCategories[ OsmTag( "highway", "residential" ) ]        = GeoDataFeature::HighwayResidential;
203
    s_visualCategories[ OsmTag( "highway", "road" ) ]               = GeoDataFeature::HighwayRoad;
204
205
206
207
208
209
210
211
212
213
214
215
    s_visualCategories[ OsmTag( "highway", "tertiary_link" ) ]      = GeoDataFeature::HighwayTertiaryLink;
    s_visualCategories[ OsmTag( "highway", "tertiary" ) ]           = GeoDataFeature::HighwayTertiary;
    s_visualCategories[ OsmTag( "highway", "secondary_link" ) ]     = GeoDataFeature::HighwaySecondaryLink;
    s_visualCategories[ OsmTag( "highway", "secondary" ) ]          = GeoDataFeature::HighwaySecondary;
    s_visualCategories[ OsmTag( "highway", "primary_link" ) ]       = GeoDataFeature::HighwayPrimaryLink;
    s_visualCategories[ OsmTag( "highway", "primary" ) ]            = GeoDataFeature::HighwayPrimary;
    s_visualCategories[ OsmTag( "highway", "trunk_link" ) ]         = GeoDataFeature::HighwayTrunkLink;
    s_visualCategories[ OsmTag( "highway", "trunk" ) ]              = GeoDataFeature::HighwayTrunk;
    s_visualCategories[ OsmTag( "highway", "motorway_link" ) ]      = GeoDataFeature::HighwayMotorwayLink;
    s_visualCategories[ OsmTag( "highway", "motorway" ) ]           = GeoDataFeature::HighwayMotorway;

    s_visualCategories[ OsmTag( "natural", "water" ) ]              = GeoDataFeature::NaturalWater;
216
217
    s_visualCategories[ OsmTag( "natural", "bay" ) ]                = GeoDataFeature::NaturalWater;
    s_visualCategories[ OsmTag( "natural", "coastline" ) ]          = GeoDataFeature::NaturalWater;
218
219
220
221
222
223
    s_visualCategories[ OsmTag( "waterway", "stream" ) ]            = GeoDataFeature::NaturalWater;
    s_visualCategories[ OsmTag( "waterway", "river" ) ]             = GeoDataFeature::NaturalWater;
    s_visualCategories[ OsmTag( "waterway", "riverbank" ) ]         = GeoDataFeature::NaturalWater;
    s_visualCategories[ OsmTag( "waterway", "canal" ) ]             = GeoDataFeature::NaturalWater;

    s_visualCategories[ OsmTag( "natural", "wood" ) ]               = GeoDataFeature::NaturalWood;
224
    s_visualCategories[ OsmTag( "natural", "beach" ) ]              = GeoDataFeature::NaturalBeach;
225
    s_visualCategories[ OsmTag( "natural", "wetland" ) ]            = GeoDataFeature::NaturalWetland;
226
    s_visualCategories[ OsmTag( "natural", "glacier" ) ]            = GeoDataFeature::NaturalGlacier;
227
    s_visualCategories[ OsmTag( "natural", "scrub" ) ]              = GeoDataFeature::NaturalScrub;
228
    s_visualCategories[ OsmTag( "natural", "cliff" ) ]              = GeoDataFeature::NaturalCliff;
229

230
231
    s_visualCategories[ OsmTag( "military", "danger_area" ) ]       = GeoDataFeature::MilitaryDangerArea;

232
233
234
235
236
237
238
239
240
    s_visualCategories[ OsmTag( "landuse", "forest" ) ]             = GeoDataFeature::NaturalWood;
    s_visualCategories[ OsmTag( "landuse", "allotments" ) ]         = GeoDataFeature::LanduseAllotments;
    s_visualCategories[ OsmTag( "landuse", "basin" ) ]              = GeoDataFeature::LanduseBasin;
    s_visualCategories[ OsmTag( "landuse", "brownfield" ) ]         = GeoDataFeature::LanduseConstruction;
    s_visualCategories[ OsmTag( "landuse", "cemetery" ) ]           = GeoDataFeature::LanduseCemetery;
    s_visualCategories[ OsmTag( "landuse", "commercial" ) ]         = GeoDataFeature::LanduseCommercial;
    s_visualCategories[ OsmTag( "landuse", "construction" ) ]       = GeoDataFeature::LanduseConstruction;
    s_visualCategories[ OsmTag( "landuse", "farm" ) ]               = GeoDataFeature::LanduseFarmland;
    s_visualCategories[ OsmTag( "landuse", "farmland" ) ]           = GeoDataFeature::LanduseFarmland;
Torsten Rahn's avatar
Torsten Rahn committed
241
    s_visualCategories[ OsmTag( "landuse", "greenhouse_horticulture" ) ] = GeoDataFeature::LanduseFarmland;
242
243
244
245
246
247
248
249
250
251
    s_visualCategories[ OsmTag( "landuse", "farmyard" ) ]           = GeoDataFeature::LanduseFarmland;
    s_visualCategories[ OsmTag( "landuse", "garages" ) ]            = GeoDataFeature::LanduseGarages;
    s_visualCategories[ OsmTag( "landuse", "greenfield" ) ]         = GeoDataFeature::LanduseConstruction;
    s_visualCategories[ OsmTag( "landuse", "industrial" ) ]         = GeoDataFeature::LanduseIndustrial;
    s_visualCategories[ OsmTag( "landuse", "landfill" ) ]           = GeoDataFeature::LanduseLandfill;
    s_visualCategories[ OsmTag( "landuse", "meadow" ) ]             = GeoDataFeature::LanduseMeadow;
    s_visualCategories[ OsmTag( "landuse", "military" ) ]           = GeoDataFeature::LanduseMilitary;
    s_visualCategories[ OsmTag( "landuse", "orchard" ) ]            = GeoDataFeature::LanduseFarmland;
    s_visualCategories[ OsmTag( "landuse", "quarry" ) ]             = GeoDataFeature::LanduseQuarry;
    s_visualCategories[ OsmTag( "landuse", "railway" ) ]            = GeoDataFeature::LanduseRailway;
Torsten Rahn's avatar
Torsten Rahn committed
252
    s_visualCategories[ OsmTag( "landuse", "recreation_ground" ) ]  = GeoDataFeature::LeisurePark;
253
254
255
    s_visualCategories[ OsmTag( "landuse", "reservoir" ) ]          = GeoDataFeature::LanduseReservoir;
    s_visualCategories[ OsmTag( "landuse", "residential" ) ]        = GeoDataFeature::LanduseResidential;
    s_visualCategories[ OsmTag( "landuse", "retail" ) ]             = GeoDataFeature::LanduseRetail;
256
    s_visualCategories[ OsmTag( "landuse", "orchard" ) ]            = GeoDataFeature::LanduseOrchard;
257
    s_visualCategories[ OsmTag( "landuse", "vineyard" ) ]           = GeoDataFeature::LanduseVineyard;
Torsten Rahn's avatar
Torsten Rahn committed
258
    s_visualCategories[ OsmTag( "landuse", "village_green" ) ]      = GeoDataFeature::LanduseGrass;
Dennis Nienhüser's avatar
Dennis Nienhüser committed
259
    s_visualCategories[ OsmTag( "landuse", "grass" ) ]              = GeoDataFeature::LanduseGrass;
260

Torsten Rahn's avatar
Torsten Rahn committed
261
    s_visualCategories[ OsmTag( "leisure", "common" ) ]             = GeoDataFeature::LanduseGrass;
Torsten Rahn's avatar
Torsten Rahn committed
262
    s_visualCategories[ OsmTag( "leisure", "garden" ) ]             = GeoDataFeature::LanduseGrass;
263
    s_visualCategories[ OsmTag( "leisure", "golf_course" ) ]        = GeoDataFeature::LeisureGolfCourse;
264
    s_visualCategories[ OsmTag( "leisure", "park" ) ]               = GeoDataFeature::LeisurePark;
Dennis Nienhüser's avatar
Dennis Nienhüser committed
265
    s_visualCategories[ OsmTag( "leisure", "playground" ) ]         = GeoDataFeature::LeisurePlayground;
266
    s_visualCategories[ OsmTag( "leisure", "pitch" ) ]              = GeoDataFeature::LeisurePitch;
267
268
    s_visualCategories[ OsmTag( "leisure", "sports_centre" ) ]      = GeoDataFeature::LeisureSportsCentre;
    s_visualCategories[ OsmTag( "leisure", "stadium" ) ]            = GeoDataFeature::LeisureStadium;
Torsten Rahn's avatar
Torsten Rahn committed
269
    s_visualCategories[ OsmTag( "leisure", "track" ) ]              = GeoDataFeature::LeisureTrack;
270
    s_visualCategories[ OsmTag( "leisure", "swimming_pool" ) ]      = GeoDataFeature::LeisureSwimmingPool;
271
272

    s_visualCategories[ OsmTag( "railway", "rail" ) ]               = GeoDataFeature::RailwayRail;
Dennis Nienhüser's avatar
Dennis Nienhüser committed
273
    s_visualCategories[ OsmTag( "railway", "narrow_gauge" ) ]       = GeoDataFeature::RailwayNarrowGauge;
274
275
276
277
278
    s_visualCategories[ OsmTag( "railway", "tram" ) ]               = GeoDataFeature::RailwayTram;
    s_visualCategories[ OsmTag( "railway", "light_rail" ) ]         = GeoDataFeature::RailwayLightRail;
    s_visualCategories[ OsmTag( "railway", "preserved" ) ]          = GeoDataFeature::RailwayPreserved;
    s_visualCategories[ OsmTag( "railway", "abandoned" ) ]          = GeoDataFeature::RailwayAbandoned;
    s_visualCategories[ OsmTag( "railway", "disused" ) ]            = GeoDataFeature::RailwayAbandoned;
279
    s_visualCategories[ OsmTag( "railway", "razed" ) ]              = GeoDataFeature::RailwayAbandoned;
280
281
282
283
284
    s_visualCategories[ OsmTag( "railway", "subway" ) ]             = GeoDataFeature::RailwaySubway;
    s_visualCategories[ OsmTag( "railway", "miniature" ) ]          = GeoDataFeature::RailwayMiniature;
    s_visualCategories[ OsmTag( "railway", "construction" ) ]       = GeoDataFeature::RailwayConstruction;
    s_visualCategories[ OsmTag( "railway", "monorail" ) ]           = GeoDataFeature::RailwayMonorail;
    s_visualCategories[ OsmTag( "railway", "funicular" ) ]          = GeoDataFeature::RailwayFunicular;
285
    s_visualCategories[ OsmTag( "railway", "platform" ) ]           = GeoDataFeature::TransportPlatform;
286
    s_visualCategories[ OsmTag( "railway", "station" ) ]            = GeoDataFeature::TransportTrainStation;
Torsten Rahn's avatar
Torsten Rahn committed
287
    s_visualCategories[ OsmTag( "railway", "halt" ) ]               = GeoDataFeature::TransportTrainStation;
288

Torsten Rahn's avatar
Torsten Rahn committed
289
290
    s_visualCategories[ OsmTag( "power", "tower" ) ]                = GeoDataFeature::PowerTower;

291
292
    s_visualCategories[ OsmTag( "aeroway", "aerodrome" ) ]          = GeoDataFeature::TransportAerodrome;
    s_visualCategories[ OsmTag( "aeroway", "helipad" ) ]            = GeoDataFeature::TransportHelipad;
293
294
    s_visualCategories[ OsmTag( "transport", "airpor_terminal" ) ]  = GeoDataFeature::TransportAirportTerminal;
    s_visualCategories[ OsmTag( "transport", "bus_station" ) ]      = GeoDataFeature::TransportBusStation;
295
    s_visualCategories[ OsmTag( "highway", "bus_stop" ) ]           = GeoDataFeature::TransportBusStop;
296
297
298
    s_visualCategories[ OsmTag( "transport", "car_share" ) ]        = GeoDataFeature::TransportCarShare;
    s_visualCategories[ OsmTag( "transport", "fuel" ) ]             = GeoDataFeature::TransportFuel;
    s_visualCategories[ OsmTag( "transport", "parking" ) ]          = GeoDataFeature::TransportParking;
299
    s_visualCategories[ OsmTag( "public_transport", "platform" ) ]  = GeoDataFeature::TransportPlatform;
300
301
    s_visualCategories[ OsmTag( "amenity", "bicycle_rental" ) ]     = GeoDataFeature::TransportRentalBicycle;
    s_visualCategories[ OsmTag( "amenity", "car_rental" ) ]         = GeoDataFeature::TransportRentalCar;
302
    s_visualCategories[ OsmTag( "amenity", "taxi" ) ]        = GeoDataFeature::TransportTaxiRank;
303
304
    s_visualCategories[ OsmTag( "transport", "train_station" ) ]    = GeoDataFeature::TransportTrainStation;
    s_visualCategories[ OsmTag( "transport", "tram_stop" ) ]        = GeoDataFeature::TransportTramStop;
305
306
307
    s_visualCategories[ OsmTag( "transport", "bus_stop" ) ]         = GeoDataFeature::TransportBusStop;
    s_visualCategories[ OsmTag( "amenity", "bicycle_parking" ) ]    = GeoDataFeature::TransportBicycleParking;
    s_visualCategories[ OsmTag( "amenity", "motorcycle_parking" ) ] = GeoDataFeature::TransportMotorcycleParking;
Torsten Rahn's avatar
Torsten Rahn committed
308
    s_visualCategories[ OsmTag( "railway", "subway_entrance" ) ]    = GeoDataFeature::TransportSubwayEntrance;
309

310
    s_visualCategories[ OsmTag( "place", "city" ) ]                 = GeoDataFeature::PlaceCity;
311
    s_visualCategories[ OsmTag( "place", "suburb" ) ]               = GeoDataFeature::PlaceSuburb;
312
313
314
315
    s_visualCategories[ OsmTag( "place", "hamlet" ) ]               = GeoDataFeature::PlaceHamlet;
    s_visualCategories[ OsmTag( "place", "locality" ) ]             = GeoDataFeature::PlaceLocality;
    s_visualCategories[ OsmTag( "place", "town" ) ]                 = GeoDataFeature::PlaceTown;
    s_visualCategories[ OsmTag( "place", "village" ) ]              = GeoDataFeature::PlaceVillage;
316
317

    // Default for buildings
318
319
320
    foreach(const QString &value, buildingValues() ) {
        s_visualCategories[ OsmTag( "building", value ) ]           = GeoDataFeature::Building;
    }
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
}

void OsmPresetLibrary::initializeAdditionalOsmTags()
{
    // Only initialize the list once
    if( !s_additionalOsmTags.isEmpty() ) {
        return;
    }

    // Recommended for nodes
    s_additionalOsmTags << OsmTag( "power", "pole" );
    s_additionalOsmTags << OsmTag( "power", "generator" );
    s_additionalOsmTags << OsmTag( "barrier", "fence" );
    s_additionalOsmTags << OsmTag( "barrier", "wall" );
    s_additionalOsmTags << OsmTag( "barrier", "gate" );



    // Recommended for ways
    s_additionalOsmTags << OsmTag( "lanes", "" );
    s_additionalOsmTags << OsmTag( "maxspeed", "" );
    s_additionalOsmTags << OsmTag( "maxheight", "" );
    s_additionalOsmTags << OsmTag( "maxweight", "" );
    s_additionalOsmTags << OsmTag( "oneway", "yes" );
    s_additionalOsmTags << OsmTag( "service", "driveway" );
    s_additionalOsmTags << OsmTag( "service", "parking_aisle" );
    s_additionalOsmTags << OsmTag( "service", "alley" );
    s_additionalOsmTags << OsmTag( "tunnel", "yes" );
    s_additionalOsmTags << OsmTag( "abutters", "commercial" );
    s_additionalOsmTags << OsmTag( "abutters", "industrial" );
    s_additionalOsmTags << OsmTag( "abutters", "mixed" );
    s_additionalOsmTags << OsmTag( "abutters", "residential" );



    // Recommended for areas
    s_additionalOsmTags << OsmTag( "surface", "unpaved" );
    s_additionalOsmTags << OsmTag( "surface", "paved" );
    s_additionalOsmTags << OsmTag( "surface", "gravel" );
    s_additionalOsmTags << OsmTag( "surface", "dirt" );
    s_additionalOsmTags << OsmTag( "surface", "grass" );


    // Relations
    s_additionalOsmTags << OsmTag( "type", "route" );
    s_additionalOsmTags << OsmTag( "type", "route_master" );
    s_additionalOsmTags << OsmTag( "type", "public_transport" );
    s_additionalOsmTags << OsmTag( "type", "destination_sign" );
    s_additionalOsmTags << OsmTag( "type", "waterway" );
    s_additionalOsmTags << OsmTag( "type", "enforcement" );



    // Relations: route
    s_additionalOsmTags << OsmTag( "route", "road" );
    s_additionalOsmTags << OsmTag( "route", "bicycle" );
    s_additionalOsmTags << OsmTag( "route", "foot" );
    s_additionalOsmTags << OsmTag( "route", "hiking" );
    s_additionalOsmTags << OsmTag( "route", "bus" );
    s_additionalOsmTags << OsmTag( "route", "trolleybus" );
    s_additionalOsmTags << OsmTag( "route", "ferry" );
    s_additionalOsmTags << OsmTag( "route", "detour" );
    s_additionalOsmTags << OsmTag( "route", "train" );
    s_additionalOsmTags << OsmTag( "route", "tram" );
    s_additionalOsmTags << OsmTag( "route", "mtb" );
    s_additionalOsmTags << OsmTag( "route", "horse" );
    s_additionalOsmTags << OsmTag( "route", "ski" );
    s_additionalOsmTags << OsmTag( "roundtrip", "yes" );
    s_additionalOsmTags << OsmTag( "network", "" );
    s_additionalOsmTags << OsmTag( "ref", "" );
    s_additionalOsmTags << OsmTag( "operator", "" );



    // Relations: route_master
    s_additionalOsmTags << OsmTag( "route_master", "train" );
    s_additionalOsmTags << OsmTag( "route_master", "subway" );
    s_additionalOsmTags << OsmTag( "route_master", "monorail" );
    s_additionalOsmTags << OsmTag( "route_master", "tram" );
    s_additionalOsmTags << OsmTag( "route_master", "bus" );
    s_additionalOsmTags << OsmTag( "route_master", "trolleybus" );
    s_additionalOsmTags << OsmTag( "route_master", "ferry" );
    s_additionalOsmTags << OsmTag( "route_master", "bicycle" );



    // Relations: public_transport
    s_additionalOsmTags << OsmTag( "public_transport", "stop_area" );
    s_additionalOsmTags << OsmTag( "public_transport", "stop_area_group" );



    // Relations: waterway
    s_additionalOsmTags << OsmTag( "waterway", "river" );
    s_additionalOsmTags << OsmTag( "waterway", "stream" );
    s_additionalOsmTags << OsmTag( "waterway", "canal" );
    s_additionalOsmTags << OsmTag( "waterway", "drain" );
    s_additionalOsmTags << OsmTag( "waterway", "ditch" );



    // Relations: enforcement
    s_additionalOsmTags << OsmTag( "enforcement", "maxheight" );
    s_additionalOsmTags << OsmTag( "enforcement", "maxweight" );
    s_additionalOsmTags << OsmTag( "enforcement", "maxspeed" );
    s_additionalOsmTags << OsmTag( "enforcement", "mindistance" );
    s_additionalOsmTags << OsmTag( "enforcement", "traffic_signals" );
    s_additionalOsmTags << OsmTag( "enforcement", "check" );
    s_additionalOsmTags << OsmTag( "enforcement", "access" );
    s_additionalOsmTags << OsmTag( "enforcement", "toll" );



    // Others
    s_additionalOsmTags << OsmTag( "height", "" );
    s_additionalOsmTags << OsmTag( "rooms", "" );
    s_additionalOsmTags << OsmTag( "beds", "" );
    s_additionalOsmTags << OsmTag( "wheelchair", "" );
    s_additionalOsmTags << OsmTag( "website", "" );
    s_additionalOsmTags << OsmTag( "email", "" );
    s_additionalOsmTags << OsmTag( "fee", "" );
    s_additionalOsmTags << OsmTag( "destination", "" );
    s_additionalOsmTags << OsmTag( "indoor", "yes" );



    // Recommended for all
    s_additionalOsmTags << OsmTag( "addr:street", "" );
    s_additionalOsmTags << OsmTag( "addr:housenumber", "" );
    s_additionalOsmTags << OsmTag( "addr:postcode", "" );
    s_additionalOsmTags << OsmTag( "addr:country", "" );
    s_additionalOsmTags << OsmTag( "access", "private" );
    s_additionalOsmTags << OsmTag( "access", "permissive" );
}

Bernhard Beschow's avatar
Bernhard Beschow committed
456
const GeoDataStyle *OsmPresetLibrary::presetStyle( const OsmTag &tag )
457
{
Bernhard Beschow's avatar
Bernhard Beschow committed
458
  GeoDataFeature::GeoDataVisualCategory category = osmVisualCategory( tag.first + "=" + tag.second );
459
460
461
462
463
464
465
466
467
  return GeoDataFeature::presetStyle( category );
}

bool OsmPresetLibrary::hasVisualCategory ( const OsmTag &tag )
{

    return s_visualCategories.contains( tag );
}

Bernhard Beschow's avatar
Bernhard Beschow committed
468
GeoDataFeature::GeoDataVisualCategory OsmPresetLibrary::osmVisualCategory( const QString &keyValue )
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
{
    initializeOsmVisualCategories();
    QStringList tokens = keyValue.split( '=' );

    if ( tokens.size() != 2 ) {
        return GeoDataFeature::None;
    }

    QString key = tokens.at( 0 );
    QString value = tokens.at( 1 );

    return s_visualCategories.value( OsmTag( key, value ) );
}

QMap<OsmPresetLibrary::OsmTag, GeoDataFeature::GeoDataVisualCategory>::const_iterator OsmPresetLibrary::begin()
{
    initializeOsmVisualCategories();
486
    return s_visualCategories.constBegin();
487
488
489
490
491
}

QMap<OsmPresetLibrary::OsmTag, GeoDataFeature::GeoDataVisualCategory>::const_iterator OsmPresetLibrary::end()
{
    initializeOsmVisualCategories();
492
    return s_visualCategories.constEnd();
493
494
495
496
497
}

QList<OsmPresetLibrary::OsmTag>::const_iterator OsmPresetLibrary::additionalTagsBegin()
{
    initializeAdditionalOsmTags();
498
    return s_additionalOsmTags.constBegin();
499
500
501
502
503
}

QList<OsmPresetLibrary::OsmTag>::const_iterator OsmPresetLibrary::additionalTagsEnd()
{
    initializeAdditionalOsmTags();
504
    return s_additionalOsmTags.constEnd();
505
506
}

507
508
509
510
511
512
bool OsmPresetLibrary::isAreaTag(const QString &keyValue)
{
    if (s_areaTags.isEmpty()) {
        // All these tags can be found updated at
        // http://wiki.openstreetmap.org/wiki/Map_Features#Landuse

513
        s_areaTags.insert( "landuse=forest" );
514
        s_areaTags.insert( "natural=water" );
515
516
517
518
519
520
521
522
        s_areaTags.insert( "natural=wood" );
        s_areaTags.insert( "natural=beach" );
        s_areaTags.insert( "natural=wetland" );
        s_areaTags.insert( "natural=glacier" );
        s_areaTags.insert( "natural=scrub" );
        s_areaTags.insert( "natural=cliff" );
        s_areaTags.insert( "area=yes" );
        s_areaTags.insert( "waterway=riverbank" );
523
524

        foreach(const QString &value, buildingValues() ) {
525
            s_areaTags.insert( QString("building=%1").arg(value) );
526
        }
527
        s_areaTags.insert( "man_made=bridge" );
528

529
530
        s_areaTags.insert( "amenity=graveyard" );
        s_areaTags.insert( "amenity=parking" );
531
        s_areaTags.insert( "amenity=parking_space" );
532
533
534
535
        s_areaTags.insert( "amenity=college" );
        s_areaTags.insert( "amenity=hospital" );
        s_areaTags.insert( "amenity=school" );
        s_areaTags.insert( "amenity=university" );
536
537
        s_areaTags.insert( "leisure=common" );
        s_areaTags.insert( "leisure=garden" );
538
        s_areaTags.insert( "leisure=golf_course" );
539
540
541
        s_areaTags.insert( "leisure=playground" );
        s_areaTags.insert( "leisure=pitch" );
        s_areaTags.insert( "leisure=park" );
542
        s_areaTags.insert( "leisure=sports_centre" );
543
        s_areaTags.insert( "leisure=stadium" );
544
        s_areaTags.insert( "leisure=swimming_pool" );
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
        s_areaTags.insert( "leisure=track" );

        s_areaTags.insert( "military=danger_area" );

        s_areaTags.insert( "landuse=allotments" );
        s_areaTags.insert( "landuse=basin" );
        s_areaTags.insert( "landuse=brownfield" );
        s_areaTags.insert( "landuse=cemetery" );
        s_areaTags.insert( "landuse=commercial" );
        s_areaTags.insert( "landuse=construction" );
        s_areaTags.insert( "landuse=farm" );
        s_areaTags.insert( "landuse=farmland" );
        s_areaTags.insert( "landuse=farmyard" );
        s_areaTags.insert( "landuse=garages" );
        s_areaTags.insert( "landuse=greenfield" );
        s_areaTags.insert( "landuse=industrial" );
        s_areaTags.insert( "landuse=landfill" );
        s_areaTags.insert( "landuse=meadow" );
        s_areaTags.insert( "landuse=military" );
        s_areaTags.insert( "landuse=orchard" );
        s_areaTags.insert( "landuse=quarry" );
        s_areaTags.insert( "landuse=railway" );
        s_areaTags.insert( "landuse=reservoir" );
        s_areaTags.insert( "landuse=residential" );
        s_areaTags.insert( "landuse=retail" );
        s_areaTags.insert( "landuse=orchard" );
        s_areaTags.insert( "landuse=vineyard" );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
572
        s_areaTags.insert( "landuse=grass" );
573
574
575
576
577
    }

    return s_areaTags.contains(keyValue);
}

578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
QStringList OsmPresetLibrary::shopValues()
{
    // from https://taginfo.openstreetmap.org/keys/building#values
    static QStringList osmShopValues = QStringList()
        << "cheese" << "chocolate" << "coffee" << "deli" << "dairy" << "farm"
        << "pasta" << "pastry" << "tea" << "wine" << "general" << "mall"
        << "baby_goods" << "boutique" << "fabric" << "leather" << "tailor" << "watches"
        << "charity" << "second_hand" << "erotic" << "hearing_aids" << "herbalist" << "massage"
        << "medical_supply" << "tattoo" << "bathroom_furnishing" << "electrical" << "energy" << "furnace"
        << "garden_centre" << "garden_furniture" << "gas" << "glaziery" << "houseware" << "locksmith"
        << "paint" << "trade" << "antiques" << "bed" << "candles" << "carpet"
        << "curtain" << "interior_decoration" << "kitchen" << "lamps" << "window_blind" << "computer"
        << "radiotechnics" << "vacuum_cleaner" << "fishing" << "free_flying" << "hunting" << "outdoor"
        << "scuba_diving" << "sports" << "tyres" << "swimming_pool" << "art" << "craft"
        << "frame" << "games" << "model" << "music" << "trophy" << "video"
        << "video_games" << "anime" << "ticket" << "copyshop" << "dry_cleaning" << "e-cigarette"
        << "funeral_directors" << "money_lender" << "pawnbroker" << "pyrotechnics" << "religion" << "storage_rental"
        << "tobacco" << "weapons" << "user defined";
    return osmShopValues;
}

599
600
601
602
603
604
605
QStringList OsmPresetLibrary::buildingValues()
{
    // from https://taginfo.openstreetmap.org/keys/building#values
    static QStringList osmBuildingValues = QStringList()
        << "yes" << "house" << "residential" << "garage" << "apartments"
        << "hut" << "industrial" << "detached" << "roof" << "garages"
        << "commercial" << "terrace" << "shed" << "school" << "retail"
Torsten Rahn's avatar
Torsten Rahn committed
606
        << "farm_auxiliary" << "church" << "cathedral" << "greenhouse" << "barn"
607
608
609
610
611
612
        << "service" << "manufacture" << "construction" << "cabin"
        << "farm" << "warehouse" << "House" << "office"
        << "civic" << "Residential" << "hangar" << "public" << "university"
        << "hospital" << "chapel" << "hotel" << "train_station" << "dormitory"
        << "kindergarten" << "stable" << "storage_tank" << "shop" << "college"
        << "supermarket" << "factory" << "bungalow" << "tower" << "silo"
Dennis Nienhüser's avatar
Dennis Nienhüser committed
613
        << "storage" << "station" << "education" << "carport" << "houseboat"
614
615
        << "castle" << "social_facility" << "water_tower" << "container"
        << "exhibition_hall" << "monastery";
616
617
618
    return osmBuildingValues;
}

619
620
621
622
623
624
625
626
GeoDataFeature::GeoDataVisualCategory OsmPresetLibrary::determineVisualCategory(const OsmPlacemarkData &osmData)
{
    if (osmData.containsTagKey("building") && buildingValues().contains(osmData.tagValue("building")) ) {
        return GeoDataFeature::Building;
    }

    for (auto iter = osmData.tagsBegin(), end=osmData.tagsEnd(); iter != end; ++iter) {
        QString const keyValue = QString("%1=%2").arg(iter.key()).arg(iter.value());
Bernhard Beschow's avatar
Bernhard Beschow committed
627
        GeoDataFeature::GeoDataVisualCategory category = osmVisualCategory(keyValue);
628
        if (category != GeoDataFeature::None) {
Bernhard Beschow's avatar
Bernhard Beschow committed
629
            return osmVisualCategory(keyValue);
630
631
632
633
634
635
636
        }
    }


    return GeoDataFeature::None;
}

637
638
639
640
641
QList<GeoDataFeature::GeoDataVisualCategory> OsmPresetLibrary::visualCategories(const OsmPlacemarkData &osmData)
{
    QList<GeoDataFeature::GeoDataVisualCategory> categories;
    for (auto iter = osmData.tagsBegin(), end=osmData.tagsEnd(); iter != end; ++iter) {
        QString const keyValue = QString("%1=%2").arg(iter.key()).arg(iter.value());
Bernhard Beschow's avatar
Bernhard Beschow committed
642
        GeoDataFeature::GeoDataVisualCategory category = osmVisualCategory(keyValue);
643
644
645
646
647
        if (category != GeoDataFeature::None) {
            categories << category;
        }
    }
    return categories;
648
649
}

650
}