[postgis-users] AsSVG inner poly reversed
Sean M. Montague
smontague at ATSDenver.com
Mon Apr 4 09:45:50 PDT 2005
In my efforts to try and narrow my problem down and simplify my examples
of some intersection problems, I've run across another oddity. PostGIS
is returning the inner polygon AsSVG of an intersection in reverse order
to the outer polygon, causing display problems. The inner polygon
should be a hole, and when returned properly, have no fill. Below are
two sets of sql statements from my PHP code. The first is just the
poly "One" from table "test_02". The SVG is below that. This displays
properly because the inner path is returned in the same direction as the
out polygon.
$sql = ("SELECT AsSVG(the_geom,0,8) As the_geom
From test_02
WHERE Name='One'");
--The outer polygon coords follow the first M, and the inner follows the
second M. I added comas and deleted the cords between the first 4 and
last 4 for simplicity purposes. These are in the correct order.
(outer)M -358 -4857 2866 -4235 3090 -2614 5520 -89 3969 4284 -651 4605
-4978 2965 -5719 -1842 -2978 -4556 -358 -4857
(inner)M 2083 -447, 2082 -497, 2081 -548, 2079 -598, ... 2079 -295, 2081
-346, 2082 -396, 2083 -447
--This is how it would look normally.
M -358 -4857 2866 -4235 3090 -2614 5520 -89 3969 4284 -651 4605 -4978
2965 -5719 -1842 -2978 -4556 -358 -4857 M 2083 -447 2082 -497 2081 -548
2079 -598 ... 2079 -295 2081 -346 2082 -396 2083 -447
The second is the intersection between the_geom from table "test_02" and
a poly defined by the coordinates $theXMax and so on.
$theXMax= 5651;
$theYMax= 5009;
$theXMin=-6072;
$theYMin= -4732;
$sql = ("SELECT AsSVG(intersection(the_geom,
PolygonFromText('POLYGON(($theXMin $theYMax, $theXMax $theYMax, $theXMax
$theYMin, $theXMin $theYMin, $theXMin $theYMax))',32767)),0,8)
As the_geom
From test_02
WHERE Name='One'
AND the_geom && PolygonFromText('POLYGON(($theXMin $theYMax,
$theXMax $theYMax, $theXMax $theYMin, $theXMin $theYMin, $theXMin
$theYMax))',32767)");
--Notice that the inner poly cords are reversed. This causes display
problems. The inner poly has a fill when it should not.
(outer)M -358 -4857 2866 -4235 3090 -2614 5520 -89 3969 4284 -651 4605
-4978 2965 -5719 -1842 -2978 -4556 -358 -4857
(inner)M 2083 -447, 2082 -396, 2081 -346, 2079 -295, ... 2079 -598, 2081
-548, 2082 -497, 2083 -447
Any insight would be appreciated.
More information about the postgis-users
mailing list