Пример #1
0
        public static void AddToMultiPolygon(GeoMultiPolygon mupltiPolygon, List <namedParameter> parametrs)
        {
            if (parametrs != null && parametrs.Count > 0)
            {
                if (mupltiPolygon.coordinates is Point[][][])
                {
                    int         length0     = ((Point[][][])mupltiPolygon.coordinates).GetLength(0);
                    Point[][][] new_polygon = new Point[length0 + 1][][];
                    for (int l = 0; l < length0; l++)
                    {
                        new_polygon[l] = ((Point[][][])mupltiPolygon.coordinates)[l];
                    }

                    new_polygon[length0]    = new Point[1][];
                    new_polygon[length0][0] = new Point[parametrs.Count + 1];
                    int i = 0;
                    for (; i < parametrs.Count; i++)
                    {
                        new_polygon[length0][0][i] = (Point)parametrs[i].ParamValue;
                    }
                    new_polygon[length0][0][i] = (Point)parametrs[0].ParamValue;

                    mupltiPolygon.coordinates = new_polygon;
                }
            }
        }
Пример #2
0
        public List <ShapeParams> GetShapeParams(GeoMultiPolygon geo_multiPoligon, OperationShapeProperty property)
        {
            List <ShapeParams> param_list = null;

            if (geo_multiPoligon != null)
            {
                int polygon_count = ((Point[][][])geo_multiPoligon.coordinates).GetLength(0);

                if (polygon_count > 0)
                {
                    param_list = new List <ShapeParams>();
                    for (int i = 0; i < polygon_count; i++)
                    {
                        ShapeParams p = new ShapeParams();
                        p.ShapeName       = "OperationPolygon" + (i + 1).ToString();
                        p.ShapeType       = "Polygon";
                        p.StrokeWeight    = property.StrokeWeight;
                        p.StrokeColor     = property.StrokeColor;
                        p.FillColor       = property.FillColor;
                        p.GeometricParams = GetNamedParams(((Point[][][])geo_multiPoligon.coordinates)[i]);
                        param_list.Add(p);
                    }
                }
            }
            return(param_list);
        }
Пример #3
0
        private GeoMultiPolygon CreateMultiPolygon()
        {
            GeoPoint center1      = new GeoPoint(Map1.CurrentBound.MinX + Map1.CurrentBound.Width * .25, Map1.CurrentCenter.Y);
            GeoPoint center2      = new GeoPoint(Map1.CurrentBound.MinX + Map1.CurrentBound.Width * .75, Map1.CurrentCenter.Y);
            double   radius       = Map1.CurrentBound.Width * .25;
            int      segmentCount = 5;

            GeoPolygon polygon1 = new GeoPolygon(CreateRing(center1, radius, segmentCount));
            GeoPolygon polygon2 = new GeoPolygon(CreateRing(center2, radius, segmentCount));

            GeoMultiPolygon multiPolygon = new GeoMultiPolygon();

            multiPolygon.Polygons.Add(polygon1);
            multiPolygon.Polygons.Add(polygon2);
            return(multiPolygon);
        }
Пример #4
0
        public void Can_Serialize()
        {
            // Arrang
            var polygon1 = new GeoPolygon(new List <GeoLineString>
            {
                new GeoLineString(new List <GeoEntity>
                {
                    new GeoEntity(0, 0),
                    new GeoEntity(1, 0),
                    new GeoEntity(1, 1),
                    new GeoEntity(0, 1),
                    new GeoEntity(0, 0)
                })
            });

            var polygon2 = new GeoPolygon(new List <GeoLineString>
            {
                new GeoLineString(new List <GeoEntity>
                {
                    new GeoEntity(100, 100),
                    new GeoEntity(101, 100),
                    new GeoEntity(101, 101),
                    new GeoEntity(100, 101),
                    new GeoEntity(100, 100)
                }),
                new GeoLineString(new List <GeoEntity>
                {
                    new GeoEntity(200, 200),
                    new GeoEntity(201, 200),
                    new GeoEntity(201, 201),
                    new GeoEntity(200, 201),
                    new GeoEntity(200, 200)
                })
            });

            var multiPolygon = new GeoMultiPolygon(new List <GeoPolygon> {
                polygon1, polygon2
            });
            var expectedJson = GetExpectedJson();

            // Act
            var actualJson = JsonSerializer.SerializeToString(multiPolygon);

            // Assert
            JsonAssert.AreEqual(expectedJson, actualJson);
        }
