Breaking Path/Polygon Data into Pieces
Breaking Path/Polygon Data into Pieces
От:
Volkan YAZICI <yazicivo@ttnet.net.tr>
Дата:
Hi, 2 weeks ago, a user in -tr-genel asked for a function to break path/polygon type data into pieces. He also told that, it creates a bottleneck in the network traffic when they try to receive rows with polygon data of thousands of nodes, while it's enough for them to have polygons partially. AFAIK, there doesn't exist such functions in PostgreSQL. (Please correct me if I'm wrong.) For this purpose, I've coded two simple C procedures: polygon part(polygon, offset, limit) path part(path, offset, limit) I thought it would be nice to see these functions in PostgreSQL and wanted to ask for other users (and developers) ideas. Regards.
Re: Breaking Path/Polygon Data into Pieces
От:
Michael Fuhr <mike@fuhr.org>
Дата:
On Mon, Feb 27, 2006 at 08:41:52PM +0200, Volkan YAZICI wrote:
> 2 weeks ago, a user in -tr-genel asked for a function to break
> path/polygon type data into pieces. He also told that, it creates a
> bottleneck in the network traffic when they try to receive rows with
> polygon data of thousands of nodes, while it's enough for them to
> have polygons partially.
>
> AFAIK, there doesn't exist such functions in PostgreSQL. (Please
> correct me if I'm wrong.) For this purpose, I've coded two simple
> C procedures:
>
> polygon part(polygon, offset, limit)
> path part(path, offset, limit)
PostGIS has geometry accessors that might work. You'd need to be
using PostGIS geometry types instead of the PostgreSQL types.
http://postgis.refractions.net/docs/ch06.html
Are the following examples anything like what the user in tr-general
was looking for?
postgis=> SELECT AsText(geom) FROM foo;
astext
----------------------------------------------------------
POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,9 1,9 9,1 9,1 1))
(1 row)
postgis=> SELECT AsText(ExteriorRing(geom)) FROM foo;
astext
-------------------------------------
LINESTRING(0 0,10 0,10 10,0 10,0 0)
(1 row)
postgis=> SELECT AsText(InteriorRingN(geom, 1)) FROM foo;
astext
---------------------------------
LINESTRING(1 1,9 1,9 9,1 9,1 1)
(1 row)
postgis=> SELECT n, AsText(PointN(ring, n))
postgis-> FROM (SELECT ExteriorRing(geom) AS ring FROM foo) AS s,
postgis-> generate_series(1, 2) AS g(n);
n | astext
---+-------------
1 | POINT(0 0)
2 | POINT(10 0)
(2 rows)
postgis=> SELECT AsText(MakeLine(PointN(ring, n)))
postgis-> FROM (SELECT ExteriorRing(geom) AS ring FROM foo) AS s,
postgis-> generate_series(1, 2) AS g(n);
astext
----------------------
LINESTRING(0 0,10 0)
(1 row)
postgis=> SELECT AsText(line_substring(ExteriorRing(geom), 0, 0.25))
postgis-> FROM foo;
astext
----------------------
LINESTRING(0 0,10 0)
(1 row)
--
Michael Fuhr
Re: Breaking Path/Polygon Data into Pieces
От:
Volkan YAZICI <yazicivo@ttnet.net.tr>
Дата:
On Feb 27 03:10, Michael Fuhr wrote: > PostGIS has geometry accessors that might work. You'd need to be > using PostGIS geometry types instead of the PostgreSQL types. > > http://postgis.refractions.net/docs/ch06.html > > Are the following examples anything like what the user in tr-general > was looking for? Yes. As I understand from your examples, they're quite efficient for related purposes I mentioned. But wouldn't it worth adding a simple part() function for this? Because, with this feature, people won't need to use another project for such a basic operation on path and polygon types which are supported by PostgreSQL by default. Regards.