コード例 #1
0
        private static List <string> MultiPolygonObjectToEsriJson(MultiPolygonGeoJson multi)
        {
            List <string> esriJsonList = new List <string>();

            foreach (List <List <List <double> > > poly in multi.coordinates)
            {
                // Convert the individual polygons within multipolygon
                var newPoly = new PolygonGeoJson {
                    type = "Polygon", coordinates = poly
                };

                // check coordinates to make sure they match ESRI requirement for outer vs inner rings
                var convertedPoly         = ConvertGeoJsonCoordsToEsriCoords(newPoly);
                var esriPolygonJsonObject = new EsriPolygonJsonObject
                {
                    spatialReference = new SpatialReference(4326),
                    rings            = convertedPoly.coordinates
                };
                var esriJson = JsonConvert.SerializeObject(esriPolygonJsonObject);
                if (!string.IsNullOrEmpty(esriJson))
                {
                    esriJsonList.Add(esriJson);
                }
            }
            return(esriJsonList);
        }
コード例 #2
0
        private static List<string> MultiPolygonObjectToEsriJson(MultiPolygonGeoJson multi)
        {
            List<string> esriJsonList = new List<string>();
            foreach (List<List<List<double>>> poly in multi.coordinates)
            {
                // Convert the individual polygons within multipolygon
                var newPoly = new PolygonGeoJson { type = "Polygon", coordinates = poly };

                // check coordinates to make sure they match ESRI requirement for outer vs inner rings
                var convertedPoly = ConvertGeoJsonCoordsToEsriCoords(newPoly);
                var esriPolygonJsonObject = new EsriPolygonJsonObject
                                                {
                                                    spatialReference = new SpatialReference(4326),
                                                    rings = convertedPoly.coordinates
                                                };
                var esriJson = JsonConvert.SerializeObject(esriPolygonJsonObject);
                if (!string.IsNullOrEmpty(esriJson))
                {
                    esriJsonList.Add(esriJson);
                }
            }
            return esriJsonList;
        }