OsmAnd/Osmand-kernel/osmand/src/mapObjects.h

95 lines
1.9 KiB
C
Raw Normal View History

2011-10-29 16:57:27 +02:00
#ifndef _OSMAND_MAP_OBJECTS_H
#define _OSMAND_MAP_OBJECTS_H
2011-10-25 01:10:06 +02:00
#include <vector>
2011-10-29 16:57:27 +02:00
#include <string>
2012-04-30 15:58:02 +02:00
#include <limits.h>
2011-10-25 01:10:06 +02:00
2011-10-28 16:01:00 +02:00
#include "common.h"
2011-10-25 01:10:06 +02:00
2012-04-30 13:33:05 +02:00
typedef pair<std::string, std::string> tag_value;
typedef pair<int, int> int_pair;
typedef vector< pair<int, int> > coordinates;
2011-10-30 00:57:40 +02:00
2011-10-29 16:57:27 +02:00
2012-04-17 23:56:41 +02:00
class MapDataObject
{
static const unsigned int UNDEFINED_STRING = INT_MAX;
2012-04-17 23:56:41 +02:00
public:
2011-10-29 16:57:27 +02:00
2012-04-17 23:56:41 +02:00
std::vector<tag_value> types;
std::vector<tag_value> additionalTypes;
2012-04-28 21:43:14 +02:00
coordinates points;
2012-04-17 23:56:41 +02:00
std::vector < coordinates > polygonInnerCoordinates;
2012-06-15 14:34:25 +02:00
UNORDERED(map)< std::string, unsigned int> stringIds;
2012-04-17 23:56:41 +02:00
2012-06-15 14:34:25 +02:00
UNORDERED(map)< std::string, std::string > objectNames;
2012-04-17 23:56:41 +02:00
bool area;
long long id;
//
bool cycle(){
return points[0] == points[points.size() -1];
}
bool containsAdditional(std::string key, std::string val) {
std::vector<tag_value>::iterator it = additionalTypes.begin();
while (it != additionalTypes.end()) {
2012-06-03 12:58:52 +02:00
if (it->first == key && it->second == val) {
return true;
2012-04-17 23:56:41 +02:00
}
it++;
}
return false;
}
2012-04-28 18:37:20 +02:00
bool contains(std::string key, std::string val) {
std::vector<tag_value>::iterator it = types.begin();
while (it != types.end()) {
if (it->first == key) {
return it->second == val;
}
it++;
}
return false;
}
2012-04-17 23:56:41 +02:00
int getSimpleLayer() {
std::vector<tag_value>::iterator it = additionalTypes.begin();
bool tunnel = false;
bool bridge = false;
2012-04-17 23:56:41 +02:00
while (it != additionalTypes.end()) {
if (it->first == "layer") {
if(it->second.length() > 0) {
if(it->second[0] == '-'){
return -1;
2012-06-13 09:17:07 +02:00
} else if (it->second[0] == '0'){
return 0;
2012-04-17 23:56:41 +02:00
} else {
2012-06-03 12:58:52 +02:00
return 1;
2012-04-17 23:56:41 +02:00
}
}
} else if (it->first == "tunnel") {
tunnel = "yes" == it->second;
} else if (it->first == "bridge") {
bridge = "yes" == it->second;
2012-04-17 23:56:41 +02:00
}
it++;
}
if (tunnel) {
return -1;
} else if (bridge) {
return 1;
}
2012-04-17 23:56:41 +02:00
return 0;
}
2011-10-29 16:57:27 +02:00
};
2011-10-25 01:10:06 +02:00
2012-04-17 23:56:41 +02:00
void deleteObjects(std::vector <MapDataObject* > & v);
2011-10-25 01:10:06 +02:00
2011-10-30 00:57:40 +02:00
2011-10-29 16:57:27 +02:00
#endif /*_OSMAND_MAP_OBJECTS_H*/