Skip to content

Commit

Permalink
Merge pull request #12 from 3dcl/bug/REN-259-LibCityGML-does-not-pars…
Browse files Browse the repository at this point in the history
…e-GenericCityObjects

Bug/ren 259 lib city gml does not parse generic city objects
  • Loading branch information
jklimke committed Apr 27, 2015
2 parents b5441e9 + 1cf17dd commit 010a6ad
Show file tree
Hide file tree
Showing 24 changed files with 485 additions and 74 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2 FATAL_ERROR)
PROJECT ( libcitygml )

set(META_VERSION_MAJOR "1")
set(META_VERSION_MINOR "3")
set(META_VERSION_MINOR "4")
set(META_VERSION_PATCH "0")
set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")

Expand Down
18 changes: 9 additions & 9 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
... if not one should think about removing the tesselation from libcitygml
* Check if OrientableSurfaces are supported properly... may be the vertices must be reverted if the orientation is '-'
* Check if Appearance assignment is correct for shared polygons
* Check if non implicit geoemtries can be shared
* Ensure that polygons that are children of shared geometries are not also children of non shared geometries (otherwise a coordinate transformation might be applied on the vertices which is not allowed for shared geometries)
* The namespace of the different modules may differ from the recommended one... make a namespace mapping based on the uri
* Currently different city object types are grouped under the same enum type (CityObjectType) e.g. WaterSurface, WaterGroundSurface, WaterClosureSurface and WaterBody are of type COT_WaterBody. The reason for this is that every enum type is identified by an individual bit... however there are only 32 bits. Check if the bitmask is actually used... if not remove that constraint and define an individual enum type for every CityObject type
* Some polygon types (PolygonSurface, Polygon, Triangle etc.) have an implicit ("planar") or explicit gml:SurfaceInterpolationType attribute... currently its ignored

