[xsd-users] Re: Struggling with CityGML 2.0.0 parsing

Olivier Tournaire olitour at gmail.com
Tue Feb 26 04:25:11 EST 2013


Hi all,

It seems that using FORCE:MULTIPLE is not a good idea ... This blog page
talk about this issue:
http://codesynthesis.com/~boris/blog/2010/01/18/dll-export-cxx-templates/#comments

To fix the link errors previously mentionned, I tried this workaround,
which make citygml links, but, at execution, the parsing fails:

#if defined(_WIN32)
// Hell begins here
// See
http://connect.microsoft.com/VisualStudio/feedback/details/586959/std-string-npos-unresolved-external-symbol-when-optimization-o2-o1-or-ox-enabled
#   include <string>
#   if _MSC_VER >= 1600
#       if !defined(NPOS_VC2010_WORKAROUND)
/*            */const std::basic_string<char>::size_type
std::basic_string<char>::npos = (std::basic_string<char>::size_type) -1;
#           define NPOS_VC2010_WORKAROUND
#      endif // NPOS_VC2010_WORKAROUND
// Hell ends here
#   endif _MSC_VER
#   if defined(citygml_EXPORTS)
#       define CITYGML_DLL_DEF __declspec(dllexport)
#   else
#       define CITYGML_DLL_DEF __declspec(dllimport)
#   endif
#else
#   define CITYGML_DLL_DEF
#endif

The only (working) solution I found is to generate a single DLL for xlink,
xAL, smil, gml and citygml. But, IMHO, it is not a viable solution at long
term since CityGML offers the ability to developp ADEs. Each ADE will need
to have its own DLL, and I might be facing the problem again when I will
need to generate the code for an ADE.

2013/2/23 Olivier Tournaire <olitour at gmail.com>

