[postgis-users] unable to assign hole to a shell
Martin Davis
mbdavis at refractions.net
Mon Sep 17 11:46:54 PDT 2007
Yep, absolutely right - I meant Union, not intersection!
Kevin Neufeld wrote:
>
> Martin Davis wrote:
>>>
>>>> I was able to rebuild your polygon this way:
>>>> 1. extract the exterior ring - you may want to add to this subquery
>>>> all
>>>> the interior rings if you have any
>>>> 2. extract all the points of the ext ring as ordered pairs (ie as
>>>> point1-point2, point2-point3, point3-point4, ....)
>>>> 3. recreate line segments from all these ordered point pairs, removing
>>>> duplicates.
>>>> 4. rebuild the polygon using st_buildarea()
>>>>
>>>
>>> Would this trick work on every polygon? By construction my polygons
>>> have no interior ring.
>>>
>> Knowing that you have no holes definitely helps.
>>
>> Another thing you might be able to try is to:
>> - convert the polygon to a linestring
>> - call intersection on it with a single point from the linestring
>> (this effectively nodes the linework)
>> - polyognize the resulting linework back to a polygon
> Nice. You mean union, not intersection though, right Martin? Because
> the intersection of a point and a line is a point.
> This is better than my solution cuz generate_series actually has
> issues when the number of points in a line is more than a few thousand
> (probably due to internal storage and toast tables).
>
> So, your query would become:
> SELECT ST_BuildArea(geom) AS geom
> FROM
> (
> -- Re-node the linear ring
> SELECT St_Union(geom, St_Startpoint(geom)) AS geom
> FROM
> (
> -- The exterior ring of your polygon
> SELECT ST_ExteriorRing(
> 'POLYGON((
> 9.50351715087891 47.3943328857422,
> 9.50386047363281 47.3943328857422,
> 9.50351715087891 47.3943328857422,
> 9.50248718261719 47.3943328857422,
> 9.50214385986328 47.3939895629883,
> 9.50180053710938 47.3943328857422,
> 9.50145721435547 47.3939895629883,
> 9.50111389160156 47.3936462402344,
> 9.50145721435547 47.3936462402344,
> 9.50145721435547 47.3939895629883,
> 9.50214385986328 47.3939895629883,
> 9.50248718261719 47.3939895629883,
> 9.50386047363281 47.3943328857422,
> 9.50351715087891 47.3943328857422))'::geometry) AS geom
> ) AS ring
> ) AS fixed_ring
>
> -- Kevin
>
> -------------
> Kevin Neufeld
> Software Developer
> Refractions Research Inc.
> 300-1207 Douglas St.
> Victoria, B.C., V8W 2E7
>
> Phone: (250) 383-3022
> Email: kneufeld at refractions.net
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022
More information about the postgis-users
mailing list