Skip to content

Commit

Permalink
Merge pull request #73 from topheg/parse_lod0
Browse files Browse the repository at this point in the history
Add Lod0Footprint / RoofEdge parsing
  • Loading branch information
jklimke authored Nov 8, 2022
2 parents 4dacf5d + 225d23e commit d2b327f
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ before_install:
- echo $LANG
- echo $LC_ALL
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
script: mkdir build && cd build && cmake ../ && make && ./bin/citygmltest ../data/berlin_open_data_sample_data.citygml && ./bin/citygmltest ../data/b1_lod2_s.gml
script: mkdir build && cd build && cmake ../ && make && ./bin/citygmltest ../data/berlin_open_data_sample_data.citygml && ./bin/citygmltest ../data/b1_lod2_s.gml && ./bin/citygmltest ../data/FZK-Haus-LoD0-KIT-IAI-KHH-B36-V1.gml
addons:
apt:
sources:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Overview over the testing data within the "data" directory:
| data/b1_lod2_cs_w_sem.gml | https://www.citygml.org/samplefiles/building/ | [https://www.citygml.org](https://www.citygml.org/samplefiles/) |
| data/b1_lod2_s.gml | https://www.citygml.org/samplefiles/building/ | [https://www.citygml.org](https://www.citygml.org/samplefiles/) |
| data/berlin_open_data_sample_data.gml | Berlin Partner für Wirtschaft und Technologie GmbH | [Berlin Partner Download Portal](http://www.businesslocationcenter.de/berlin3d-downloadportal/?lang=en) |
| data/FZK-Haus-LoD0-KIT-IAI-KHH-B36-V1.gml | Institute for Automation and Applied Computer Science (IAI) / Karlsruhe Institute of Technology (KIT) | https://www.citygmlwiki.org/index.php?title=FZK_Haus |



Expand Down
80 changes: 80 additions & 0 deletions data/FZK-Haus-LoD0-KIT-IAI-KHH-B36-V1.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?><!-- Generated by: --><!-- IFC -> cityGML Converter --><!-- (C) - Institute for Applied Computer Science --><!-- Forschungszentrum Karlsruhe --><!-- Not for commercial use --><!-- Generated by: IfcExplorer--><!-- cityGML Schema: 1.0.0 --><!-- Level of Detail 1--><!-- Creation Date: Tuesday, 23 November 2010 - 10:37:59--><!-- Edited Manually in Oxygen 8.2 --><!-- Modified by GMLOffset.xslt at Mon Dec 6 2010 --><!-- Version 2 Building located in the area of KIT Campus North)--><!-- Modified by GMLOffset.xslt at Wed Dec 8 2010 --><!-- Modified by GMLOffset.xslt at Wed Mar 29 2017 --><core:CityModel xsi:schemaLocation="http://www.opengis.net/citygml/2.0 http://schemas.opengis.net/citygml/2.0/cityGMLBase.xsd http://www.opengis.net/citygml/appearance/2.0 http://schemas.opengis.net/citygml/appearance/2.0/appearance.xsd http://www.opengis.net/citygml/building/2.0 http://schemas.opengis.net/citygml/building/2.0/building.xsd http://www.opengis.net/citygml/generics/2.0 http://schemas.opengis.net/citygml/generics/2.0/generics.xsd" xmlns:core="http://www.opengis.net/citygml/2.0" xmlns="http://www.opengis.net/citygml/profiles/base/2.0" xmlns:bldg="http://www.opengis.net/citygml/building/2.0" xmlns:gen="http://www.opengis.net/citygml/generics/2.0" xmlns:grp="http://www.opengis.net/citygml/cityobjectgroup/2.0" xmlns:app="http://www.opengis.net/citygml/appearance/2.0" xmlns:gml="http://www.opengis.net/gml" xmlns:xAL="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- Manually edited by KHH 23.01.2017, Address added, roof edge added -->
<gml:name>AC14-FZK-Haus</gml:name>
<gml:boundedBy>
<gml:Envelope srsDimension="3" srsName="urn:adv:crs:ETRS89_UTM32*DE_DHHN92_NH">
<gml:lowerCorner srsDimension="3">457842 5439083 111.8 </gml:lowerCorner>
<gml:upperCorner srsDimension="3">457854 5439093 118.317669 </gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<core:cityObjectMember>
<bldg:Building gml:id="UUID_d281adfc-4901-0f52-540b-4cc1a9325f82">
<gml:description>FZK-Haus (Forschungszentrum Karlsruhe, now KIT), created by Karl-Heinz
Haefele </gml:description>
<gml:name>AC14-FZK-Haus</gml:name>
<core:creationDate>2017-01-23</core:creationDate>
<core:relativeToTerrain>entirelyAboveTerrain</core:relativeToTerrain>
<gen:measureAttribute name="GrossPlannedArea">
<gen:value uom="m2">120.00</gen:value>
</gen:measureAttribute>
<gen:stringAttribute name="ConstructionMethod">
<gen:value>New Building</gen:value>
</gen:stringAttribute>
<gen:stringAttribute name="IsLandmarked">
<gen:value>NO</gen:value>
</gen:stringAttribute>
<bldg:class codeSpace="http://www.sig3d.org/codelists/citygml/2.0/building/2.0/_AbstractBuilding_class.xml">1000</bldg:class>
<bldg:function codeSpace="http://www.sig3d.org/codelists/citygml/2.0/building/2.0/_AbstractBuilding_function.xml">1000</bldg:function>
<bldg:usage codeSpace="http://www.sig3d.org/codelists/citygml/2.0/building/2.0/_AbstractBuilding_usage.xml">1000</bldg:usage>
<bldg:yearOfConstruction>2020</bldg:yearOfConstruction>
<bldg:roofType codeSpace="http://www.sig3d.org/codelists/citygml/2.0/building/2.0/_AbstractBuilding_roofType.xml">1030</bldg:roofType>
<bldg:measuredHeight uom="m">6.52</bldg:measuredHeight>
<bldg:storeysAboveGround>2</bldg:storeysAboveGround>
<bldg:storeysBelowGround>0</bldg:storeysBelowGround>
<bldg:lod0FootPrint>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">457842 5439083 111.8 457842 5439093 111.8 457854 5439093 111.8 457854 5439083 111.8 457842 5439083 111.8 </gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod0FootPrint>
<bldg:lod0RoofEdge>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">457841.5 5439082.5 111.8 457841.5 5439093.5 111.8 457854.5 5439093.5 111.8 457854.5 5439082.5 111.8 457841.5 5439082.5 111.8 </gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod0RoofEdge>
<bldg:address>
<core:Address>
<core:xalAddress>
<xAL:AddressDetails>
<xAL:Locality Type="Town">
<xAL:LocalityName>Eggenstein-Leopoldshafen</xAL:LocalityName>
<xAL:Thoroughfare Type="Street">
<xAL:ThoroughfareNumber>4711</xAL:ThoroughfareNumber>
<xAL:ThoroughfareName>Spöcker Straße</xAL:ThoroughfareName>
</xAL:Thoroughfare>
<xAL:PostalCode>
<xAL:PostalCodeNumber>76344</xAL:PostalCodeNumber>
</xAL:PostalCode>
</xAL:Locality>
</xAL:AddressDetails>
</core:xalAddress>
</core:Address>
</bldg:address>
</bldg:Building>
</core:cityObjectMember>
</core:CityModel>
1 change: 1 addition & 0 deletions sources/include/parser/cityobjectelementparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace citygml {
static bool attributesSetInitialized;

void parseGeometryForLODLevel(int lod);
void parseGeometryForLODLevel(int lod, CityObject::CityObjectsType parentType);
void parseImplicitGeometryForLODLevel(int lod);
void parseGeometryPropertyElementForLODLevel(int lod, const std::string& id);
};
Expand Down
4 changes: 3 additions & 1 deletion sources/include/parser/nodetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ namespace citygml {
NODETYPE( BLDG, RoomInstallation)
NODETYPE( BLDG, Opening)
NODETYPE( BLDG, RoofType)


NODETYPE( BLDG, Lod0FootPrint )
NODETYPE( BLDG, Lod0RoofEdge )
NODETYPE( BLDG, Lod1Solid )
NODETYPE( BLDG, Lod2Solid )
NODETYPE( BLDG, Lod3Solid )
Expand Down
19 changes: 16 additions & 3 deletions sources/src/parser/cityobjectelementparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ namespace citygml {
|| node == NodeType::WTR_Lod0MultiSurfaceNode) {

parseGeometryForLODLevel(0);
} else if (node == NodeType::BLDG_Lod0FootPrintNode) {
// for Lod0 footprint, we must explicitly set the City Object Type, because the parent type is "Building", and it doesn't allow to discriminate between the ground and roof surface
parseGeometryForLODLevel(0, CityObject::CityObjectsType::COT_GroundSurface);
} else if (node == NodeType::BLDG_Lod0RoofEdgeNode) {
// for Lod0 roof edge, we must explicitly set the City Object Type, because the parent type is "Building", and it doesn't allow to discriminate between the ground and roof surface
parseGeometryForLODLevel(0, CityObject::CityObjectsType::COT_RoofSurface);
} else if (node == NodeType::BLDG_Lod1MultiCurveNode
|| node == NodeType::BLDG_Lod1MultiSurfaceNode
|| node == NodeType::BLDG_Lod1SolidNode
Expand Down Expand Up @@ -480,6 +486,8 @@ namespace citygml {
|| node == NodeType::BLDG_OpeningNode
|| node == NodeType::APP_AppearanceNode
|| node == NodeType::APP_AppearanceMemberNode
|| node == NodeType::BLDG_Lod0FootPrintNode
|| node == NodeType::BLDG_Lod0RoofEdgeNode
|| node == NodeType::BLDG_Lod1MultiCurveNode
|| node == NodeType::BLDG_Lod1MultiSurfaceNode
|| node == NodeType::BLDG_Lod1SolidNode
Expand Down Expand Up @@ -584,13 +592,18 @@ namespace citygml {
{
return m_model;
}

void CityObjectElementParser::parseGeometryForLODLevel(int lod)
void CityObjectElementParser::parseGeometryForLODLevel(int lod, CityObject::CityObjectsType parentType)
{
setParserForNextElement(new GeometryElementParser(m_documentParser, m_factory, m_logger, lod, m_model->getType(), [this](Geometry* geom) {
setParserForNextElement(new GeometryElementParser(m_documentParser, m_factory, m_logger, lod, parentType, [this](Geometry* geom) {
m_model->addGeometry(geom);
}));
}

void CityObjectElementParser::parseGeometryForLODLevel(int lod)
{
parseGeometryForLODLevel(lod, m_model->getType());
}

void CityObjectElementParser::parseImplicitGeometryForLODLevel(int lod)
{
Expand Down
8 changes: 6 additions & 2 deletions sources/src/parser/nodetypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ namespace citygml {
INITIALIZE_NODE( GML, Surface )
INITIALIZE_NODE( GML, PolygonPatch)
INITIALIZE_NODE( GML, LineString)


INITIALIZE_NODE( BLDG, Lod0FootPrint )
INITIALIZE_NODE( BLDG, Lod0RoofEdge )
INITIALIZE_NODE( BLDG, Lod1Solid )
INITIALIZE_NODE( BLDG, Lod2Solid )
INITIALIZE_NODE( BLDG, Lod3Solid )
Expand Down Expand Up @@ -548,7 +550,9 @@ namespace citygml {
DEFINE_NODE( GML, PosList )
DEFINE_NODE( GML, OrientableSurface )
DEFINE_NODE( GML, LinearRing )


DEFINE_NODE( BLDG, Lod0FootPrint )
DEFINE_NODE( BLDG, Lod0RoofEdge )
DEFINE_NODE( BLDG, Lod1Solid )
DEFINE_NODE( BLDG, Lod2Solid )
DEFINE_NODE( BLDG, Lod3Solid )
Expand Down
56 changes: 47 additions & 9 deletions test/citygmltest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
#include <citygml/citygml.h>
#include <citygml/citymodel.h>
#include <citygml/cityobject.h>
#include <citygml/geometry.h>

void analyzeObject( const citygml::CityObject*, unsigned int );
void analyzeObject( const citygml::CityObject&, unsigned int );

void usage()
{
Expand Down Expand Up @@ -120,21 +121,58 @@ int main( int argc, char **argv )
if ( log )
{
std::cout << std::endl << "Objects hierarchy:" << std::endl;
// const citygml::ConstCityObjects& roots = city->getRootCityObjects();

// for ( unsigned int i = 0; i < roots.size(); i++ ) analyzeObject( roots[ i ], 2 );
const citygml::ConstCityObjects& roots = city->getRootCityObjects();
for ( unsigned int i = 0; i < roots.size(); i++ ) analyzeObject( *(roots[ i ]), 2 );
}

std::cout << "Done." << std::endl;

return EXIT_SUCCESS;
}

void analyzeObject( const citygml::CityObject* object, unsigned int indent )
void printIndent(unsigned int indent) {
for ( unsigned int i = 0; i < indent; i++ ) std::cout << " ";
}

void printGeometry( const citygml::Geometry& geometry, unsigned int indent )
{
// for ( unsigned int i = 0; i < indent; i++ ) std::cout << " ";
// std::cout << "Object " << citygml::getCityObjectsClassName( object->getType() ) << ": " << object->getId() << std::endl;
printIndent(indent);
std::cout << "Geometry for LOD" << geometry.getLOD() << ", type: " << geometry.getTypeAsString() << std::endl;

if(geometry.getLineStringCount() > 0)
{
printIndent(indent+1);
std::cout << "Linestrings:" << geometry.getLineStringCount() << std::endl;
}

if(geometry.getPolygonsCount() > 0)
{
printIndent(indent+1);
std::cout << "Polygons:" << geometry.getPolygonsCount() << std::endl;
}

if(geometry.getGeometriesCount() >0)
{
printIndent(indent+1);
std::cout << "SubGeometries:" << std::endl;
for( unsigned int i = 0; i < geometry.getGeometriesCount(); i++ )
{
printGeometry(geometry.getGeometry(i), indent+1);
}
}
}

// for ( unsigned int i = 0; i < object->getChildCount(); i++ )
// analyzeObject( object->getChild(i), indent+1 );
void analyzeObject( const citygml::CityObject& object, unsigned int indent )
{
printIndent(indent);
std::cout << "Object " << object.getTypeAsString() << ": " << object.getId() << std::endl;


for ( unsigned int i = 0; i < object.getGeometriesCount(); i++ )
{
printGeometry( object.getGeometry(i), indent+1 );
}

for ( unsigned int i = 0; i < object.getChildCityObjectsCount(); i++ )
analyzeObject( object.getChildCityObject(i), indent+1 );
}

0 comments on commit d2b327f

Please sign in to comment.