[postgis-devel] Split By function

Obe, Regina robe.dnd at cityofboston.gov
Mon Jun 23 11:41:42 PDT 2008


I recall we were discussing a need for a split by function and that ST_GeometryN etc. is slow for large geometries. Unfortunately I don't have any humongous geometries to test with.
 
I just looked at ST_Dump (not sure why I never used it before, I guess because generate_series is more versatile.).  Anyrate it seems to me it comes very close to a split by and with range ability.  
 
I presume ST_Dump is much more efficient than ST_GeometryN since it would make only one call out.  Kevin can you test out that old generate_series one you had with dump?
 
E.g. I can do this
 

SELECT a.somefield1, a.somefield2, a.geom
FROM
(SELECT somefield1, somefield2, (ST_Dump(the_geom)).*
FROM sometablewithmulties) as a
WHERE
a.path[1] between 2 and 5;
 
To grab all geometries in all records in a MULTI between 2 and 5 slot. Granted I can't think of a use for such a thing.
 
Which allows me to wrap this in an sql function wrapper to generate a 
pgis_GeometryRangeN(start int, end int) 
 
 
or 
pgis_GeometryAll() returns geometry[]
 
similarly the below denatures a MULTIPOLYGON/LINESTRING to single POLYGON/LINESTRINGS
SELECT a.somefield, (ST_Dump(the_geom)).geom
FROM sometable as a;
 
Which allows me to wrap this in a simple SQL function that does all sorts of split by stuff.  E.g. for geometry collections I suppose it could get interesting with those multidimensional arrays.  Unfortunately I guess ST_Dump is not going to deal with single geometries and breaking into points etc.  But seems if its efficient for the other case - we can create a similar one to deal with the other cases by cutting and pasting some of the logic.
 
Thanks,
Regina
 

 
 
 


-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20080623/4a2dd546/attachment.html>


More information about the postgis-devel mailing list