Wraps a JTS {@link Geometry} (i.e. may be a polygon or basically anything). JTS's does a great deal of the hard work, but there is work here in handling dateline wrap.
Inheritance: Shape
Ejemplo n.º 1
0
        public SpatialRelation Relate(NtsGeometry jtsGeometry)
        {
            IGeometry oGeom = jtsGeometry.geom;

            //don't bother checking bbox since geom.relate() does this already
            return(IntersectionMatrixToSpatialRelation(geom.Relate(oGeom)));
        }
Ejemplo n.º 2
0
        public void testArea()
        {
            //simple bbox
            Rectangle r = RandomRectangle(20);
            var ctxJts = (NtsSpatialContext) ctx;
            var rPoly = new NtsGeometry(ctxJts.GetGeometryFrom(r), ctxJts, false);
            CustomAssert.EqualWithDelta(r.GetArea(null), rPoly.GetArea(null), 0.0);
            CustomAssert.EqualWithDelta(r.GetArea(ctx), rPoly.GetArea(ctx), 0.000001); //same since fills 100%

            CustomAssert.EqualWithDelta(1300, POLY_SHAPE.GetArea(null), 0.0);

            //fills 27%
            CustomAssert.EqualWithDelta(0.27, POLY_SHAPE.GetArea(ctx)/POLY_SHAPE.GetBoundingBox().GetArea(ctx), 0.009);
            Assert.True(POLY_SHAPE.GetBoundingBox().GetArea(ctx) > POLY_SHAPE.GetArea(ctx));
        }
Ejemplo n.º 3
0
        public NtsPolygonTest()
            : base(NtsSpatialContext.GEO_KM)
        {
            POLY_SHAPE = (NtsGeometry) ctx.ReadShape(POLY_STR);

            if (TEST_DL_POLY && ctx.IsGeo())
            {
                var pGeom = POLY_SHAPE.GetGeom();
                Assert.True(pGeom.IsValid);
                //shift 180 to the right
                pGeom = (IGeometry) pGeom.Clone();
                pGeom.Apply(new NtsPolygonTestCoordinateFilter((NtsSpatialContext) ctx));
                pGeom.GeometryChanged();
                Assert.False(pGeom.IsValid);
                POLY_SHAPE_DL = (NtsGeometry) ctx.ReadShape(pGeom.AsText());
                Assert.True(
                    POLY_SHAPE_DL.GetBoundingBox().GetCrossesDateLine() ||
                    360 == POLY_SHAPE_DL.GetBoundingBox().GetWidth());
            }
        }
Ejemplo n.º 4
0
 public SpatialRelation Relate(NtsGeometry jtsGeometry)
 {
     IGeometry oGeom = jtsGeometry.geom;
     //don't bother checking bbox since geom.relate() does this already
     return IntersectionMatrixToSpatialRelation(geom.Relate(oGeom));
 }
Ejemplo n.º 5
0
 public virtual SpatialRelation Relate(NtsGeometry ntsGeometry)
 {
     //don't bother checking bbox since geom.relate() does this already
     return(Relate(ntsGeometry.geom));
 }