public void WriteNtsGeom(BinaryWriter dataOutput, IShape s)
        {
            NtsSpatialContext ctx  = (NtsSpatialContext)base.ctx;
            IGeometry         geom = ctx.GetGeometryFrom(s);//might even translate it

            new WKBWriter().Write(geom, new OutputStreamAnonymousHelper(dataOutput));
        }
Example #2
0
        public virtual SpatialRelation Relate(IRectangle rectangle)
        {
            SpatialRelation bboxR = bbox.Relate(rectangle);

            if (bboxR == SpatialRelation.WITHIN || bboxR == SpatialRelation.DISJOINT)
            {
                return(bboxR);
            }
            // FYI, the right answer could still be DISJOINT or WITHIN, but we don't know yet.
            return(Relate(ctx.GetGeometryFrom(rectangle)));
        }
Example #3
0
        public SpatialRelation Relate(Rectangle rectangle)
        {
            SpatialRelation bboxR = bbox.Relate(rectangle);

            if (bboxR == SpatialRelation.WITHIN || bboxR == SpatialRelation.DISJOINT)
            {
                return(bboxR);
            }
            IGeometry oGeom = ctx.GetGeometryFrom(rectangle);

            return(IntersectionMatrixToSpatialRelation(geom.Relate(oGeom)));
        }
Example #4
0
        public virtual void TestArea()
        {
            //simple bbox
            IRectangle        r      = RandomRectangle(20);
            NtsSpatialContext ctxNts = (NtsSpatialContext)ctx;
            NtsGeometry       rPoly  = ctxNts.MakeShape(ctxNts.GetGeometryFrom(r), false, 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.BoundingBox.GetArea(ctx), 0.009);
            Assert.True(POLY_SHAPE.BoundingBox.GetArea(ctx) > POLY_SHAPE.GetArea(ctx));
        }