# Completness
* Implement parsing of CityObject <generalizesTo> member (contains a cityobject or references one that is the generalization of the current one) => requires cityobject sharing
* Implement parsing of CityObject <externalReference> member
* Implement complete address parsing: Currently the address attributes (street, postalcode, etc.) are stored as indivdual address attributes. However a address can be assigned zero or more 2D or 3D point geometries (one gml:MultiPoint geometry) locating the entrance. This requires parsing of the <Address> as an individual element
* Implement parsing of ImplicitGeometry <libraryObject> member
* Implement parsing of CityObject `<generalizesTo>` member (contains a cityobject or references one that is the generalization of the current one) =>` requires cityobject sharing
* Implement parsing of CityObject `<externalReference>` member
* Implement complete address parsing: Currently the address attributes (street, postalcode, etc.) are stored as indivdual address attributes. However a address can be assigned zero or more 2D or 3D point geometries (one gml:MultiPoint geometry) locating the entrance. This requires parsing of the `<Address>` as an individual element
* Implement parsing of ImplicitGeometry `<libraryObject>` member
* Implement GeoreferencedTexture parsing
* Implement appearence <TexCoordGen> support
* Implement <grp:geometry> support (Darunter kann eine beliebige GML Geometrie hängen)
* Implement full support for <grp:groupMember> and <grp:parent> (requires city object sharing, currently only inline definitions are supported)
* Implement appearence `<TexCoordGen>` support
* Implement `<grp:geometry>` support (Darunter kann eine beliebige GML Geometrie hängen)
* Implement full support for `<grp:groupMember>` and `<grp:parent>` (requires city object sharing, currently only inline definitions are supported)
* Implement sharing for all geometries (currently onl ImplicitGeometries)
* Implement lod0 parsing
* Implement Relief/Terrain Model (Namespace DEM) parsing. More precisely implement ReliefComponentPropertyType parsing.
* Requires gml:MultiPointPropertyType parsing
* Requires gml:MultiCurvePropertyType parsing (also required for wtr module)
* Requires gml:RectifiedGridCoverage parsing
* Implement gml:Tin parsing (possible child of <surfaceMember> element that uses delauny triangulation)
* Implement gml:Tin parsing (possible child of `<surfaceMember>` element that uses delauny triangulation)

# Refactoring
* Change the NodeTypes so that typeID is a constant expression -> Use switch-case structures instead of if-then-else in the element parsers
Expand Down
4 changes: 4 additions & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ SET(SOURCES
src/citygml/citygmlfactory.cpp
src/citygml/polygonmanager.cpp
src/citygml/geometrymanager.cpp
src/citygml/linestring.cpp

src/parser/nodetypes.cpp
src/parser/attributes.cpp
Expand All @@ -66,6 +67,7 @@ SET(SOURCES
src/parser/georeferencedtextureelementparser.cpp
src/parser/geometryelementparser.cpp
src/parser/polygonelementparser.cpp
src/parser/linestringelementparser.cpp
src/parser/linearringelementparser.cpp
src/parser/implicitgeometryelementparser.cpp
)
Expand Down Expand Up @@ -96,6 +98,7 @@ SET(PUBLIC_HEADER
include/citygml/texturecoordinates.h
include/citygml/appearancetarget.h
include/citygml/citygmlfactory.h
include/citygml/linestring.h
)

SET(HEADERS
Expand Down Expand Up @@ -135,6 +138,7 @@ SET(HEADERS
include/parser/georeferencedtextureelementparser.h
include/parser/geometryelementparser.h
include/parser/polygonelementparser.h
include/parser/linestringelementparser.h
include/parser/linearringelementparser.h
include/parser/implicitgeometryelementparser.h
)
Expand Down
4 changes: 3 additions & 1 deletion sources/include/citygml/citygmlfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace citygml {
class Geometry;
class ImplicitGeometry;
class Polygon;
class LineString;

class Appearance;
class Texture;
Expand All @@ -33,9 +34,10 @@ namespace citygml {

CityModel* createCityModel(const std::string& id);
CityObject* createCityObject(const std::string& id, CityObject::CityObjectsType type);
Geometry* createGeometry(const std::string& id, Geometry::GeometryType type = Geometry::GeometryType::GT_Unknown, unsigned int lod = 0);
Geometry* createGeometry(const std::string& id, const CityObject::CityObjectsType& cityObjType = CityObject::CityObjectsType::COT_All, unsigned int lod = 0);

std::shared_ptr<Polygon> createPolygon(const std::string& id);
std::shared_ptr<LineString> createLineString(const std::string& id);

/**
* @brief requests a polygon for a Geometry object that will be added later
Expand Down
10 changes: 7 additions & 3 deletions sources/include/citygml/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Tesselator;

namespace citygml {

class LineString;
class Polygon;
class AppearanceManager;
class Appearance;
Expand All @@ -34,14 +35,16 @@ namespace citygml {
GT_Ceiling = 1 << 7
};

// Get the geometry LOD
unsigned int getLOD() const;

// Get the polygons
unsigned int getPolygonsCount() const;
Polygon& getPolygon( unsigned int i );
const Polygon& getPolygon( unsigned int i ) const;

unsigned int getLineStringCount() const;
LineString& getLineString( unsigned int i );
const LineString& getLineString( unsigned int i ) const;

unsigned int getGeometriesCount() const;
const Geometry& getGeometry( unsigned int i ) const;
Geometry& getGeometry( unsigned int i );
Expand All @@ -50,12 +53,12 @@ namespace citygml {
GeometryType getType() const;

std::string getTypeAsString() const;
//std::string getTypeAsString( void ) const { return getGeometryClassName( _type ); }

unsigned int lod() const;
void setLod(unsigned int lod);

void addPolygon(std::shared_ptr<Polygon> );
void addLineString(std::shared_ptr<LineString>);

/**
* @brief finishes the geometry by finishing its child polygons after broadcasting its appearances to all child polygons
Expand All @@ -80,6 +83,7 @@ namespace citygml {
std::vector<std::shared_ptr<Geometry>> m_childGeometries;

std::vector<std::shared_ptr<Polygon>> m_polygons;
std::vector<std::shared_ptr<LineString>> m_lineStrings;
};

std::ostream& operator<<( std::ostream& os, const citygml::Geometry& s );
Expand Down
40 changes: 40 additions & 0 deletions sources/include/citygml/linestring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include <citygml/citygml_api.h>
#include <citygml/object.h>
#include <citygml/vecs.hpp>
#include <memory>

#include <vector>

namespace citygml {

class CityGMLFactory;

/**
* @brief The LineString class implements the gml:LineString object may also be used as a container of a single gml::Point
*/
class LIBCITYGML_EXPORT LineString : public Object {
friend class CityGMLFactory;
public:
int getDimensions() const;

const std::vector<TVec2d>& getVertices2D() const;
const std::vector<TVec3d>& getVertices3D() const;

std::vector<TVec2d>& getVertices2D();
std::vector<TVec3d>& getVertices3D();

void setVertices2D(const std::vector<TVec2d>& vertices);
void setVertices3D(const std::vector<TVec3d>& vertices);

void setDimensions(int dim);

protected:
LineString(const std::string& id);
std::vector<TVec2d> m_vertices_2d;
std::vector<TVec3d> m_vertices_3d;
int m_dimensions;
};

}
4 changes: 4 additions & 0 deletions sources/include/parser/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ namespace citygml {
virtual std::string getAttribute( const std::string& attname, const std::string& defvalue = "" ) const = 0;
virtual const DocumentLocation& getDocumentLocation() const = 0;

/**
* @brief gets the citygml id attribute value or if not present generates a value based on the document location
* @return the value of the gml::id attribute or "genID_<CityGMLFileName>_<LineNumber>_<ColumnNumber>" if there is no id attribute
*/
std::string getCityGMLIDAttribute() const;

bool hasXLinkAttribute() const;
Expand Down
1 change: 1 addition & 0 deletions sources/include/parser/cityobjectelementparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace citygml {

void parseGeometryForLODLevel(int lod);
void parseImplicitGeometryForLODLevel(int lod);
void parseGeometryPropertyElementForLODLevel(int lod, const std::string& id);
};

}
7 changes: 7 additions & 0 deletions sources/include/parser/delayedchoiceelementparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ namespace citygml {
*/
class DelayedChoiceElementParser : public ElementParser {
public:

/**
* @brief creates a DelayedChoiceElementParser
* @param documentParser
* @param logger
* @param choices the parsers to choose from. The DelayedChoiceElementParser takes ownership of the parsers.
*/
DelayedChoiceElementParser(CityGMLDocumentParser& documentParser, std::shared_ptr<CityGMLLogger> logger, std::vector<ElementParser*> choices);

// ElementParser interface
Expand Down
1 change: 1 addition & 0 deletions sources/include/parser/geocoordinatetransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace citygml {
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;

void transformRecursive(CityObject& obj, GeoTransform& transformation);
void transformRecursive_helper(CityObject& obj, GeoTransform& transformation);
Expand Down
36 changes: 36 additions & 0 deletions sources/include/parser/linestringelementparser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include <parser/gmlobjectparser.h>

#include <functional>
#include <memory>

namespace citygml {

class LineString;

class LineStringElementParser : public GMLObjectElementParser {
public:
LineStringElementParser(CityGMLDocumentParser& documentParser, CityGMLFactory& factory, std::shared_ptr<CityGMLLogger> logger, std::function<void(std::shared_ptr<LineString>)> callback);

// ElementParser interface
virtual std::string elementParserName() const;
virtual bool handlesElement(const NodeType::XMLNode &node) const override;
protected:
// CityGMLElementParser interface
virtual bool parseElementStartTag(const NodeType::XMLNode& node, Attributes& attributes) override;
virtual bool parseElementEndTag(const NodeType::XMLNode& node, const std::string& characters) override;
virtual bool parseChildElementStartTag(const NodeType::XMLNode& node, Attributes& attributes) override;
virtual bool parseChildElementEndTag(const NodeType::XMLNode& node, const std::string& characters) override;

// GMLObjectElementParser interface
virtual Object* getObject() override;

private:
std::shared_ptr<LineString> m_model;
std::function<void(std::shared_ptr<LineString>)> m_callback;

void parseDimension(Attributes& attributes);
};

}
9 changes: 8 additions & 1 deletion sources/include/parser/nodetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ namespace citygml {
NODETYPE( GML, Surface )
NODETYPE( GML, PolygonPatch)

NODETYPE( GML, LineString )

// BLDG
NODETYPE( BLDG, Building )
NODETYPE( BLDG, BuildingPart )
Expand Down Expand Up @@ -178,7 +180,6 @@ namespace citygml {
NODETYPE( BLDG, Lod2Solid )
NODETYPE( BLDG, Lod3Solid )
NODETYPE( BLDG, Lod4Solid )
NODETYPE( BLDG, Lod1Geometry )
NODETYPE( BLDG, Lod2Geometry )
NODETYPE( BLDG, Lod3Geometry )
NODETYPE( BLDG, Lod4Geometry )
Expand Down Expand Up @@ -281,6 +282,12 @@ namespace citygml {
NODETYPE( VEG, TrunkDiameter )
NODETYPE( VEG, CrownDiameter )

NODETYPE( VEG, Lod0Geometry )
NODETYPE( VEG, Lod1Geometry )
NODETYPE( VEG, Lod2Geometry )
NODETYPE( VEG, Lod3Geometry )
NODETYPE( VEG, Lod4Geometry )

// TRANS
NODETYPE( TRANS, TransportationComplex )
NODETYPE( TRANS, TrafficArea )
Expand Down
35 changes: 33 additions & 2 deletions sources/src/citygml/citygmlfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "citygml/cityobject.h"
#include "citygml/appearancetarget.h"
#include "citygml/polygon.h"
#include "citygml/linestring.h"
#include "citygml/implictgeometry.h"
#include "citygml/texture.h"
#include "citygml/georeferencedtexture.h"
Expand Down Expand Up @@ -36,9 +37,32 @@ namespace citygml {
return cityObject;
}

Geometry* CityGMLFactory::createGeometry(const std::string& id, Geometry::GeometryType type, unsigned int lod)
Geometry::GeometryType mapCityObjectsTypeToGeometryType(const CityObject::CityObjectsType& cityObjType) {

switch (cityObjType) {
case CityObject::CityObjectsType::COT_RoofSurface:
return Geometry::GeometryType::GT_Roof;
case CityObject::CityObjectsType::COT_WallSurface:
return Geometry::GeometryType::GT_Wall;
case CityObject::CityObjectsType::COT_GroundSurface:
return Geometry::GeometryType::GT_Ground;
case CityObject::CityObjectsType::COT_ClosureSurface:
return Geometry::GeometryType::GT_Closure;
case CityObject::CityObjectsType::COT_FloorSurface:
return Geometry::GeometryType::GT_Floor;
case CityObject::CityObjectsType::COT_InteriorWallSurface:
return Geometry::GeometryType::GT_InteriorWall;
case CityObject::CityObjectsType::COT_CeilingSurface:
return Geometry::GeometryType::GT_Ceiling;
default:
return Geometry::GeometryType::GT_Unknown;
}

}

Geometry* CityGMLFactory::createGeometry(const std::string& id, const CityObject::CityObjectsType& cityObjType, unsigned int lod)
{
Geometry* geom = new Geometry(id, type, lod);
Geometry* geom = new Geometry(id, mapCityObjectsTypeToGeometryType(cityObjType), lod);
appearanceTargetCreated(geom);
return geom;
}
Expand All @@ -54,6 +78,13 @@ namespace citygml {
return shared;
}

std::shared_ptr<LineString> CityGMLFactory::createLineString(const std::string& id)
{
LineString* lineString = new LineString(id);
return std::shared_ptr<LineString>(lineString);

}

void CityGMLFactory::requestSharedPolygonForGeometry(Geometry* geom, const std::string& polygonId)
{
m_polygonManager->requestSharedPolygonForGeometry(geom, polygonId);
Expand Down
22 changes: 21 additions & 1 deletion sources/src/citygml/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ namespace citygml {
return *m_polygons.at(i);
}

unsigned int Geometry::getLineStringCount() const
{
return m_lineStrings.size();
}

LineString& Geometry::getLineString(unsigned int i)
{
return *m_lineStrings.at(i);
}

const LineString& Geometry::getLineString(unsigned int i) const
{
return *m_lineStrings.at(i);
}

unsigned int Geometry::getGeometriesCount() const
{
return m_childGeometries.size();
Expand Down Expand Up @@ -99,7 +114,12 @@ namespace citygml {

void Geometry::addPolygon( std::shared_ptr<Polygon> p )
{
m_polygons.push_back( p );
m_polygons.push_back(p);
}

void Geometry::addLineString(std::shared_ptr<LineString> l)
{
m_lineStrings.push_back(l);
}

void Geometry::finish(Tesselator& tesselator, bool optimize, std::shared_ptr<CityGMLLogger> logger)
Expand Down
Loading

0 comments on commit 010a6ad

Please sign in to comment.