[postgis-devel] Idea for a vector clipping function

Sandro Santilli strk at keybit.net
Tue Jul 15 01:52:36 PDT 2014


I'm thinking about implementing a function that "loosely clips" a geometry
to a bounding box, where the "loosy" approach means it does not mind about
keeping some areas outside of the "clipping" bounding box but tries to
minimize the number of vertices falling outside of it.

It would basically remove vertices falling outside the box ensuring no
internal area changes.
Actually, ST_Intersection is very likely to change (slightly) the internal
area, as forced noding involves snapping to the floating-point grid so
this new function would improve that part (drifting) allowing area
(or pointset) "leaks" outside the box.

The goal would be for such function to be faster than ST_Intersection
but as effective from a renderer point of view (whereas a renderer would
further clip the geometry on its side).

Example (fixed-width fonts required):

  Polygon A looses non-significant areas          +----------+
  outside of the query box Q, but does not        |          |
  get more intersection points                    |   +------+
                                                  |   |
 +-----------------+                +-------------+   +
 | A               |                | A               |
 |    p +-----------------+         |      +-----------------+
 |      | Q        |      |         |      | Q        |      |
 |      |          |      |         |      |          |      |
 +------|----------+      |         +------|----------+      |
        |                 |                |                 |
        +-----------------+                +-----------------+

   NOTE: the upper-left corner of A in the output is retained
         because removing that one would cut an upper-left
         corner of Q.

Does it make sense to have such a function ?
How would you call it ?

--strk; 

 ()  ASCII ribbon campaign  --  Keep it simple !
 /\  http://strk.keybit.net/rants/ascii_mails.txt  



More information about the postgis-devel mailing list