[libcitygml] 01/11: Imported Upstream version 2.0

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Mon Aug 31 22:02:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository libcitygml.

commit 9e30b172236c16bc71f758307ce5d57403785157
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Mon Aug 31 00:21:55 2015 +0200

    Imported Upstream version 2.0
---
 CMakeLists.txt                                    | 28 ++++++++++++++++++++---
 osgplugin/ReaderWriterCityGML.cpp                 |  6 ++---
 sources/CMakeLists.txt                            | 16 +++++++++----
 sources/citygml.pc.cmake                          | 11 +++++++++
 sources/include/citygml/appearancetarget.h        |  8 +++----
 sources/include/citygml/geometry.h                |  8 +++----
 sources/include/citygml/polygon.h                 |  8 +++----
 sources/include/citygml/texturetargetdefinition.h | 12 +++++-----
 sources/include/parser/elementparser.h            |  2 ++
 sources/include/parser/geocoordinatetransformer.h |  5 ++--
 sources/include/parser/textureelementparser.h     |  2 +-
 sources/src/citygml/appearancetarget.cpp          | 16 ++++++-------
 sources/src/citygml/geometry.cpp                  | 18 +++++++--------
 sources/src/citygml/linearring.cpp                |  8 +++----
 sources/src/citygml/polygon.cpp                   | 26 ++++++++++-----------
 sources/src/citygml/texturetargetdefinition.cpp   | 16 ++++++-------
 sources/src/parser/addressparser.cpp              |  8 +++----
 sources/src/parser/geocoordinatetransformer.cpp   | 26 ++++++++++-----------
 sources/src/parser/geometryelementparser.cpp      |  2 +-
 sources/src/parser/gmlfeaturecollectionparser.cpp |  2 +-
 sources/src/parser/textureelementparser.cpp       |  3 +--
 test/CMakeLists.txt                               |  3 +++
 test/citygmltest.cpp                              |  2 +-
 23 files changed, 140 insertions(+), 96 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0ca992..d193f0b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,9 +2,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2 FATAL_ERROR)
 
 PROJECT ( libcitygml )
 
-set(META_VERSION_MAJOR       "1")
-set(META_VERSION_MINOR       "4")
-set(META_VERSION_PATCH       "3")
+set(META_VERSION_MAJOR       "2")
+set(META_VERSION_MINOR       "0")
+set(META_VERSION_PATCH       "0")
 
 set(META_VERSION             "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")
 
@@ -97,6 +97,28 @@ SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
 MAKE_DIRECTORY(${OUTPUT_LIBDIR})
 SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
 
+if(NOT DEFINED BIN_INSTALL_DIR)
+    set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
+endif(NOT DEFINED BIN_INSTALL_DIR)
+if(NOT DEFINED LIB_INSTALL_DIR)
+    set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
+endif(NOT DEFINED LIB_INSTALL_DIR)
+if(NOT DEFINED DATA_INSTALL_DIR)
+    set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share")
+endif(NOT DEFINED DATA_INSTALL_DIR)
+if(NOT DEFINED INCLUDE_INSTALL_DIR)
+    set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/citygml")
+endif(NOT DEFINED INCLUDE_INSTALL_DIR)
+if(NOT DEFINED MAN_INSTALL_DIR)
+    set(MAN_INSTALL_DIR "${DATA_INSTALL_DIR}/man")
+endif(NOT DEFINED MAN_INSTALL_DIR)
+if(NOT DEFINED RESOURCE_INSTALL_DIR)
+    set(RESOURCE_INSTALL_DIR "${DATA_INSTALL_DIR}/libcitygml${META_VERSION_MAJOR}/resource/")
+endif(NOT DEFINED RESOURCE_INSTALL_DIR)
+if(NOT DEFINED LOCALE_INSTALL_DIR)
+    set(LOCALE_INSTALL_DIR "${DATA_INSTALL_DIR}/locale/")
+endif(NOT DEFINED LOCALE_INSTALL_DIR)
+
 # IF( DEBUG_BUILD )
   # SET( CMAKE_BUILD_TYPE "Debug" )
 # ELSE( DEBUG_BUILD )
