Spatial4n
Spatial4n copied to clipboard
Date line bug using multi polygon
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);
}
}
}
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
If you switch the SpatialContext to NtsSpatialContext it is still showing the same behavior