55#include <polyconvert/pc_typemap.h>
64 oc.
addCallExample(
"-c <CONFIGURATION>",
"run with configuration options set in file");
81 oc.
addDescription(
"net-file",
"Input",
TL(
"Loads SUMO-network FILE as reference to offset and projection"));
85 oc.
addDescription(
"dlr-navteq-poly-files",
"Input",
TL(
"Reads polygons from FILE assuming they're coded in DLR-Navteq (Elmar)-format"));
87 oc.
addDescription(
"dlr-navteq-poi-files",
"Input",
TL(
"Reads pois from FILE assuming they're coded in DLR-Navteq (Elmar)-format"));
92 oc.
addDescription(
"visum-files",
"Input",
TL(
"Reads polygons from FILE assuming it's a Visum-net"));
95 oc.
addDescription(
"visum.language-file",
"Input",
TL(
"Load language mappings from FILE"));
100 oc.
addDescription(
"xml-files",
"Input",
TL(
"Reads pois and shapes from FILE assuming they're coded in XML"));
105 oc.
addDescription(
"osm-files",
"Input",
TL(
"Reads pois from FILE assuming they're coded in OSM"));
107 oc.
addDescription(
"osm.keep-full-type",
"Input",
TL(
"The type will be made of the key-value - pair"));
109 oc.
addDescription(
"osm.use-name",
"Input",
TL(
"The id will be set from the given 'name' attribute"));
111 oc.
addDescription(
"osm.merge-relations",
"Input",
TL(
"If FLOAT >= 0, assemble one polygon from all ways of a relation if they all connect with gaps below FLOAT"));
115 oc.
addSynonyme(
"shapefile-prefixes",
"shapefile-prefix");
117 oc.
addSynonyme(
"shapefile-prefixes",
"shape-files",
true);
118 oc.
addDescription(
"shapefile-prefixes",
"Input",
TL(
"Reads shapes from shapefiles FILE"));
121 oc.
addSynonyme(
"shapefile.guess-projection",
"arcview.guess-projection",
true);
122 oc.
addDescription(
"shapefile.guess-projection",
"Input",
TL(
"Guesses the shapefile's projection"));
125 oc.
addDescription(
"shapefile.traditional-axis-mapping",
"Input",
TL(
"Use traditional axis order (lon, lat)"));
128 oc.
addSynonyme(
"shapefile.id-column",
"shapefile.id-name",
true);
129 oc.
addSynonyme(
"shapefile.id-column",
"shape-files.id-name",
true);
130 oc.
addDescription(
"shapefile.id-column",
"Input",
TL(
"Defines in which column the id can be found"));
133 oc.
addSynonyme(
"shapefile.type-columns",
"shapefile.type-column");
134 oc.
addDescription(
"shapefile.type-columns",
"Input",
TL(
"Defines which columns form the type id (comma separated list)"));
137 oc.
addDescription(
"shapefile.use-running-id",
"Input",
TL(
"A running number will be used as id"));
140 oc.
addDescription(
"shapefile.add-param",
"Input",
TL(
"Extract all additional columns as params"));
143 oc.
addDescription(
"shapefile.fill",
"Input",
TL(
"[auto|true|false]. Forces the 'fill' status to the given value. Default 'auto' tries to determine it from the data type"));
156 oc.
addDescription(
"output-file",
"Output",
TL(
"Write generated polygons/pois to FILE"));
159 oc.
addDescription(
"dlr-tdp-output",
"Output",
TL(
"Write generated polygons/pois to a dlr-tdp file with the given prefix"));
164 oc.
addSynonyme(
"prune.in-net",
"prune.on-net",
true);
165 oc.
addDescription(
"prune.in-net",
TL(
"Pruning"),
TL(
"Enables pruning on net boundaries"));
168 oc.
addSynonyme(
"prune.in-net.offsets",
"prune.on-net.offsets",
true);
169 oc.
addDescription(
"prune.in-net.offsets",
TL(
"Pruning"),
TL(
"Uses FLOAT,FLOAT,FLOAT,FLOAT as offset definition added to the net boundary. Positive values grow the boundary on all sides while negative values shrink it."));
172 oc.
addDescription(
"prune.boundary",
TL(
"Pruning"),
TL(
"Uses STR as pruning boundary"));
176 oc.
addSynonyme(
"prune.keep-list",
"prune.ignore",
true);
177 oc.
addDescription(
"prune.keep-list",
TL(
"Pruning"),
TL(
"Items in STR will be kept though out of boundary"));
181 oc.
addDescription(
"prune.explicit",
TL(
"Pruning"),
TL(
"Items with names in STR[] will be removed"));
185 oc.
addSynonyme(
"offset.x",
"x-offset-to-apply",
true);
186 oc.
addDescription(
"offset.x",
"Processing",
TL(
"Adds FLOAT to net x-positions"));
189 oc.
addSynonyme(
"offset.y",
"y-offset-to-apply",
true);
190 oc.
addDescription(
"offset.y",
"Processing",
TL(
"Adds FLOAT to net y-positions"));
193 oc.
addDescription(
"offset.z",
"Processing",
TL(
"Adds FLOAT to net z-positions"));
196 oc.
addDescription(
"all-attributes",
"Processing",
TL(
"Imports all attributes as key/value pairs"));
199 oc.
addDescription(
"ignore-errors",
"Processing",
TL(
"Continue on broken input"));
202 oc.
addDescription(
"poi-layer-offset",
"Processing",
TL(
"Adds FLOAT to the layer value for each poi (i.e. to raise it above polygons)"));
209 oc.
addDescription(
"color",
"Building Defaults",
TL(
"Sets STR as default color"));
212 oc.
addDescription(
"prefix",
"Building Defaults",
TL(
"Sets STR as default prefix"));
215 oc.
addDescription(
"type",
"Building Defaults",
TL(
"Sets STR as default type"));
218 oc.
addDescription(
"fill",
"Building Defaults",
TL(
"Fills polygons by default"));
221 oc.
addDescription(
"icon",
"Building Defaults",
TL(
"Sets STR as default icon"));
224 oc.
addDescription(
"layer",
"Building Defaults",
TL(
"Sets FLOAT as default layer"));
227 oc.
addDescription(
"discard",
"Building Defaults",
TL(
"Sets default action to discard"));
231 oc.
addDescription(
"proj.plain-geo",
"Projection",
TL(
"Write geo coordinates in output"));
239 oc.
setApplicationName(
"polyconvert",
"Eclipse SUMO polyconvert Version " VERSION_STRING);
253 if (oc.
isDefault(
"aggregate-warnings")) {
259 if ((oc.
isSet(
"dlr-navteq-poly-files") || oc.
isSet(
"dlr-navteq-poi-files")) && oc.
isDefault(
"proj.scale")) {
262 if (!oc.
isSet(
"net")) {
265 const int numProjections = oc.
getBool(
"simple-projection") + oc.
getBool(
"proj.utm") + oc.
getBool(
"proj.dhdn") + (oc.
getString(
"proj").length() > 1);
266 if ((oc.
isSet(
"osm-files") || oc.
isSet(
"dlr-navteq-poly-files") || oc.
isSet(
"dlr-navteq-poi-files") || oc.
isSet(
"shapefile-prefixes")) && numProjections == 0) {
268 oc.
set(
"proj.utm",
"true");
271 oc.
set(
"proj.plain-geo",
"true");
289 if (oc.
getBool(
"prune.in-net")) {
290 if (!oc.
isSet(
"net")) {
291 throw ProcessError(
TL(
"In order to prune the input on the net, you have to supply a network."));
296 oc.
getString(
"prune.in-net.offsets"),
"--prune.on-net.offsets",
nullptr, ok,
true,
true);
298 pruningBoundary.
xmin() - offsets.
xmin(),
299 pruningBoundary.
ymin() - offsets.
ymin(),
300 pruningBoundary.
xmax() + offsets.
xmax(),
301 pruningBoundary.
ymax() + offsets.
ymax());
304 if (oc.
isSet(
"prune.boundary")) {
317 if (!oc.
isSet(
"type-file")) {
318 const char* sumoPath = std::getenv(
"SUMO_HOME");
319 if (sumoPath ==
nullptr) {
320 WRITE_WARNING(
TL(
"Environment variable SUMO_HOME is not set, using built in type maps."));
322 const std::string path = sumoPath + std::string(
"/data/typemap/");
323 if (oc.
isSet(
"dlr-navteq-poly-files")) {
324 oc.
setDefault(
"type-file", path +
"navteqPolyconvert.typ.xml");
326 if (oc.
isSet(
"osm-files")) {
327 oc.
setDefault(
"type-file", path +
"osmPolyconvert.typ.xml");
329 if (oc.
isSet(
"visum-files")) {
330 oc.
setDefault(
"type-file", path +
"visumPolyconvert.typ.xml");
336 if (oc.
isSet(
"type-file")) {
344 if (oc.
isSet(
"dlr-navteq-poly-files")) {
347 if (oc.
isSet(
"osm-files")) {
350 if (oc.
isSet(
"visum-files")) {
367 if (!oc.
isSet(
"output-file") && !oc.
isSet(
"dlr-tdp-output")) {
368 std::string out =
"polygons.xml";
369 if (oc.
isSet(
"configuration-file")) {
374 if (oc.
isSet(
"output-file")) {
377 if (oc.
isSet(
"dlr-tdp-output")) {
382 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
388 }
catch (
const std::exception& e) {
389 if (std::string(e.what()) != std::string(
"")) {
402 std::cout <<
"Success." << std::endl;
#define WRITE_WARNING(msg)
std::vector< std::string > StringVector
Definition of a vector of strings.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
void setOffsets(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values, ignoring min < max constraints.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
void setFileName(const std::string &name)
Sets the current file name.
static void addProjectionOptions(OptionsCont &oc)
Adds projection options to the given container.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data,...
const Boundary & getConvBoundary() const
Returns the converted boundary.
static Boundary parseBoundaryReporting(const std::string &def, const std::string &objecttype, const char *objectid, bool &ok, bool report=true, bool offsets=false)
Builds a boundary from its string representation, reporting occurred errors.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
static void initOutputOptions()
init output options
A storage for options typed value containers)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool setDefault(const std::string &name, const std::string &value)
Sets the given value for the named option as new default value.
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
bool set(const std::string &name, const std::string &value, const bool append=false)
Sets the given value for the named option.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
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 OptionsCont & getOptions()
Retrieves the options.
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored as shape files-files.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored as according DLR-Navteq (Elmar)-files.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored as OSM-XML.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored using VISUM-format.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored as XML.
static void load(const std::string &file, double scale)
Loads network projection if wished.
A storage for loaded polygons and pois.
void save(const std::string &file, bool useGeo)
Saves the stored polygons and pois into the given file.
void saveDlrTDP(const std::string &prefix)
Saves the stored polygons and pois into the given file in dlrTDP format.
A handler for loading polygon type maps.
A storage for type mappings.
SAX-reader encapsulation containing binary reader.
void parseString(std::string content)
Parse XML from the given string.
static StringBijection< POIIcon > POIIcons
POI icon values.
static void close()
Closes all of an applications subsystems.
static bool checkOptions(OptionsCont &oc)
checks shared options and sets StdDefs
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler, const bool isNet=false, const bool isRoute=false)
Builds a reader and assigns the handler to it.
static void init()
Initialises the xml-subsystem.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.
int main(int argc, char **argv)