[xsd-users] Some difficulties with GML/CityGML Tree Parser generation : a bug?

Erwann HOUZAY erwann.houzay at ign.fr
Tue Oct 20 11:18:27 EDT 2009


Hi everybody;

I use the following to produce a C++ libs for GML and CityGML:

http://wiki.codesynthesis.com/Schemas/CityGML

All is OK... (for code production)

I've done the following C++ code:

--------------------------------------------------------------------------
std::auto_ptr< ::citygml::CityModelType > model;
    try
    {
        model = 
citygml::CityModel("C:\\Users\\ehouzay\\Desktop\\waldbruecke_v1.0.0\\waldbruecke_v1.0.0.gml", 
::xml_schema::flags::dont_validate);
    }
    catch (const xml_schema::exception& e)
    {
        cerr << e << endl;
        return 1;
    }

    std::ofstream test_out("test.gml");
    try
    {
         CityModel (test_out,*model.get());

        
//citygml::CityModel(test_out,model,::xml_schema::flags::dont_validate);
    }
    catch (const xml_schema::exception& e)
    {
        cerr << e << endl;
        return 1;
    }
   
    //Model description
    std::cout<<model->description()<<std::endl;

    //Model Name
    for(::gml::AbstractGMLType::name_iterator itName = 
model->name().begin();itName!=model->name().end();itName++)
        std::cout<<"Name" <<(*itName)<<std::endl;

    //Model bound
    ::gml::EnvelopeType ModelEnvelop = 
model->boundedBy().get().Envelope().get();

    //std::cout<<ModelEnvelop.srsName().get()<<std::endl;
   
    std::cout<<"Bound:"<<std::endl;
    //Model Enveloppe...
    for(::gml::EnvelopeType::pos_iterator itCoord = 
ModelEnvelop.pos().begin();itCoord!=ModelEnvelop.pos().end();itCoord++)
    {
        ::gml::DirectPositionType LowerCorner = (*itCoord);
        for(::xsd::cxx::tree::sequence< double >::iterator it 
=LowerCorner.begin();it!=LowerCorner.end();it++)
            std::cout<<(*it)<<std::endl;
    }

    //Model features
    for(::gml::AbstractFeatureCollectionType::featureMember_iterator 
itFeature 
=model->featureMember().begin();itFeature!=model->featureMember().end();itFeature++)
    {
        ::gml::FeaturePropertyType feature = (*itFeature);


        ::gml::AbstractFeatureType FeatureType = feature._Feature().get();
    }

...

-----------------------

Here my sample inpuy file (from City GML web Site but reduced to get a 
very simple try):

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Written on 2009-02-05T06:14:44+01:00 by the CityGML exporter of
            the WB3 project http://www.wb3-project.de for CityGML 
Version 1.0. Usage, modification and storage of this data requires the
            consent of the WB3 project. All rights remain with the WB3 
project or organizations
            named therein. This copyright notice is part of the data and 
may not be removed without
            explicit consent of the WB3 project -->
<CityModel xmlns="http://www.opengis.net/citygml/1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:smil20lang="http://www.w3.org/2001/SMIL20/Language"
    xmlns:smil20="http://www.w3.org/2001/SMIL20/"
    xmlns:xAL="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"
    xmlns:gen="http://www.opengis.net/citygml/generics/1.0"
    xmlns:veg="http://www.opengis.net/citygml/vegetation/1.0"
    xmlns:wtr="http://www.opengis.net/citygml/waterbody/1.0"
    xmlns:trans="http://www.opengis.net/citygml/transportation/1.0"
    xmlns:tex="http://www.opengis.net/citygml/texturedsurface/1.0"
    xmlns:app="http://www.opengis.net/citygml/appearance/1.0"
    xmlns:frn="http://www.opengis.net/citygml/cityfurniture/1.0"
    xmlns:grp="http://www.opengis.net/citygml/cityobjectgroup/1.0"
    xmlns:bldg="http://www.opengis.net/citygml/building/1.0"
    xmlns:luse="http://www.opengis.net/citygml/landuse/1.0"
    xmlns:dem="http://www.opengis.net/citygml/relief/1.0" 
