コード例 #1
0
        public void PointInsideGeofenceTransmeridian()
        {
            var verts = new[]
            {
                new GeoCoord(0.01m, -Constants.H3.M_PI + 0.01m),
                new GeoCoord(0.01m, Constants.H3.M_PI - 0.01m),
                new GeoCoord(-0.01m, Constants.H3.M_PI - 0.01m),
                new GeoCoord(-0.01m, -Constants.H3.M_PI + 0.01m)
            };

            var transMeridianGeofence = new GeoFence {
                NumVerts = 4, Verts = verts
            };

            var eastPoint        = new GeoCoord(0.001m, -Constants.H3.M_PI + 0.001m);
            var eastPointOutside = new GeoCoord(0.001m, -Constants.H3.M_PI + 0.1m);
            var westPoint        = new GeoCoord(0.001m, Constants.H3.M_PI - 0.001m);
            var westPointOutside = new GeoCoord(0.001m, Constants.H3.M_PI - 0.1m);

            var bbox = transMeridianGeofence.ToBBox();

            Assert.IsTrue(transMeridianGeofence.PointInside(bbox, westPoint));
            Assert.IsTrue(transMeridianGeofence.PointInside(bbox, eastPoint));
            Assert.IsFalse(transMeridianGeofence.PointInside(bbox, westPointOutside));
            Assert.IsFalse(transMeridianGeofence.PointInside(bbox, eastPointOutside));
        }
コード例 #2
0
        private static void RepeatBoxTest(GeoFence geofence, BBox expected, GeoCoord inside, GeoCoord outside)
        {
            var result = geofence.ToBBox();

            Assert.AreEqual(result, expected);
            Assert.IsTrue(result.Contains(inside));
            Assert.IsFalse(result.Contains(outside));
        }
コード例 #3
0
        public void BboxFromGeofenceNoVertices()
        {
            var geofence = new GeoFence();

            var expected = new BBox(0.0m, 0.0m, 0.0m, 0.0m);

            var result = geofence.ToBBox();

            Assert.AreEqual(result, expected);
        }
コード例 #4
0
        public void PointInsideGeofence()
        {
            var geofence = new GeoFence {
                NumVerts = 6, Verts = SfVerts
            };

            var inside    = new GeoCoord(0.659m, -2.136m);
            var somewhere = new GeoCoord(1, 2);

            BBox bbox = geofence.ToBBox();

            Assert.IsFalse(geofence.PointInside(bbox, SfVerts[0]));
            Assert.IsTrue(geofence.PointInside(bbox, SfVerts[4]));
            Assert.IsTrue(geofence.PointInside(bbox, inside));
            Assert.IsFalse(geofence.PointInside(bbox, somewhere));
        }
コード例 #5
0
        public void BboxFromGeofence()
        {
            var verts = new[]
            {
                new GeoCoord(0.8m, 0.3m), new GeoCoord(0.7m, 0.6m),
                new GeoCoord(1.1m, 0.7m), new GeoCoord(1.0m, 0.2m)
            };

            var geofence = new GeoFence {
                NumVerts = 4, Verts = verts
            };

            var expected = new BBox(1.1m, 0.7m, 0.7m, 0.2m);

            BBox result = geofence.ToBBox();

            Assert.AreEqual(result, expected);
        }
コード例 #6
0
        public void BboxFromGeofenceTransmeridian()
        {
            var verts =
                new[]
            {
                new GeoCoord(0.1m, -Constants.H3.M_PI + 0.1m), new GeoCoord(0.1m, Constants.H3.M_PI - 0.1m),
                new GeoCoord(0.05m, Constants.H3.M_PI - 0.2m), new GeoCoord(-0.1m, Constants.H3.M_PI - 0.1m),
                new GeoCoord(-0.1m, -Constants.H3.M_PI + 0.1m), new GeoCoord(-0.05m, -Constants.H3.M_PI + 0.2m)
            };

            var geofence = new GeoFence {
                NumVerts = 6, Verts = verts
            };

            var expected = new BBox(0.1m, -0.1m, -Constants.H3.M_PI + 0.2m, Constants.H3.M_PI - 0.2m);

            var result = geofence.ToBBox();

            Assert.AreEqual(result, expected);
        }