示例#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
        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));
        }