C#将ESRI.Geometry.IGeometry多边形集合转为带面积的GeoJSON多边形对象集合

代码如下(异常在外部捕捉):

                    Func, JArray> ConvertShapeWithArea = (lsGeo) =>
                    {
                        JArray aJArray = new JArray();
                        foreach (var pGeo in lsGeo)
                        {
                            JObject aJObject = new JObject(
                                new JProperty("shape", JObject.FromObject(GeometryFactory.CreateGeoJsonFromEsriGeometry(pGeo as ESRI.ArcGIS.Geometry.IPolygon))),
                                new JProperty("area", (pGeo as ESRI.ArcGIS.Geometry.IArea).Area)
                                );
                            aJArray.Add(JToken.FromObject(aJObject));
                        }
                        return aJArray;
                    };

调用时返回结果示例:

[
    {
        "shape": {
            "type": "Polygon",
            "coordinates": [
                [
                    [
                        37563651.04561424,
                        3213571.488904953,
                        0
                    ],
                    [
                        37563587.07734108,
                        3213570.668844223,
                        0
                    ],
                    [
                        37563586.81415367,
                        3213621.285943985,
                        0
                    ],
                    [
                        37563587.53163338,
                        3213647.6975917816,
                        0
                    ],
                    [
                        37563728.04936409,
                        3213650.374227524,
                        0
                    ],
                    [
                        37563729.5853405,
                        3213575.4888095856,
                        0
                    ],
                    [
                        37563653.70521355,
                        3213574.189157486,
                        0
                    ],
                    [
                        37563651.04561424,
                        3213571.488904953,
                        0
                    ]
                ]
            ]
        },
        "area": 10767.57596575679
    }
]

你可能感兴趣的:(C#将ESRI.Geometry.IGeometry多边形集合转为带面积的GeoJSON多边形对象集合)