Skip to content

RL2_GetRasterCoverageDefaults

Mark Johnson edited this page Nov 11, 2015 · 29 revisions

Retrieving of RasterDefaults

[--> 'List of Sql-Commands'] (Home#commands)

[<-- 'Index Page for RasterLite2 - Commands'] (RasterLite2-Index#commands)

[<-- 'Cutline / RasterDefaults Index'] (Cutline-Index#rasterdefaults)


Original Documentation [[RasterLite2 SQL functions - reference list)|https://www.gaia-gis.it/fossil/librasterlite2/wiki?name=sql_reference_list]]

  • RL2_GetRasterCoverageDefaults(text coverage, int parm_type, int zoom_level)

Parameters [optional parameters]:

  • coverage: chosen name of raster_coverage
  • [parm_type]: 0,1,2,3,4,5,13,14,15 [return type of result]
    • 0 : [default] - Text representation of all parms, divided by
      • ';' : between the center-point values and the zoom-level values
      • ',' : between the single values of the center-point or zoom-level
        • center_x,center_y,coverage_srid;zoom_min,zoom_default.zoom_max
    • 1 : center point as blob / geometry [without third parameter]
    • 2 : center point as ewkt [without third parameter]
    • 1 : resolution_x as double [with third parameter]
    • 2 : resolution_y as double [with third parameter]
    • 3 : zoom_min as integer
    • 4 : zoom_default as integer
    • 5 : zoom_max as integer
    • 13 : scale of zoom_min as double
    • 14 : scale of zoom_default as double
    • 15 : scale of zoom_max as double
    • 23 : resolution of zoom_min as double
    • 24 : resolution of zoom_default as double
    • 25 : resolution of zoom_max as double
    • parm_type = 1 : resolution_x as double
    • parm_type = 2 : resolution_y as double

Note:

  • when resolutions are returned
    • they correspond to the nearest resolutions found in the pyramid table

  • Sample of default usage with
    • together with the raster_coverage name
SELECT 
 coverage_name,
 RL2_GetRasterCoverageDefaults(coverage_name) AS csv_text
FROM raster_coverages;

The result of the command would then look like this:

1861.world_mercators	           -1982.3723119,-1224.5405843,3395;3,5,7
1868.rote_rathausturm_panorama	   4987.5000000,502.0000000,-1;15,17,19
1927.436b_43668	                   6400.0000000,28000.0000000,3068;16,18,20
dritte_landesaufnahme_toscana	   28.5000000,43.0000000,4805;10,13,16
dritte_landesaufnahme_toscana_dir  28.5000000,43.0000000,4805;6,13,20

  • Sample to retrieve the Zoom_Levels of min/default/max as integer
    • together with the raster_coverage name
SELECT 
 coverage_name,
 RL2_GetRasterCoverageDefaults(coverage_name,3) AS zoom_min, 
 RL2_GetRasterCoverageDefaults(coverage_name,4) AS zoom_default, 
 RL2_GetRasterCoverageDefaults(coverage_name,5) AS zoom_max
FROM raster_coverages;

The result of the command would then look like this:

1861.world_mercators	                3	5	7
1868.rote_rathausturm_panorama	       15	17	19
1927.436b_43668	                       16	18	20
dritte_landesaufnahme_toscana	       10	13	16
dritte_landesaufnahme_toscana_dir       6	13	20

  • Sample to retrieve the Scale of min/default/max Zoom-Levels as double
SELECT 
 RL2_GetRasterCoverageDefaults(coverage_name,13) AS scale_min,
 RL2_GetRasterCoverageDefaults(coverage_name,14) AS scale_double,
 RL2_GetRasterCoverageDefaults(coverage_name,15) AS scale_max
FROM raster_coverages;

The result of the command would then look like this:

6443393980.216690  6443393980.216690  1610848495.054173
     17360.034720        4340.008680        1085.002170
     10726.761716        2681.690429         670.422607
    911991.611701      113998.951462      113998.951462
   7302825.602992      114106.650047      114106.650047

  • Sample to retrieve the Min/Max-ScaleDenominator for a Wms-1.3.0 service as integer
    • together with the raster_coverage name
SELECT 
 coverage_name,
 CAST
 (
  RL2_GetRasterCoverageDefaults(coverage_name,15) AS int
 ) AS min_scale_denominator,
 CAST
 (
  RL2_GetRasterCoverageDefaults(coverage_name,13) AS int
 ) AS max_scale_denominator
FROM raster_coverages;

The result of the command would then look like this:

1861.world_mercators	                1610848495  6443393980
1868.rote_rathausturm_panorama	              1085       17360
1927.436b_43668                                670       10726
dritte_landesaufnahme_toscana               113998      911991
dritte_landesaufnahme_toscana_dir           114106     7302825

Note:

  • wmslite, which up to now, did not support the wms-specific
    • Wms-1.3.0: MinScaleDenominator and MaxScaleDenominator
    • Wms-1.1.1: ScaleHint min and max
      • int scale_hint_min=(int)min_scale_denominator/2004.40;
      • int scale_hint_max=(int)max_scale_denominator/2004.40;

now does so based on this function (without casting).


  • Sample to retrieve the Resolution of min/default/max Zoom-Levels as double
SELECT 
 RL2_GetRasterCoverageDefaults(coverage_name,23) AS resolution_min,
 RL2_GetRasterCoverageDefaults(coverage_name,24) AS resolution_default,
 RL2_GetRasterCoverageDefaults(coverage_name,25) AS resolution_max
FROM raster_coverages;

The result of the command would then look like this:

1484542.589998  1484542.589998  371135.647499
      4.000000        1.000000       0.250000
      2.471520        0.617880       0.154470
      0.001888        0.000236       0.000029
      0.030203        0.000236       0.000002

  • Sample to retrieve the y and y Resolutions from a specific raster_coverage
    • Note: coverage_name are stored in Lower case, so always use Lower
    • of the original resolution of the raster_coverage
      • which is in this case 18
        • but in the other raster_coverage are 5,17 and 13
SELECT
 RL2_GetRasterCoverageDefaults
 ( -- return resolution_x
  coverage_name,0,
   -- from zoom_default
  RL2_GetRasterCoverageDefaults(coverage_name,4)
 ) AS resolution_x_default,
 RL2_GetRasterCoverageDefaults
 ( -- return resolution_y
  coverage_name,1,
   -- from zoom_default
  RL2_GetRasterCoverageDefaults(coverage_name,4)
 ) AS resolution_y_default
FROM raster_coverages
WHERE 
 -- coverage_name are store in Lower case
 (coverage_name = Lower('1927.436B_43668'));

which bring the same results as:

SELECT
 RL2_GetRasterCoverageDefaults
 ( -- return resolution_x
  coverage_name,0,18
 ) AS resolution_x_default,
 RL2_GetRasterCoverageDefaults
 ( -- return resolution_y
  coverage_name,1,18
 ) AS resolution_y_default
FROM raster_coverages
WHERE 
 -- coverage_name are store in Lower case
 (coverage_name = Lower('1927.436B_43668'));

which is:

0.617880	0.617920

  • Sample to create a GeoTiff, using ['RL2_WriteGeoTiff'] (RL2_WriteGeoTiff)
    • in the original resolution of the raster_coverage
SELECT RL2_WriteGeoTiff
(
 coverage_name,
 coverage_name||'.'||srid||'.nocut.tif', 
 0,0, -- image-size width,height (will be calculate)
 -- SRID=3068;POLYGON((6000 27100,8800 27100,8800 30999.99999999999,6000 30999.99999999999,6000 27100))
 BuildMbr
 ( -- 1: Eiskeller ; 2: Teufelsbruch ; 3: minimal area of 312, 231 pixel where cut is used
  6000.000,27100.000, 8020.000, 29220.000,
  -- 6480.000,28600.000, 7490.000, 29070.000,
  -- 7180.000,28600.000, 7373.000, 28743.000,
  3068
 ), -- area to extract,
 -- resolution horz,vert (using base resolution)
 RL2_GetRasterCoverageDefaults
 ( -- return resolution_x
  coverage_name,0,
   -- from zoom_default
  RL2_GetRasterCoverageDefaults(coverage_name,4)
 ),
 RL2_GetRasterCoverageDefaults
 ( -- return resolution_y
  coverage_name,1,
   -- from zoom_default
  RL2_GetRasterCoverageDefaults(coverage_name,4)
 ),
 0,     -- no world-file
 'DEFLATE',     -- compression
 256 -- tile-size  (of tif)
)
FROM raster_coverages
WHERE 
 -- coverage_name are store in Lower case
 (coverage_name = Lower('1927.436B_43668'));

Note:

  • since the area being extracted
    • using BuildMbr(6000.000,27100.000, 8020.000, 29220.000,3068)
  • and the resolution of x and y is known
    • using RL2_GetRasterCoverageDefaults

the size of resulting image will be calculated automatically

  • this is done in r2dbms.c
    • rl2_resolve_image_sanity
      • which will resolve all needed parameters, where possible
      • and is used for all of the EXPORT functions
        • including those used in rl2tool.c

2015-11-11: Mark Johnson, Berlin Germany