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

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

[1] https://github.com/locationtech/jts/blob/master/modules/core/src/test/java/org/locationtech/jts/geom/util/AffineTransformationTest.java

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



Back to the top