-
Notifications
You must be signed in to change notification settings - Fork 310
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
When a SRID is provided, use its units for metrics of length, distance, and area instead of input units #233
Comments
NTS does not perform any special geography operations.
JTS doesn't implement specific geography functions or operations either. |
Thanks for your answer. For supporting PostGIS's |
I've started a bit on this: https://github.com/NetTopologySuite/NetTopologySuite.Geography I just sorta went through some of this page for SQL Server and added stuff (not everything yet, but all OGC instance methods are represented). Where there were direct equivalents on |
Packages are now being auto-built and auto-pushed to my personal MyGet feed for now: https://www.myget.org/feed/airbreather/package/nuget/NetTopologySuite.Geography |
I'm unassigning myself from this one and waiting for the EF Core team to gather community feedback and provide a recommendation for how it makes sense to move forward with geography from their perspective. Not that I'm saying that EF Core is the authoritative source for this, but I expect them to be a very large use case, and based on other communication, there may very well be more appropriate alternative ways to support this kind of thing client-side (even if it makes EF Core's SQL Server database provider a pain). |
Sorry! I meant to follow up on this yesterday. I just merged dotnet/efcore#13408 which allows you to map to SQL Server class SpatialThing
{
public int Id { get; set; }
[Column(TypeName = "geography")]
public Point Location { get; set; }
} This will alter the translation of a few members: (note, the semantics are similar to how WKT is handled)
The members that are't available in SQL Server will be evaluated on the client using the NTS implementations. This will probably be unexpected, but if you know you're working with We're considering making Again, all this is open to change based on feedback. |
The decisions that EF Core made on this issue for 2.2 are the best I could also come up with:
That third bullet point is why I still want to keep this issue open. As annoying as it is to suggest major deviations from JTS, I think it's inappropriate for us to keep this situation working the way it does: IPolygon poly = GetGeometry();
Console.WriteLine(poly.SRID); // writes 4326
Console.WriteLine(poly.Area); // writes a useless value This is especially true now that our interfaces are used to enable this kind of scenario where that's exactly how to get a useful area (sorry for what's probably bad hygiene in this LINQ query): var q = from q1 in GetQueryableFeatures1()
from q2 in GetQueryableFeatures2()
where q1.Geom.Intersects(q2.Geom)
select (id1: q1.Id, id2: q2.Id, area: q1.Geom.Intersection(q2.Geom).Area);
foreach (var (id1, id2, area) in q)
{
Console.WriteLine($"{id1} and {id2} share {area} square meters.");
} I think that "real-world metric" operations in NTS (distance / area / length / more?) should start using Unproductive RantTo elaborate on that issue I have with the state of existing GIS software packages: I know of precious few software packages (especially FOSS) that really "understand" that we're dealing with an ellipsoidal representation of the Earth where a point is identified by a pair of angles.
So, forget about accurately modeling (non-geostationary) satellites that orbit the Earth constantly in one direction. For all we care, they actually follow Pac-Man logic: once they reach a particular point in their orbit, they just zap over to "the other side" to continue their journey. If I want a geometry that represents the water area within 1 mile of the coast of any land on Earth, then it's not just
Of course, what can be done about this? I'm sure that I'm not the first, nor will I be the last, to be bothered by all this, but it's not like we got here by incompetence or anything. It's just really hard to model that, and what we have is "good enough" for enough real-world use cases that developers just live with the pain and extra grey hairs of working around the flaws of imperfect solutions. |
Loved the rant :) Just one point - |
Ideally, the magic should be opt-out, which, for the first round, pretty much means that NTS needs to be able to access ProjNet stuff. @FObermaier has already expressed in NetTopologySuite/ProjNet4GeoAPI#44 (comment) that ProjNet should not reference anything from NetTopologySuite, which is perfect, since that lets NetTopologySuite reference ProjNet 😀. So the basic plan of attack to get to a place where it's definitely more useful than what we do today:
Bad things about that:
Resolving those "bad things" would probably require us to implement the calculations using ellipsoidal math, using ProjNet for nothing more than its ability to extract the parameters we need for a given SRID, which seems very time-consuming. |
Then again, if all of it just flows from distance and area... Distance can be calculated using Vincenty's formulae (Mike Gavaghan did a C# implementation which I've already copied to GitHub with permission). https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid#Area_of_a_geodesic_polygon doesn't look too awful. |
Looks like the way to go is actually Charles F. F. Karney's Algorithms for geodesics + addenda. There's already an implementation, so it should just be a matter of porting it and/or updating suryapratap/GeographicLib or Flitesys/GeographicLib or oldrev/GeographicLib or similar. |
So, since we're probably going to wind up doing this via ProjNET's pointwise stuff, I've gone ahead and started a branch Notably, |
2.0 is releasing without this, but I would like a future 2.x release to add support for this, on an opt-in basis to avoid breaking existing consumers. |
Before creating a new issue I wanted to chime in here because this seems related. I also read This But didn't find it helpful because even after projecting or using LengthLocationMap I get the same distance Given a LineString:
The Length = SQL Server gives a length of How can I get to that value without having to manually select it from SQL Server using FromSql? Is there a way to convert easily? |
I tried the following:
But the distance is if I modify slightly with the code in NetTopologySuite/ProjNet4GeoAPI#36 So in short I am totally lost here |
You need to transform the whole geometry/linestring and not just start- and end-point. |
I see.... With this I get closer:
I get Thank you! BTW, looking forward to seeing this type of functionality be enhanced in future versions, I already specify the SRID and I feel it would be beneficial if there was at least a built in function set to tackle these types of problems especially when you are dealing with many LineStrings and many Points as you have to loop over every coordinate, transform and then calculate which can eat up memory vs having that information already provided via the SRID and easily available at the server level. |
Does NetTopologySuite include any sort of support for geography (as opposed to geometry)? I'm specifically interested in communicating with PostgreSQL/PostGIS.
If not, is geography support something that is planned or possible? Does JTS implement it?
The text was updated successfully, but these errors were encountered: