[xsd-users] Re: Struggling with CityGML 2.0.0 parsing
Olivier Tournaire
olitour at gmail.com
Mon Feb 25 14:42:12 EST 2013
Hi all,
I finally managed to make my simple test program work. I had tu use
references, and all work like a charm:
AbstractFeatureCollectionType::featureMember_sequence::const_iterator it =
iCity->featureMember().begin(), ite = iCity->featureMember().end();
for(;it!=ite;++it)
{
// Note the use of references!!!
const gml::FeaturePropertyType& f = (*it);
const gml::AbstractFeatureType& af = f._Feature().get();
if (BuildingType* b = dynamic_cast<BuildingType*> (af._clone()))
{
cout << "Got a Building!" << endl;
cout << b->_GenericApplicationPropertyOfBuilding ().size() <<
endl;
}
else if (ReliefFeatureType* b = dynamic_cast<ReliefFeatureType*>
(af._clone()))
{
cout << "Got a ReliefFeature!" << endl;
}
}
However, it works, but only on ubuntu ... I tried today to generate the
code on windows with VC++ 2010 and struggled with DLL import / export
symbols. I finally found that with the options:
--export-symbol GML_DLL_DEF
--hxx-prologue #include "gml_dll_def.hpp"
where gml_dll_def.hpp is classically:
#ifndef __GML_DLL_DEF_HPP__
#define __GML_DLL_DEF_HPP__
#if defined(_WIN32)
# if defined(gml_EXPORTS)
# define GML_DLL_DEF __declspec(dllexport)
# else
# define GML_DLL_DEF __declspec(dllimport)
# endif
#else
# define GML_DLL_DEF
#endif
#endif // __GMLL_DLL_DEF_HPP__
Of course, these options are added for each dll. I also add to use the
/FORCE:MULTIPLE option in VC++2010 to prevent link errors on "already
defined symbol ...". Everything works, except for CityGML. This library
(dll) does not link and gives me the following errors:
Link:
Création de la bibliothèque
F:/work/dev/citygml2-0-0/build_unstable/Release/citygml.lib et de l'objet
F:/work/dev/citygml2-0-0/build_unstable/Release/citygml.exp
tunnel.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
vegetation.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
waterBody.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
landUse.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
relief.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
texturedSurface.obj : error LNK2001: symbole externe non résolu "public:
static unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
transportation.obj : error LNK2001: symbole externe non résolu "public:
static unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
cityFurniture.obj : error LNK2001: symbole externe non résolu "public:
static unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
cityGMLBase.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
cityObjectGroup.obj : error LNK2001: symbole externe non résolu "public:
static unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
generics.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
CityGML.obj : error LNK2019: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
référencé dans la fonction "unsigned __int64 __cdecl
xsd::cxx::tree::bits::find_ns<wchar_t>(wchar_t const *,unsigned
__int64,unsigned __int64)" (??$find_ns at _W@bits at tree@cxx at xsd@@YA_KPEB_W_K1 at Z)
appearance.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
bridge.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
building.obj : error LNK2001: symbole externe non résolu "public: static
unsigned __int64 const std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >::npos" (?npos@
?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@std@@2_KB)
F:\work\dev\citygml2-0-0\build_unstable\Release\citygml.dll : fatal error
LNK1120: 1 externes non résolus
I googled for this error, and found some old threads, but did not manged to
make a trick for my case:
http://www.codesynthesis.com/pipermail/xsd-users/2009-October/002490.html
and
http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003010.html
Could you please give me some hint on how to solve this issue? It is a real
problem, and I do not understand how to properly use --export-xml-schema.
Note that my project contains 5 DLLs:
* xlink
* smil
* xAL
* gml
* citygml
Dependencies are as follow:
* gml depends on xlink and smil
* citygml depends on gml and xAL
Any help would really be appreciated.
Best regards,
Olivier
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