[xsd-users] CityGML deserialization - CityModel generation
Adrian Victor Manoliu
victor.manoliu at yahoo.com
Wed Mar 2 05:03:47 EST 2011
Hello,
Thanks for the casting method advice, however I still don't have anything to
iterate upon, after the parsing is done. From what I've seen, the only way to go
through the created elements is via the
_GenericApplicationPropertyOfCityModel_(const_)iterator. In this case, this
iterator does not work because the begin() and end() methods look in the v_
field, which is empty. The field where the items exist perfectly well is
container_, but I don't have access to that through any public method.
Adrian
----- Original Message ----
From: Boris Kolpackov <boris at codesynthesis.com>
To: Adrian Victor Manoliu <victor.manoliu at yahoo.com>
Cc: xsd-users at codesynthesis.com
Sent: Mon, February 28, 2011 3:48:35 PM
Subject: Re: [xsd-users] CityGML deserialization - CityModel generation
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