Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE...

32
Energy ADE Support for SimStadt Marcel Bruse, 24th of November 2015

Transcript of Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE...

Page 1: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Energy ADE Support

for SimStadt

Marcel Bruse, 24th of November 2015

Page 2: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Objectives

• Enable SimStadt to process the Energy ADE

• Minimize the need to adjust SimStadt to changing XML schema definitions

11/25/2015 2

Page 3: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

What was the initial situation in the SimStadt project before the Energy

ADE?

11/25/2015 3

Page 4: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j

CityDoctor

SimStadt

Data Structures

CityGML File

11/25/2015 4

Page 5: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j

CityDoctor

SimStadt

Data Structures

11/25/2015 5

CityGML File

Page 6: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j

• Java library to read, process, write, and validate CityGML

• Generated from the CityGML schema definition via JAXB

11/25/2015 6

Java

Java

Java

Source: Open Geospatial Consortium, Inc; 2012

Page 7: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j

CityDoctor

SimStadt

Data Structures

11/25/2015 7

CityGML File

Page 8: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

CityDoctor

Its main purpose for SimStadt is to provide a simplified representation

of the complex CityGML geometries

Byproduct is an additional level of indirection not

only for geometries but also for

features like buildings and

boundary surfaces

11/25/2015 8

Page 9: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j

CityDoctor

SimStadt

Data Structures

11/25/2015 9

CityGML File

Page 10: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

How to integrate the Energy ADE into SimStadt?

11/25/2015 10

Page 11: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j

CityDoctor

SimStadt

Energy ADE Plugin

Data Structures

11/25/2015 11

CityGML File

Page 12: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j and ADEs The citygml4j library instantiates DOM nodes for each ADE element

11/25/2015 12

Page 13: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

ade-xjc (1)

ade-xjc expects all schema definitions to be

present in ./schemas relative to energy.xsd

11/25/2015 13

Page 14: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

ade-xjc (2)

Parse the schema with: java –jar ade-xjc.jar –package <package> -output <destination> -b <binding> <schema file>

11/25/2015 14

Page 15: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

ade-xjc (3)

There will be a Java class for each ADE element plus some

useful helper classes.

11/25/2015 15

Page 16: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Extension Handlers (1)

• Each CityGML feature that is loaded by citygml4j has to be checked for extensions by a special implementation of ExtensionHandler

• Part of CityDoctor plugins

• Has to be implemented manually

11/25/2015 16

Page 17: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Extension Handlers (2) […]

public abstract class ExtensionHandler {

[…]

public abstract ArrayList<ADEComponent> marshal(citydoctor.Building building);

public abstract ArrayList<ADEComponent> marshal(citydoctor.BuildingPart buildingPart);

public abstract ArrayList<ADEComponent> marshal(citydoctor.BoundarySurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.Building building);

public abstract ArrayList<Extension> unmarshal(citygml4j.BuildingPart buildingPart);

public abstract ArrayList<Extension> unmarshal(citygml4j.WallSurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.RoofSurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.GroundSurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.FloorSurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.CeilingSurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.OuterFloorSurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.OuterCeilingSurface boundarySurface);

public abstract ArrayList<Extension> unmarshal(citygml4j.ClosureSurface boundarySurface);

[…]

}

11/25/2015 17

Page 18: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Marshallers

• Each CityGML feature that is loaded through citygml4j has to be checked for extensions

• marshallers methods of the extension handler have to instantiate the previously generated ADE speicfic Java classes

11/25/2015 18

Page 19: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Unmarshallers

• In order to write the (manipulated) DOM back to the data source, an unmarshaller has to be triggered

• These unmarshallers are also methods defined in the extension handler interface

11/25/2015 19

Page 20: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Associate ADE Elements with City Objects

• CityDoctor has its own representation of city objects

• CityDoctor‘s city objects can be extended

11/25/2015 20

Page 21: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Energy ADE Plugin

The Energy ADE Plugin consists of …

• EnergyADEHandler

• AbstractBuildingExt

• AbstractBoundarySurfaceExt

• Java classes generated from the XML schema definition

… and is deployed as a JAR.

11/25/2015 21

Page 22: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

citygml4j

CityDoctor

SimStadt

Energy ADE Plugin

Data Structures

CityGML File

11/25/2015 22

Page 23: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Service Provider Interface (SPI)

• CityDoctor will detect provided plugins at runtime by searching for implementations of the SPI ExtensionHandler

• This way CityDoctor can deal with any CityGML ADE

11/25/2015 23

Page 24: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

11/25/2015 24

Page 25: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Extension Registry

• There may be more than one plugin for different CityGML ADEs

• CityDoctor registers all found plugins in its extension registry

• Each loaded CityGML feature will be passed to the registry where it will be tested against every plugin / extension handler

11/25/2015 25

Page 26: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

11/25/2015 26

Page 27: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Energy ADE Support

for SimStadt

Marcel Bruse, 9th of June, 2015

Page 28: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Appendix

11/25/2015 28

Page 29: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

ADE Example

1. <?xml version="1.0" encoding="UTF-8"?> 2. <xsd:schema xmlns="http://anydomain.de/ade/exposure" 3. xmlns:xsd="http://www.w3.org/2001/XMLSchema" 4. xmlns:core="http://www.opengis.net/citygml/1.0" 5. targetNamespace="http://anydomain.de/ade/exposure" 6. elementFormDefault="qualified" 7. attributeFormDefault="unqualified" 8. version="0.3"> 9. <xsd:import namespace="http://www.opengis.net/citygml/1.0" 10. schemaLocation="./schemas/CityGML/1.0.0/cityGMLBase.xsd" /> 11. <xsd:element name="radiationExposure" type="xsd:double" 12. substitutionGroup="core:_GenericApplicationPropertyOfSite" /> 13. <xsd:element name="distanceToSiteOfAccident" type="xsd:int“ 14. substitutionGroup="core:_GenericApplicationPropertyOfSite" /> 15. <xsd:element name="teardownAndDisposalPlan" type="TeardownAndDisposalPlan" 16. substitutionGroup="core:_GenericApplicationPropertyOfSite" /> 17. <xsd:complexType name="TeardownAndDisposalPlan"> 18. <xsd:sequence minOccurs="0"> 19. <xsd:element name="planDescription" type="xsd:string" minOccurs="0" maxOccurs="1" /> 20. <xsd:element name="costs" type="xsd:double" minOccurs="0" maxOccurs="1" /> 21. </xsd:sequence> 22. </xsd:complexType> 23. </xsd:schema>

11/25/2015 29

Page 30: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Unmarshaller Example

1. @Override

2. public ArrayList<Extension> unmarshal(Building building)

3. throws JAXBException, SAXException {

4. HashSet<Extension> extensionSet = new HashSet<>();

5. List<ADEComponent> adeComponentList = building.getGenericApplicationPropertyOfSite();

6. SiteExtension siteExtension = new SiteExtension();

7. for (ADEComponent adeComponent : adeComponentList) {

8. if (adeComponent.getNamespaceURI().equals(handlesNamespaceURI())) {

9. JAXBElement<?> element =

10. (JAXBElement<?>) getJAXBUnmarshaller().unmarshal(adeComponent.getContent());

11. switch (adeComponent.getLocalName()) {

12. case "teardownAndDisposalPlan“:

13. extensionSet.add((TeardownAndDisposalPlan) element.getValue()); break;

14. case "radiationExposure“:

15. siteExtension.setRadiationExposure((Double) element.getValue()); break;

16. case "distanceToSiteOfAccident“:

17. siteExtension.setDistanceToSiteOfAccident((Integer) element.getValue()); break;

18. }

19. }

20. }

21. ArrayList<Extension> extensionList = new ArrayList<Extension>(extensionSet);

22. return extensionList;

23.}

11/25/2015 30

Page 31: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Source: Open Geospatial Consortium, Inc; 2012

11/25/2015 31

Page 32: Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE 11/25/2015 23 . 11/25/2015 24 . Extension Registry •There may be more than one plugin

Vertex Geometry

Polygon LinearRing

*

*

*

exterior

interior

*

11/25/2015 32