[xsd-users] CityGML deserialization - CityModel generation
Boris Kolpackov
boris at codesynthesis.com
Mon Feb 28 09:48:35 EST 2011
Hi Adrian,
Adrian Victor Manoliu <victor.manoliu at yahoo.com> writes:
> const std::string fName = "waldbruecke_v1.0.0.gml";
> std::auto_ptr<CityModelType> iCity(CityModel(fName, flags.dont_validate));
>
> [...]
>
> Now, once I have iCity, I simply want to iterate over its elements, that
> is the Buildings, BuildingParts etc. by doing something like this (I have
> been doing this from the start):
>
> CityModelType::_GenericApplicationPropertyOfCityModel_const_iterator ci;
>
> for (ci = iCity->_GenericApplicationPropertyOfCityModel().begin();
> ci != iCity->_GenericApplicationPropertyOfCityModel().end();
> ++ci)
> {
> [...]
> }
>
> however in this case I don't see how I could know what type to cast these
> objects to
You need to study the GML/CityGML schemas to see which concrete elements
(and types) substitute which abstract elements.
Here is an example body of the above for-loop. Hopefully, it will get you
started:
for (ci = iCity->_GenericApplicationPropertyOfCityModel().begin();
ci != iCity->_GenericApplicationPropertyOfCityModel().end();
++ci)
{
xml_schema::type& x (*ci);
if (gml::FeaturePropertyType* cityObjectMember =
dynamic_cast<gml::FeaturePropertyType*> (&x))
{
gml::FeaturePropertyType::_Feature_const_iterator fi;
for (fi = cityObjectMember->_Feature ().begin ();
fi != cityObjectMember->_Feature ().end ();
++fi)
{
gml::AbstractFeatureType& f (*fi);
if (citygml::building::BuildingType* b =
dynamic_cast<citygml::building::BuildingType*> (&f);
{
// We've got a building.
}
else if (...)
{
...
}
}
}
}
Boris
More information about the xsd-users
mailing list