55 if (!oc.
isSet(
"visum-files")) {
60 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
62 throw ProcessError(
"Could not open visum-file '" + *file +
"'.");
65 load(*file, oc, toFill, tm);
77 std::map<long long int, Position> punkte;
78 std::map<long long int, PositionVector> kanten;
79 std::map<long long int, PositionVector> teilflaechen;
80 std::map<long long int, long long int> flaechenelemente;
86 if (line.length() == 0 || line[0] ==
'*' || line[0] ==
'$') {
90 if (what ==
"$PUNKT") {
101 }
else if (what ==
"$KANTE") {
107 vec.push_back(punkte[fromID]);
108 vec.push_back(punkte[toID]);
111 }
else if (what ==
"$ZWISCHENPUNKT") {
121 kanten[id].insert(kanten[
id].begin() + index, pos);
123 }
else if (what ==
"$TEILFLAECHENELEMENT") {
130 if (teilflaechen.find(
id) == teilflaechen.end()) {
134 for (
int i = 0; i < (int) kanten[kid].size(); ++i) {
135 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
138 for (
int i = (
int) kanten[kid].size() - 1; i >= 0; --i) {
139 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
143 }
else if (what ==
"$FLAECHENELEMENT") {
147 flaechenelemente[id] = tid;
151 if (line[0] ==
'$') {
153 if (line.find(
"$PUNKT") == 0) {
155 }
else if (line.find(
"$KANTE") == 0) {
157 }
else if (line.find(
"$ZWISCHENPUNKT") == 0) {
158 what =
"$ZWISCHENPUNKT";
159 }
else if (line.find(
"$TEILFLAECHENELEMENT") == 0) {
160 what =
"$TEILFLAECHENELEMENT";
161 }
else if (line.find(
"$FLAECHENELEMENT") == 0) {
162 what =
"$FLAECHENELEMENT";
165 lineParser.
reinit(line.substr(what.length() + 1));
172 std::map<std::string, std::string> typemap;
175 bool parsingCategories =
false;
176 bool parsingPOIs =
false;
177 bool parsingDistrictsDirectly =
false;
179 std::string polyType, lastID;
184 if (line.length() == 0) {
188 if (line[0] ==
'*') {
192 if (line[0] ==
'$') {
194 parsingCategories =
false;
196 parsingDistrictsDirectly =
false;
200 if (parsingCategories) {
203 std::string catid = st.
next();
204 std::string catname = st.
next();
205 typemap[catid] = catname;
213 std::string catid = lineParser.
get(
"CATID");
219 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
221 std::string type = typemap[catid];
223 bool discard = oc.
getBool(
"discard");
224 double layer = oc.
getFloat(
"layer");
245 if (polyType !=
"") {
247 std::string
id = st.
next();
249 if (!first && lastID !=
id) {
252 double layer = oc.
getFloat(
"layer");
253 bool discard = oc.
getBool(
"discard");
254 if (tm.
has(polyType)) {
275 std::string index = st.
next();
276 std::string xpos = st.
next();
277 std::string ypos = st.
next();
278 Position pos2D((
double) atof(xpos.c_str()), (
double) atof(ypos.c_str()));
280 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
282 vec.push_back(pos2D);
286 if (parsingDistrictsDirectly) {
295 std::string type =
"district";
296 bool discard = oc.
getBool(
"discard");
297 double layer = oc.
getFloat(
"layer");
312 if (teilflaechen[flaechenelemente[area]].size() > 0) {
313 SUMOPolygon* poly =
new SUMOPolygon(
id, type, color, teilflaechen[flaechenelemente[area]],
false,
false, 1, layer);
318 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
327 if (line.find(
"$POIKATEGORIEDEF:") == 0 || line.find(
"$POIKATEGORIE:") == 0) {
329 parsingCategories =
true;
330 lineParser.
reinit(line.substr(line.find(
":") + 1));
332 if (line.find(
"$POI:") == 0) {
335 lineParser.
reinit(line.substr(line.find(
":") + 1));
337 if (line.find(
"$BEZIRK") == 0 && line.find(
"FLAECHEID") != std::string::npos) {
339 parsingDistrictsDirectly =
true;
340 lineParser.
reinit(line.substr(line.find(
":") + 1));
344 if (line.find(
"$BEZIRKPOLY") != std::string::npos) {
345 polyType =
"district";
347 if (line.find(
"$GEBIETPOLY") != std::string::npos) {
#define WRITE_WARNING(msg)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool isReadable(std::string path)
Checks whether the given file is readable.
static methods for processing the coordinates conversion for the current net
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.
Retrieves a file linewise and reports the lines to a handler.
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
void reinit()
Reinitialises the reading (of the previous file)
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
A parser to retrieve information from a table with known columns.
void reinit(const std::string &def, const std::string &defDelim=";", const std::string &lineDelim=";", bool chomp=false, bool ignoreCase=true)
Reinitialises the parser.
void parseLine(const std::string &line)
Parses the contents of the line.
std::string get(const std::string &name, bool prune=false) const
Returns the named information.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static void load(const std::string &file, OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Parses pois/polys stored within the given file.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored using VISUM-format.
A storage for loaded polygons and pois.
bool add(SUMOPolygon *poly, bool ignorePruning=false)
Adds a polygon to the storage.
A storage for type mappings.
const TypeDef & get(const std::string &id)
Returns a type definition.
bool has(const std::string &id)
Returns the information whether the named type is known.
A point in 2D or 3D with translation and scaling methods.
static RGBColor parseColor(std::string coldef)
Parses a color information.
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter,...
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
A single definition of values that shall be used for a given type.
bool discard
Information whether polygons of this type shall be discarded.
std::string prefix
The prefix to use.
double layer
The layer to use.
std::string id
The new type id to use.
RGBColor color
The color to use.