Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jts-dev] split a polygon or line at the antimeridian

I thought I'd mention that Spatial4j, a library I'm involved with that works with JTS, addresses the dateline / antimeridian in the JtsGeometry class:
https://github.com/locationtech/spatial4j/blob/master/src/main/java/org/locationtech/spatial4j/shape/jts/JtsGeometry.java

Perhaps this code might have a home in JTS 2.0.

On Mon, Sep 25, 2017 at 7:56 PM Martin Davis <mtnclimb@xxxxxxxxx> wrote:
And now in the FAQ:  https://locationtech.github.io/jts/jts-faq.html#E3

Further suggestions welcome...

On Mon, Sep 25, 2017 at 4:39 PM, Martin Davis <mtnclimb@xxxxxxxxx> wrote:
John,

JTS doesn't at the moment contain a Split Polygon By Line function, so your approach of constructing clipping polygons is the recommended alternative.  The good news in your case is (a)  you know a priori the maximum extent of the input geometries and (b) the splitting line is vertical.  So you can simply create two fixed orthnormal rectangles and use them as the splitting polygons. 

(Aside - it would be a nice little exercise to create a function which takes a splitting line and turns it into a splitting polygon, and then computes and returns both sides of the split.  Someone may have already done this...)

As for translating to [0 - 360], yes, the AffineTransformation API is designed to do this.  For example code see the unit test file [1] (This would be a nice candidate for some code in the examples module)

HTH


On Mon, Sep 25, 2017 at 4:20 PM, John Cartwright - NOAA Federal <john.c.cartwright@xxxxxxxx> wrote:
Hello All,

I feel like this is a common question but don't seem to find a good answer.  

I'm trying to split a simple shape at the antimeridian to form a multipart geometry.  My general approach was to construct two clipping polygons for the eastern and western hemispheres and intersect them with the target geometry.

Can someone suggest a better approach to doing this with JTS or GeoTools?

Related question - it seems that I need to shift the geometries from a -180 to 180 coordinate space to a 0 to 360 coordinate space in order to perform some of the calculations.  Is AffineTransformation the best way to approach this?  Any examples of using it for this purpose?

Thanks for any help you can provide!

--john


_______________________________________________
jts-dev mailing list
jts-dev@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/jts-dev



_______________________________________________
jts-dev mailing list
jts-dev@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/jts-dev
--
Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker

Back to the top