Hi all,

I'm trying to parse some citygml files, thus far unsuccessful. I'me getting
SimpleFeatures returned from the GML, but they are missing attributes, they
basically are CityGML AbstractCityObject features plus some other
attributes.
Any hints or pointers are welcome.

So far I have the following code (full code+data etc is in:
https://github.com/mprins/bgt-gml-loader/ -
https://github.com/mprins/bgt-gml-loader/blob/master/src/test/java/nl/b3p/brmo/loader/gml/BGTGMLLoaderTest.java
actually):

...
    @Before
    public void setUpParser() {
        schemaLocation = "
http://schemas.geonovum.nl/imgeo/2.1/imgeo-2.1.1.xsd";;

        Configuration configuration = new ApplicationSchemaConfiguration("
http://www.geostandaarden.nl/imgeo/2.1";, schemaLocation);
        configuration.getContext().registerComponentInstance(new
GeometryFactory(new PrecisionModel(), 28992));

        parser = new Parser(configuration);
        parser.setValidating(true);
        parser.setStrict(true);
    }

    @Test
    public void testGMLFile() throws IOException, SAXException,
ParserConfigurationException {
        LOG.debug("Start testing for: " + typeNamespace + ":" +
elementName);

        InputStream is =
BGTGMLLoaderTest.class.getResourceAsStream(gmlFileName);

        FeatureCollection<?, ?> featureCollection = (FeatureCollection<?,
?>) parser.parse(is);
        assertEquals("Collection size should be as expected.",
expectedNumOfElements, featureCollection.size());

        final Name wegTypeName = new NameImpl(typeNamespace, elementName);
        featureCollection.accepts(new AbstractFeatureVisitor() {
            @Override
            public void visit(Feature feature) {
                assertEquals("TypeName should match.", wegTypeName,
feature.getType().getName());

                Collection<Property> props = feature.getProperties();
                assertTrue("There should be a number of properties",
props.size() > 0);

                String s = "Feature " + feature.getIdentifier() + "\n";
                for (Property p : props) {
                    s = s.concat(" - " + p.getName() + " (" + p.getType() +
"):\t " + p.getValue() + "\n");
                }
                LOG.debug(s);
            }

        }, new NullProgressListener());
    }
...

parsing a document like:

<?xml version="1.0" encoding="UTF-8"?>
<CityModel xmlns:gml="http://www.opengis.net/gml";
           xmlns:imgeo="http://www.geostandaarden.nl/imgeo/2.1";
           xmlns:lu="http://www.opengis.net/citygml/landuse/2.0";
           xmlns:tra="http://www.opengis.net/citygml/transportation/2.0";
           xmlns:tun="http://www.opengis.net/citygml/tunnel/2.0";
           xmlns:veg="http://www.opengis.net/citygml/vegetation/2.0";
           xmlns:xlink="http://www.w3.org/1999/xlink";
           xmlns:wat="http://www.opengis.net/citygml/waterbody/2.0";
           xmlns:bri="http://www.opengis.net/citygml/bridge/2.0";
           xmlns:bui="http://www.opengis.net/citygml/building/2.0";
           xmlns:cif="http://www.opengis.net/citygml/cityfurniture/2.0";
           xmlns="http://www.opengis.net/citygml/2.0";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xsi:schemaLocation="http://www.geostandaarden.nl/imgeo/2.1
http://schemas.geonovum.nl/imgeo/2.1/imgeo-2.1.1.xsd";>
    <cityObjectMember>
        <imgeo:Weginrichtingselement
gml:id="A2E13E51EEBE24CE7E0532B0B5B0AB11F">
            <creationDate>2015-11-12</creationDate>

<imgeo:LV-publicatiedatum>2015-12-16T14:55:09.000</imgeo:LV-publicatiedatum>

<imgeo:tijdstipRegistratie>2015-11-30T08:48:14.000</imgeo:tijdstipRegistratie>
            <imgeo:inOnderzoek>false</imgeo:inOnderzoek>
            <imgeo:relatieveHoogteligging>0</imgeo:relatieveHoogteligging>
            <imgeo:identificatie>
                <imgeo:NEN3610ID>
                    <imgeo:namespace>NL.IMGeo</imgeo:namespace>

<imgeo:lokaalID>G0160.8a47d4e922204936928d617cab986f5b</imgeo:lokaalID>
                </imgeo:NEN3610ID>
            </imgeo:identificatie>
            <imgeo:plus-status codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#VoidReasonValue
">geenWaarde</imgeo:plus-status>
            <imgeo:bgt-status codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#Status
">bestaand</imgeo:bgt-status>
            <imgeo:bronhouder>G0175</imgeo:bronhouder>
            <function xmlns="
http://www.opengis.net/citygml/cityfurniture/2.0"; codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#TypeWeginrichting
">niet-bgt</function>
            <imgeo:plus-type codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#TypeWeginrichtingPlus
">molgoot</imgeo:plus-type>
            <imgeo:geometrie2dWeginrichtingselement>
                <gml:Curve srsName="urn:ogc:def:crs:EPSG::28992">
                    <gml:segments>
                        <gml:Arc>
                            <gml:posList srsDimension="2"
count="3">225269.007 504002.064 225268.370 503995.720 225267.160
503989.460</gml:posList>
                        </gml:Arc>
                    </gml:segments>
                </gml:Curve>
            </imgeo:geometrie2dWeginrichtingselement>
        </imgeo:Weginrichtingselement>
    </cityObjectMember>
....

Gives me:

Running nl.b3p.brmo.loader.gml.BGTGMLLoaderTest
BGT-GML TEST: DEBUG 14:23:28
(nl.b3p.brmo.loader.gml.BGTGMLLoaderTest#testGMLFile:350) - Start testing
for: http://www.geostandaarden.nl/imgeo/2.1:Weginrichtingselement
Mar 22, 2016 2:23:28 PM org.geotools.xml.impl.ParserHandler error
WARNING: cvc-elt.1: Cannot find the declaration of element 'CityModel'.
BGT-GML TEST:  INFO 14:23:37 (org.hsqldb.persist.Logger#logInfoEvent:?) -
dataFileCache open start
BGT-GML TEST: DEBUG 14:23:38
(nl.b3p.brmo.loader.gml.BGTGMLLoaderTest$1#visit:370) - Feature
A2E13E51EEBE24CE7E0532B0B5B0AB11F
 - metaDataProperty (AttributeTypeImpl metaDataProperty<Object>): null
 - description (AttributeTypeImpl description<String>): null
 - name (AttributeTypeImpl name<String>): null
 - boundedBy (AttributeTypeImpl boundedBy<Envelope>): null
 - location (GeometryTypeImpl location<Geometry>): null
 - creationDate (AttributeTypeImpl creationDate<Date>): 2015-11-12
 - terminationDate (AttributeTypeImpl terminationDate<Date>): null
 - externalReference (AttributeTypeImpl externalReference<Object>): null
 - generalizesTo (AttributeTypeImpl generalizesTo<Object>): null
 - relativeToTerrain (AttributeTypeImpl relativeToTerrain<String>): null
 - relativeToWater (AttributeTypeImpl relativeToWater<String>): null
 - _GenericApplicationPropertyOfCityObject (AttributeTypeImpl
_GenericApplicationPropertyOfCityObject<Object>): null
 - class (AttributeTypeImpl class<String>): null
 - function (AttributeTypeImpl function<String>): niet-bgt
 - usage (AttributeTypeImpl usage<String>): null
 - lod1Geometry (GeometryTypeImpl lod1Geometry<Geometry>): null
 - lod2Geometry (GeometryTypeImpl lod2Geometry<Geometry>): null
 - lod3Geometry (GeometryTypeImpl lod3Geometry<Geometry>): null
 - lod4Geometry (GeometryTypeImpl lod4Geometry<Geometry>): null
 - lod1TerrainIntersection (GeometryTypeImpl
lod1TerrainIntersection<MultiLineString>): null
 - lod2TerrainIntersection (GeometryTypeImpl
lod2TerrainIntersection<MultiLineString>): null
 - lod3TerrainIntersection (GeometryTypeImpl
lod3TerrainIntersection<MultiLineString>): null
 - lod4TerrainIntersection (GeometryTypeImpl
lod4TerrainIntersection<MultiLineString>): null
 - lod1ImplicitRepresentation (AttributeTypeImpl
lod1ImplicitRepresentation<Object>): null
 - lod2ImplicitRepresentation (AttributeTypeImpl
lod2ImplicitRepresentation<Object>): null
 - lod3ImplicitRepresentation (AttributeTypeImpl
lod3ImplicitRepresentation<Object>): null
 - lod4ImplicitRepresentation (AttributeTypeImpl
lod4ImplicitRepresentation<Object>): null
 - _GenericApplicationPropertyOfCityFurniture (AttributeTypeImpl
_GenericApplicationPropertyOfCityFurniture<Object>): null
 - plus-type (AttributeTypeImpl plus-type<String>): molgoot
 - geometrie2dWeginrichtingselement (GeometryTypeImpl
geometrie2dWeginrichtingselement<Geometry>): CIRCULARSTRING (225269.007
504002.064, 225268.37 503995.72, 225267.16 503989.46)
 - lod0GeometrieWeginrichtingselement (GeometryTypeImpl
lod0GeometrieWeginrichtingselement<Geometry>): null

Note that the <imgeo:geometrie2dWeginrichtingselement> is actually parsed
in this case

parsing:

<?xml version="1.0" encoding="UTF-8"?>
<CityModel xmlns:gml="http://www.opengis.net/gml";
           xmlns:imgeo="http://www.geostandaarden.nl/imgeo/2.1";
           xmlns:lu="http://www.opengis.net/citygml/landuse/2.0";
           xmlns:tra="http://www.opengis.net/citygml/transportation/2.0";
           xmlns:tun="http://www.opengis.net/citygml/tunnel/2.0";
           xmlns:veg="http://www.opengis.net/citygml/vegetation/2.0";
           xmlns:xlink="http://www.w3.org/1999/xlink";
           xmlns:wat="http://www.opengis.net/citygml/waterbody/2.0";
           xmlns:bri="http://www.opengis.net/citygml/bridge/2.0";
           xmlns:bui="http://www.opengis.net/citygml/building/2.0";
           xmlns:cif="http://www.opengis.net/citygml/cityfurniture/2.0";
           xmlns="http://www.opengis.net/citygml/2.0";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xsi:schemaLocation="http://www.geostandaarden.nl/imgeo/2.1
http://schemas.geonovum.nl/imgeo/2.1/imgeo-2.1.1.xsd";>
    <cityObjectMember>
        <BridgeConstructionElement xmlns="
http://www.opengis.net/citygml/bridge/2.0";
gml:id="A2E14021C10394F01E0532B0B5B0A654E">
            <creationDate xmlns="http://www.opengis.net/citygml/2.0
">2015-11-12</creationDate>
            <imgeo:inOnderzoek>false</imgeo:inOnderzoek>
            <imgeo:relatieveHoogteligging>1</imgeo:relatieveHoogteligging>

<imgeo:LV-publicatiedatum>2015-11-24T13:10:24.000</imgeo:LV-publicatiedatum>

<imgeo:tijdstipRegistratie>2015-11-13T10:15:03.000</imgeo:tijdstipRegistratie>
            <imgeo:identificatie>
                <imgeo:NEN3610ID>
                    <imgeo:namespace>NL.IMGeo</imgeo:namespace>

<imgeo:lokaalID>G0160.33dd635f17a74792b1bd325541194090</imgeo:lokaalID>
                </imgeo:NEN3610ID>
            </imgeo:identificatie>
            <imgeo:bgt-status codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#Status
">bestaand</imgeo:bgt-status>
            <imgeo:plus-status codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#VoidReasonValue"/>
            <imgeo:bronhouder>G0175</imgeo:bronhouder>
            <class codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbruggingsdeel
">dek</class>
            <imgeo:geometrie2dOverbruggingsdeel>
                <gml:Surface srsName="urn:ogc:def:crs:EPSG::28992">
                    <gml:patches>
                        <gml:PolygonPatch>
                            <gml:exterior>
                                <gml:LinearRing>
                                    <gml:posList srsDimension="2"
count="13">224231.535 503313.563 224231.578 503313.221 224233.626
503313.480 224233.583 503313.822 224233.277 503316.247 224232.708
503320.753 224232.548 503322.022 224232.446 503322.829 224230.398
503322.571 224230.553 503321.347 224230.630 503320.740 224231.237
503315.927 224231.535 503313.563</gml:posList>
                                </gml:LinearRing>
                            </gml:exterior>
                        </gml:PolygonPatch>
                    </gml:patches>
                </gml:Surface>
            </imgeo:geometrie2dOverbruggingsdeel>
            <imgeo:hoortBijTypeOverbrugging codeSpace="
http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbrugging
">brug</imgeo:hoortBijTypeOverbrugging>
        </BridgeConstructionElement>
    </cityObjectMember>
....

gives me:

BGT-GML TEST: DEBUG 14:23:38
(nl.b3p.brmo.loader.gml.BGTGMLLoaderTest#testGMLFile:350) - Start testing
for: http://www.opengis.net/citygml/bridge/2.0:BridgeConstructionElement
Mar 22, 2016 2:23:38 PM org.geotools.xml.impl.ParserHandler error
WARNING: cvc-elt.1: Cannot find the declaration of element 'CityModel'.
BGT-GML TEST: DEBUG 14:23:44
(nl.b3p.brmo.loader.gml.BGTGMLLoaderTest$1#visit:370) - Feature
A2E14021C10394F01E0532B0B5B0A654E
 - metaDataProperty (AttributeTypeImpl metaDataProperty<Object>): null
 - description (AttributeTypeImpl description<String>): null
 - name (AttributeTypeImpl name<String>): null
 - boundedBy (AttributeTypeImpl boundedBy<Envelope>): null
 - location (GeometryTypeImpl location<Geometry>): null
 - creationDate (AttributeTypeImpl creationDate<Date>): 2015-11-12
 - terminationDate (AttributeTypeImpl terminationDate<Date>): null
 - externalReference (AttributeTypeImpl externalReference<Object>): null
 - generalizesTo (AttributeTypeImpl generalizesTo<Object>): null
 - relativeToTerrain (AttributeTypeImpl relativeToTerrain<String>): null
 - relativeToWater (AttributeTypeImpl relativeToWater<String>): null
 - _GenericApplicationPropertyOfCityObject (AttributeTypeImpl
_GenericApplicationPropertyOfCityObject<Object>): null
 - class (AttributeTypeImpl class<String>): dek
 - function (AttributeTypeImpl function<String>): null
 - usage (AttributeTypeImpl usage<String>): null
 - lod1Geometry (GeometryTypeImpl lod1Geometry<Geometry>): null
 - lod2Geometry (GeometryTypeImpl lod2Geometry<Geometry>): null
 - lod3Geometry (GeometryTypeImpl lod3Geometry<Geometry>): null
 - lod4Geometry (GeometryTypeImpl lod4Geometry<Geometry>): null
 - lod1TerrainIntersection (GeometryTypeImpl
lod1TerrainIntersection<MultiLineString>): null
 - lod2TerrainIntersection (GeometryTypeImpl
lod2TerrainIntersection<MultiLineString>): null
 - lod3TerrainIntersection (GeometryTypeImpl
lod3TerrainIntersection<MultiLineString>): null
 - lod4TerrainIntersection (GeometryTypeImpl
lod4TerrainIntersection<MultiLineString>): null
 - lod1ImplicitRepresentation (AttributeTypeImpl
lod1ImplicitRepresentation<Object>): null
 - lod2ImplicitRepresentation (AttributeTypeImpl
lod2ImplicitRepresentation<Object>): null
 - lod3ImplicitRepresentation (AttributeTypeImpl
lod3ImplicitRepresentation<Object>): null
 - lod4ImplicitRepresentation (AttributeTypeImpl
lod4ImplicitRepresentation<Object>): null
 - boundedBy (AttributeTypeImpl boundedBy<Object>): null
 - _GenericApplicationPropertyOfBridgeConstructionElement
(AttributeTypeImpl
_GenericApplicationPropertyOfBridgeConstructionElement<Object>): null

No geometry (<imgeo:geometrie2dOverbruggingsdeel>) in this case :-(

Also I'm primarily interested in the <imgeo> elements which appear to be
skipped.




-- 
Disclaimer;
This message is just a reflection of what I thought at the time of sending.
The message may contain information that is not intended for you or that
you don't understand.
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to