Exemplo n.º 1
0
        public static double GetDistance(double fromLat, double fromLng, double toLat, double toLng)
        {
            Point ptFrom = Context.MakePoint(fromLng, fromLat);
            Point ptTo   = Context.MakePoint(toLng, toLat);

            return(Context.GetDistCalc().Distance(ptFrom, ptTo));
        }
Exemplo n.º 2
0
        public static double GetDistance(double fromLat, double fromLng, double toLat, double toLng)
        {
            Point ptFrom   = Context.MakePoint(fromLng, fromLat);
            Point ptTo     = Context.MakePoint(toLng, toLat);
            var   distance = Context.GetDistCalc().Distance(ptFrom, ptTo);

            return((distance / RadiansToDegrees) * EarthMeanRadiusKm);
        }
Exemplo n.º 3
0
        public static double GetGeographicalDistance(double fromLat, double fromLng, double toLat, double toLng)
        {
            var   Context  = new NtsSpatialContext(true);
            Point ptFrom   = Context.MakePoint(fromLng, fromLat);
            Point ptTo     = Context.MakePoint(toLng, toLat);
            var   distance = Context.GetDistCalc().Distance(ptFrom, ptTo);

            return((distance / RadiansToDegrees) * EarthMeanRadiusKm);
        }
Exemplo n.º 4
0
        public SpatialRelation Relate(Point pt)
        {
            //TODO if not jtsPoint, test against bbox to avoid JTS if disjoint
            var jtsPoint = (NtsPoint)(pt is NtsPoint ? pt : ctx.MakePoint(pt.GetX(), pt.GetY()));

            return(geom.Disjoint(jtsPoint.GetGeom()) ? SpatialRelation.DISJOINT : SpatialRelation.CONTAINS);
        }
Exemplo n.º 5
0
        public virtual void TestFiji()
        {
            //Fiji is a group of islands crossing the dateline.
            string wktStr = ReadFirstLineFromRsrc("fiji.wkt.txt");

            NtsSpatialContextFactory factory = new NtsSpatialContextFactory();

            factory.normWrapLongitude = true;
            NtsSpatialContext ctx = (NtsSpatialContext)factory.NewSpatialContext();

            IShape shape = ctx.ReadShapeFromWkt(wktStr);

            AssertRelation(null, SpatialRelation.CONTAINS, shape,
                           ctx.MakePoint(-179.99, -16.9));
            AssertRelation(null, SpatialRelation.CONTAINS, shape,
                           ctx.MakePoint(+179.99, -16.9));
            Assert.True(shape.BoundingBox.Width < 5);//smart bbox
            Console.WriteLine("Fiji Area: " + shape.GetArea(ctx));
        }