diff --git a/osgplugin/ReaderWriterCityGML.cpp b/osgplugin/ReaderWriterCityGML.cpp
index a516a30..d611ff7 100644
--- a/osgplugin/ReaderWriterCityGML.cpp
+++ b/osgplugin/ReaderWriterCityGML.cpp
@@ -274,7 +274,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCityGML::readCity(std::shared_ptr<co
 }
 
 void setTexture(osg::ref_ptr<osg::StateSet> stateset, osg::Geometry* geom, const citygml::Polygon& polygon, CityGMLSettings& settings) {
-    const citygml::Texture* citygmlTex = polygon.getTextureFor(settings._theme);
+    const auto citygmlTex = polygon.getTextureFor(settings._theme);
 
     if ( !citygmlTex )
     {
@@ -338,7 +338,7 @@ void setTexture(osg::ref_ptr<osg::StateSet> stateset, osg::Geometry* geom, const
 
 void setMaterial(osg::ref_ptr<osg::StateSet> stateset, const citygml::Polygon& polygon, CityGMLSettings& settings) {
 
-    const citygml::Material* citygmlMaterial = polygon.getMaterialFor(settings._theme);
+    const auto citygmlMaterial = polygon.getMaterialFor(settings._theme);
 
     if (!citygmlMaterial) {
         return;
@@ -364,7 +364,7 @@ void setMaterial(osg::ref_ptr<osg::StateSet> stateset, const citygml::Polygon& p
 void createOsgGeometryFromCityGMLGeometry(const citygml::Geometry& geometry, CityGMLSettings& settings, osg::Geode* geometryContainer, const osg::Vec3d& offset ) {
     for ( unsigned int j = 0; j < geometry.getPolygonsCount(); j++ )
     {
-        const citygml::Polygon& p = geometry.getPolygon(j);
+        const citygml::Polygon& p = *geometry.getPolygon(j);
 
         if ( p.getIndices().size() == 0 ) continue;
 
diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt
index fc404af..1a52087 100644
--- a/sources/CMakeLists.txt
+++ b/sources/CMakeLists.txt
@@ -151,15 +151,23 @@ ADD_LIBRARY( ${target} ${LIBCITYGML_USER_DEFINED_DYNAMIC_OR_STATIC} ${SOURCES} $
 
 TARGET_LINK_LIBRARIES( ${target} ${XERCESC_LIBRARIES} ${OPENGL_LIBRARIES} ${GDAL_LIBRARY} )
 
+set_target_properties( ${target} PROPERTIES
+    VERSION ${META_VERSION}
+    SOVERSION ${META_VERSION_MAJOR}
+)
+
 INSTALL(
     TARGETS ${target}
-    RUNTIME DESTINATION bin
-    LIBRARY DESTINATION lib
-    ARCHIVE DESTINATION lib
+    RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+    LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+    ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
 )
 # FIXME: Do not run for OS X framework
 INSTALL(
     FILES        ${PUBLIC_HEADER}
-    DESTINATION  ${CMAKE_INSTALL_PREFIX}/include/${target}
+    DESTINATION  ${INCLUDE_INSTALL_DIR}
 )
 
+configure_file(citygml.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/citygml.pc)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/citygml.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
diff --git a/sources/citygml.pc.cmake b/sources/citygml.pc.cmake
new file mode 100644
index 0000000..164305d
--- /dev/null
+++ b/sources/citygml.pc.cmake
@@ -0,0 +1,11 @@
+prefix=${CMAKE_INSTALL_PREFIX}
+exec_prefix=${BIN_INSTALL_DIR}
+libdir=${LIB_INSTALL_DIR}
+includedir=${INCLUDE_INSTALL_DIR}
+
+Name: citygml
+Description: Read and Write CityGML files
+Requires: libxml-2.0 glu
+Version: ${META_VERSION}
+Libs: -L${LIB_INSTALL_DIR} -lcitygml
+Cflags: -I${INCLUDE_INSTALL_DIR}
diff --git a/sources/include/citygml/appearancetarget.h b/sources/include/citygml/appearancetarget.h
index b5db0b7..9a47e54 100644
--- a/sources/include/citygml/appearancetarget.h
+++ b/sources/include/citygml/appearancetarget.h
@@ -28,11 +28,11 @@ namespace citygml {
 
         void addTargetDefinitionsOf(const AppearanceTarget& other);
 
-        MaterialTargetDefinition* getMaterialTargetDefinitionForTheme(const std::string& theme, bool front);
-        const MaterialTargetDefinition* getMaterialTargetDefinitionForTheme(const std::string& theme, bool front) const;
+        std::shared_ptr<MaterialTargetDefinition> getMaterialTargetDefinitionForTheme(const std::string& theme, bool front);
+        std::shared_ptr<const MaterialTargetDefinition> getMaterialTargetDefinitionForTheme(const std::string& theme, bool front) const;
 
-        TextureTargetDefinition* getTextureTargetDefinitionForTheme(const std::string& theme, bool front);
-        const TextureTargetDefinition* getTextureTargetDefinitionForTheme(const std::string& theme, bool front) const;
+        std::shared_ptr<TextureTargetDefinition> getTextureTargetDefinitionForTheme(const std::string& theme, bool front);
+        std::shared_ptr<const TextureTargetDefinition> getTextureTargetDefinitionForTheme(const std::string& theme, bool front) const;
 
         std::vector<TextureTargetDefinition*> getTextureTargetDefinitions();
 
diff --git a/sources/include/citygml/geometry.h b/sources/include/citygml/geometry.h
index 8179dc5..c8e4b04 100644
--- a/sources/include/citygml/geometry.h
+++ b/sources/include/citygml/geometry.h
@@ -38,12 +38,12 @@ namespace citygml {
         unsigned int getLOD() const;
 
         unsigned int getPolygonsCount() const;
-        Polygon& getPolygon( unsigned int i );
-        const Polygon& getPolygon( unsigned int i ) const;
+        std::shared_ptr<Polygon> getPolygon( unsigned int i );
+        std::shared_ptr<const Polygon> getPolygon( unsigned int i ) const;
 
         unsigned int getLineStringCount() const;
-        LineString& getLineString( unsigned int i );
-        const LineString& getLineString( unsigned int i ) const;
+        std::shared_ptr<LineString> getLineString( unsigned int i );
+        std::shared_ptr<const LineString> getLineString( unsigned int i ) const;
 
         unsigned int getGeometriesCount() const;
         const Geometry& getGeometry( unsigned int i ) const;
diff --git a/sources/include/citygml/polygon.h b/sources/include/citygml/polygon.h
index defa024..5025b4e 100644
--- a/sources/include/citygml/polygon.h
+++ b/sources/include/citygml/polygon.h
@@ -45,14 +45,14 @@ namespace citygml {
          * @param front determines for which side the material should be returned (true = front side, false = backside)
          * @return a Material object or nullptr if there is no material for the theme and side
          */
-        const Material* getMaterialFor(const std::string& theme, bool front) const;
+        std::shared_ptr<const Material> getMaterialFor(const std::string& theme, bool front) const;
 
         /**
          * @brief returns the material of this polygon for the given theme. Prefers front side materials over back side materials
          * @param theme a name of an appearance theme
          * @return a Material object or nullptr if there is no material for the theme
          */
-        const Material* getMaterialFor(const std::string& theme) const;
+        std::shared_ptr<const Material> getMaterialFor(const std::string& theme) const;
 
         /**
          * @brief returns the texture of this polygon for the given theme and side
@@ -60,14 +60,14 @@ namespace citygml {
          * @param front determines for which side the texture should be returned (true = front side, false = backside)
          * @return a Texture object or nullptr if there is no texture for the theme and side
          */
-        const Texture* getTextureFor(const std::string& theme, bool front) const;
+        std::shared_ptr<const Texture> getTextureFor(const std::string& theme, bool front) const;
 
         /**
          * @brief returns the texture of this polygon for the given theme. Prefers front side textures over back side textures
          * @param theme a name of an appearance theme
          * @return a Texture object or nullptr if there is no texture for the theme
          */
-        const Texture* getTextureFor(const std::string& theme) const;
+        std::shared_ptr<const Texture> getTextureFor(const std::string& theme) const;
 
         /**
          * @brief returns the texture coordinates for the given theme and side
diff --git a/sources/include/citygml/texturetargetdefinition.h b/sources/include/citygml/texturetargetdefinition.h
index 3de0517..a9893c7 100644
--- a/sources/include/citygml/texturetargetdefinition.h
+++ b/sources/include/citygml/texturetargetdefinition.h
@@ -29,17 +29,17 @@ namespace citygml {
         /**
          * @brief the i-th texture coordinates in texture coordinates list (gml::TexCoordList)
          */
-        TextureCoordinates* getTextureCoordinates(unsigned int i);
-        const TextureCoordinates* getTextureCoordinates(unsigned int i) const;
+        std::shared_ptr<TextureCoordinates> getTextureCoordinates(unsigned int i);
+        std::shared_ptr<const TextureCoordinates> getTextureCoordinates(unsigned int i) const;
 
         /**
          * @brief the texture coordinates for linear ring with the given id
          * @return the TextureCoordinates object or nullptr if no such object exists for ringID
          */
-        TextureCoordinates* getTextureCoordinatesForID(const std::string& ringID);
-        const TextureCoordinates* getTextureCoordinatesForID(const std::string& ringID) const;
+        std::shared_ptr<TextureCoordinates> getTextureCoordinatesForID(const std::string& ringID);
+        std::shared_ptr<const TextureCoordinates> getTextureCoordinatesForID(const std::string& ringID) const;
 
-        void addTexCoordinates(TextureCoordinates* texCoords);
+        void addTexCoordinates(std::shared_ptr<TextureCoordinates> texCoords);
 
 
         ~TextureTargetDefinition();
@@ -47,6 +47,6 @@ namespace citygml {
     protected:
         TextureTargetDefinition(const std::string& targetID, std::shared_ptr<Texture> appearance, const std::string& id);
         std::vector<std::shared_ptr<TextureCoordinates>> m_coordinatesList;
-        std::unordered_map<std::string, TextureCoordinates*> m_idTexCoordMap;
+        std::unordered_map<std::string, std::shared_ptr<TextureCoordinates>> m_idTexCoordMap;
     };
 }
diff --git a/sources/include/parser/elementparser.h b/sources/include/parser/elementparser.h
index 2429146..c948882 100644
--- a/sources/include/parser/elementparser.h
+++ b/sources/include/parser/elementparser.h
@@ -40,6 +40,8 @@ namespace citygml {
         /**
          * @brief returns wether the parser handels elements of type node
          * @note this is required for the delayed choice mechanism @see DelayedChoiceElementParser
+         * @return true if node is a valid !!root!! element for this parser
+         * (e.g. <Appearence> is valid root element for the appearance parser but <theme> is not since its a child element of an appearance)
          */
         virtual bool handlesElement(const NodeType::XMLNode& node) const = 0;
 
diff --git a/sources/include/parser/geocoordinatetransformer.h b/sources/include/parser/geocoordinatetransformer.h
index 34d8cb6..06893d8 100644
--- a/sources/include/parser/geocoordinatetransformer.h
+++ b/sources/include/parser/geocoordinatetransformer.h
@@ -14,6 +14,7 @@ namespace citygml {
     class ImplicitGeometry;
     class Geometry;
     class Polygon;
+    class LineString;
 
     class GeoCoordinateTransformer {
     public:
@@ -23,8 +24,8 @@ namespace citygml {
     private:
         std::string m_destinationSRS;
         std::shared_ptr<CityGMLLogger> m_logger;
-        std::unordered_map<std::string, std::string> m_transformedPolygonsSourceURNMap;
-        std::unordered_map<std::string, std::string> m_transformedLineStringsSourceURNMap;
+        std::unordered_map<Polygon*, std::string> m_transformedPolygonsSourceURNMap;
+        std::unordered_map<LineString*, std::string> m_transformedLineStringsSourceURNMap;
 
         void transformRecursive(CityObject& obj, GeoTransform& transformation);
         void transformRecursive_helper(CityObject& obj, GeoTransform& transformation);
diff --git a/sources/include/parser/textureelementparser.h b/sources/include/parser/textureelementparser.h
index b190681..4fdd560 100644
--- a/sources/include/parser/textureelementparser.h
+++ b/sources/include/parser/textureelementparser.h
@@ -34,7 +34,7 @@ namespace citygml {
         std::shared_ptr<Texture> m_model;
         std::function<void(std::shared_ptr<Texture>)> m_callback;
         std::shared_ptr<TextureTargetDefinition> m_currentTexTargetDef;
-        TextureCoordinates* m_currentTexCoords;
+        std::shared_ptr<TextureCoordinates> m_currentTexCoords;
     };
 
 }
diff --git a/sources/src/citygml/appearancetarget.cpp b/sources/src/citygml/appearancetarget.cpp
index 44d58b3..047de91 100644
--- a/sources/src/citygml/appearancetarget.cpp
+++ b/sources/src/citygml/appearancetarget.cpp
@@ -56,44 +56,44 @@ namespace citygml {
         m_themeTexMapBack.insert(other.m_themeTexMapBack.begin(), other.m_themeTexMapBack.end());
     }
 
-    MaterialTargetDefinition* AppearanceTarget::getMaterialTargetDefinitionForTheme(const std::string& theme, bool front)
+    std::shared_ptr<MaterialTargetDefinition> AppearanceTarget::getMaterialTargetDefinitionForTheme(const std::string& theme, bool front)
     {
         auto& map = front ? m_themeMatMapFront : m_themeMatMapBack;
         auto it = map.find(theme);
         if (it == map.end()) {
             return nullptr;
         }
-        return it->second.get();
+        return it->second;
     }
 
-    const MaterialTargetDefinition* AppearanceTarget::getMaterialTargetDefinitionForTheme(const std::string& theme, bool front) const
+    std::shared_ptr<const MaterialTargetDefinition> AppearanceTarget::getMaterialTargetDefinitionForTheme(const std::string& theme, bool front) const
     {
         auto& map = front ? m_themeMatMapFront : m_themeMatMapBack;
         const auto it = map.find(theme);
         if (it == map.end()) {
             return nullptr;
         }
-        return it->second.get();
+        return it->second;
     }
 
-    TextureTargetDefinition* AppearanceTarget::getTextureTargetDefinitionForTheme(const std::string& theme, bool front)
+    std::shared_ptr<TextureTargetDefinition> AppearanceTarget::getTextureTargetDefinitionForTheme(const std::string& theme, bool front)
     {
         auto& map = front ? m_themeTexMapFront : m_themeTexMapBack;
         auto it = map.find(theme);
         if (it == map.end()) {
             return nullptr;
         }
-        return it->second.get();
+        return it->second;
     }
 
-    const TextureTargetDefinition* AppearanceTarget::getTextureTargetDefinitionForTheme(const std::string& theme, bool front) const
+    std::shared_ptr<const TextureTargetDefinition> AppearanceTarget::getTextureTargetDefinitionForTheme(const std::string& theme, bool front) const
     {
         auto& map = front ? m_themeTexMapFront : m_themeTexMapBack;
         const auto it = map.find(theme);
         if (it == map.end()) {
             return nullptr;
         }
-        return it->second.get();
+        return it->second;
     }
 
     std::vector<TextureTargetDefinition*> AppearanceTarget::getTextureTargetDefinitions()
diff --git a/sources/src/citygml/geometry.cpp b/sources/src/citygml/geometry.cpp
index da5018b..1118c07 100644
--- a/sources/src/citygml/geometry.cpp
+++ b/sources/src/citygml/geometry.cpp
@@ -23,14 +23,14 @@ namespace citygml {
         return m_polygons.size();
     }
 
-    Polygon& Geometry::getPolygon(unsigned int i)
+    std::shared_ptr<Polygon> Geometry::getPolygon(unsigned int i)
     {
-        return *m_polygons.at(i);
+        return m_polygons.at(i);
     }
 
-    const Polygon& Geometry::getPolygon(unsigned int i) const
+    std::shared_ptr<const Polygon> Geometry::getPolygon(unsigned int i) const
     {
-        return *m_polygons.at(i);
+        return m_polygons.at(i);
     }
 
     unsigned int Geometry::getLineStringCount() const
@@ -38,14 +38,14 @@ namespace citygml {
         return m_lineStrings.size();
     }
 
-    LineString& Geometry::getLineString(unsigned int i)
+    std::shared_ptr<LineString> Geometry::getLineString(unsigned int i)
     {
-        return *m_lineStrings.at(i);
+        return m_lineStrings.at(i);
     }
 
-    const LineString& Geometry::getLineString(unsigned int i) const
+    std::shared_ptr<const LineString> Geometry::getLineString(unsigned int i) const
     {
-        return *m_lineStrings.at(i);
+        return m_lineStrings.at(i);
     }
 
     unsigned int Geometry::getGeometriesCount() const
@@ -149,7 +149,7 @@ namespace citygml {
         for ( unsigned int i = 0; i < s.getPolygonsCount(); i++ )
         {
             os << s.getPolygon(i);
-            count += s.getPolygon(i).getVertices().size();
+            count += s.getPolygon(i)->getVertices().size();
         }
 
         os << "  @ " << s.getPolygonsCount() << " polys [" << count << " vertices]" << std::endl;
diff --git a/sources/src/citygml/linearring.cpp b/sources/src/citygml/linearring.cpp
index 45eb24a..8a77db5 100644
--- a/sources/src/citygml/linearring.cpp
+++ b/sources/src/citygml/linearring.cpp
@@ -66,14 +66,14 @@ namespace citygml {
     {
         // Currently TextureCoordinates sharing via xlink is not supported (every TextureTargetDefinition is the
         // sole owner of its TextureCoordinate objects... if this ever changes use an unordered_set for the texture coordinates
-        std::vector<TextureCoordinates*> coordinatesList;
+        std::vector<std::shared_ptr<TextureCoordinates>> coordinatesList;
 
         bool textureCoordinatesVerticesMismatch = false;
 
         for (auto& texTarget : targets) {
 
             for (unsigned int i = 0; i < texTarget->getTextureCoordinatesCount(); i++) {
-                TextureCoordinates* texCoords = texTarget->getTextureCoordinates(i);
+                auto texCoords = texTarget->getTextureCoordinates(i);
 
                 if (texCoords->targets(*this)) {
 
@@ -100,7 +100,7 @@ namespace citygml {
             if ( ( m_vertices[i] - m_vertices[ ( i + 1 ) % m_vertices.size() ] ).sqrLength() <= DBL_EPSILON )
             {
                 m_vertices.erase( m_vertices.begin() + i );
-                for (TextureCoordinates* coordinates : coordinatesList) {
+                for (auto coordinates : coordinatesList) {
                     coordinates->eraseCoordinate(i);
                 }
             } else {
@@ -114,7 +114,7 @@ namespace citygml {
             return;
         }
 
-        for (TextureCoordinates* coordinates : coordinatesList) {
+        for (auto coordinates : coordinatesList) {
             if (coordinates->getCoords().size() != m_vertices.size()) {
                 CITYGML_LOG_ERROR(logger, "Broken implementation. Duplicate vertex removal in LinearRing with id '" << this->getId()
                                   << "' caused a mismatch of texture coordinates in coordinates list  with id '" << coordinates->getId()
diff --git a/sources/src/citygml/polygon.cpp b/sources/src/citygml/polygon.cpp
index 2d2c5c6..a31962a 100644
--- a/sources/src/citygml/polygon.cpp
+++ b/sources/src/citygml/polygon.cpp
@@ -38,36 +38,36 @@ namespace citygml {
     }
 
 
-    const Material* Polygon::getMaterialFor(const std::string& theme, bool front) const
+    std::shared_ptr<const Material> Polygon::getMaterialFor(const std::string& theme, bool front) const
     {
-        const MaterialTargetDefinition* targetDef = getMaterialTargetDefinitionForTheme(theme, front);
+        const auto targetDef = getMaterialTargetDefinitionForTheme(theme, front);
         if (targetDef == nullptr) {
             return nullptr;
         }
-        return targetDef->getAppearance().get();
+        return targetDef->getAppearance();
     }
 
-    const Material* Polygon::getMaterialFor(const std::string& theme) const
+    std::shared_ptr<const Material> Polygon::getMaterialFor(const std::string& theme) const
     {
-        const Material* result = getMaterialFor(theme, true);
+        const auto result = getMaterialFor(theme, true);
         if (result != nullptr) {
             return result;
         }
         return getMaterialFor(theme, false);
     }
 
-    const Texture* Polygon::getTextureFor(const std::string& theme, bool front) const
+    std::shared_ptr<const Texture> Polygon::getTextureFor(const std::string& theme, bool front) const
     {
-        const TextureTargetDefinition* targetDef = getTextureTargetDefinitionForTheme(theme, front);
+        const auto targetDef = getTextureTargetDefinitionForTheme(theme, front);
         if (targetDef == nullptr) {
             return nullptr;
         }
-        return targetDef->getAppearance().get();
+        return targetDef->getAppearance();
     }
 
-    const Texture* Polygon::getTextureFor(const std::string& theme) const
+    std::shared_ptr<const Texture> Polygon::getTextureFor(const std::string& theme) const
     {
-        const Texture* result = getTextureFor(theme, true);
+        const auto result = getTextureFor(theme, true);
         if (result != nullptr) {
             return result;
         }
@@ -96,7 +96,7 @@ namespace citygml {
 
     std::shared_ptr<const Texture> Polygon::getTextureForTheme(const std::string& theme, bool front) const
     {
-        const TextureTargetDefinition* targetDef = getTextureTargetDefinitionForTheme(theme, front);
+        const auto targetDef = getTextureTargetDefinitionForTheme(theme, front);
 
         if (targetDef == nullptr) {
             return nullptr;
@@ -142,13 +142,13 @@ namespace citygml {
 
     std::vector<TVec2f> Polygon::getTexCoordsForRingAndTheme(const LinearRing& ring, const std::string& theme, bool front) {
 
-        const TextureTargetDefinition* targetDef = getTextureTargetDefinitionForTheme(theme, front);
+        const auto targetDef = getTextureTargetDefinitionForTheme(theme, front);
 
         if (targetDef == nullptr) {
             return std::vector<TVec2f>();
         }
 
-        const TextureCoordinates* coords = targetDef->getTextureCoordinatesForID(ring.getId());
+        const auto coords = targetDef->getTextureCoordinatesForID(ring.getId());
 
         if (coords == nullptr || coords->getCoords().empty()) {
             return std::vector<TVec2f>();
diff --git a/sources/src/citygml/texturetargetdefinition.cpp b/sources/src/citygml/texturetargetdefinition.cpp
index 65b9d97..6b74ef5 100644
--- a/sources/src/citygml/texturetargetdefinition.cpp
+++ b/sources/src/citygml/texturetargetdefinition.cpp
@@ -12,17 +12,17 @@ namespace citygml {
         return m_coordinatesList.size();
     }
 
-    TextureCoordinates* TextureTargetDefinition::getTextureCoordinates(unsigned int i)
+    std::shared_ptr<TextureCoordinates> TextureTargetDefinition::getTextureCoordinates(unsigned int i)
     {
-        return m_coordinatesList.at(i).get();
+        return m_coordinatesList.at(i);
     }
 
-    const TextureCoordinates*TextureTargetDefinition::getTextureCoordinates(unsigned int i) const
+    std::shared_ptr<const TextureCoordinates> TextureTargetDefinition::getTextureCoordinates(unsigned int i) const
     {
-        return m_coordinatesList.at(i).get();
+        return m_coordinatesList.at(i);
     }
 
-    TextureCoordinates* TextureTargetDefinition::getTextureCoordinatesForID(const std::string& ringID)
+    std::shared_ptr<TextureCoordinates> TextureTargetDefinition::getTextureCoordinatesForID(const std::string& ringID)
     {
         auto it = m_idTexCoordMap.find(ringID);
         if (it != m_idTexCoordMap.end()) {
@@ -31,7 +31,7 @@ namespace citygml {
         return nullptr;
     }
 
-    const TextureCoordinates* TextureTargetDefinition::getTextureCoordinatesForID(const std::string& ringID) const
+    std::shared_ptr<const TextureCoordinates> TextureTargetDefinition::getTextureCoordinatesForID(const std::string& ringID) const
     {
         const auto it = m_idTexCoordMap.find(ringID);
         if (it != m_idTexCoordMap.end()) {
@@ -40,9 +40,9 @@ namespace citygml {
         return nullptr;
     }
 
-    void TextureTargetDefinition::addTexCoordinates(TextureCoordinates* texCoords)
+    void TextureTargetDefinition::addTexCoordinates(std::shared_ptr<TextureCoordinates> texCoords)
     {
-        m_coordinatesList.push_back(std::unique_ptr<TextureCoordinates>(texCoords));
+        m_coordinatesList.push_back(texCoords);
         m_idTexCoordMap[texCoords->getTargetLinearRingID()] = texCoords;
     }
 
diff --git a/sources/src/parser/addressparser.cpp b/sources/src/parser/addressparser.cpp
index 09aba39..f6f1162 100644
--- a/sources/src/parser/addressparser.cpp
+++ b/sources/src/parser/addressparser.cpp
@@ -72,9 +72,7 @@ namespace citygml {
 
     bool AddressParser::handlesElement(const NodeType::XMLNode& node) const
     {
-        return k_rootElements.count(node) > 0
-            || k_subElements.count(node) > 0
-            || k_dataElements.count(node) > 0;
+        return k_rootElements.count(node) > 0;
     }
 
     bool AddressParser::parseElementStartTag(const NodeType::XMLNode& node, Attributes& attributes)
@@ -97,7 +95,7 @@ namespace citygml {
 
     bool AddressParser::parseChildElementStartTag(const NodeType::XMLNode& node, Attributes& attributes)
     {
-        return handlesElement(node);
+        return k_subElements.count(node) > 0 || k_dataElements.count(node) > 0 || k_rootElements.count(node) > 0;
     }
 
     bool AddressParser::parseChildElementEndTag(const NodeType::XMLNode& node, const std::string& characters)
@@ -108,7 +106,7 @@ namespace citygml {
             return true;
         }
 
-        return handlesElement(node);
+        return k_subElements.count(node) > 0 || k_dataElements.count(node) > 0 || k_rootElements.count(node) > 0;
     }
 
 } /* namespace citygml */
diff --git a/sources/src/parser/geocoordinatetransformer.cpp b/sources/src/parser/geocoordinatetransformer.cpp
index df34024..abff46e 100644
--- a/sources/src/parser/geocoordinatetransformer.cpp
+++ b/sources/src/parser/geocoordinatetransformer.cpp
@@ -233,20 +233,20 @@ namespace citygml {
 
         for (unsigned int i = 0; i < obj.getPolygonsCount(); i++) {
 
-            Polygon& poly = obj.getPolygon(i);
+            const auto poly = obj.getPolygon(i);
 
-            auto it = m_transformedPolygonsSourceURNMap.find(poly.getId());
+            auto it = m_transformedPolygonsSourceURNMap.find(poly.get());
 
             if (it == m_transformedPolygonsSourceURNMap.end()) {
 
-                for (TVec3d& vertex : poly.getVertices()) {
+                for (TVec3d& vertex : poly->getVertices()) {
                     transformation.transform(vertex);
                 }
 
-                m_transformedPolygonsSourceURNMap[poly.getId()] = transformation.sourceURN();
+                m_transformedPolygonsSourceURNMap[poly.get()] = transformation.sourceURN();
 
             } else if (it->second != transformation.sourceURN()) {
-                CITYGML_LOG_WARN(m_logger, "Polygon with id '" << poly.getId() << "' was already transformed from " << it->second << " to " << m_destinationSRS
+                CITYGML_LOG_WARN(m_logger, "Polygon with id '" << poly->getId() << "' was already transformed from " << it->second << " to " << m_destinationSRS
                                  << ". But the spatial reference system of Geometry object with id '" << obj.getId() << "' that also contains the polygon is different "
                                  << "(" << transformation.sourceURN() << "). Ignoring new source SRS.");
             }
@@ -254,26 +254,26 @@ namespace citygml {
 
         for (unsigned int i = 0; i < obj.getLineStringCount(); i++) {
 
-            LineString& lineString = obj.getLineString(i);
+            const auto lineString = obj.getLineString(i);
 
-            auto it = m_transformedLineStringsSourceURNMap.find(lineString.getId());
+            auto it = m_transformedLineStringsSourceURNMap.find(lineString.get());
 
             if (it == m_transformedLineStringsSourceURNMap.end()) {
 
-                if (lineString.getDimensions() == 2) {
-                    for (TVec2d& vertex : lineString.getVertices2D()) {
+                if (lineString->getDimensions() == 2) {
+                    for (TVec2d& vertex : lineString->getVertices2D()) {
                         transformation.transform(vertex);
                     }
-                } else if (lineString.getDimensions() == 3) {
-                    for (TVec3d& vertex : lineString.getVertices3D()) {
+                } else if (lineString->getDimensions() == 3) {
+                    for (TVec3d& vertex : lineString->getVertices3D()) {
                         transformation.transform(vertex);
                     }
                 }
 
-                m_transformedLineStringsSourceURNMap[lineString.getId()] = transformation.sourceURN();
+                m_transformedLineStringsSourceURNMap[lineString.get()] = transformation.sourceURN();
 
             } else if (it->second != transformation.sourceURN()) {
-                CITYGML_LOG_WARN(m_logger, "LineString with id '" << lineString.getId() << "' was already transformed from " << it->second << " to " << m_destinationSRS
+                CITYGML_LOG_WARN(m_logger, "LineString with id '" << lineString->getId() << "' was already transformed from " << it->second << " to " << m_destinationSRS
                                  << ". But the spatial reference system of Geometry object with id '" << obj.getId() << "' that also contains the LineString is different "
                                  << "(" << transformation.sourceURN() << "). Ignoring new source SRS.");
             }
diff --git a/sources/src/parser/geometryelementparser.cpp b/sources/src/parser/geometryelementparser.cpp
index e136d10..e5b78bd 100644
--- a/sources/src/parser/geometryelementparser.cpp
+++ b/sources/src/parser/geometryelementparser.cpp
@@ -86,7 +86,7 @@ namespace citygml {
     {
         if (m_orientation == "-") {
             for (int i = 0; i < m_model->getPolygonsCount(); i++) {
-                m_model->getPolygon(i).setNegNormal(true);
+                m_model->getPolygon(i)->setNegNormal(true);
             }
         }
 
diff --git a/sources/src/parser/gmlfeaturecollectionparser.cpp b/sources/src/parser/gmlfeaturecollectionparser.cpp
index fc1d287..472e50f 100644
--- a/sources/src/parser/gmlfeaturecollectionparser.cpp
+++ b/sources/src/parser/gmlfeaturecollectionparser.cpp
@@ -61,7 +61,7 @@ namespace citygml {
         } else if (node == NodeType::GML_UpperCornerNode) {
 
             if (m_bounds != nullptr) {
-                m_bounds->setLowerBound(parseValue<TVec3d>(characters, m_logger, getDocumentLocation()));
+                m_bounds->setUpperBound(parseValue<TVec3d>(characters, m_logger, getDocumentLocation()));
             } else {
                 CITYGML_LOG_WARN(m_logger, "Definition of " << NodeType::GML_UpperCornerNode << " outside " << NodeType::GML_EnvelopeNode << " at " << getDocumentLocation());
             }
diff --git a/sources/src/parser/textureelementparser.cpp b/sources/src/parser/textureelementparser.cpp
index b9fb63a..f1100a6 100644
--- a/sources/src/parser/textureelementparser.cpp
+++ b/sources/src/parser/textureelementparser.cpp
@@ -81,7 +81,7 @@ namespace citygml {
             } else if (m_currentTexCoords != nullptr) {
                 CITYGML_LOG_WARN(m_logger, "Nested texture coordinates definition detected at: " << getDocumentLocation());
             } else {
-                m_currentTexCoords = new TextureCoordinates(attributes.getCityGMLIDAttribute(), parseReference(attributes.getAttribute("ring"), m_logger, getDocumentLocation()));
+                m_currentTexCoords = std::make_shared<TextureCoordinates>(attributes.getCityGMLIDAttribute(), parseReference(attributes.getAttribute("ring"), m_logger, getDocumentLocation()));
             }
             return true;
         }
@@ -122,7 +122,6 @@ namespace citygml {
 
             if (m_currentTexCoords != nullptr) {
                 CITYGML_LOG_WARN(m_logger, "TexCoordList node finished before TextureCoordinates child is finished at " << getDocumentLocation());
-                delete m_currentTexCoords;
                 m_currentTexCoords = nullptr;
             }
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index fca674f..71c3ed7 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -41,3 +41,6 @@ ADD_EXECUTABLE( citygmltest ${PRG_SRCS} )
 # ENDIF( MSVC_IDE )
 
 TARGET_LINK_LIBRARIES( citygmltest citygml ${XERCESC_LIBRARY} ${OPENGL_LIBRARIES} )
+
+install(TARGETS citygmltest RUNTIME DESTINATION ${BIN_INSTALL_DIR})
+
diff --git a/test/citygmltest.cpp b/test/citygmltest.cpp
index 74811d4..9ccf60f 100644
--- a/test/citygmltest.cpp
+++ b/test/citygmltest.cpp
@@ -28,7 +28,7 @@ void usage()
 {
     std::cout << "Usage: citygmltest [-options...] <filename>" << std::endl;
     std::cout << " Options:" << std::endl;
-    std::cout << "  -log            Print some informations during parsing" << std::endl;
+    std::cout << "  -log            Print some information during parsing" << std::endl;
     std::cout << "  -filter <mask>  CityGML objects to parse (default:All)" << std::endl
         << "                  The mask is composed of:" << std::endl
         << "                   GenericCityObject, Building, Room," << std::endl

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/libcitygml.git



More information about the Pkg-grass-devel mailing list