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

Empty Polygon #14

Closed
juliusfriedman opened this issue Nov 19, 2020 · 7 comments
Closed

Empty Polygon #14

juliusfriedman opened this issue Nov 19, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@juliusfriedman
Copy link

juliusfriedman commented Nov 19, 2020

I am having issues writing an Empty Polygon:

 Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.ArgumentException: Ring has fewer than 4 points, so orientation cannot be determined (Parameter 'ring')

Is there an easy way around this?

I can read them just fine but can't insert what I read if I needed to...

I have manually inserted an Empty Polygon using SQL and have resorted to copying it with SQL when after I insert with NULL in that column I would otherwise have the Empty Polygon, I could also use a Trigger but that is even nastier.

See also
#9
#4

@airbreather airbreather added the bug Something isn't working label Nov 19, 2020
@airbreather
Copy link
Member

Eww -- there's no specific repro here to confirm, but I think it's probably this line that's throwing the underlying exception because there's no "is it empty?" check.

As a workaround, I would recommend using an empty instance of some other geometry type, such as an empty MultiPolygon.

@juliusfriedman
Copy link
Author

Can't use a MULTIPOLYGON because the type on the model is Polygon but I can issue a manual INSERT with the desired SQL since I know all the other field values.

Eager to see this fixed

@roji
Copy link

roji commented Apr 10, 2021

We seem to be seeing the same thing via EF Core in dotnet/efcore#24621. Note the possible similarity with NetTopologySuite/NetTopologySuite.IO.PostGis#14 (same bug?).

@FObermaier
Copy link
Member

... but I think it's probably this line that's throwing the underlying exception because there's no "is it empty?" check.

If it is, then the issue should be resolved with NTS v2.3 because the ArgumentException has been removed in favor of a default result value of false.

FObermaier added a commit that referenced this issue Apr 12, 2021
... for geography data type to prevent ArgumentException when ring orientation can't be computed.

* Add unit test

refers to #14
@rmja
Copy link

rmja commented Jan 11, 2022

@FObermaier Would it be possible to get a 2.0.1 version with this fix?

@rmja
Copy link

rmja commented Jan 25, 2022

@FObermaier ping:-)

@FObermaier
Copy link
Member

Fixed with d859a1c

New package is out, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants