 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
57 if (!oc.
isSet(
"visum-files")) {
62 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
64 throw ProcessError(
"Could not open visum-file '" + *file +
"'.");
67 load(*file, oc, toFill, tm);
79 std::map<long long int, Position> punkte;
80 std::map<long long int, PositionVector> kanten;
81 std::map<long long int, PositionVector> teilflaechen;
82 std::map<long long int, long long int> flaechenelemente;
88 if (line.length() == 0 || line[0] ==
'*' || line[0] ==
'$') {
92 if (what ==
"$PUNKT") {
103 }
else if (what ==
"$KANTE") {
109 vec.push_back(punkte[fromID]);
110 vec.push_back(punkte[toID]);
113 }
else if (what ==
"$ZWISCHENPUNKT") {
123 kanten[id].insert(kanten[
id].begin() + index, pos);
125 }
else if (what ==
"$TEILFLAECHENELEMENT") {
132 if (teilflaechen.find(
id) == teilflaechen.end()) {
136 for (
int i = 0; i < (int) kanten[kid].size(); ++i) {
137 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
140 for (
int i = (
int) kanten[kid].size() - 1; i >= 0; --i) {
141 teilflaechen[id].push_back_noDoublePos(kanten[kid][i]);
145 }
else if (what ==
"$FLAECHENELEMENT") {
149 flaechenelemente[id] = tid;
153 if (line[0] ==
'$') {
155 if (line.find(
"$PUNKT") == 0) {
157 }
else if (line.find(
"$KANTE") == 0) {
159 }
else if (line.find(
"$ZWISCHENPUNKT") == 0) {
160 what =
"$ZWISCHENPUNKT";
161 }
else if (line.find(
"$TEILFLAECHENELEMENT") == 0) {
162 what =
"$TEILFLAECHENELEMENT";
163 }
else if (line.find(
"$FLAECHENELEMENT") == 0) {
164 what =
"$FLAECHENELEMENT";
167 lineParser.
reinit(line.substr(what.length() + 1));
174 std::map<std::string, std::string> typemap;
177 bool parsingCategories =
false;
178 bool parsingPOIs =
false;
179 bool parsingDistrictsDirectly =
false;
181 std::string polyType, lastID;
186 if (line.length() == 0) {
190 if (line[0] ==
'*') {
194 if (line[0] ==
'$') {
196 parsingCategories =
false;
198 parsingDistrictsDirectly =
false;
202 if (parsingCategories) {
205 std::string catid = st.
next();
206 std::string catname = st.
next();
207 typemap[catid] = catname;
215 std::string catid = lineParser.
get(
"CATID");
221 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
223 std::string type = typemap[catid];
225 bool discard = oc.
getBool(
"discard");
226 double layer = oc.
getFloat(
"layer");
247 if (polyType !=
"") {
249 std::string
id = st.
next();
251 if (!first && lastID !=
id) {
254 double layer = oc.
getFloat(
"layer");
255 bool discard = oc.
getBool(
"discard");
256 if (tm.
has(polyType)) {
277 std::string index = st.
next();
278 std::string xpos = st.
next();
279 std::string ypos = st.
next();
280 Position pos2D((
double) atof(xpos.c_str()), (
double) atof(ypos.c_str()));
282 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
284 vec.push_back(pos2D);
288 if (parsingDistrictsDirectly) {
297 std::string type =
"district";
298 bool discard = oc.
getBool(
"discard");
299 double layer = oc.
getFloat(
"layer");
314 if (teilflaechen[flaechenelemente[area]].size() > 0) {
315 SUMOPolygon* poly =
new SUMOPolygon(
id, type, color, teilflaechen[flaechenelemente[area]],
false,
false, 1, layer);
320 WRITE_WARNING(
"Unable to project coordinates for POI '" +
id +
"'.");
329 if (line.find(
"$POIKATEGORIEDEF:") == 0 || line.find(
"$POIKATEGORIE:") == 0) {
331 parsingCategories =
true;
332 lineParser.
reinit(line.substr(line.find(
":") + 1));
334 if (line.find(
"$POI:") == 0) {
337 lineParser.
reinit(line.substr(line.find(
":") + 1));
339 if (line.find(
"$BEZIRK") == 0 && line.find(
"FLAECHEID") != std::string::npos) {
341 parsingDistrictsDirectly =
true;
342 lineParser.
reinit(line.substr(line.find(
":") + 1));
346 if (line.find(
"$BEZIRKPOLY") != std::string::npos) {
347 polyType =
"district";
349 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.
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.
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)
A parser to retrieve information from a table with known columns.