Beispiel #1
0
        public void DifferenceTest()
        {
            var source  = new Point(new GeographicPosition(30.0, 110.0));
            var targets = new IGeometryObject[]
            {
                new Point(new GeographicPosition(30.0, 110.0))
            };
            var relation = SpatialFilter.RELATION_CONTAIN;

            var url     = String.Join("/", new string[] { urlPrefix, "analysis/difference" });
            var handler = new MockHttpHandler(url, "POST", (req, res, param) =>
            {
                var result = new RestResult();
                var form   = req.GetFormData();
                if (form.ContainsKey("source") && form.ContainsKey("targets"))
                {
                    result.Data    = JsonConvert.SerializeObject(targets);
                    result.Success = true;
                }
                return(JsonConvert.SerializeObject(result));
            });

            mockServer.AddRequestHandler(handler);

            try
            {
                var topo   = new TopoQuery();
                var result = topo.Difference(source, targets);
                Assert.AreEqual(targets.Length, result.Length);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Beispiel #2
0
        public void IntersectionTest()
        {
            var source  = new Point(new GeographicPosition(30.0, 110.0));
            var targets = new IGeometryObject[]
            {
                new Point(new GeographicPosition(30.0, 110.0))
            };

            var url     = String.Join("/", new string[] { urlPrefix, "analysis/intersection" });
            var handler = new MockHttpHandler(url, "POST", (req, res, param) =>
            {
                var result = new RestResult();
                var form   = req.GetFormData();
                if (form.ContainsKey("source") && form.ContainsKey("targets"))
                {
                    result.Success = true;
                }
                return(JsonConvert.SerializeObject(result));
            });

            mockServer.AddRequestHandler(handler);

            try
            {
                var topo = new TopoQuery();
                topo.Intersection(source, targets);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Beispiel #3
0
        public void ConvexHullTest()
        {
            var input = new IGeometryObject[]
            {
                new Point(new GeographicPosition(30.0, 110.0))
            };

            var url     = String.Join("/", new string[] { urlPrefix, "analysis/convexhull" });
            var handler = new MockHttpHandler(url, "POST", (req, res, param) =>
            {
                var result = new RestResult();
                var form   = req.GetFormData();
                if (form.ContainsKey("targets"))
                {
                    result.Data    = JsonConvert.SerializeObject(input);
                    result.Success = true;
                }
                return(JsonConvert.SerializeObject(result));
            });

            mockServer.AddRequestHandler(handler);

            try
            {
                var topo   = new TopoQuery();
                var result = topo.ConvexHull(input);
                Assert.AreEqual(input.Length, result.Length);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }