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

A line splitter would be really useful however. Even if you have geometry that plays nice, you can be interacting with systems that do not. My use case is doing a spatial query-by-polygon on a map. Map properties come from AGS or OGC webmap services neither of which are much good at polygons that span the 180 line. You have to split the polygon into pieces and create query with OR clause on the geometry pieces.

 

From: jts-dev-bounces@xxxxxxxxxxxxxxxx [mailto:jts-dev-bounces@xxxxxxxxxxxxxxxx] On Behalf Of David Smiley
Sent: Tuesday, 26 September 2017 3:47 p.m.
To: JTS developer discussions <jts-dev@xxxxxxxxxxxxxxxx>
Subject: 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:

 

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

Notice: This email and any attachments are confidential and may not be used, published or redistributed without the prior written consent of the Institute of Geological and Nuclear Sciences Limited (GNS Science). If received in error please destroy and immediately notify GNS Science. Do not copy or disclose the contents.

Back to the top