Changes between Version 3 and Version 4 of NewDistCalcSubGeom


Ignore:
Timestamp:
11/08/09 12:23:06 (15 years ago)
Author:
nicklas
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • NewDistCalcSubGeom

    v3 v4  
    55[[Image(illustration1.png, 300, border=1)]]
    66
    7 In postgis 1.4 this would cause 178137 * 12167 = 2 167 392 879 iterations.
    8 With the faster algorithm described in [wiki:NewDistCalcGeom2Geom How the distance calculations is done] the iterations will be very much reduced and then takes about 7 seconds. But even now there is a lot of unnecessary work done when calculating the exact distance to each and every of the sub geometries. This is how we now instead uses bounding boxes to only calculate a selection of geometries.
     7In postgis 1.4 this would cause 178137 * 12167 = 2 167 392 879 iterations. This uses about 1440 seconds (22 minutes and 20 seconds). With the faster algorithm described in [wiki:NewDistCalcGeom2Geom How the distance calculations is done] the iterations will be very much reduced and then takes about 7 seconds. But even now there is a lot of unnecessary work done when calculating the exact distance to each and every of the sub geometries. This is how we now instead uses bounding boxes to only calculate a selection of geometries.
    98
    109[[Image(illustration2.png, 300, border=1)]]
    1110
    12 Here is the bounding boxes of the two states. The first thing we do is to iterate through all combinations of bounding boxes to find the “smallest max distance” between the boxes. What we know from this value is that the distance we get here is longer or the same (if two inputed points) than the min distance we are looking  for
    13 The result is the distance along a line like this:
     11Here is the bounding boxes of the two states. Because postgis can handle nested geometrycollections, the first thing we have to du is "unwind" the collection or multi geometries so we get them in a "flat list" with all sub geometries without hierarchical order. Then we iterate through all combinations of bounding boxes to find the “smallest max distance” between the boxes. What we know from this value is that the distance we get here is longer or the same (if two inputed points) than the min distance we are looking  for. The result is the distance along a line like this:
    1412
    1513[[Image(illustration3.png, 300, border=1)]]