int sosicon::shape::Shapefile:: build( ISosiElement* sosiTree, std::string objType, sosi::ElementType geomType ) { int count = 0; mSosiTree = sosiTree; ISosiElement* sosi = 0; sosi::SosiElementSearch src; ShapeType shapeTypeEquivalent = shape_type_none; std::vector<std::string>& f = mFilterSosiId; while( sosiTree->getChild( src ) ) { sosi = src.element(); if( ( objType.empty() || objType == sosi->getObjType() ) && ( f.size() == 0 || std::find( f.begin(), f.end(), sosi->getSerial() ) != f.end() ) ) { if( sosi->getType() == geomType ) { shapeTypeEquivalent = getShapeEquivalent( sosi->getType() ); buildShpElement( sosi, shapeTypeEquivalent ); insertDbfRecord( sosi ); ++count; } } } if( count > 0 ) { buildShpHeader( shapeTypeEquivalent ); buildDbf(); // database (attributes table) buildShx(); // index } return count; }
void sosicon::shape::Shapefile:: extractDbfFields( ISosiElement* sosi, DbfRecord& rec ) { std::string field; std::string data; ISosiElement* child = 0; sosi::SosiElementSearch src; while( sosi->getChild( src ) ) { child = src.element(); if( child->getType() != sosi::sosi_element_ne ) { data = utils::trim( child->getData() ); saveToDbf( rec, child->getName(), data ); extractDbfFields( child, rec ); } } }