使用点空间重新投影的Shapefile与原始文件不同

问题描述 投票:0回答:1

我有一个带有EPSG的shapefile:32749,它将被插入Oracle数据库并显示在地理服务器中。在此之前,我想将我的shapefile重新投影到ESPG:4326使用点空间库,这是我的代码

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);

但是当我在geoserver中预览时,我的shapefile显示如下,当原始shapefile像这样

enter image description here

enter image description here

而我的问题是,为什么重新投影到EPSG 4326的shapefile与原始版本不同?

谢谢

asp.net geoserver dotspatial
1个回答
0
投票

这有点晚了,但您应该能够从几何体中访问内环。您可能需要将IGeometry转换为IPolygon以专门使用内环,而不是像getGeometryN一样。以下代码尚未经过测试,但至少应该指向正确的方向。

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
                }
            }

        }

    }

}
© www.soinside.com 2019 - 2024. All rights reserved.