[xsd-users] [cxx-tree] CityGML and ADEs
Olivier Tournaire
olitour at gmail.com
Mon Jul 8 07:19:43 EDT 2013
Hi all,
I was recently playing with CityGML schemas and managed to have something
working with xsd cxx-tree. Now, I would like to extend files parsing with
schemas from ADEs. To give it a first try, I used the NoiseADE schema
distributed with "core" schemas.
Following Boris tips, I managed to compile and like without import/export
problems a "noiseade" library (leaf) and a "citygml" library (root).
"noiseade" depends on "citygml". However, when trying to parse a sample
noiseade file, I am unable to access the specific objects defined in this
ADE. Here is a code sample:
int main(int argc, char** argv)
{
try
{
auto_ptr<CityModelType> iCity = auto_ptr<CityModelType>(
CityModel(DROPBOX_SAMPLES_PATH + "/NoiseADE/cityfurniture_example.xml",
xsd::cxx::tree::flags::dont_validate) );
AbstractFeatureCollectionType::featureMember_sequence::const_iterator it =
iCity->featureMember().begin(), ite = iCity->featureMember().end();
for(;it!=ite;++it)
{
// Note the use of references!!!
const FeaturePropertyType& f = (*it);
const AbstractFeatureType& af = f._Feature().get();
if (const frn::CityFurnitureType* r = dynamic_cast<const
frn::CityFurnitureType*> (&af))
{
cout << "Got a frn::CityFurnitureType!" << endl;
cout << "frn::CityFurnitureType contains " <<
r->_GenericApplicationPropertyOfCityFurniture().size() << " features" <<
endl;
frn::CityFurnitureType::_GenericApplicationPropertyOfCityFurniture_sequence::const_iterator
it2 = r->_GenericApplicationPropertyOfCityFurniture().begin();
frn::CityFurnitureType::_GenericApplicationPropertyOfCityFurniture_sequence::const_iterator
ite2 = r->_GenericApplicationPropertyOfCityFurniture().end();
for(;it2!=ite2;++it2)
{
//cout << "\t* " << it->_name() << " in " <<
it->_namespace() << endl;
if (const
noise_de::NoiseCityFurnitureSegmentPropertyType* r2 = dynamic_cast<const
noise_de::NoiseCityFurnitureSegmentPropertyType*> (&(*it2)))
cout << "\t --> Got a
NoiseCityFurnitureSegmentPropertyType!" << endl;
else
cout << "\t --> NOT a
NoiseCityFurnitureSegmentPropertyType!" << endl;
}
}
}
}
catch (const xml_schema::exception& e)
{
cerr << "Exception caught: " << e.what() << " --> " << e << endl;
}
return 0;
}
>From this code, I am able to retrieve a "frn::CityFurnitureType" object,
but cannot iterate over its children to get the
noise_de::NoiseCityFurnitureSegmentPropertyType.
I made another try: compile and link all citygml AND noiseade in the same
DLL. In this case, I can iterate over
frn::CityFurnitureType::_GenericApplicationPropertyOfCityFurniture_sequence
to get all underlying objects of the frn::CityFurnitureType object.
However, I would like to keep ADEs separated from the core citygml DLL. Do
you have any idea on how I can achieve this?
Best regards,
Olivier
More information about the xsd-users
mailing list