1 #ifndef OSMSCOUT_TYPECONFIG_H 2 #define OSMSCOUT_TYPECONFIG_H 26 #include <unordered_map> 27 #include <unordered_set> 71 static const uint8_t typeNode = 1u << 0u;
72 static const uint8_t typeWay = 1u << 1u;
73 static const uint8_t typeArea = 1u << 2u;
74 static const uint8_t typeRelation = 1u << 3u;
107 std::list<TypeCondition> conditions;
108 std::unordered_map<std::string,size_t> nameToFeatureMap;
109 std::vector<FeatureInstance> features;
110 size_t featureMaskBytes=0;
111 size_t specialFeatureMaskBytes=0;
112 size_t valueBufferSize=0;
114 bool canBeNode=
false;
116 bool canBeArea=
false;
117 bool canBeRelation=
false;
119 bool canRouteFoot=
false;
120 bool canRouteBicycle=
false;
121 bool canRouteCar=
false;
122 bool indexAsAddress=
false;
123 bool indexAsLocation=
false;
124 bool indexAsRegion=
false;
125 bool indexAsPOI=
false;
126 bool optimizeLowZoom=
false;
129 bool mergeAreas=
false;
130 bool ignoreSeaLand=
false;
133 uint8_t onewayLanes=1;
135 std::unordered_set<std::string> groups;
136 std::unordered_map<std::string,std::string> descriptions;
142 TypeInfo(
const TypeInfo& other) =
delete;
144 TypeInfo& operator=(
const TypeInfo& other) =
delete;
147 explicit TypeInfo(
const std::string& name);
152 TypeInfo& SetNodeId(
TypeId id);
157 TypeInfo& SetWayId(
TypeId id);
162 TypeInfo& SetAreaId(
TypeId id);
167 TypeInfo& SetRouteId(
TypeId id);
172 TypeInfo& SetIndex(
size_t index);
177 TypeInfo& SetInternal();
182 TypeInfo& SetType(
const std::string& name);
184 TypeInfo& AddCondition(
unsigned char types,
190 TypeInfo& AddFeature(
const FeatureRef& feature);
195 TypeInfo& AddGroup(
const std::string& groupName);
197 TypeInfo& AddDescription(
const std::string& languageCode,
198 const std::string& description);
202 return !features.empty();
209 bool HasFeature(
const std::string& featureName)
const;
214 bool GetFeature(
const std::string& name,
215 size_t& index)
const;
222 return features[idx];
238 return features.size();
246 return featureMaskBytes;
255 return specialFeatureMaskBytes;
263 return valueBufferSize;
331 return !conditions.empty();
347 this->canBeNode=canBeNode;
362 this->canBeWay=canBeWay;
377 this->canBeArea=canBeArea;
392 this->canBeRelation=canBeRelation;
399 return canBeRelation;
422 this->canRouteFoot=canBeRoute;
429 this->canRouteBicycle=canBeRoute;
439 this->canRouteCar=canBeRoute;
446 return canRouteFoot || canRouteBicycle || canRouteCar;
459 return canRouteBicycle;
474 return canRouteBicycle;
482 uint8_t GetDefaultAccess()
const;
489 this->indexAsAddress=indexAsAddress;
496 return indexAsAddress;
504 this->indexAsLocation=indexAsLocation;
511 return indexAsLocation;
519 this->indexAsRegion=indexAsRegion;
526 return indexAsRegion;
534 this->indexAsPOI=indexAsPOI;
549 this->optimizeLowZoom=optimize;
556 return optimizeLowZoom;
560 this->specialType=specialType;
575 this->specialType=SpecialType::multipolygon;
585 this->specialType=SpecialType::routeMaster;
595 this->specialType=SpecialType::route;
602 return specialType==SpecialType::multipolygon;
607 return specialType==SpecialType::routeMaster;
612 return specialType==SpecialType::route;
632 this->mergeAreas=mergeAreas;
647 this->ignoreSeaLand=ignoreSeaLand;
654 return ignoreSeaLand;
687 this->onewayLanes=lanes;
700 const std::unordered_set<std::string>&
GetGroups()
const 707 return groups.find(groupName)!=groups.end();
715 std::string GetDescription(
const std::string& languageCode)
const;
728 uint8_t *featureBits;
729 char *featureValueBuffer;
734 void AllocateValueBufferLazy();
740 FeatureValue* GetValueAndAllocateBuffer(
size_t idx)
742 AllocateValueBufferLazy();
743 return static_cast<FeatureValue*
>(
static_cast<void*
>(&featureValueBuffer[type->GetFeature(idx).GetOffset()]));
747 FeatureValueBuffer();
748 FeatureValueBuffer(
const FeatureValueBuffer& other);
749 ~FeatureValueBuffer();
758 void Set(
const FeatureValueBuffer& other);
773 void CopyMissingValues(
const FeatureValueBuffer& other);
778 void ClearFeatureValues();
792 return type->GetFeatureCount();
800 return type->GetFeature(idx);
808 size_t featureBit=type->GetFeature(idx).GetFeatureBit();
810 return (featureBits[featureBit/8] & (1u << featureBit%8))!=0;
823 return featureValueBuffer==
nullptr ? nullptr
824 :
static_cast<FeatureValue*
>(
static_cast<void*
>(&featureValueBuffer[type->GetFeature(idx).GetOffset()]));
828 void FreeValue(
size_t idx);
831 const TagRegistry& tagRegistry,
832 const ObjectOSMRef&
object,
835 void Read(FileScanner& scanner);
836 void Read(FileScanner& scanner,
838 void Read(FileScanner& scanner,
841 void Write(FileWriter& writer)
const;
842 void Write(FileWriter& writer,
843 bool specialFlag)
const;
844 void Write(FileWriter& writer,
846 bool specialFlag2)
const;
848 FeatureValueBuffer& operator=(
const FeatureValueBuffer& other);
849 bool operator==(
const FeatureValueBuffer& other)
const;
850 bool operator!=(
const FeatureValueBuffer& other)
const;
854 for (
const auto& featureInstance :GetType()->GetFeatures()) {
855 if (HasFeature(featureInstance.GetIndex())) {
857 if (feature->HasValue()) {
859 const auto *v=
dynamic_cast<const T*
>(value);
893 TagRegistry tagRegistry;
897 std::vector<TypeInfoRef> types;
898 std::vector<TypeInfoRef> nodeTypes;
899 std::vector<TypeInfoRef> wayTypes;
900 std::vector<TypeInfoRef> areaTypes;
901 std::vector<TypeInfoRef> routeTypes;
903 uint8_t nodeTypeIdBytes=1;
904 uint8_t wayTypeIdBytes=1;
905 uint8_t areaTypeIdBits=1;
906 uint8_t areaTypeIdBytes=1;
907 uint8_t routeTypeIdBytes=1;
909 std::unordered_map<std::string,TypeInfoRef> nameToTypeMap;
913 std::vector<FeatureRef> features;
915 std::unordered_map<std::string,FeatureRef> nameToFeatureMap;
965 return tagRegistry.GetTagId(name);
970 return tagRegistry.GetTagId(name);
991 tagRegistry.RegisterSurfaceToGradeMapping(surface,
1003 tagRegistry.RegisterMaxSpeedAlias(alias,
1032 return nodeTypeIdBytes;
1045 return wayTypeIdBytes;
1058 return areaTypeIdBits;
1063 return areaTypeIdBytes;
1076 return routeTypeIdBytes;
1085 return types.size();
1091 TypeId GetMaxTypeId()
const;
1098 assert(index<types.size());
1100 return types[index];
1108 assert(
id<=nodeTypes.size());
1111 return typeInfoIgnore;
1114 return nodeTypes[
id-1];
1122 assert(
id<=wayTypes.size());
1125 return typeInfoIgnore;
1128 return wayTypes[
id-1];
1136 assert(
id<=areaTypes.size());
1139 return typeInfoIgnore;
1142 return areaTypes[
id-1];
1150 assert(
id<=routeTypes.size());
1153 return typeInfoIgnore;
1156 return routeTypes[
id-1];
1163 const TypeInfoRef GetTypeInfo(
const std::string& name)
const;
1179 bool GetWayAreaType(
const TagMap& tagMap,
1197 void RegisterFeature(
const FeatureRef& feature);
1203 FeatureRef GetFeature(
const std::string& name)
const;
1218 bool LoadFromOSTFile(
const std::string& filename);
1219 bool LoadFromDataFile(
const std::string& directory);
1220 bool StoreToDataFile(
const std::string& directory)
const;
TypeInfo & SetIgnoreSeaLand(bool ignoreSeaLand)
Definition: TypeConfig.h:645
TypeInfo & CanBeNode(bool canBeNode)
Definition: TypeConfig.h:345
bool GetIndexAsAddress() const
Definition: TypeConfig.h:494
TypeInfoRef typeInfoTileSea
Internal type for ground tiles of type "sea".
Definition: TypeConfig.h:948
bool IsPath() const
Definition: TypeConfig.h:412
FeatureInstance GetFeature(size_t idx) const
Definition: TypeConfig.h:798
Definition: OSMScoutTypes.h:59
TypeInfoRef typeInfoOSMSubTileBorder
Internal type for OSM tile borders.
Definition: TypeConfig.h:953
bool CanRoute(Vehicle vehicle) const
Definition: TypeConfig.h:452
uint16_t TagId
Definition: Tag.h:39
std::string GetName() const
Definition: TypeConfig.h:319
uint8_t GetRouteTypeIdBytes() const
Definition: TypeConfig.h:1074
uint8_t GetAreaTypeIdBytes() const
Definition: TypeConfig.h:1061
TagId tagType
Definition: TypeConfig.h:942
TypeInfo & SetRouteMaster()
Definition: TypeConfig.h:583
bool GetPinWay() const
Definition: TypeConfig.h:622
const TagRegistry & GetTagRegistry() const
Definition: TypeConfig.h:973
bool IsInternal() const
Definition: TypeConfig.h:311
TypeInfoRef GetTypeInfo(size_t index) const
Definition: TypeConfig.h:1096
const std::list< TypeCondition > & GetConditions() const
Definition: TypeConfig.h:337
TypeInfoRef GetAreaTypeInfo(TypeId id) const
Definition: TypeConfig.h:1134
static const TypeId typeIgnore
Definition: TypeConfig.h:54
uint8_t GetLanes() const
Definition: TypeConfig.h:680
const std::vector< TypeInfoRef > & GetTypes() const
Definition: TypeConfig.h:1017
bool GetIndexAsPOI() const
Definition: TypeConfig.h:539
bool CanBeWay() const
Definition: TypeConfig.h:367
TypeId GetNodeId() const
Definition: TypeConfig.h:270
TagId tagNatural
Definition: TypeConfig.h:940
bool IsMultipolygon() const
Definition: TypeConfig.h:600
TypeInfo & SetIsPath(bool isPath)
Definition: TypeConfig.h:405
const std::vector< FeatureRef > & GetFeatures() const
Definition: TypeConfig.h:1208
bool GetIgnore() const
Definition: TypeConfig.h:668
bool CanRouteBicycle() const
Definition: TypeConfig.h:472
uint16_t TypeId
Definition: OSMScoutTypes.h:53
uint8_t GetNodeTypeIdBytes() const
Definition: TypeConfig.h:1030
const std::unordered_set< std::string > & GetGroups() const
Definition: TypeConfig.h:700
TypeId GetWayId() const
Definition: TypeConfig.h:279
Vehicle
Definition: OSMScoutTypes.h:55
TypeId GetRouteId() const
Definition: TypeConfig.h:295
const std::vector< TypeInfoRef > & GetNodeTypes() const
Definition: TypeConfig.h:1025
TagConditionRef condition
The root condition.
Definition: TypeConfig.h:94
TypeInfo & SetSpecialType(SpecialType specialType)
Definition: TypeConfig.h:559
TypeInfo & CanBeArea(bool canBeArea)
Definition: TypeConfig.h:375
TypeInfo & SetPinWay(bool pinWay)
Definition: TypeConfig.h:615
TagId GetTagId(const std::string &name) const
Definition: TypeConfig.h:968
TypeInfoRef GetType() const
Definition: TypeConfig.h:782
bool operator!=(const MapViewStruct &r1, const MapViewStruct &r2)
Definition: DBThread.h:61
TypeInfo & SetIndexAsAddress(bool indexAsAddress)
Definition: TypeConfig.h:487
const std::vector< TypeInfoRef > & GetRouteTypes() const
Definition: TypeConfig.h:1069
const std::vector< FeatureInstance > & GetFeatures() const
Definition: TypeConfig.h:228
const std::vector< TypeInfoRef > & GetAreaTypes() const
Definition: TypeConfig.h:1051
bool GetMergeAreas() const
Definition: TypeConfig.h:637
static const uint32_t FILE_FORMAT_VERSION
Definition: TypeConfig.h:876
bool HasFeature(size_t idx) const
Definition: TypeConfig.h:806
TypeInfo & SetOptimizeLowZoom(bool optimize)
Definition: TypeConfig.h:547
TypeInfo & SetIndexAsPOI(bool indexAsPOI)
Definition: TypeConfig.h:532
size_t GetSpecialFeatureMaskBytes() const
Definition: TypeConfig.h:253
bool IsRouteMaster() const
Definition: TypeConfig.h:605
Definition: OSMScoutTypes.h:57
TypeInfo & CanRouteFoot(bool canBeRoute)
Definition: TypeConfig.h:420
TagId tagRestriction
Definition: TypeConfig.h:943
TypeInfo & CanRouteCar(bool canBeRoute)
Definition: TypeConfig.h:437
TypeInfoRef typeInfoTileLand
Internal type for ground tiles of type "land".
Definition: TypeConfig.h:947
bool CanBeRelation() const
Definition: TypeConfig.h:397
bool GetOptimizeLowZoom() const
Definition: TypeConfig.h:554
std::shared_ptr< FeatureValueBuffer > FeatureValueBufferRef
Definition: TypeConfig.h:871
TypeInfo & SetOnewayLanes(uint8_t lanes)
Definition: TypeConfig.h:685
SpecialType GetSpecialType() const
Definition: TypeConfig.h:565
bool GetIndexAsRegion() const
Definition: TypeConfig.h:524
size_t GetFeatureCount() const
Definition: TypeConfig.h:236
bool HasConditions() const
Definition: TypeConfig.h:329
TypeInfoRef GetWayTypeInfo(TypeId id) const
Definition: TypeConfig.h:1120
Definition: TypeFeature.h:40
size_t GetTypeCount() const
Definition: TypeConfig.h:1083
TypeInfo & CanRouteBicycle(bool canBeRoute)
Definition: TypeConfig.h:427
#define CLASS_FINAL
Definition: Compiler.h:26
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
TypeInfoRef typeInfoIgnore
Definition: TypeConfig.h:946
size_t GetIndex() const
Definition: TypeConfig.h:303
unsigned char types
Bitset of types the condition can be applied to.
Definition: TypeConfig.h:93
FeatureValue * GetValue(size_t idx) const
Definition: TypeConfig.h:821
bool GetIgnoreSeaLand() const
Definition: TypeConfig.h:652
TypeId GetAreaId() const
Definition: TypeConfig.h:287
std::shared_ptr< Feature > FeatureRef
Definition: TypeFeature.h:219
TypeInfoRef typeInfoCoastline
Internal type for coastlines.
Definition: TypeConfig.h:951
Definition: TagErrorReporter.h:32
bool CanBeNode() const
Definition: TypeConfig.h:352
bool HasFeatures() const
Definition: TypeConfig.h:200
TagRegistry & GetTagRegistry()
Definition: TypeConfig.h:978
TypeInfoRef typeInfoTileUnknown
Internal type for ground tiles of type "unknown".
Definition: TypeConfig.h:950
const T * findValue() const
Definition: TypeConfig.h:852
TypeInfoRef typeInfoTileCoast
Internal type for ground tiles of type "coast".
Definition: TypeConfig.h:949
TypeInfo & SetMergeAreas(bool mergeAreas)
Definition: TypeConfig.h:630
static const char * FILE_TYPES_DAT
Definition: TypeConfig.h:887
bool operator==(const MapView &a, const MapView &b)
Definition: InputHandler.h:222
void RegisterMaxSpeedAlias(const std::string &alias, uint8_t maxSpeed)
Definition: TypeConfig.h:1000
bool CanRouteCar() const
Definition: TypeConfig.h:477
TagId tagJunction
Definition: TypeConfig.h:944
TypeInfo & SetMultipolygon()
Definition: TypeConfig.h:573
TagId tagArea
Definition: TypeConfig.h:939
TagId tagDataPolygon
Definition: TypeConfig.h:941
TypeInfoRef typeInfoOSMTileBorder
Internal type for OSM tile borders.
Definition: TypeConfig.h:952
const std::unordered_map< std::string, std::string > & GetDescriptions() const
Definition: TypeConfig.h:710
TypeInfoRef GetRouteTypeInfo(TypeId id) const
Definition: TypeConfig.h:1148
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
size_t GetFeatureMaskBytes() const
Definition: TypeConfig.h:244
TypeInfo & CanBeRelation(bool canBeRelation)
Definition: TypeConfig.h:390
const FeatureInstance & GetFeature(size_t idx) const
Definition: TypeConfig.h:220
const std::vector< TypeInfoRef > & GetWayTypes() const
Definition: TypeConfig.h:1038
TypeInfo & SetIgnore(bool ignore)
Definition: TypeConfig.h:661
void RegisterSurfaceToGradeMapping(const std::string &surface, size_t grade)
Definition: TypeConfig.h:988
uint8_t GetAreaTypeIdBits() const
Definition: TypeConfig.h:1056
uint8_t GetWayTypeIdBytes() const
Definition: TypeConfig.h:1043
bool CanRoute() const
Definition: TypeConfig.h:444
SpecialType
Definition: TypeConfig.h:76
uint8_t GetOnewayLanes() const
Definition: TypeConfig.h:692
std::unordered_map< TagId, std::string > TagMap
Definition: Tag.h:41
std::shared_ptr< TagCondition > TagConditionRef
Definition: Tag.h:68
TypeInfo & CanBeWay(bool canBeWay)
Definition: TypeConfig.h:360
std::shared_ptr< TypeConfig > TypeConfigRef
Definition: TypeConfig.h:1227
TypeInfo & SetRoute()
Definition: TypeConfig.h:593
Definition: TypeConfig.h:91
bool CanBeArea() const
Definition: TypeConfig.h:382
TagId GetTagId(const char *name) const
Definition: TypeConfig.h:963
TypeInfo & SetIndexAsRegion(bool indexAsRegion)
Definition: TypeConfig.h:517
TypeInfo & SetLanes(uint8_t lanes)
Definition: TypeConfig.h:673
bool IsRoute() const
Definition: TypeConfig.h:610
Definition: OSMScoutTypes.h:58
bool CanRouteFoot() const
Definition: TypeConfig.h:467
bool GetIndexAsLocation() const
Definition: TypeConfig.h:509
TypeInfo & SetIndexAsLocation(bool indexAsLocation)
Definition: TypeConfig.h:502
TypeInfoRef GetNodeTypeInfo(TypeId id) const
Definition: TypeConfig.h:1106
bool IsInGroup(const std::string &groupName) const
Definition: TypeConfig.h:705
size_t GetFeatureValueBufferSize() const
Definition: TypeConfig.h:261