Inheritance: GeoJsonBaseObject
        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);
        }
        private static string GeojsonToEsriJson(PolygonGeoJson poly)
        {
            var convertedPoly = ConvertGeoJsonCoordsToEsriCoords(poly);

            var esriJsonObject = new EsriPolygonJsonObject
            {
                spatialReference = new SpatialReference(4326),
                rings            = convertedPoly.coordinates
            };

            var outputString = JsonConvert.SerializeObject(esriJsonObject);

            return(outputString);
        }
 private static PolygonGeoJson ConvertGeoJsonCoordsToEsriCoords(PolygonGeoJson poly)
 {
     for (int i = 0; i <= poly.coordinates.Count - 1; i++)
     {
         // if the outer polygon isn't clock wise reverse the order of the coordinates.
         if (i == 0 && !IsClockwise(poly.coordinates[i]))
         {
             poly.coordinates[i].Reverse();
             continue;
         }
         // if the holes in the polygon are not counter-clockwise then revese the order.
         if (i > 0 && IsClockwise(poly.coordinates[i]))
         {
             poly.coordinates[i].Reverse();
         }
     }
     return(poly);
 }
        private static PolygonGeoJson ConvertGeoJsonCoordsToEsriCoords(PolygonGeoJson poly)
        {
            for (int i = 0; i <= poly.coordinates.Count - 1; i ++)
            {
                // if the outer polygon isn't clock wise reverse the order of the coordinates.
                if (i == 0 && !IsClockwise(poly.coordinates[i]))
                {
                    poly.coordinates[i].Reverse();
                    continue;
                }
                // if the holes in the polygon are not counter-clockwise then revese the order.
                if (i > 0 && IsClockwise(poly.coordinates[i]))
                {
                    poly.coordinates[i].Reverse();
                }

            }
            return poly;
        }
        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;
        }
        private static string GeojsonToEsriJson(PolygonGeoJson poly)
        {
            var convertedPoly = ConvertGeoJsonCoordsToEsriCoords(poly);

            var esriJsonObject = new EsriPolygonJsonObject
                                     {
                                         spatialReference = new SpatialReference(4326),
                                         rings = convertedPoly.coordinates
                                     };

            var outputString = JsonConvert.SerializeObject(esriJsonObject);

            return outputString;
        }