xmlns:gml="http://www.opengis.net/gml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="         
http://www.opengis.net/citygml/relief/1.0 
http://schemas.opengis.net/citygml/relief/1.0/relief.xsd          
http://www.opengis.net/citygml/landuse/1.0 
http://schemas.opengis.net/citygml/landuse/1.0/landUse.xsd          
http://www.opengis.net/citygml/building/1.0 
http://schemas.opengis.net/citygml/building/1.0/building.xsd          
http://www.opengis.net/citygml/cityobjectgroup/1.0 
http://schemas.opengis.net/citygml/cityobjectgroup/1.0/cityObjectGroup.xsd         
http://www.opengis.net/citygml/cityfurniture/1.0 
http://schemas.opengis.net/citygml/cityfurniture/1.0/cityFurniture.xsd          
http://www.opengis.net/citygml/appearance/1.0 
http://schemas.opengis.net/citygml/appearance/1.0/appearance.xsd          
http://www.opengis.net/citygml/texturedsurface/1.0 
http://schemas.opengis.net/citygml/texturedsurface/1.0/texturedSurface.xsd          
http://www.opengis.net/citygml/transportation/1.0 
http://schemas.opengis.net/citygml/transportation/1.0/transportation.xsd          
http://www.opengis.net/citygml/waterbody/1.0 
http://schemas.opengis.net/citygml/waterbody/1.0/waterBody.xsd             
http://www.opengis.net/citygml/vegetation/1.0 
http://schemas.opengis.net/citygml/vegetation/1.0/vegetation.xsd          
http://www.opengis.net/citygml/generics/1.0 
http://schemas.opengis.net/citygml/generics/1.0/generics.xsd">
    <gml:description> Written on 2009-02-05T06:14:44+01:00 by the 
CityGML exporter of the WB3
        project http://www.wb3-project.de for CityGML Version 1.0. 
Usage, modification and storage
        of this data requires the consent of the WB3 project. All rights 
remain with the WB3 project
        or organizations named therein. This copyright notice is part of 
the data and may not be
        removed without explicit consent of the WB3 project. 
</gml:description>
    <gml:name>Waldbrücke</gml:name>
    <gml:boundedBy>
        <gml:Envelope srsName="WB3_local">
            <gml:pos srsDimension="3">-648.04 -563.6 0</gml:pos>
            <gml:pos srsDimension="3">270.42 301.74 0</gml:pos>
        </gml:Envelope>
    </gml:boundedBy>
    <cityObjectMember>
        <CityObjectGroup gml:id="g_12529">
        </CityObjectGroup>
    </cityObjectMember>
</CityModel>


After reading, I output the file and I got:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<p1:CityModel xmlns:p1="http://www.opengis.net/citygml/1.0" 
xmlns:p2="http://www.opengis.net/gml">

  <p2:description xmlns:p3="http://www.w3.org/1999/xlink" 
p3:type="simple"> Written on 2009-02-05T06:14:44+01:00 by the CityGML 
exporter of the WB3
        project http://www.wb3-project.de for CityGML Version 1.0. 
Usage, modification and storage
        of this data requires the consent of the WB3 project. All rights 
remain with the WB3 project
        or organizations named therein. This copyright notice is part of 
the data and may not be
        removed without explicit consent of the WB3 project. 
</p2:description>

  <p2:name>Waldbrücke</p2:name>

  <p2:boundedBy>
    <p2:Envelope srsName="WB3_local">
      <p2:pos srsDimension="3">-648.04 -563.6 0</p2:pos>
      <p2:pos srsDimension="3">270.42 301.74 0</p2:pos>
    </p2:Envelope>
  </p2:boundedBy>

  <p2:featureMember xmlns:p3="http://www.w3.org/1999/xlink" 
p3:type="simple"/>

</p1:CityModel>


What had happen to the "cityObjectMember"?


According to the CityGML doc 
(http://www.citygml.org/citygml/documentation/):

CityModelType  is "Type describing the "root" element of any city model 
file. It is a collection whose members are restricted to be features of 
a city model. All features are included as cityObjectMember. "

CityModelType is  AbstractFeatureCollectionType 
<feature.xsd.html_h-188478937.html> from gml and it seems not to be read 
correctly... (in fact sub CityGML sub element child of the 
cityObjectMember node seems not to be red correctly and constructors of 
those object are not called!!!)

Is there a way to overcome this problem? I think it's a polymorphism 
pb.. I'm a newby so I have no idea of how to process...

Any help will be usefull to overcome this difficulty...

Tkanks

Erwann








More information about the xsd-users mailing list