[postgis-devel] ST_ShiftLongitude

strk strk at keybit.net
Tue Feb 23 06:08:05 PST 2010


Hi guys,
I'm in need to do some "longitude shifting" and went looking
at the function I wrote long time ago (ST_ShiftLongitude).

That function is documented to translate every point with X<0 to X+=360.

What I need is shift on a different "prime meridian" (correct name?),
so I was thinking to take the condition (X<0 currently) as a parameter.

Now, one problem I found is that the ST_ShiftLongitude really does
more then documented, that is it takes any point with X>180 and
translate them back to X-=360 (!)
This was to allow symetrical operations (shit/unshift).

Another problem is the name of this function, which I find somewhat
confusing in that it's not a "shift" happening, but a "conditional
shift" which I pretty much see like taking a piece of paper with
the printed muap on cutting it to a given longitude-value (0 by default
for the current function) and glueing the two pieces again swapped.

So, what I think should be paremetrized is:
	1: X-value for where to cut (longitude)
	2: Side to move (left to right or right to left)
	3: range of the whole block
	   (minx if moving right to left, maxx if moving left to right)

As you can see the current 'symmetrical' behaviour can't be implemented
by only using the parameters above (as the range [param 3] changes after
the cut&glue operation and can't be assumed.

Problem with current ST_ShiftLongitude is then probably hard-coding
of the valid range.

I hope someone will be able to follow this disquisition :)
Writing here for your opinion on the value of generalizing such
function.

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://foo.keybit.net/~strk/services.html



More information about the postgis-devel mailing list