[postgis-devel] [PostGIS] #870: [raster] Optimize ST_DumpAsWKTPolygons

PostGIS trac at osgeo.org
Fri Mar 18 13:04:04 PDT 2011


#870: [raster] Optimize ST_DumpAsWKTPolygons
-------------------------+--------------------------------------------------
 Reporter:  dzwarg       |       Owner:  dzwarg       
     Type:  enhancement  |      Status:  new          
 Priority:  medium       |   Milestone:  PostGIS 2.0.0
Component:  postgis      |     Version:  trunk        
 Keywords:               |  
-------------------------+--------------------------------------------------
 I looked at the code for ST_DumpAsWKTPolygons(), and identified a good
 place for optimization after talking it over with Frank W at the code
 sprint this afternoon.

 In rt_raster_dump_as_wktpolygons (see
 [source:/trunk/raster/rt_core/rt_api.c at 6923#L1728], after calling
 GDALPolygonize, there are notes regarding what to do with polygons that
 contain NODATA cell values. Instead of iterating over both loops (which
 both create and destroy all features in the memory layer -- copying and
 destroying them, effectively), it would probably be more performant to do
 the following steps after
 [source:/trunk/raster/rt_core/rt_api.c at 6923#L2002]:

  1. Add a sql-like filter to the layer to select the features that are +/-
 FLT_EPSILON.
  1. Iterate over all those features, and delete them from the layer.
  1. Remove the filter, and get all the remaining features in the memory
 layer.

 This approach means that all features in the layer are read once, even
 though there are 2 loops. The first loop would cycle over the features to
 remove, and the second loop would cycle over the features to create and
 return.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/870>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list