> Hi all,
>
> This is my first post on the mailing list, and have already searched in
> the past message, but did not found a way to fix the issue I am currently
> facing while trying to parse a CityGML 2.0.0 file.
>
> I have generate the code using the 2.0.0 schemas available at
> http://www.citygml.org/?id=1540. I used the following options, mainly
> inspired by code synthesis wiki pages:
>
> * xAL / xlink
> --generate-polymorphic
> --polymorphic-type-all
> --generate-inline
> --generate-forward
> --disable-warning F001
> --disable-warning F002
>
> * smil:
> --generate-polymorphic
> --namespace-map http://www.w3.org/1999/02/22-rdf-syntax-ns#=rdif
> --anonymous-regex %.* transitionFilterPrototype/calcMode%calcMode2%
> --generate-inline
> --generate-forward
> --show-sloc
> --disable-warning F001
> --disable-warning F002
>
> * gml:
> --root-element-none
> --generate-polymorphic
> --polymorphic-type-all
> --generate-serialization
> --generate-inline
> --generate-forward
> --generate-doxygen
> --root-element Array
> --root-element Bag
> --disable-warning F001
> --disable-warning F002
>
> * citygml base:
> --root-element CityModel
> --generate-polymorphic
> --polymorphic-type-all
> --generate-inline
> --generate-forward
> --generate-serialization
> --generate-doxygen
> --namespace-map http://www.opengis.net/citygml/profiles/base/2.0=citygml
> --disable-warning F001
> --disable-warning F002
>
> * citygml:
> --root-element CityModel
> --generate-polymorphic
> --polymorphic-type-all
> --generate-serialization
> --generate-inline
> --generate-forward
> --generate-doxygen
> --namespace-map http://www.opengis.net/citygml/2.0=citygml
> --namespace-regex %.* http://www.opengis.net/citygml/([
> ^/]*)/2.0%citygml::$1%
> --disable-warning F001
> --disable-warning F002
>
>
> The code seems to be well generated, and the doxygen doc is really
> usefull. However, I still have some warnings, but I do not know if they are
> important or if I can ignore them. I compile the code as a .so with g++
> 4.6.3.
>
> For smil:
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20.xsd:
> warning T004: generating parsing functions for 4 global elements
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20.xsd: info:
> use --root-element-* options to specify document root(s)
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:35:34:
> warning T005: assuming type 'animateType' is polymorphic
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20.xsd:37:96:
> info: because type 'animateType' is used in a substitution group declared
> here
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:35:34:
> info: use --polymorphic-type to indicate this type is polymorphic when
> compiling schemas that reference it
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:71:40:
> warning T005: assuming type 'animateMotionType' is polymorphic
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20.xsd:38:114:
> info: because type 'animateMotionType' is used in a substitution group
> declared here
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:71:40:
> info: use --polymorphic-type to indicate this type is polymorphic when
> compiling schemas that reference it
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:87:39:
> warning T005: assuming type 'animateColorType' is polymorphic
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20.xsd:39:111:
> info: because type 'animateColorType' is used in a substitution group
> declared here
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:87:39:
> info: use --polymorphic-type to indicate this type is polymorphic when
> compiling schemas that reference it
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:103:30:
> warning T005: assuming type 'setType' is polymorphic
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20.xsd:40:84:
> info: because type 'setType' is used in a substitution group declared here
> /home/olivier/work/dev/citygml/CityGML_2.0.0/3.1.1/smil/smil20-language.xsd:103:30:
> info: use --polymorphic-type to indicate this type is polymorphic when
> compiling schemas that reference it
>
> For xAL:
> /home/olivier/work/dev/citygml/CityGML_2.0.0/xAL/xAL.xsd: warning T004:
> generating parsing functions for 18 global elements
> /home/olivier/work/dev/citygml/CityGML_2.0.0/xAL/xAL.xsd: info: use
> --root-element-* options to specify document root(s)
>
> I don think that these warnings are a real problem, since I can link a
> test program against the created libraries without any problem. Now, I have
> a problem with a simple program trying to parse a CityGML file.
>
> Here is my code:
>
> #include <iostream>
>
>
> #include "CityGML.hxx"
>
> #include "3.1.1/base/gml.hxx"
>
>
> #include <typeinfo>
>
>
> using namespace std;
>
> using namespace citygml;
>
> using namespace citygml::building;
>
> using namespace gml;
>
>
> int main(int argc, char** argv)
>
> {
>
>     string filename("/home/olivier/work/dev/citygml/CityGML_2.0.0/Examples/Building_LOD0-4/Building_and_garage_LOD2-EPSG25832.gml");
>
>     auto_ptr<CityModelType> iCity( citygml::CityModel(filename) );
>
>
>     cout << "name        --> " << iCity->name().front() << endl;
>
>     if ( iCity->description().present() )
>
>         cout << "description --> " << iCity->description() << endl;
>
>     else
>
>         cout << "[no description available]" << endl;
>
>     if ( iCity->id().present() )
>
>         cout << "id          --> " << iCity->id() << endl;
>
>     else
>
>         cout << "[no id available]" << endl;
>
>     if ( iCity->location().present() )
>
>         ;
>
>     else
>
>         cout << "[no location available]" << endl;
>
>     if( iCity->boundedBy().present() )
>
>     {
>
>         if( iCity->boundedBy()->Envelope().present() )
>
>             ;
>
>         if( iCity->boundedBy()->Null().present() )
>
>             ;
>
>     }
>
>     else
>
>         cout << "[no boundBy available]" << endl;
>
>
>     cout << "Loaded model contains " << iCity->featureMember().size() << " features" << endl;
>
>
>     AbstractFeatureCollectionType::featureMember_sequence::const_iterator it = iCity->featureMember().begin(), ite = iCity->featureMember().end();
>
>     for(;it!=ite;++it)
>
>     {
>
>         cout << "Looping..." << endl;
>
>         FeaturePropertyType feature = *it;
>
>         AbstractFeatureType featureType = feature._Feature().get();
>
>
>         if ( dynamic_cast<AbstractCityObjectType*>(featureType._clone()) )
>
>             cout << "AbstractCityObjectType !" << endl;
>
>         else if ( dynamic_cast<BuildingType*>(featureType._clone()) )
>
>             cout << "BuildingType !" << endl;
>
>     }
>
>
>     CityModelType cmt;
>
>     cmt._GenericApplicationPropertyOfCityModel();
>
>     return 0;
>
> }
>
>
>
> The problem is in the for loop on the AbstractFeatureCollectionType::
> featureMember_sequence . First I need to use the _clone() method, however
> g++ warns me that the dynamic_cast can never succeeds. The second point is
> that there are 2 features in my sample file
> (Building_and_garage_LOD2-EPSG25832.gml in the Examples directory). The
> first one is a building. Here is the begining of the file:
>
> <?xml version="1.0" encoding="utf-8"?>
> <!-- CityGML Version No. 2.0, February 2012 -->
> <!-- CityGML - GML 3.1.1 application schema for 3D city models -->
> <!-- International encoding standard of the Open Geospatial Consortium,
> see http://www.opengeospatial.org/standards/citygml -->
> <!-- Jointly developed by the Special Interest Group 3D (SIG 3D) of
> GDI-DE, see http://www.sig3d.org               -->
> <!-- For further information see: http://www.citygml.org -->
> <CityModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="
> http://www.opengis.net/citygml/2.0"
>  xmlns:xAL="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:xlink="
> http://www.w3.org/1999/xlink"
>  xmlns:gml="http://www.opengis.net/gml" xmlns:dem="
> http://www.opengis.net/citygml/relief/2.0"
>  xmlns:bldg="http://www.opengis.net/citygml/building/2.0"
> xsi:schemaLocation="http://www.opengis.net/citygml/building/2.0../../CityGML/building.xsd
> http://www.opengis.net/citygml/relief/2.0 ../../CityGML/relief.xsd">
>  <gml:name>3D city model LOD2 without Appearance</gml:name>
> <gml:boundedBy>
>  <gml:Envelope srsDimension="3"
> srsName="urn:ogc:def:crs,crs:EPSG::25832,crs:EPSG::5783">
> <gml:lowerCorner>458868.0 5438343.0 112.0</gml:lowerCorner>
>  <gml:upperCorner>458892.0 5438362.0 117.0</gml:upperCorner>
> </gml:Envelope>
>  </gml:boundedBy>
> <cityObjectMember>
> <bldg:Building gml:id="GML_7b1a5a6f-ddad-4c3d-a507-3eb9ee0a8e68">
>  <gml:name>Example Building LOD2</gml:name>
> .....
>
> I can access the name correctly, but none of my dynamic_cast actually
> succeeds, and I do not understand why. Could you please explain why, and
> what should I do to get the concrete type of each feature?
>
> Hope you could help.
>
> Best regards,
>
> Olivier
>
>
>
>


More information about the xsd-users mailing list