Fixes for feature density computation

* The initial iteration of the recursive feature density query shouldn't
  start beyond the maximum level
* Correct off-by-one limit the rest of iterations
This commit is contained in:
Javier Goizueta
2016-05-25 11:21:12 +02:00
parent c3fada29a8
commit 803b3671d0
+2 -2
View File
@@ -326,7 +326,7 @@ AS $$
FROM ext, base FROM ext, base
), ),
seed AS ( seed AS (
SELECT xt, yt, base.z, ( SELECT xt, yt, least(base.z, _CDB_MaxOverviewLevel()), (
SELECT count(*) FROM %1$s SELECT count(*) FROM %1$s
WHERE the_geom_webmercator && CDB_XYZ_Extent(xt, yt, base.z) WHERE the_geom_webmercator && CDB_XYZ_Extent(xt, yt, base.z)
) e ) e
@@ -339,7 +339,7 @@ AS $$
WHERE the_geom_webmercator && CDB_XYZ_Extent(x*2 + xx, y*2 + yy, t.z+1) WHERE the_geom_webmercator && CDB_XYZ_Extent(x*2 + xx, y*2 + yy, t.z+1)
) )
FROM t, base, (VALUES (0, 0), (0, 1), (1, 1), (1, 0)) AS c(xx, yy) FROM t, base, (VALUES (0, 0), (0, 1), (1, 1), (1, 0)) AS c(xx, yy)
WHERE t.e > %2$s AND t.z < (base.z + %3$s) AND t.z <= _CDB_MaxOverviewLevel() WHERE t.e > %2$s AND t.z < (base.z + %3$s) AND t.z < _CDB_MaxOverviewLevel()
) )
SELECT MAX(e/ST_Area(CDB_XYZ_Extent(x,y,z))) FROM t where e > 0; SELECT MAX(e/ST_Area(CDB_XYZ_Extent(x,y,z))) FROM t where e > 0;
', reloid::text, min_features, nz, n, c, reloid::oid) ', reloid::text, min_features, nz, n, c, reloid::oid)