public static PointsOfInterest Create()
        {
            var res = new PointsOfInterest();
            var f   = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326);

            res.Add(new PointOfInterest {
                ID = 1, Address = "ll", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(0, 0))
            });
            res.Add(new PointOfInterest {
                ID = 2, Address = "cl", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(1, 0))
            });
            res.Add(new PointOfInterest {
                ID = 3, Address = "rl", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(2, 0))
            });
            res.Add(new PointOfInterest {
                ID = 4, Address = "lc", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(0, 1))
            });
            res.Add(new PointOfInterest {
                ID = 5, Address = "cc", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(1, 1))
            });
            res.Add(new PointOfInterest {
                ID = 6, Address = "cr", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(2, 1))
            });
            res.Add(new PointOfInterest {
                ID = 7, Address = "tl", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(0, 2))
            });
            res.Add(new PointOfInterest {
                ID = 8, Address = "tc", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(1, 2))
            });
            res.Add(new PointOfInterest {
                ID = 9, Address = "tr", Kind = "African food", Geometry = f.CreatePoint(new Coordinate(2, 2))
            });

            return(res);
        }
예제 #2
0
        public void TestGetMap()
        {
            using (var m = new Map(new Size(300, 300)))
            {
                m.BackColor = Color.White;

                IProvider p    = null;
                var       data = PointsOfInterest.Create();
                Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

                m.Layers.Add(new VectorLayer("POIs", p));
                var ll = new LabelLayer("POIsLabel");
                ll.DataSource          = p;
                ll.LabelStringDelegate = (fdr) => string.Format("{0} - {1}", fdr["ID"], fdr["Address"]);
                m.Layers.Add(ll);

                m.ZoomToExtents();
                m.Zoom *= 1.1;

                using (var img = m.GetMap())
                {
                    img.Save("PoiImage.png", ImageFormat.Png);
                }
            }
        }
예제 #3
0
        public void TestConstruction()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            Assert.AreEqual(data.Count, p.GetFeatureCount());
        }
예제 #4
0
        public void TestGetExtetnts()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            var e = p.GetExtents();

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;
            var e2  = bop.GetExtents();

            Assert.AreEqual(e, e2);
            Assert.AreEqual(new Envelope(0, 2, 0, 2), e);
        }
예제 #5
0
        public void TestAsReadOnly()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;

            // select all business objects
            PointOfInterest[] pts;
            pts = bop.AsReadOnly();
            Assert.NotNull(pts);
            Assert.AreEqual(pts.Length, 9);
        }
예제 #6
0
        public void TestAttributeSelectionMulti()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;

            // select 5 business objects
            PointOfInterest[] pts;
            pts = bop.FindAll(b => b.ID < 6 && b.Kind == "African food");
            Assert.NotNull(pts);
            Assert.AreEqual(pts.Length, 5);
        }
예제 #7
0
        public void TestExecuteFeatureQuery()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            var fds = new FeatureDataSet();

            p.ExecuteIntersectionQuery(new Envelope(0.5, 1.5, 0.5, 1.5), fds);
            Assert.AreEqual(1, fds.Tables.Count);
            Assert.AreEqual("PointOfInterest", fds.Tables[0].TableName);
            Assert.AreEqual(1, fds.Tables[0].Rows.Count);
            Assert.AreEqual(5, fds.Tables[0].Rows[0]["ID"]);
            Assert.AreEqual(new Coordinate(1, 1), ((FeatureDataRow)fds.Tables[0].Rows[0]).Geometry.Coordinate);
        }
예제 #8
0
        public void TestAttributeDelete()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;

            var cnt = bop.Count;
            var env = bop.GetExtents();

            // delete 3 features on RHS
            bop.Delete(b => b.Address == "rl" || b.Address == "cr" || b.Address == "tr");

            Assert.AreEqual(bop.Count, cnt - 3);
            Assert.That(env.Width == 2 && env.Height == 2);
            Assert.That(bop.GetExtents().Width == 1 && bop.GetExtents().Height == 2);
        }
예제 #9
0
        public void TestAttributeUpdate()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;
            // update single business object
            var bo = bop.Find(b => b.Address == "lc");

            Assert.AreEqual(bo.Kind, "African food");
            bo.Kind = "Indian food";

            FeatureDataRow row = null;

            Assert.DoesNotThrow(() => row = p.GetFeature(4));
            Assert.IsNotNull(row);
            Assert.AreEqual(bo.Kind, row["Kind"]);
        }
예제 #10
0
        public void TestGetFeature()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            FeatureDataRow row = null;

            Assert.DoesNotThrow(() => row = p.GetFeature(1));
            Assert.IsNotNull(row);
            Assert.IsNotNull(row.Geometry);
            Assert.AreEqual(OgcGeometryType.Point, row.Geometry.OgcGeometryType);
            Assert.AreEqual(new Coordinate(0, 0), row.Geometry.Coordinate);

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;
            var bo  = bop.Select(1);

            Assert.AreEqual(bo.ID, row["ID"]);
            Assert.AreEqual(bo.Geometry, row.Geometry);
            Assert.AreEqual(bo.Address, row["Address"]);
        }
예제 #11
0
        public void TestAttributeSelection()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            FeatureDataRow row = null;

            Assert.DoesNotThrow(() => row = p.GetFeature(4));
            Assert.IsNotNull(row);
            Assert.IsNotNull(row.Geometry);
            Assert.AreEqual(OgcGeometryType.Point, row.Geometry.OgcGeometryType);
            Assert.AreEqual(new Coordinate(0, 1), row.Geometry.Coordinate);

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;
            // select single business objects
            var bo = bop.Find(b => b.Address == "lc");

            Assert.NotNull(bo);
            Assert.AreEqual(bo.ID, row["ID"]);
            Assert.AreEqual(bo.Geometry, row.Geometry);
            Assert.AreEqual(bo.Address, row["Address"]);
        }
예제 #12
0
        public void TestBusinessObjectInsert()
        {
            IProvider p    = null;
            var       data = PointsOfInterest.Create();

            Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data));

            var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source;

            var cnt = bop.Count;
            var env = bop.GetExtents();

            // insert single feature outside of existing extents
            var             f     = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326);
            var             coord = new Coordinate(env.Right() + 10, env.Top() + 10);
            PointOfInterest bo    = new PointOfInterest {
                ID = 10, Address = "tr++", Kind = "Thai food", Geometry = f.CreatePoint(coord)
            };

            bop.Insert(bo);

            Assert.AreEqual(bop.Count, cnt + 1);
            Assert.That(bop.GetExtents().Contains(coord));
        }