Ahmad zainuri
Ahmad zainuri

Reputation: 1

Shapefile that is reprojected using dotspatial is different from the original one

I have a shapefile with EPSG:32749 that will be inserted to Oracle Database and displayed in geoserver. Before that I want to reproject my shapefile to ESPG:4326 using dotspatial library, here's my code

var EXTRACTED_NAME = Server.MapPath("~/upload/shp/example/");
string shapeFilePath = @"\example.shp";
shapeFilePath = EXTRACTED_NAME + shapeFilePath;
Shapefile indexMapFile = Shapefile.OpenFile(shapeFilePath);
indexMapFile.Reproject(KnownCoordinateSystems.Geographic.World.WGS1984);

But when I preview in geoserver, my shapefile displayed like this, when the original shapefile like this

enter image description here

enter image description here

And my question, why shapefile that is reprojected to EPSG 4326 is different from the original one?

Thanks

Upvotes: 0

Views: 386

Answers (1)

Ted
Ted

Reputation: 3260

This is a little late, but you should be able to access the inner rings from the geometry. You might need to cast the IGeometry into IPolygon to specifically work with the inner rings, rather than just as getGeometryN. The following code hasn't been tested yet, but should at least get you pointed in the right direction.

Shapefile file = Shapefile.OpenFile(@"D:\Data\Counties\Counties.shp");
foreach(Feature f in file.Features){
    if(f.Geometry is IPolygon){
        IPolygon p = (IPolygon)f.Geometry;
        Debug.WriteLine("Feature " + f.Fid + "\n");
        foreach(ILineString innerRing in p.InteriorRings){
            // Do stuff with your innerRing
            Debug.WriteLine("Ring length : " + innerRing.Length);
        }
    }
    if (f.Geometry is IMultiPolygon)
    {
        IMultiPolygon multi = (IMultiPolygon)f.Geometry;
        for (int i = 0; i < multi.NumGeometries; i++)
        {
            IGeometry g = multi.GetGeometryN(i);
            if (g is IPolygon)
            {
                IPolygon p = (IPolygon)g;
                foreach (ILineString innerRing in p.InteriorRings)
                {
                    // Do stuff with your innerRing
                }
            }

        }

    }

}

Upvotes: 1

Related Questions