Exemple #1
0
        public void TestMethodPolygon()
        {
            WKTParser wkt      = new WKTParser();
            Geometry  geometry = wkt.Read("POLYGON((1.01 1.02, 2.01 2.02, 3.01 3.02, 1.05 2.02), (1.013 1.014, 1.015 1.016))");
            Type      t        = typeof(Polygon);

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

            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(3.01).SetY(3.02));
            tempList.Add(new Point().SetX(1.05).SetY(2.02));

            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");
        }
Exemple #2
0
        public void PullAndComapreGeoObjects()
        {
            IList <Dictionary <String, Object> > pers = Backendless.Data.Of("GeoData").Find();

            WKTParser wkt = new WKTParser();

            Point      point    = (Point)wkt.Read("POINT (40.41 -3.706)");
            Geometry   geometry = wkt.Read("POINT (10.2 48.5)");
            LineString line     = (LineString)wkt.Read("LINESTRING (30.1 10.05, 30.2 10.04)");
            Polygon    poly     = (Polygon)wkt.Read("POLYGON((-77.05786152 38.87261877,-77.0546978 38.87296123,-77.05317431 38.87061405," +
                                                    "-77.0555883 38.86882611,-77.05847435 38.87002898,-77.05786152 38.87261877),(-77.05579215 38.87026286," +
                                                    "-77.05491238 38.87087264,-77.05544882 38.87170794,-77.05669337 38.87156594,-77.05684357 38.87072228," +
                                                    "-77.05579215 38.87026286))");

            Dictionary <String, Object> result = new Dictionary <String, Object>();

            foreach (Dictionary <String, Object> entry in pers)
            {
                if (entry.ContainsValue((String)"Geo data name"))
                {
                    result = new Dictionary <String, object>(entry);
                    break;
                }
            }
            Assert.AreEqual(result["P1"], point, "Point WKT data are not equals");
            Assert.AreEqual(result["GeoValue"], geometry, "Geometry(Point) WKT data are not equals");
            Assert.AreEqual(result["LineValue"], line, "LineString WKT data are not equals");
            Assert.AreEqual(result["PolyValue"], poly, "Polygon WKT data are not equals");
        }
Exemple #3
0
        public void LineStringWKTEquals()
        {
            Dictionary <String, object> pers = new Dictionary <String, object>();

            WKTParser wkt            = new WKTParser();
            String    StrCoordinates = "LINESTRING(5 10.2,3.05 8.6,2.04 11.006)";

            LineString line = (LineString)wkt.Read(StrCoordinates);

            Assert.AreEqual(line.AsWKT(), StrCoordinates, "LineString WKT data are not equals");
        }
Exemple #4
0
        public void PointWKTEquals()
        {
            Dictionary <String, object> pers = new Dictionary <String, object>();

            WKTParser wkt            = new WKTParser();
            String    StrCoordinates = "POINT(30.05 10.1)";

            Point point = (Point)wkt.Read(StrCoordinates);

            Assert.AreEqual(point.AsWKT(), StrCoordinates, "Point WKT data are not equals");
        }
Exemple #5
0
        public void PolygonWKTEquals()
        {
            Dictionary <String, object> pers = new Dictionary <String, object>();

            WKTParser wkt            = new WKTParser();
            String    StrCoordinates = "POLYGON((-77.05786152 38.87261877,-77.0546978 38.87296123,-77.05317431 38.87061405," +
                                       "-77.0555883 38.86882611,-77.05847435 38.87002898,-77.05786152 38.87261877),(-77.05579215 38.87026286," +
                                       "-77.05491238 38.87087264,-77.05544882 38.87170794,-77.05669337 38.87156594,-77.05684357 38.87072228," +
                                       "-77.05579215 38.87026286))";

            Polygon poly = ( Polygon )wkt.Read(StrCoordinates);

            Assert.AreEqual(poly.AsWKT(), StrCoordinates, "Polygon WKT data are not equals");
        }
Exemple #6
0
        public void TestMethodPoint()
        {
            WKTParser wkt = new WKTParser();

            Geometry geometry = wkt.Read("POINT (30.05 10.1)");
            Type     t        = typeof(Point);

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

            Point point = (Point)geometry;

            Assert.AreEqual(point.GetX(), 30.05, "Point X was not equal to double 30.05");
            Assert.AreEqual(point.GetY(), 10.1, "Point Y was not equal to double 10.1");
        }
        /// <summary>
        /// Copies all spatial contexts
        /// </summary>
        /// <param name="spatialContexts">The spatial contexts.</param>
        /// <param name="target">The target.</param>
        /// <param name="overwrite">if set to <c>true</c> [overwrite].</param>
        public override void Execute(ICollection <SpatialContextInfo> spatialContexts, FdoConnection target, bool overwrite)
        {
            List <SpatialContextInfo> contexts = new List <SpatialContextInfo>(spatialContexts);

            foreach (SpatialContextInfo sc in contexts)
            {
                //Make sure that CSName != Spatial Context Name
                WKTParser parser = new WKTParser(sc.CoordinateSystemWkt);
                if (!string.IsNullOrEmpty(parser.CSName))
                {
                    sc.CoordinateSystem = parser.CSName;
                    sc.Name             = parser.CSName;
                }
            }
            base.Execute(contexts, target, overwrite);
        }
Exemple #8
0
        public void TestMethodLineString()
        {
            WKTParser wkt = new WKTParser();

            Geometry geometry = wkt.Read("LINESTRING(5.0 10.2, 3.05 8.6, 2.04 11.006)");
            Type     t        = typeof(LineString);

            Assert.IsInstanceOfType(geometry, t, "Type is not a \"LineString\"");
            List <Point> list = new List <Point>();

            list.Add(new Point().SetX(5.0).SetY(10.2));
            list.Add(new Point().SetX(3.05).SetY(8.6));
            list.Add(new Point().SetX(2.04).SetY(11.006));

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

            Assert.AreEqual(line, finalLine, "Points was not Equal");
        }
        /// <summary>
        /// Copies the spatial contexts given in the list
        /// </summary>
        /// <param name="source">The source connection</param>
        /// <param name="target">The target connection</param>
        /// <param name="overwrite">If true will overwrite any existing spatial contexts</param>
        /// <param name="spatialContextNames">The list of spatial contexts to copy</param>
        public override void Execute(FdoConnection source, FdoConnection target, bool overwrite, string [] spatialContextNames)
        {
            if (spatialContextNames.Length == 0)
            {
                return;
            }

            string             srcName     = spatialContextNames[0];
            FdoFeatureService  srcService  = source.CreateFeatureService();
            FdoFeatureService  destService = target.CreateFeatureService();
            SpatialContextInfo context     = srcService.GetSpatialContext(srcName);

            if (context != null)
            {
                //Make sure that CSName != Spatial Context Name
                WKTParser parser = new WKTParser(context.CoordinateSystemWkt);
                if (!string.IsNullOrEmpty(parser.CSName))
                {
                    context.CoordinateSystem = parser.CSName;
                    context.Name             = parser.CSName;
                    destService.CreateSpatialContext(context, overwrite);
                }
            }
        }