-
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
Required Changes for NetTopologySuite.Curve #526
base: develop
Are you sure you want to change the base?
Conversation
@airbreather, I'd really appreciate your input on these changes to NTS core to make NTS.Curve work. |
b6e92ce
to
7ddfc79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I'm seeing some great auxiliary helpers (CoordinateList
change and CoordinateSequences
changes all make me happy), but I'm not sure about punching holes into our types and methods just so that an "external" project can fill them, especially (but not exclusively) given that it can only be completely done by something with InternalsVisibleTo
access.
In general, I feel like NetTopologySuite is not in a position where it makes sense to try to "plug in" new Geometry
subclasses externally and have them work with the rest of the system, and that it would take some dedicated refactoring / redesign in order to make it that way (the NtsGeometryServices
changes are a start, but I think even those need to be revisited).
At the moment, I am strongly in favor of bringing the curve geometry support into this project.
I haven't COMPLETELY reviewed this, as the deeper I got into it, the more strongly I started to feel the above opinions. If we do wind up taking this approach, then I will want to spend more time on this.
@@ -233,5 +236,12 @@ private static LinearRing EnsureOrientation(LinearRing ring, LinearRingOrientati | |||
|
|||
return ring; | |||
} | |||
|
|||
[OnDeserialized] | |||
protected new void OnDeserialized(StreamingContext context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of shadowing, we should probably make the base method virtual
and override it here
Summarizing:
|
I'm not claiming that we should. I'm claiming that, for all intents and purposes, geometry types that aren't defined inside of NetTopologySuite already are second-class citizens at best. In other words, it's already locked up. I'm also not claiming that we need to address all of the below before releasing support for curves. On the contrary, I think that it's a really good idea to release with some support for this as soon as we can get a viable subset of features integrated with NTS, as long as we make sure that the release comes with prominent warning labels making it clear what's supported and what isn't. I'm just listing some of the additional issues that I see, which prevent these external types from being fully integrated into the system. You've already identified WKT and WKB, so I'm not going to repeat the details of that. Here are the specific issues I can see regarding subclasses of Casting to the NTS-specific geometry typesThere are many places throughout the code base that check against a specific list of built-in types, assuming that a geometry can't be anything other than those. In order to support unknown types completely, I believe that we will need to evaluate every block that does a type check like this to figure out what we can possibly Just the first five that I found (there are many!): NetTopologySuite/src/NetTopologySuite/Algorithm/Centroid.cs Lines 95 to 115 in 7a54d3b
NetTopologySuite/src/NetTopologySuite/Algorithm/Distance/DistanceToPoint.cs Lines 21 to 42 in 7a54d3b
NetTopologySuite/src/NetTopologySuite/Geometries/Utilities/GeometryEditor.cs Lines 285 to 307 in 7a54d3b
NetTopologySuite/src/NetTopologySuite/Geometries/Utilities/GeometryTransformer.cs Lines 99 to 115 in 7a54d3b
NetTopologySuite/src/NetTopologySuite/GeometriesGraph/GeometryGraph.cs Lines 185 to 201 in 7a54d3b
Implicit Straight-Line AssumptionsJust as a random example (not the ONLY issue), a NetTopologySuite/src/NetTopologySuite/LinearReferencing/LinearLocation.cs Lines 266 to 283 in 7a54d3b
Which callers then use to figure out the "30%" part by calling this method or something like it:
To put it together: NetTopologySuite/src/NetTopologySuite/LinearReferencing/LengthIndexedLine.cs Lines 59 to 64 in 7a54d3b
In this example, in order to even allow for supporting curves, How would we even begin to upgrade this in a way that supports the broad concept of curves without defining them in our project? I guess you kind-of answered this:
But that brings us back to the situation we were in with GeoAPI / NetTopologySuite: interfaces that nobody else other than us will actually implement, each with its own set of constraints that the framework / SDK really doesn't help validate for the unfortunate soul who wants to implement it, both managed independently yet intrinsically tied together. I don't know about how everybody else felt about this situation, but I found this to be a major hassle when doing NTS development, and a minor hassle when doing application development using NTS. The only advantage that I can see is what you've said:
Agreed, we don't know what JTS will do in the future. However, as long as we name our types and any curve-specific members according to conventions that JTS would never follow (e.g., instead of Edit: I ran out of time at the end of this comment. See my next comment on this thread for the rest. |
Joe, I don't know if you have looked at the implementation side on NetTopologySuite.Curve. All the issues you listed above can be solved/approximated by calling Yes, this is a simplification, but it is the way it is done in both |
That doesn't solve the problem of NTS core needing to have built-in support for this geometry type in its own routines, which is the main point I was trying to make. In other words, the fact that NTS core defines an interface called So why bother with the indirection and extra overhead of maintaining an additional project long-term to make it possible for us to define new geometry types in a separate GitHub project, with its own separate GitHub issue tracker, maintained in a separate VS solution, deployed as a separate NuGet package that users have to know to look for in order to get this support (potentially with those weird issues like I literally don't see the benefit. I ran out of time yesterday to finish off this part of my response, but the fact that we don't know what JTS is going to do about curves later seems like a non-sequitur on its face. The only way that I can relate it to the proposal of defining our own invention in a separate project is if the plan is to just stop maintaining the other project whenever we port what JTS does into NTS, which is problematic:
|
In order to be able to derive a class from it. Additional changes: * Make ToText virtual
…ter) ... to activate override mechanism
... to properly implement CompareToSameClass on curve and surface geometries. Add NetTopologySuite.Curved to InternalsVisibleTo.
Increase visibility for reusable functions of WKTReader and make TokenStream public
Prevent writing ordinate information for nested geometries.
Change access modifier from internal to protected for WKTReader.ReadOtherGeometryText
* Remove ICurve and ISurface interfaces * Cache result of IsSimple operation. * Add and wire Assert.IsTrue overload
981d404
to
d6b6198
Compare
* `Geometry`: remove virtual from To[Text|Binary] * `GeometryFactory`: make OnDeserialized virtual, optionally take NtsGeometryServices object from `StreamingContext` on deserialization * `GeometryFactoryEx`: override OnDeserialized * `LineString`: seal Start-/EndPoint * `Surface`, `Assert`, `NtsGeometryServices`: Xml code documentation *
This PR contains changes that are required to make an extension for curve geometry work