Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE...
Transcript of Generic ADE Support - SIG3Den.wiki.energy.sig3d.org/.../Energy_ADE_Support_for... · CityGML ADE...
Energy ADE Support
for SimStadt
Marcel Bruse, 24th of November 2015
Objectives
• Enable SimStadt to process the Energy ADE
• Minimize the need to adjust SimStadt to changing XML schema definitions
11/25/2015 2
What was the initial situation in the SimStadt project before the Energy
ADE?
11/25/2015 3
citygml4j
CityDoctor
SimStadt
Data Structures
CityGML File
11/25/2015 4
citygml4j
CityDoctor
SimStadt
Data Structures
11/25/2015 5
CityGML File
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
citygml4j
CityDoctor
SimStadt
Data Structures
11/25/2015 7
CityGML File
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
citygml4j
CityDoctor
SimStadt
Data Structures
11/25/2015 9
CityGML File
How to integrate the Energy ADE into SimStadt?
11/25/2015 10
citygml4j
CityDoctor
SimStadt
Energy ADE Plugin
Data Structures
11/25/2015 11
CityGML File
citygml4j and ADEs The citygml4j library instantiates DOM nodes for each ADE element
11/25/2015 12
ade-xjc (1)
ade-xjc expects all schema definitions to be
present in ./schemas relative to energy.xsd
11/25/2015 13
ade-xjc (2)
Parse the schema with: java –jar ade-xjc.jar –package <package> -output <destination> -b <binding> <schema file>
11/25/2015 14
ade-xjc (3)
There will be a Java class for each ADE element plus some
useful helper classes.
11/25/2015 15
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
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
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
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
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
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
citygml4j
CityDoctor
SimStadt
Energy ADE Plugin
Data Structures
CityGML File
11/25/2015 22
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
11/25/2015 24
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
11/25/2015 26
Energy ADE Support
for SimStadt
Marcel Bruse, 9th of June, 2015
Appendix
11/25/2015 28
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
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
Source: Open Geospatial Consortium, Inc; 2012
11/25/2015 31
Vertex Geometry
Polygon LinearRing
*
*
*
exterior
interior
*
11/25/2015 32