Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Large Spatials (which cross datetime line) from Azure SQL into Geography Type #525

Open
euangordon opened this issue May 28, 2021 · 5 comments

Comments

@euangordon
Copy link

euangordon commented May 28, 2021

I am having some trouble using three large spatial stored in an Azure SQL Database. All three cross the datetime line and I get an exception "shell is empty but holes are not".

Very similar issue to:
Loading polygons from MS SQL cause "shell is empty but holes are not"

but my spatials not crossing the datetime line are working fine, just the ones over the datetime line are failing.

.Net Core 3.1
.NET 5.0
Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite 5.0.6

Polygon 1
POLYGON ((127 42.89, 131.674444444444 42.4672222222222, 135.673888888889 42.4675, 138.555 45.6505555555556, 180 45.6525, 180 50, 172 53, 180 58.1344444444444, -168.20305555555603 67, 180 67, 127 62.5, 127 42.89))

0xE610000001040C00000052B81E85EB7145400000000000C05F40533412F0CD3B454063FB830C95756040A4703D0AD73B4540505D6E7F90F56040D4AB896745D34640F6285C8FC2516140EC51B81E85D346400000000000806640000000000000494000000000008066400000000000804A4000000000008065404002BE7935114D4000000000008066400000000000C050404C4C5D6E7F0665C00000000000C0504000000000008066400000000000404F400000000000C05F4052B81E85EB7145400000000000C05F4001000000020000000001000000FFFFFFFF0000000003

Polygon 2
POLYGON ((180 0.00138888888888889, 170.673611111111 0.00138888888888889, 170.673055555556 -29.6683333333333, 160.6725 -45.6675, 160.620277777778 -85, 180 -85, -158.995833333333 -85, -120.024722222222 -85, -120.001944444444 0.00138888888888889, 180 0.00138888888888889))

0xE610000001040A0000001C6CC1166CC1563F00000000008066401C6CC1166CC1563F358EE3388E556540427EB1E417AB3DC022F0CDAB895565403D0AD7A370D546C0EC51B81E8515644000000000004055C0BF3FC850D913644000000000004055C0000000000080664000000000004055C0D2DDDDDDDDDF63C000000000004055C063FB830C95015EC01C6CC1166CC1563FF05297DB1F005EC01C6CC1166CC1563F000000000080664001000000020000000001000000FFFFFFFF0000000003

Polygon 3
POLYGON ((125 62.3341666666667, 152.5 64.667083333333352, 180 67, -175 67, -169 67, -169 85, 180 85, 125 85, 125 62.3341666666667))

0xE6100000010409000000975F2CF9C52A4F400000000000405F40E6174B7EB12A504000000000001063400000000000C0504000000000008066400000000000C050400000000000E065C00000000000C0504000000000002065C0000000000040554000000000002065C00000000000405540000000000080664000000000004055400000000000405F40975F2CF9C52A4F400000000000405F4001000000020000000001000000FFFFFFFF0000000003

All three polygons pass:
STIsValid()
Shape.EnvelopeAngle() > 90
polygon.Shell.IsCCW

entity.Property(e => e.Position).HasColumnType("geography").HasColumnName("Position");
    public partial class Navarea
    {
        public int Id { get; set; }
        public Polygon Position { get; set; }
    }

To get the exception:

var co = context.Navareas.Where(n => n.Id == 13).ToList();

Here are the three spatials being shown in SQL Management Studio:
image

@euangordon euangordon changed the title Loading Large Spatials (which cross datetime line from SQL into Geography Type Loading Large Spatials (which cross datetime line) from Azure SQL into Geography Type May 28, 2021
@bricelam
Copy link
Contributor

bricelam commented Jun 3, 2021

Duplicate of #384

@euangordon
Copy link
Author

@bricelam @airbreather Thanks for the update, I can see from #384 that "This crosses the antimeridian. NTS's model doesn't completely support that.".

Are there any plans to rectify this issue? Do you have any suggested workarounds? Feels like quite a big deficiency in NTS....

@FObermaier
Copy link
Member

Perhaps #496 is a way to solve your issue.

@euangordon
Copy link
Author

@bricelam @airbreather @FObermaier Is it possible to request that this gets fixed in future releases?

I get that we could work around the issue by splitting polygons into mulitpolygons or even just many polygons. We used to have to do this in SQL 2008 which had a similar issue. However, since 2012 with SQL Server Types polygons crossing the 180 meridian has been working fine. We would like to move to .net core but the lack of sufficient spatial support has been holding us back. Things that we can do easily in framework don't work anymore.

@euangordon
Copy link
Author

Hi All, is there any chance of getting NTS improved to support this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants