Spatial4n icon indicating copy to clipboard operation
Spatial4n copied to clipboard

Date line bug using multi polygon

Open ayende opened this issue 10 years ago • 2 comments

The following failing test demonstrate the problem. A mutli polygon that crosses the date line doesn't work properly.

    using NetTopologySuite.Geometries;
    using NetTopologySuite.IO;
    using Spatial4n.Core.Context;
    using Spatial4n.Core.Context.Nts;
    using Spatial4n.Core.Shapes.Nts;
    using Xunit;

    namespace Spatial4n.Tests.bugs
    {
        public class DateLine
        {
            [Fact]
            public void ShouldWork()
            {
                var wktReader = new WKTReader(NtsSpatialContext.GEO.GetGeometryFactory());
                var poly = wktReader.Read("MULTIPOLYGON (((100 50, -100 50, -100 -50, 100 -50, 100 50)))");

                var polyShape = new NtsGeometry(poly, NtsSpatialContext.GEO, true);
                var ptShape = new NtsPoint(new Point(0, 0), SpatialContext.GEO);

                var spatialRelation = polyShape.Relate(ptShape);
                Assert.Equal(spatialRelation, Spatial4n.Core.Shapes.SpatialRelation.INTERSECTS);
            } 
        }
    }

ayende avatar Aug 25 '13 12:08 ayende

The test you've posted here has spatial context mismatch

There are still some known issues with datelines and polygons that wrap pole in the spatial4j project, and I posted a failing test to them

https://github.com/spatial4j/spatial4j/issues/46

synhershko avatar Aug 25 '13 16:08 synhershko

If you switch the SpatialContext to NtsSpatialContext it is still showing the same behavior

ayende avatar Aug 25 '13 16:08 ayende