-
Notifications
You must be signed in to change notification settings - Fork 364
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
Use JTS geometries in vector package #2932
Use JTS geometries in vector package #2932
Conversation
In the interest of furthering a new RFP process for major changes or new features that we're trying out, I'd like to post my plans for this work, in case there is useful feedback. This will call out some of the salient features of the experimental code. Proposed deletionsHere is the subset of the vector package that will be removed:
The sub-packages to be removed add little if anything in the way of functionality. We will favor using JTS directly for these features. Obviously, the basic geometry types will be removed; however, I have opted to this point to keep the companion objects to aid in object creation. This does create some type weirdness, though, in some cases requiring importing JTS into a Proposed Preservations
Notable here is the maintenance of the |
976b7d2
to
2577afb
Compare
implicit class ProjectGeometry[G <: Geometry](g: G) { | ||
/** Upgrade Geometry to Projected[Geometry] */ | ||
def withSRID(srid: Int) = Projected(g, srid) | ||
} | ||
|
||
@typeclass trait MultiGeometry[G] |
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.
This isn't used anywhere but for an import in ProtobufGeom
. Do you think this is something important or just left-over at this point?
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.
Yeah, I'd agree that it's mostly vestigial. Not entirely clear what its value was in the first place.
57a5cc3
to
5a55294
Compare
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
0d8efb1
to
08363c4
Compare
@jpolchlo |
def distanceToInfiniteLine(a: Point, b: Point): Double = | ||
CGAlgorithms.distancePointLinePerpendicular(jtsGeom.getCoordinate, a.toCoordinate, b.toCoordinate) | ||
} | ||
object Point extends PointConstructors |
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.
I think this is actually the last thing we talked about, keeping the geotrellis.vector.jts.Point
is the thing that would provide duplicate imports if org.locationtech.jts.geom._
was imported. IIRC our discussion landed on removing these constructors and using only the ones in JTS
object.
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.
We discussed this, and I remember settling on "eh, no, maybe not". The footprint of this "simple" change is wide, necessitating either another import (after we went through the trouble to minimize them), or requiring a clumsy prefix for every geometry creation. It's going to be less common for a user to import org.locationtech.jts.geom._
, so I made a note in the docs (https://github.com/locationtech/geotrellis/pull/2932/files#diff-38390c0856b2dfe9eff77f20e8a0d9d1R249) to avoid doing so in a careless fashion. The JTS
object feels like a kludge to get around a broken thing, not a thing that I would want to use all the time. I would hope that one day the scala REPL would fix its problems and we can just get rid of it.
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.
Ok, thats not what I recall ending on, but I accept this argument now. The docs certainly help. 👍
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
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.
LGTM, will squash-merge on green CI.
Signed-off-by: jpolchlo <[email protected]>
Signed-off-by: jpolchlo <[email protected]>
@jpolchlo sweet PR! 🎉 |
Overview
We are now favoring direct use of JTS geometries for improved interoperability with other projects. Scala wrapper classes for Geometry have been snuffed. Many submodules of
geotrellis.vector
have also been removed in favor of direct usage of the corresponding JTS functionality. Extension methods and companion objects have been added to maintain a crisp, candy shell around JTS to keep most interactions from messing up your fingers. Importgeotrellis.vector._
to access these niceties; if it is required,import org.locationtech.jts.{geom => jts}
to prevent namespace collisions.Note: In the REPL, geometries will need to be constructed via the duplicate definitions in the
JTS
object to avoid namespace clashes that appear to be buggy behavior on the part of the REPL (that is, useJTS.Point(0,0)
to construct a point at the origin in interactive sessions, but in compiled code,Point(0,0)
will suffice). See core concepts documentation in the guide for more details.Closes #2930
Closes #2931
Closes #2955
Signed-off-by: jpolchlo [email protected]
Checklist
docs/CHANGELOG.rst
updated, if necessarydocs
guides update, if necessary