63 if (!oc.
isSet(
"visum-files")) {
68 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
70 throw ProcessError(
"Could not open visum-file '" + *file +
"'.");
73 load(*file, oc, toFill, tm);
85 std::map<long long int, Position> punkte;
86 std::map<long long int, PositionVector> kanten;
87 std::map<long long int, PositionVector> teilflaechen;
88 std::map<long long int, long long int> flaechenelemente;
94 if (line.length() == 0 || line[0] ==
'*' || line[0] ==
'$') {
98 if (what ==
"$PUNKT") {
109 }
else if (what ==
"$KANTE") {
115 vec.push_back(punkte[fromID]);
116 vec.push_back(punkte[toID]);
119 }
else if (what ==
"$ZWISCHENPUNKT") {
129 kanten[id].insert(kanten[
id].begin() + index, pos);
131 }
else if (what ==
"$TEILFLAECHENELEMENT") {
138 if (teilflaechen.find(
id) == teilflaechen.end()) {
142 for (
int i = 0; i < (int) kanten[kid].size(); ++i) {
143 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
146 for (
int i = (
int) kanten[kid].size() - 1; i >= 0; --i) {
147 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
151 }
else if (what ==
"$FLAECHENELEMENT") {
155 flaechenelemente[id] = tid;
159 if (line[0] ==
'$') {
161 if (line.find(
"$PUNKT") == 0) {
163 }
else if (line.find(
"$KANTE") == 0) {
165 }
else if (line.find(
"$ZWISCHENPUNKT") == 0) {
166 what =
"$ZWISCHENPUNKT";
167 }
else if (line.find(
"$TEILFLAECHENELEMENT") == 0) {
168 what =
"$TEILFLAECHENELEMENT";
169 }
else if (line.find(
"$FLAECHENELEMENT") == 0) {
170 what =
"$FLAECHENELEMENT";
173 lineParser.
reinit(line.substr(what.length() + 1));
180 std::map<std::string, std::string> typemap;
183 bool parsingCategories =
false;
184 bool parsingPOIs =
false;
185 bool parsingDistrictsDirectly =
false;
187 std::string polyType, lastID;
192 if (line.length() == 0) {
196 if (line[0] ==
'*') {
200 if (line[0] ==
'$') {
202 parsingCategories =
false;
204 parsingDistrictsDirectly =
false;
208 if (parsingCategories) {
211 std::string catid = st.
next();
212 std::string catname = st.
next();
213 typemap[catid] = catname;
221 std::string catid = lineParser.
get(
"CATID");
227 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
229 std::string type = typemap[catid];
231 bool discard = oc.
getBool(
"discard");
232 double layer = oc.
getFloat(
"layer");
253 if (polyType !=
"") {
255 std::string
id = st.
next();
257 if (!first && lastID !=
id) {
260 double layer = oc.
getFloat(
"layer");
261 bool discard = oc.
getBool(
"discard");
262 if (tm.
has(polyType)) {
283 std::string index = st.
next();
284 std::string xpos = st.
next();
285 std::string ypos = st.
next();
286 Position pos2D((
double) atof(xpos.c_str()), (
double) atof(ypos.c_str()));
288 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
290 vec.push_back(pos2D);
294 if (parsingDistrictsDirectly) {
303 std::string type =
"district";
304 bool discard = oc.
getBool(
"discard");
305 double layer = oc.
getFloat(
"layer");
320 if (teilflaechen[flaechenelemente[area]].size() > 0) {
321 SUMOPolygon* poly =
new SUMOPolygon(
id, type, color, teilflaechen[flaechenelemente[area]],
false,
false, layer);
326 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
335 if (line.find(
"$POIKATEGORIEDEF:") == 0 || line.find(
"$POIKATEGORIE:") == 0) {
337 parsingCategories =
true;
338 lineParser.
reinit(line.substr(line.find(
":") + 1));
340 if (line.find(
"$POI:") == 0) {
343 lineParser.
reinit(line.substr(line.find(
":") + 1));
345 if (line.find(
"$BEZIRK") == 0 && line.find(
"FLAECHEID") != std::string::npos) {
347 parsingDistrictsDirectly =
true;
348 lineParser.
reinit(line.substr(line.find(
":") + 1));
352 if (line.find(
"$BEZIRKPOLY") != std::string::npos) {
353 polyType =
"district";
355 if (line.find(
"$GEBIETPOLY") != std::string::npos) {
std::string id
The new type id to use.
static RGBColor parseColor(std::string coldef)
Parses a color information.
A single definition of values that shall be used for a given type.
static bool isReadable(std::string path)
Checks whether the given file is readable.
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
bool add(SUMOPolygon *poly, bool ignorePruning=false)
Adds a polygon to the storage.
Retrieves a file linewise and reports the lines to a handler.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
static void load(const std::string &file, OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Parses pois/polys stored within the given file.
double layer
The layer to use.
static long long int _2long(const E *const data)
converts a char-type array into the long value described by it
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
std::string get(const std::string &name, bool prune=false) const
Returns the named information.
#define WRITE_WARNING(msg)
bool discard
Information whether polygons of this type shall be discarded.
A storage for loaded polygons and pois.
RGBColor color
The color to use.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void reinit(const std::string &def, const std::string &defDelim=";", const std::string &lineDelim=";", bool chomp=false, bool ignoreCase=true)
Reinitialises the parser.
A storage for type mappings.
const TypeDef & get(const std::string &id)
Returns a type definition.
static methods for processing the coordinates conversion for the current net
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A point in 2D or 3D with translation and scaling methods.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored using VISUM-format.
bool has(const std::string &id)
Returns the information whether the named type is known.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
#define PROGRESS_BEGIN_MESSAGE(msg)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
std::string prefix
The prefix to use.
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
A storage for options typed value containers)
static double _2double(const E *const data)
converts a char-type array into the double value described by it
void reinit()
Reinitialises the reading (of the previous file)
A parser to retrieve information from a table with known columns.
#define PROGRESS_DONE_MESSAGE()
void parseLine(const std::string &line)
Parses the contents of the line.