Skip to content

Commit

Permalink
fix #4414
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Aug 14, 2018
1 parent 50b7301 commit 0e9dc26
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/netbuild/NBNetBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ NBNetBuilder::transformCoordinate(Position& from, bool includeInBoundary, GeoCon
bool ok = true;
if (GeoConvHelper::getNumLoaded() > 1
&& GeoConvHelper::getLoaded().usingGeoProjection()
&& from_srs != 0
&& from_srs->usingGeoProjection()
&& *from_srs != GeoConvHelper::getLoaded()) {
from_srs->cartesian2geo(from);
Expand Down
27 changes: 27 additions & 0 deletions src/netimport/NIImporter_OpenDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ StringBijection<int>::Entry NIImporter_OpenDrive::openDriveTags[] = {
{ "width", NIImporter_OpenDrive::OPENDRIVE_TAG_WIDTH },
{ "speed", NIImporter_OpenDrive::OPENDRIVE_TAG_SPEED },
{ "elevation", NIImporter_OpenDrive::OPENDRIVE_TAG_ELEVATION },
{ "geoReference", NIImporter_OpenDrive::OPENDRIVE_TAG_GEOREFERENCE },

{ "", NIImporter_OpenDrive::OPENDRIVE_TAG_NOTHING }
};
Expand Down Expand Up @@ -1761,6 +1762,32 @@ NIImporter_OpenDrive::myStartElement(int element,
}


void NIImporter_OpenDrive::characters(const XMLCh* const chars,
const XERCES3_SIZE_t length) {
if (myElementStack.size() > 0 && myElementStack.back() == OPENDRIVE_TAG_GEOREFERENCE) {
std::string cdata = TplConvert::_2str(chars, (int)length);
int startI = cdata.find("+proj");
if (startI != std::string::npos) {
std::string proj = cdata.substr(startI);
GeoConvHelper* result = 0;
Boundary convBoundary;
Boundary origBoundary;
Position networkOffset(0, 0);
// XXX read values from the header
convBoundary.add(Position(0,0));
origBoundary.add(Position(0,0));
try {
result = new GeoConvHelper(proj, networkOffset, origBoundary, convBoundary);
GeoConvHelper::setLoaded(*result);
} catch (ProcessError& e) {
WRITE_ERROR("Could not set projection. (" + std::string(e.what()) + ")");
}
}
}
}



void
NIImporter_OpenDrive::myEndElement(int element) {
myElementStack.pop_back();
Expand Down
12 changes: 11 additions & 1 deletion src/netimport/NIImporter_OpenDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class NIImporter_OpenDrive : public GenericSAXHandler {
OPENDRIVE_TAG_LANELINK,
OPENDRIVE_TAG_WIDTH,
OPENDRIVE_TAG_SPEED,
OPENDRIVE_TAG_ELEVATION
OPENDRIVE_TAG_ELEVATION,
OPENDRIVE_TAG_GEOREFERENCE
};


Expand Down Expand Up @@ -498,6 +499,15 @@ class NIImporter_OpenDrive : public GenericSAXHandler {
*/
void myStartElement(int element, const SUMOSAXAttributes& attrs);

/** @brief Called on the occurence of character data
*
* If this occurs inside a single tag it sets the option named
* by the tag to the value given by the character data.
* This is considered deprecated in favor of attributes.
* @todo Describe better
*/
void characters(const XMLCh* const chars, const XERCES3_SIZE_t length);


/** @brief Called when a closing tag occurs
*
Expand Down

2 comments on commit 0e9dc26

@behrisch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use myCharacters here?

@namdre
Copy link
Contributor Author

@namdre namdre commented on 0e9dc26 Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I did not look closely enough at the code.

Please sign in to comment.