예제 #1
0
        public void TestJSONPolygonMethod()
        {
            GeoJSONParser <Polygon> geo = new GeoJSONParser <Polygon>();
            Geometry geometry           = geo.Read("{ \"type\": \"Polygon\", \"coordinates\": [ [ [ 1.01, 1.02 ]," +
                                                   "[ 2.01, 2.02 ], [ 2.02, 2.03 ], [ 1.015, 1.017 ] ], [ [ 1.013, 1.014 ], [ 1.015, 1.016 ] ] ] }");
            Type t = typeof(Polygon);

            Assert.IsInstanceOfType(geometry, t, "Type is not \"Polygon\" class");

            List <Point> tempList = new List <Point>();

            tempList.Add(new Point().SetX(1.01).SetY(1.02));
            tempList.Add(new Point().SetX(2.01).SetY(2.02));
            tempList.Add(new Point().SetX(2.02).SetY(2.03));
            tempList.Add(new Point().SetX(1.015).SetY(1.017));

            List <Point> tempList2 = new List <Point>();

            tempList2.Add(new Point().SetX(1.013).SetY(1.014));
            tempList2.Add(new Point().SetX(1.015).SetY(1.016));
            LineString        tempLines = new LineString(tempList2);
            List <LineString> lines     = new List <LineString>();

            lines.Add(tempLines);


            Polygon poly    = new Polygon(tempList, lines);
            Polygon polygon = (Polygon)geometry;

            Assert.AreEqual(polygon, poly, "Object \"Polygon\" is not equal actual object");
        }
예제 #2
0
        public void TestJSONPointMethod()
        {
            GeoJSONParser <Point> geo = new GeoJSONParser <Point>();
            Geometry geometry         = geo.Read("{ \"type\": \"Point\", \"coordinates\": [ 1.01, 1.02 ] }");
            Type     t = typeof(Point);

            Assert.IsInstanceOfType(geometry, t, "Type is not \"Point\" class");

            Point point = ( Point )geometry;


            Assert.AreEqual(point.GetX(), 1.01, "Point X was not equal to double 1.01");
            Assert.AreEqual(point.GetY(), 1.02, "Point Y was not equal to double 1.02");
        }
예제 #3
0
        public void TestJSONLineStringMethod()
        {
            GeoJSONParser <LineString> geo = new GeoJSONParser <LineString>();
            Geometry geometry = geo.Read("{ \"type\": \"LineString\", \"coordinates\": [ [ 1.01, 1.02 ]," +
                                         "[ 2.01, 2.02 ], [ 3.01, 3.02 ], [ 4.01, 4.02 ] ] }");
            Type t = typeof(LineString);

            Assert.IsInstanceOfType(geometry, t, "Type is not \"LineString\" class");

            List <Point> list = new List <Point>();

            list.Add(new Point().SetX(1.01).SetY(1.02));
            list.Add(new Point().SetX(2.01).SetY(2.02));
            list.Add(new Point().SetX(3.01).SetY(3.02));
            list.Add(new Point().SetX(4.01).SetY(4.02));

            LineString listLineStr = new LineString(list);
            LineString line        = (LineString)geometry;

            Assert.AreEqual(line, listLineStr, "Points was not Equal");
        }