Пример #5
0
        public void Can_Deserialize()
        {
            var json = GetExpectedJson();

            var expectMultiPolygon = new GeoMultiPolygon(new List <GeoPolygon>
            {
                new GeoPolygon(new List <GeoLineString>
                {
                    new GeoLineString(new List <IGeoEntity>
                    {
                        new GeoEntity(-2.6797102391514338, 52.959676831105995),
                        new GeoEntity(-2.6769029474483279, 52.9608756693609),
                        new GeoEntity(-2.6079763270327119, 52.908449372833715),
                        new GeoEntity(-2.5815104708998668, 52.891287242948195),
                        new GeoEntity(-2.5851645010668989, 52.875476700983896),
                        new GeoEntity(-2.6050779098387191, 52.882954723868622),
                        new GeoEntity(-2.6373482332006359, 52.875255907042678),
                        new GeoEntity(-2.6932445076063951, 52.878791122091066),
                        new GeoEntity(-2.6931334629377890, 52.89564268523565),
                        new GeoEntity(-2.6548779332193022, 52.930592009390175),
                        new GeoEntity(-2.6797102391514338, 52.959676831105995)
                    })
                }),
                new GeoPolygon(new List <GeoLineString>
                {
                    new GeoLineString(new List <IGeoEntity>
                    {
                        new GeoEntity(-2.69628632041613, 52.89610842810761),
                        new GeoEntity(-2.75901233808515, 52.8894641454077),
                        new GeoEntity(-2.7663172788742449, 52.89938894657412),
                        new GeoEntity(-2.804554822840895, 52.90253773227807),
                        new GeoEntity(-2.83848602260174, 52.929801009654575),
                        new GeoEntity(-2.838979264607087, 52.94013913205788),
                        new GeoEntity(-2.7978187468478741, 52.937353122653533),
                        new GeoEntity(-2.772273870352612, 52.920394929466184),
                        new GeoEntity(-2.6996509024137052, 52.926572918779222),
                        new GeoEntity(-2.69628632041613, 52.89610842810761)
                    })
                })
            });

            var actualMultiPolygon = JsonSerializer.DeserializeFromString <GeoMultiPolygon>(json);

            Assert.AreEqual(expectMultiPolygon, actualMultiPolygon);
        }
Пример #6
0
        public void Can_Serialize_MultiPolygon_Feature()
        {
            var multiPolygon = new GeoMultiPolygon(new List <GeoPolygon>
            {
                new GeoPolygon(new List <GeoLineString>
                {
                    new GeoLineString(new List <GeoEntity>
                    {
                        new GeoEntity(0, 0),
                        new GeoEntity(1, 0),
                        new GeoEntity(1, 1),
                        new GeoEntity(0, 1),
                        new GeoEntity(0, 0)
                    })
                }),
                new GeoPolygon(new List <GeoLineString>
                {
                    new GeoLineString(new List <GeoEntity>
                    {
                        new GeoEntity(100, 100),
                        new GeoEntity(101, 100),
                        new GeoEntity(101, 101),
                        new GeoEntity(100, 101),
                        new GeoEntity(100, 100)
                    }),
                    new GeoLineString(new List <GeoEntity>
                    {
                        new GeoEntity(200, 200),
                        new GeoEntity(201, 200),
                        new GeoEntity(201, 201),
                        new GeoEntity(200, 201),
                        new GeoEntity(200, 200)
                    })
                })
            });

            var feature = new Net.Feature.Feature(multiPolygon);

            var expectedJson = GetExpectedJson();
            var actualJson   = JsonSerializer.SerializeToString(feature);

            JsonAssert.AreEqual(expectedJson, actualJson);
        }