smart guessing optional
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ Function to generate a contour map from an scatter dataset of points, using one
|
|||||||
| method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW|
|
| method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW|
|
||||||
| classmethod | integer | 0:equals, 1: heads&tails, 2:jenks, 3:quantiles |
|
| classmethod | integer | 0:equals, 1: heads&tails, 2:jenks, 3:quantiles |
|
||||||
| steps | integer | Number of steps in the classification|
|
| steps | integer | Number of steps in the classification|
|
||||||
| max_time | integer | Max time in millisecons for processing time
|
| resolution | integer | if <= 0: max processing time in seconds (smart resolution) , if >0: resolution in meters
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
Returns a table object
|
Returns a table object
|
||||||
|
|||||||
+10
-13
@@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION CDB_Contour(
|
|||||||
IN intmethod integer,
|
IN intmethod integer,
|
||||||
IN classmethod integer,
|
IN classmethod integer,
|
||||||
IN steps integer,
|
IN steps integer,
|
||||||
IN max_time integer DEFAULT 60000
|
IN resolution integer DEFAULT -90
|
||||||
)
|
)
|
||||||
RETURNS TABLE(
|
RETURNS TABLE(
|
||||||
the_geom geometry,
|
the_geom geometry,
|
||||||
@@ -17,18 +17,11 @@ RETURNS TABLE(
|
|||||||
DECLARE
|
DECLARE
|
||||||
cell_count integer;
|
cell_count integer;
|
||||||
tin geometry[];
|
tin geometry[];
|
||||||
|
max_time integer;
|
||||||
BEGIN
|
BEGIN
|
||||||
-- calc the cell size in web mercator units
|
|
||||||
-- WITH center as (
|
|
||||||
-- SELECT ST_centroid(ST_Collect(geomin)) as c
|
|
||||||
-- )
|
|
||||||
-- SELECT
|
|
||||||
-- round(resolution / cos(ST_y(c) * pi()/180))
|
|
||||||
-- INTO cell
|
|
||||||
-- FROM center;
|
|
||||||
-- raise notice 'Resol: %', cell;
|
|
||||||
|
|
||||||
-- calc the optimal number of cells for the current dataset
|
-- calc the optimal number of cells for the current dataset
|
||||||
|
max_time := -1 * resolution;
|
||||||
SELECT
|
SELECT
|
||||||
CASE intmethod
|
CASE intmethod
|
||||||
WHEN 0 THEN round(3.7745903782 * max_time - 9.4399210051 * array_length(geomin,1) - 1350.8778213073)
|
WHEN 0 THEN round(3.7745903782 * max_time - 9.4399210051 * array_length(geomin,1) - 1350.8778213073)
|
||||||
@@ -70,9 +63,13 @@ BEGIN
|
|||||||
),
|
),
|
||||||
resolution as(
|
resolution as(
|
||||||
SELECT
|
SELECT
|
||||||
round(|/ (
|
CASE WHEN resolution <= 0 THEN
|
||||||
ST_area(geom) / cell_count
|
round(|/ (
|
||||||
)) as cell
|
ST_area(geom) / abs(cell_count)
|
||||||
|
))
|
||||||
|
ELSE
|
||||||
|
resolution
|
||||||
|
END AS cell
|
||||||
FROM envelope3857
|
FROM envelope3857
|
||||||
),
|
),
|
||||||
grid as(
|
grid as(
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ SELECT
|
|||||||
foo.*
|
foo.*
|
||||||
FROM
|
FROM
|
||||||
a,
|
a,
|
||||||
cdb_crankshaft.CDB_contour(a.g, a.vals, 0.0, 1, 3, 5, 60) foo
|
cdb_crankshaft.CDB_contour(a.g, a.vals, 0.0, 1, 3, 5, -60) foo
|
||||||
)
|
)
|
||||||
SELECT bin, avg_value from b order by bin;
|
SELECT bin, avg_value from b order by bin;
|
||||||
|
|||||||
Reference in New Issue
Block a user