 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
56 if (!oc.
isSet(
"visum-files")) {
61 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
63 throw ProcessError(
"Could not open visum-file '" + *file +
"'.");
66 load(*file, oc, toFill, tm);
78 std::map<long long int, Position> punkte;
79 std::map<long long int, PositionVector> kanten;
80 std::map<long long int, PositionVector> teilflaechen;
81 std::map<long long int, long long int> flaechenelemente;
87 if (line.length() == 0 || line[0] ==
'*' || line[0] ==
'$') {
91 if (what ==
"$PUNKT") {
102 }
else if (what ==
"$KANTE") {
108 vec.push_back(punkte[fromID]);
109 vec.push_back(punkte[toID]);
112 }
else if (what ==
"$ZWISCHENPUNKT") {
122 kanten[id].insert(kanten[
id].begin() + index, pos);
124 }
else if (what ==
"$TEILFLAECHENELEMENT") {
131 if (teilflaechen.find(
id) == teilflaechen.end()) {
135 for (
int i = 0; i < (int) kanten[kid].size(); ++i) {
136 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
139 for (
int i = (
int) kanten[kid].size() - 1; i >= 0; --i) {
140 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
144 }
else if (what ==
"$FLAECHENELEMENT") {
148 flaechenelemente[id] = tid;
152 if (line[0] ==
'$') {
154 if (line.find(
"$PUNKT") == 0) {
156 }
else if (line.find(
"$KANTE") == 0) {
158 }
else if (line.find(
"$ZWISCHENPUNKT") == 0) {
159 what =
"$ZWISCHENPUNKT";
160 }
else if (line.find(
"$TEILFLAECHENELEMENT") == 0) {
161 what =
"$TEILFLAECHENELEMENT";
162 }
else if (line.find(
"$FLAECHENELEMENT") == 0) {
163 what =
"$FLAECHENELEMENT";
166 lineParser.
reinit(line.substr(what.length() + 1));
173 std::map<std::string, std::string> typemap;
176 bool parsingCategories =
false;
177 bool parsingPOIs =
false;
178 bool parsingDistrictsDirectly =
false;
180 std::string polyType, lastID;
185 if (line.length() == 0) {
189 if (line[0] ==
'*') {
193 if (line[0] ==
'$') {
195 parsingCategories =
false;
197 parsingDistrictsDirectly =
false;
201 if (parsingCategories) {
204 std::string catid = st.
next();
205 std::string catname = st.
next();
206 typemap[catid] = catname;
214 std::string catid = lineParser.
get(
"CATID");
220 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
222 std::string type = typemap[catid];
224 bool discard = oc.
getBool(
"discard");
225 double layer = oc.
getFloat(
"layer");
246 if (polyType !=
"") {
248 std::string
id = st.
next();
250 if (!first && lastID !=
id) {
253 double layer = oc.
getFloat(
"layer");
254 bool discard = oc.
getBool(
"discard");
255 if (tm.
has(polyType)) {
276 std::string index = st.
next();
277 std::string xpos = st.
next();
278 std::string ypos = st.
next();
279 Position pos2D((
double) atof(xpos.c_str()), (
double) atof(ypos.c_str()));
281 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
283 vec.push_back(pos2D);
287 if (parsingDistrictsDirectly) {
296 std::string type =
"district";
297 bool discard = oc.
getBool(
"discard");
298 double layer = oc.
getFloat(
"layer");
313 if (teilflaechen[flaechenelemente[area]].size() > 0) {
314 SUMOPolygon* poly =
new SUMOPolygon(
id, type, color, teilflaechen[flaechenelemente[area]],
false,
false, 1, layer);
319 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
328 if (line.find(
"$POIKATEGORIEDEF:") == 0 || line.find(
"$POIKATEGORIE:") == 0) {
330 parsingCategories =
true;
331 lineParser.
reinit(line.substr(line.find(
":") + 1));
333 if (line.find(
"$POI:") == 0) {
336 lineParser.
reinit(line.substr(line.find(
":") + 1));
338 if (line.find(
"$BEZIRK") == 0 && line.find(
"FLAECHEID") != std::string::npos) {
340 parsingDistrictsDirectly =
true;
341 lineParser.
reinit(line.substr(line.find(
":") + 1));
345 if (line.find(
"$BEZIRKPOLY") != std::string::npos) {
346 polyType =
"district";
348 if (line.find(
"$GEBIETPOLY") != std::string::npos) {
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
#define WRITE_WARNING(msg)
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
double layer
The layer to use.
void reinit()
Reinitialises the reading (of the previous file)
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
bool discard
Information whether polygons of this type shall be discarded.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
static void load(const std::string &file, OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Parses pois/polys stored within the given file.
void parseLine(const std::string &line)
Parses the contents of the line.
const TypeDef & get(const std::string &id)
Returns a type definition.
static methods for processing the coordinates conversion for the current net
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
std::string get(const std::string &name, bool prune=false) const
Returns the named information.
bool add(SUMOPolygon *poly, bool ignorePruning=false)
Adds a polygon to the storage.
static RGBColor parseColor(std::string coldef)
Parses a color information.
A point in 2D or 3D with translation and scaling methods.
A storage for options typed value containers)
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored using VISUM-format.
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
void reinit(const std::string &def, const std::string &defDelim=";", const std::string &lineDelim=";", bool chomp=false, bool ignoreCase=true)
Reinitialises the parser.
Retrieves a file linewise and reports the lines to a handler.
std::string prefix
The prefix to use.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
#define PROGRESS_BEGIN_MESSAGE(msg)
bool has(const std::string &id)
Returns the information whether the named type is known.
#define PROGRESS_DONE_MESSAGE()
A storage for loaded polygons and pois.
static bool isReadable(std::string path)
Checks whether the given file is readable.
std::string id
The new type id to use.
RGBColor color
The color to use.
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,...
A storage for type mappings.
A single definition of values that shall be used for a given type.
A parser to retrieve information from a table with known columns.