C# converts ESRI.Geometry.IGeometry polygon collection to GeoJSON polygon object collection with area

The code is as follows (exception is caught outside):

                    Func<List<ESRI.ArcGIS.Geometry.IGeometry>, 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;
                    };

An example of the result returned when called:

[
    {
        "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
    }
]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325547865&siteId=291194637