legeochen wrote: > Hi All > I try to create some multipolygons with OGR. After creating them, but > when I want view them in arcscene, it just make arcscene crash! Then I > tried osgviewer with ESRI Shapefile, I was warned: > ESRIShape loader: .dbf file containe different record number that .shp > file. .dbf record skipped.
Inspect your shapefile with ogrinfo as well as with Shapelib's shpdump and dbfdump. Check if .dbf contains exactly the same number of records as .shp file > Actually, only one feature in the dataset had been readed out. > Then, I tried osgviewer with ogr, got warnings like this: > Warning something wrong with a polygon in a multi polygon. No idea what's osgviewer and what its errors mean. > for(Roadway::RoadWayArray::iterator itrw = _roadwayArr.begin(); itrw != > _roadwayArr.end();itrw++) ++itrw; if you care about performance. > { > OGRFeature *poFeature; > > OGRMultiPolygon multiPoly; > poFeature = OGRFeature::CreateFeature(poLayer->GetLayerDefn()); > Roadway::Triangle_list tris = (*itrw)->getTrianglelist(); No idea what Triangle and Roadway is, I assume it's your own geometry type. > for(Triangle_list::const_iterator ittri = tris.begin();ittri != > tris.end();ittri++) ++ittri; > { > OGRPolygon polygon; > OGRLinearRing poRing; > poRing.addPoint((*ittri).a().x(),(*ittri).a().y(),(*ittri).a().z()); > poRing.addPoint((*ittri).b().x(),(*ittri).b().y(),(*ittri).b().z()); > poRing.addPoint((*ittri).c().x(),(*ittri).c().y(),(*ittri).c().z()); > poRing.addPoint((*ittri).a().x(),(*ittri).a().y(),(*ittri).a().z()); Assure that TRUE == poRing.get_IsClosed(); > polygon.addRing(&poRing); > multiPoly.addGeometry(&polygon); > > } > poFeature->SetGeometry(&multiPoly); > if( poLayer->CreateFeature( poFeature ) != OGRERR_NONE ) > { > printf( "Failed to create feature in shapefile.\n" ); > return false; > } > OGRFeature::DestroyFeature( poFeature ); > } > OGRDataSource::DestroyDataSource( poDS ); > Any help is appreciated!! I'd suggest you to translate your Roadway/Triangle it to OGRPolygon and OGRMultiPolygon (what you actually have done) and then dump it to OGC Well-Known-Text (WKT). Then, try to validate these geometries with PostGIS using ST_GeometryFromText and ST_IsValid and friends. See chapter 4 and 6 of PostGIS manual. PostGIS (or GEOS) is good for geometries validation. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev