43 #ifdef CHECK_MEMORY_LEAKS
45 #endif // CHECK_MEMORY_LEAKS
66 myGeoScale(pow(10, (double) - shift)),
67 myProjectionMethod(NONE),
68 myUseInverseProjection(inverse),
70 myConvBoundary(conv) {
73 }
else if (proj ==
"-") {
75 }
else if (proj ==
"UTM") {
77 }
else if (proj ==
"DHDN") {
82 myProjection = pj_init_plus(proj.c_str());
83 if (myProjection == 0) {
94 if (myProjection != 0) {
95 pj_free(myProjection);
111 if (myProjection != 0) {
112 pj_free(myProjection);
115 if (orig.myProjection != 0) {
125 std::string proj =
"!";
126 int shift = oc.
getInt(
"proj.scale");
128 bool inverse = oc.
exists(
"proj.inverse") && oc.
getBool(
"proj.inverse");
130 if (oc.
getBool(
"simple-projection")) {
136 WRITE_ERROR(
"Inverse projection works only with explicit proj parameters.");
139 unsigned numProjections = oc.
getBool(
"simple-projection") + oc.
getBool(
"proj.utm") + oc.
getBool(
"proj.dhdn") + (oc.
getString(
"proj").length() > 1);
140 if (numProjections > 1) {
141 WRITE_ERROR(
"The projection method needs to be uniquely defined.");
147 }
else if (oc.
getBool(
"proj.dhdn")) {
175 oc.
addSynonyme(
"simple-projection",
"proj.simple",
true);
176 oc.
addDescription(
"simple-projection",
"Projection",
"Uses a simple method for projection");
180 oc.
addDescription(
"proj.scale",
"Projection",
"Number of places to shift decimal point to right in geo-coordinates");
184 oc.
addDescription(
"proj.utm",
"Projection",
"Determine the UTM zone (for a universal transversal mercator projection based on the WGS84 ellipsoid)");
187 oc.
addDescription(
"proj.dhdn",
"Projection",
"Determine the DHDN zone (for a transversal mercator projection based on the bessel ellipsoid)");
190 oc.
addDescription(
"proj",
"Projection",
"Uses STR as proj.4 definition for projection");
193 oc.
addDescription(
"proj.inverse",
"Projection",
"Inverses projection");
220 p = pj_inv(p, myProjection);
231 if (includeInBoundary) {
236 if (myProjection == 0) {
240 int zone = (
int)(x + 180) / 6 + 1;
242 " +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
248 int zone = (
int)(x / 3);
249 if (zone < 1 || zone > 5) {
254 " +k=1 +x_0=" +
toString(zone * 1000000 + 500000) +
255 " +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs";
268 if (includeInBoundary) {
285 if (x > 180.1 || x < -180.1 || y > 90.1 || y < -90.1) {
289 if (myProjection != 0) {
291 p.u = x * DEG_TO_RAD;
292 p.v = y * DEG_TO_RAD;
293 p = pj_fwd(p, myProjection);
301 x *= 111320. * cos(
DEG2RAD(ys));
void sub(SUMOReal dx, SUMOReal dy)
Substracts the given position from this one.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static GeoConvHelper myProcessing
coordinate transformation to use for input conversion and processing
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
~GeoConvHelper()
Destructor.
void add(const Position &pos)
Adds the given position to this one.
Position myOffset
The offset to apply.
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)
Boundary myOrigBoundary
The boundary before conversion (x2cartesian)
static void setLoaded(const GeoConvHelper &loaded)
sets the coordinate transformation loaded from a location element
static GeoConvHelper myLoaded
coordinate transformation loaded from a location element
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static void resetLoaded()
resets loaded location elements
bool myUseInverseProjection
Information whether inverse projection shall be used.
SUMOReal x() const
Returns the x-position.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
double myGeoScale
The scaling to apply to geo-coordinates.
static void computeFinal()
compute the location attributes which will be used for output based on the loaded location data...
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
static methods for processing the coordinates conversion for the current net
static GeoConvHelper myFinal
coordinate transformation to use for writing the location element and for tracking the original coord...
A point in 2D or 3D with translation and scaling methods.
ProjectionMethod myProjectionMethod
Information whether no projection shall be done.
std::string myProjString
A proj options string describing the proj.4-projection to use.
const std::string & getProjString() const
Returns the network offset.
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
const Position getOffsetBase() const
Returns the network base.
const Boundary & getConvBoundary() const
Returns the converted boundary.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static void addProjectionOptions(OptionsCont &oc)
Adds projection options to the given container.
GeoConvHelper(OptionsCont &oc)
Constructor based on the stored options.
Boundary myConvBoundary
The boundary after conversion (x2cartesian)
static int myNumLoaded
the numer of coordinate transformations loaded from location elements
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
SUMOReal y() const
Returns the y-position.
A storage for options typed value containers)
void set(SUMOReal x, SUMOReal y)
const Position getOffset() const
Returns the network offset.
const Boundary & getOrigBoundary() const
Returns the original boundary.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void moveby(SUMOReal x, SUMOReal y)
Moves the boundary by the given amount.
bool usingInverseGeoProjection() const
Returns the information whether an inverse transformation will happen.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void moveConvertedBy(SUMOReal x, SUMOReal y)
Shifts the converted boundary by the given amounts.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
GeoConvHelper & operator=(const GeoConvHelper &)
assignment operator.