citygml4j / citygml-tools

Collection of tools for processing CityGML files
Apache License 2.0
115 stars 18 forks source link

doesn't export referenceSystem #3

Closed strech345 closed 5 years ago

strech345 commented 5 years ago

It looks like the referenceSystem in the metadata is missing. For me it only export the bbox.

clausnagel commented 5 years ago

GML supports multiple encoding schemes for spatial reference system names and there can be many different srsName attributes in the same CityGML file. So, automatically retrieving a unique EPSG code as required by CityJSON can become a tricky task. To support your request, I made the following changes to the to-cityjson operation (f39bfba853d6efbd901d7b2eae66dd97116b7092).

First, the operation now tries to read the EPSG code from the CityGML file in the following way:

  1. The gml:Envelope of the root CityModel is searched for a srsName attribute.
  2. If no srsName was found, then all envelopes of all top-level city objects contained in the CityModel are searched for an srsName attribute. All srsName attributes found must share the identical value.

If a srsName was found, then the following encoding schemes are supported to retrieve the EPSG code:

Only if the srsName follows one of the above schemes, the EPSG will be written into the CityJSON file as metadata.

Second, instead of this automatic procedure, the user can now force a certain EPSG code to be used in the CityJSON file through the --epsg=<code> option. This is the recommended way if the EPSG code is known a priori.

Hope this helps. Both changes will be available in the next release.

strech345 commented 5 years ago

Thanks. That sound good.

clausnagel commented 5 years ago

Just released version 1.1.0. Should be working now as outlined above. Can you please test and confirm?

strech345 commented 5 years ago

Hallo Claus, for me it change the epsg from (citygml)25832 to (json)3857

<?xml version="1.0" encoding="UTF-8"?>
<CityModel xmlns:smil20="http://www.w3.org/2001/SMIL20/" xmlns:grp="http://www.opengis.net/citygml/cityobjectgroup/1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:smil20lang="http://www.w3.org/2001/SMIL20/Language" xmlns:base="http://www.citygml.org/citygml/profiles/base/1.0" xmlns:luse="http://www.opengis.net/citygml/landuse/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:frn="http://www.opengis.net/citygml/cityfurniture/1.0" xmlns:tex="http://www.opengis.net/citygml/texturedsurface/1.0" xmlns:xAL="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:bldg="http://www.opengis.net/citygml/building/1.0" xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:app="http://www.opengis.net/citygml/appearance/1.0" xmlns:veg="http://www.opengis.net/citygml/vegetation/1.0" xmlns:gml="http://www.opengis.net/gml" xmlns:gen="http://www.opengis.net/citygml/generics/1.0" xmlns:dem="http://www.opengis.net/citygml/relief/1.0" xmlns:wtr="http://www.opengis.net/citygml/waterbody/1.0" xmlns:tran="http://www.opengis.net/citygml/transportation/1.0" xmlns="http://www.opengis.net/citygml/1.0">
<gml:name>LoD1_496_6050_1_SH</gml:name>
<gml:boundedBy>
<gml:Envelope srsName="EPSG:25832" srsDimension="3">
<gml:lowerCorner>497141.625 6049454.116 0.897</gml:lowerCorner>
<gml:upperCorner>501338.219 6052916.669 38.695</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>

Update: Sorry, the converter works fine, i think. I think its a problem of the qgis city json loader wich doenst use the right epsg code.

{"type":"CityJSON","version":"0.9","metadata":{"referenceSystem":"urn:ogc:def:crs:EPSG::25832","geographicalExtent":[497141.625,6049454.116,0.897,501338.219,6052916.669,38.695]
clausnagel commented 5 years ago

Thanks for testing. Yes, based on your snippet it seems that the converter works as expected. So I'm closing this issue. Feel free to re-open if you have further questions.