diff --git a/sources/include/parser/gmlfeaturecollectionparser.h b/sources/include/parser/gmlfeaturecollectionparser.h index f50cdd4c..a1305b58 100644 --- a/sources/include/parser/gmlfeaturecollectionparser.h +++ b/sources/include/parser/gmlfeaturecollectionparser.h @@ -24,9 +24,12 @@ namespace citygml { // GMLObjectElementParser interface virtual Object* getObject() override; + const Envelope& getEnvelope() const; + bool getSourceSRSOverride() const; + private: Envelope* m_bounds; - bool m_srsSRSOverride; + bool m_sourceSRSOverride; }; diff --git a/sources/src/parser/citymodelelementparser.cpp b/sources/src/parser/citymodelelementparser.cpp index 915dd91a..b662b090 100644 --- a/sources/src/parser/citymodelelementparser.cpp +++ b/sources/src/parser/citymodelelementparser.cpp @@ -49,6 +49,12 @@ namespace citygml { CITYGML_LOG_WARN(m_logger, "Expected end tag <" << NodeType::CORE_CityModelNode.name() << "> got <" << node.name() << "> at " << getDocumentLocation()); } + if (getSourceSRSOverride()) { + Envelope *envelope = new Envelope(getEnvelope().srsName()); + envelope->setLowerBound(m_model->getEnvelope().getLowerBound()); + envelope->setUpperBound(m_model->getEnvelope().getUpperBound()); + m_model->setEnvelope(envelope); + } m_callback(m_model); return true; } diff --git a/sources/src/parser/cityobjectelementparser.cpp b/sources/src/parser/cityobjectelementparser.cpp index dd43786a..26628a02 100644 --- a/sources/src/parser/cityobjectelementparser.cpp +++ b/sources/src/parser/cityobjectelementparser.cpp @@ -237,6 +237,12 @@ namespace citygml { bool CityObjectElementParser::parseElementEndTag(const NodeType::XMLNode&, const std::string&) { + if (getSourceSRSOverride()) { + Envelope *envelope = new Envelope(getEnvelope().srsName()); + envelope->setLowerBound(m_model->getEnvelope().getLowerBound()); + envelope->setUpperBound(m_model->getEnvelope().getUpperBound()); + m_model->setEnvelope(envelope); + } m_callback(m_model); m_model = nullptr; return true; diff --git a/sources/src/parser/gmlfeaturecollectionparser.cpp b/sources/src/parser/gmlfeaturecollectionparser.cpp index ea1908c4..1ee7bbfe 100644 --- a/sources/src/parser/gmlfeaturecollectionparser.cpp +++ b/sources/src/parser/gmlfeaturecollectionparser.cpp @@ -20,11 +20,11 @@ namespace citygml { : GMLObjectElementParser(documentParser, factory, logger) { m_bounds = nullptr; - m_srsSRSOverride = false; + m_sourceSRSOverride = false; std::string paramsSrcSRS = documentParser.getParserParams().srcSRS; if (!paramsSrcSRS.empty()) { m_bounds = new Envelope(paramsSrcSRS); - m_srsSRSOverride = true; + m_sourceSRSOverride = true; } } @@ -40,7 +40,7 @@ namespace citygml { return true; } else if (node == NodeType::GML_EnvelopeNode) { - if (m_srsSRSOverride) { + if (m_sourceSRSOverride) { return true; } if (m_bounds != nullptr) { @@ -93,6 +93,14 @@ namespace citygml { return getFeatureObject(); } + const Envelope& GMLFeatureCollectionElementParser::getEnvelope() const + { + return *m_bounds; + } + bool GMLFeatureCollectionElementParser::getSourceSRSOverride() const + { + return m_sourceSRSOverride; + } }