57 #ifdef CHECK_MEMORY_LEAKS 59 #endif // CHECK_MEMORY_LEAKS 68 if (!oc.
isSet(
"visum-files")) {
73 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
75 throw ProcessError(
"Could not open visum-file '" + *file +
"'.");
78 load(*file, oc, toFill, tm);
90 std::map<long long int, Position> punkte;
91 std::map<long long int, PositionVector> kanten;
92 std::map<long long int, PositionVector> teilflaechen;
93 std::map<long long int, long long int> flaechenelemente;
99 if (line.length() == 0 || line[0] ==
'*' || line[0] ==
'$') {
103 if (what ==
"$PUNKT") {
114 }
else if (what ==
"$KANTE") {
120 vec.push_back(punkte[fromID]);
121 vec.push_back(punkte[toID]);
124 }
else if (what ==
"$ZWISCHENPUNKT") {
134 kanten[id].insert(kanten[
id].begin() + index, pos);
136 }
else if (what ==
"$TEILFLAECHENELEMENT") {
143 if (teilflaechen.find(
id) == teilflaechen.end()) {
147 for (
int i = 0; i < (int) kanten[kid].size(); ++i) {
148 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
151 for (
int i = (
int) kanten[kid].size() - 1; i >= 0; --i) {
152 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
156 }
else if (what ==
"$FLAECHENELEMENT") {
160 flaechenelemente[id] = tid;
164 if (line[0] ==
'$') {
166 if (line.find(
"$PUNKT") == 0) {
168 }
else if (line.find(
"$KANTE") == 0) {
170 }
else if (line.find(
"$ZWISCHENPUNKT") == 0) {
171 what =
"$ZWISCHENPUNKT";
172 }
else if (line.find(
"$TEILFLAECHENELEMENT") == 0) {
173 what =
"$TEILFLAECHENELEMENT";
174 }
else if (line.find(
"$FLAECHENELEMENT") == 0) {
175 what =
"$FLAECHENELEMENT";
178 lineParser.
reinit(line.substr(what.length() + 1));
185 std::map<std::string, std::string> typemap;
188 bool parsingCategories =
false;
189 bool parsingPOIs =
false;
190 bool parsingDistrictsDirectly =
false;
192 std::string polyType, lastID;
197 if (line.length() == 0) {
201 if (line[0] ==
'*') {
205 if (line[0] ==
'$') {
207 parsingCategories =
false;
209 parsingDistrictsDirectly =
false;
213 if (parsingCategories) {
216 std::string catid = st.
next();
217 std::string catname = st.
next();
218 typemap[catid] = catname;
226 std::string catid = lineParser.
get(
"CATID");
232 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
234 std::string type = typemap[catid];
236 bool discard = oc.
getBool(
"discard");
237 int layer = oc.
getInt(
"layer");
253 toFill.
insert(
id, poi, layer);
258 if (polyType !=
"") {
260 std::string
id = st.
next();
262 if (!first && lastID !=
id) {
265 int layer = oc.
getInt(
"layer");
266 bool discard = oc.
getBool(
"discard");
267 if (tm.
has(polyType)) {
281 toFill.
insert(
id, poly, 1);
288 std::string index = st.
next();
289 std::string xpos = st.
next();
290 std::string ypos = st.
next();
293 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
295 vec.push_back(pos2D);
299 if (parsingDistrictsDirectly) {
308 std::string type =
"district";
309 bool discard = oc.
getBool(
"discard");
310 int layer = oc.
getInt(
"layer");
325 if (teilflaechen[flaechenelemente[area]].size() > 0) {
326 Polygon* poly =
new Polygon(
id, type, color, teilflaechen[flaechenelemente[area]],
false, (
SUMOReal)layer);
327 toFill.
insert(
id, poly, layer);
331 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
334 toFill.
insert(
id, poi, layer);
340 if (line.find(
"$POIKATEGORIEDEF:") == 0 || line.find(
"$POIKATEGORIE:") == 0) {
342 parsingCategories =
true;
343 lineParser.
reinit(line.substr(line.find(
":") + 1));
345 if (line.find(
"$POI:") == 0) {
348 lineParser.
reinit(line.substr(line.find(
":") + 1));
350 if (line.find(
"$BEZIRK") == 0 && line.find(
"FLAECHEID") != std::string::npos) {
352 parsingDistrictsDirectly =
true;
353 lineParser.
reinit(line.substr(line.find(
":") + 1));
357 if (line.find(
"$BEZIRKPOLY") != std::string::npos) {
358 polyType =
"district";
360 if (line.find(
"$GEBIETPOLY") != std::string::npos) {
std::string id
The new type id to use.
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) ...
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.
static SUMOReal _2SUMOReal(const E *const data)
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)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static void load(const std::string &file, OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Parses pois/polys stored within the given file.
std::string get(const std::string &name, bool prune=false) const
Returns the named information.
bool insert(const std::string &id, Polygon *poly, int layer, bool ignorePruning=false)
Adds a polygon to the storage.
static long long int _2long(const E *const data)
#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.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
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
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.
#define PROGRESS_BEGIN_MESSAGE(msg)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static int _2int(const E *const data)
std::string prefix
The prefix to use.
A storage for options typed value containers)
void reinit()
Reinitialises the reading (of the previous file)
A parser to retrieve information from a table with known columns.
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
int layer
The layer to use.
#define PROGRESS_DONE_MESSAGE()
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void parseLine(const std::string &line)
Parses the contents of the line.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.