[Geoserver-users] Polygon wrapping around the globe

Hi,

I'm new to GeoServer, so I may be missing something obvious. When I visualise a line or polygon that spans the dateline (eg. 175 0 to -179 0) it goes the long way, all the way around the globe (354 degrees). Of course, what I want to see is it crossing the dateline (6 degrees). Is there an easy way to do this? Some setting perhaps? I'm using GeoServer 2.2.1 with PostGIS 2.0.0.

Regards,

Evan

Evan, what are you visualising it with? If OL, then make sure you have
OL 2.11.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

On Mon, Nov 21, 2011 at 3:29 PM, Evan Martin
<geoserver@anonymised.com> wrote:

Hi,

I'm new to GeoServer, so I may be missing something obvious. When I
visualise a line or polygon that spans the dateline (eg. 175 0 to -179
0) it goes the long way, all the way around the globe (354 degrees). Of
course, what I want to see is it crossing the dateline (6 degrees). Is
there an easy way to do this? Some setting perhaps? I'm using GeoServer
2.2.1 with PostGIS 2.0.0.

The code does not try to go the short way, it goes the obvious one.
There are actual users that have this large polygons spanning the entire
world, from -180 to 180
(it's actually the same people that sponsored the map wrapping functionality).

The WCS specification offers some guidance in terms of bbox, if a bbox
has the min lat that is higher than the max lat the bbox is supposed to
cross the dateline, but I would not know how to apply the same logic to
a generic polygon without also breaking the above use case.

Cheers
Andrea

--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------

Thanks, Andrea. So it sounds like there is currently no (built-in) way to visualise my polygon properly. Perhaps a setting could be added to GeoServer that allows it to work both ways: the "obvious to the code" way (current) and the "obvious to the user" way (shortest)?

Ideally, I think it should go the short way by default - surely that's what most people would expect? If anyone does want a polygon going all the way around the globe they could simply add an intermediate point, eg. -180 0,0 0, 180 0. But I'm less concerned about the default behaviour and more about just being able to visualise this somehow, even if it requires some tweaks.

Regards,
Evan

On 22/11/2011 8:35 PM, Andrea Aime wrote:

On Mon, Nov 21, 2011 at 3:29 PM, Evan Martin
<geoserver@anonymised.com> wrote:

Hi,

I'm new to GeoServer, so I may be missing something obvious. When I
visualise a line or polygon that spans the dateline (eg. 175 0 to -179
0) it goes the long way, all the way around the globe (354 degrees). Of
course, what I want to see is it crossing the dateline (6 degrees). Is
there an easy way to do this? Some setting perhaps? I'm using GeoServer
2.2.1 with PostGIS 2.0.0.

The code does not try to go the short way, it goes the obvious one.
There are actual users that have this large polygons spanning the entire
world, from -180 to 180
(it's actually the same people that sponsored the map wrapping functionality).

The WCS specification offers some guidance in terms of bbox, if a bbox
has the min lat that is higher than the max lat the bbox is supposed to
cross the dateline, but I would not know how to apply the same logic to
a generic polygon without also breaking the above use case.

Cheers
Andrea

On Tue, Nov 22, 2011 at 11:04 AM, Evan Martin
<geoserver@anonymised.com> wrote:

Thanks, Andrea. So it sounds like there is currently no (built-in) way to
visualise my polygon properly. Perhaps a setting could be added to GeoServer
that allows it to work both ways: the "obvious to the code" way (current)
and the "obvious to the user" way (shortest)?

Ideally, I think it should go the short way by default - surely that's what
most people would expect? If anyone does want a polygon going all the way
around the globe they could simply add an intermediate point, eg. -180 0,0
0, 180 0. But I'm less concerned about the default behaviour and more about
just being able to visualise this somehow, even if it requires some tweaks.

Definitely not the default, for a few reasons:
- it would break the functionality of people that gave funding to GeoServer to
  deal, at least partially, with the dateline, that would be most ungrateful
- it would break upgrades, as the behavior changes without the admin changing
  anything in the configuration

The functionality you want could be surely added as optional behavior, I
agree it would be useful for those dong mapping across the dateline.
It is probably not trivial to add though.
The code to be modified is in the GeoTools render module, along with some
modifications to GeoServer to add the flag.... patches welcomed :slight_smile:

Btw, I believe you can get what you want already if you change the coordinates
and make the polygons cross the dateline also in aritmetic terms, that is,
go from 175 to 195. That's how people map polygons crossing the dateline
today, I believe.

Cheers
Andrea

--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------

Yes, you're right, changing the default would be a breaking change and that would be bad. I hope the option is added, though. I probably wouldn't be able to contribute a patch myself, but at least anyone else that finds this thread will know where to look in the code, so thanks. :slight_smile:

Changing the coordinates does seem to work as a workaround, so yes, I'll have to make to with that. Thanks for your help.

Regards,
Evan

On 22/11/2011 9:49 PM, Andrea Aime wrote:

On Tue, Nov 22, 2011 at 11:04 AM, Evan Martin
<geoserver@anonymised.com> wrote:

Thanks, Andrea. So it sounds like there is currently no (built-in) way to
visualise my polygon properly. Perhaps a setting could be added to GeoServer
that allows it to work both ways: the "obvious to the code" way (current)
and the "obvious to the user" way (shortest)?

Ideally, I think it should go the short way by default - surely that's what
most people would expect? If anyone does want a polygon going all the way
around the globe they could simply add an intermediate point, eg. -180 0,0
0, 180 0. But I'm less concerned about the default behaviour and more about
just being able to visualise this somehow, even if it requires some tweaks.

Definitely not the default, for a few reasons:
- it would break the functionality of people that gave funding to GeoServer to
   deal, at least partially, with the dateline, that would be most ungrateful
- it would break upgrades, as the behavior changes without the admin changing
   anything in the configuration

The functionality you want could be surely added as optional behavior, I
agree it would be useful for those dong mapping across the dateline.
It is probably not trivial to add though.
The code to be modified is in the GeoTools render module, along with some
modifications to GeoServer to add the flag.... patches welcomed :slight_smile:

Btw, I believe you can get what you want already if you change the coordinates
and make the polygons cross the dateline also in aritmetic terms, that is,
go from 175 to 195. That's how people map polygons crossing the dateline
today, I believe.

Cheers
Andrea

Well I am definitely visualising lines that cross the 180. I have issues
with polygons. They draw a line down the 180. I think you can get around
that by using two layers; one with fill and no outlines and the other
with polygon turned into arcs. However, the trick I think is using a
tiled client. (and OL2.11 - geoserver ships with something ancient).
That way there is no request going to geoserver for objects that cross
the 180. I dont have things stored as 195 instead of -175. It can look
rubbish, wont zoom etc, in the preview client but work okay in proper
client. We are still running 2.0.2 (but with jvm parameters set for
wrapping the 180 line) because of a bug with the connection to arcSDE in
2.1.x, however the data is served fine in 2.1.x when coming from PostGIS.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

On 22/11/2011 10:35 p.m., Andrea Aime wrote:

The code does not try to go the short way, it goes the obvious one.
There are actual users that have this large polygons spanning the
entire world, from -180 to 180 (it's actually the same people that
sponsored the map wrapping functionality).

Just thinking about this and it seems to be an extraordinarily unusual
use case. You have a polygon where two consecutive points are in
different east/west hemispheres and you want the polygon to go the long
way round the globe? I struggle to think of what the application must be
that paid for that. However this is the case which is much easier to
PROGRAM for.

So could the 99% that want polygons crossing the 180 to be drawn in a
more logical way outbid this case in paying for a solution?

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

On Tue, Nov 22, 2011 at 10:08 PM, Phil Scadden <p.scadden@anonymised.com> wrote:

On 22/11/2011 10:35 p.m., Andrea Aime wrote:

The code does not try to go the short way, it goes the obvious one.
There are actual users that have this large polygons spanning the
entire world, from -180 to 180 (it's actually the same people that
sponsored the map wrapping functionality).

Just thinking about this and it seems to be an extraordinarily unusual
use case. You have a polygon where two consecutive points are in
different east/west hemispheres and you want the polygon to go the long
way round the globe? I struggle to think of what the application must be
that paid for that. However this is the case which is much easier to
PROGRAM for.

United Nation global maps may have polygons that span the world
from east to west, often with a single line connecting the two datelines.
But even without going there, every global map has at least a single
line connecting the two datelines: the south edge of Antarctica
(a line which is actually a point, since it connects -180,-90 to 180,90)

So could the 99% that want polygons crossing the 180 to be drawn in a
more logical way outbid this case in paying for a solution?

As said, we are not in the business of breaking backwards compatibility
so lightly, in the past we did for some cases when jumping from the 1.x series
to the 2.x one.
I'd be happy to help in case someone wants to sponsor for the
needs of people mapping across the dateline (by adding a flag that enables
this mode, not the other way around).

Cheers
Andrea

--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------