[postgis-users] AsSVG inner poly reversed

strk at refractions.net strk at refractions.net
Tue Apr 5 00:30:43 PDT 2005


I don't think AsSVG checks ring directions, and postgis doesn't
need a specific direction to distinguish an hole from an shell.

If the SVG format really requires specific direction I think
AsSVG() should take care of that. 

Check out the ForceRHR() function to change vertex order manually.

--strk;


On Tue, Apr 05, 2005 at 09:12:05AM +0200, klaus Förster wrote:
> hi Sean,
> 
> does this occur when you use AsText() as well or is it limited to 
> AsSVG()? are you using the latest PostGIS version? AsSVG(the_geom,0,8) 
> seems to be the notation for an old version where precision was 
> specified by number of significant digits and there some other bugs in 
> this version as well.
> Could you give an example with the original inner ring? you're using 
> "..." to indicate you ommit some coords and the inner ring presented 
> here is 4 units wide so it's hard to visually figure out direction with 
> marker-symbols.
> i think it's not true that in the first poly "the inner path is returned 
> in the same direction as the out polygon." outer and inner path have to 
> follow different directions to create a hole in SVG.
> 
> klaus
> 
> Sean M. Montague wrote:
> >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.
> >
> >
> >
> >
> >_______________________________________________
> >postgis-users mailing list
> >postgis-users at postgis.refractions.net
> >http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> -- 
>          O-.
>          /_ )
>           | (U
> klaus*   /|
>         / /
>         ~ ~
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list