Harvesting.pm

Summary
Harvesting.pm
BE4::HarvestingStores parameters and builds WMS request.
WMSDefine allowed values for attribute wms_format.
DEFAULTDefine default values for attributes.
Constructors
newHarvesting constructor.
_initChecks and stores attributes’ values.
Request methods
doRequestUrlFrom an bbox, determine the request to send to obtain what we want.
getCommandWms2workCompose the BBoxes’ array and the Wms2work call (bash function), used to obtain wanted image.
Attributes’ testers
isWmsFormatTests if format value is allowed.
Getters - Setters
getURL
getVersion
getRequest
getFormat
getLayers
getOptions
Export methods
exportForDebugReturns all harvesting’s components.

BE4::Harvesting

Exporter
BE4::Harvesting

Stores parameters and builds WMS request.

Using

use BE4::Harvesting;

# Image width and height not defined

# Harvesting object creation
my $objHarvesting = BE4::Harvesting->new({
    wms_layer   => "ORTHO_RAW_LAMB93_PARIS_OUEST",
    wms_url     => "http://localhost/wmts/rok4",
    wms_version => "1.3.0",
    wms_request => "getMap",
    wms_format  => "image/tiff"
});

OR

# Image width and height defined, style, transparent and background color (for a WMS vector)

# Harvesting object creation
my $objHarvesting = BE4::Harvesting->new({
    wms_layer   => "BDD_WLD_WM",
    wms_url     => "http://localhost/wmts/rok4",
    wms_version => "1.3.0",
    wms_request => "getMap",
    wms_format  => "image/png",
    wms_bgcolor => "0xFFFFFF",
    wms_transparent  => "FALSE",
    wms_style  => "line",
    max_width  => 1024,
    max_height  => 1024
});

Attributes

URLstring - Left part of a WMS request, before the ?.
VERSIONstring - Parameter VERSION of a WMS request : “1.3.0”.
REQUESTstring - Parameter REQUEST of a WMS request : “getMap”
FORMATstring - Parameter FORMAT of a WMS request : “image/tiff”
LAYERSstring - Layer name to harvest, parameter LAYERS of a WMS request.
OPTIONSstring - Contains style, background color and transparent parameters : STYLES=line&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE for example.  If background color is defined, transparent must be ‘FALSE’.
min_sizeinteger - Used to remove too small harvested images (full of nodata), in bytes.  Can be zero (no limit).
max_widthinteger - Max image’s pixel width which will be harvested, can be undefined (no limit).
max_heightinteger - Max image’s pixel height which will be harvested, can be undefined (no limit).

If max_width and max_height are not defined, images will be harvested all-in-one.  If defined, requested image size have to be a multiple of this size.

Summary
WMSDefine allowed values for attribute wms_format.
DEFAULTDefine default values for attributes.
Constructors
newHarvesting constructor.
_initChecks and stores attributes’ values.
Request methods
doRequestUrlFrom an bbox, determine the request to send to obtain what we want.
getCommandWms2workCompose the BBoxes’ array and the Wms2work call (bash function), used to obtain wanted image.
Attributes’ testers
isWmsFormatTests if format value is allowed.
Getters - Setters
getURL
getVersion
getRequest
getFormat
getLayers
getOptions
Export methods
exportForDebugReturns all harvesting’s components.

WMS

my %WMS

Define allowed values for attribute wms_format.

DEFAULT

my %DEFAULT

Define default values for attributes.

Constructors

new

sub new

Harvesting constructor.  Bless an instance.

Parameters (hash)

wms_layerstring - Layer to harvest.
wms_urlstring - WMS server url.
wms_versionstring - WMS version.
wms_requeststring - Request’s type.
wms_formatstring - Result’s format.
wms_bgcolorstring - Optionnal.  Hexadecimal red-green-blue colour value for the background color (white = “0xFFFFFF”).
wms_transparentboolean - Optionnal.
wms_stylestring - Optionnal.
min_sizeinteger - Optionnal.  0 by default
max_widthinteger - Optionnal.
max_heightinteger - Optionnal.  See also: _init

_init

sub _init

Checks and stores attributes’ values.

Parameters (hash)

wms_layerstring - Layer to harvest.
wms_urlstring - WMS server url.
wms_versionstring - WMS version.
wms_requeststring - Request’s type.
wms_formatstring - Result’s format.
wms_bgcolorstring - Optionnal.  Hexadecimal red-green-blue colour value for the background color (white = “0xFFFFFF”).
wms_transparentboolean - Optionnal.
wms_stylestring - Optionnal.
min_sizeinteger - Optionnal.  0 by default
max_widthinteger - Optionnal.
max_heightinteger - Optionnal.

Request methods

doRequestUrl

sub doRequestUrl

From an bbox, determine the request to send to obtain what we want.

Parameters (hash)

srsstring - Bounding box’s SRS
inversionboolean - To know if we have to reverse coordinates in the request.
bboxdouble array - Extent of the harvested image
widthinteger - Pixel width of the harvested image
heightinteger - Pixel height of the harvested image

Example

# Do a request
my $request = $objHarvesting->doRequestUrl(
    inversion => TRUE,
    srs => "EPSG:4326",
    bbox => [5,47,6,48],
    width => 4096,
    height => 4096
);

# $request =
# http://localhost/wmts/rok4?LAYERS=ORTHO_RAW_LAMB93_PARIS_OUEST&SERVICE=WMS&VERSION=1.3.0&
# REQUEST=getMap&FORMAT=image/tiff&CRS=EPSG:4326&BBOX=47,5,48,6&WIDTH=4096&HEIGHT=4096&STYLES=

getCommandWms2work

sub getCommandWms2work

Compose the BBoxes’ array and the Wms2work call (bash function), used to obtain wanted image.

Returns

a string list, the command and the harvested image format (tif, png...).  (undef, undef) if an error is occured.

Parameters

dirstring - directory, to know the final image location and where to write temporary images
srsstring - Bounding box’s SRS
inversionboolean - To know if we have to reverse coordinates in the request.
bboxdouble array - Extent of the harvested image
widthinteger - Pixel width of the harvested image
heightinteger - Pixel height of the harvested image

Example

# Obtain a "Wms2work" command
my $cmd = $objHarvesting->getCommandWms2work(
    dir => "path/image_several_requests",
    inversion => FALSE,
    srs => "WGS84",
    bbox => [10018754.17139461632,-2504688.54284865024,12523442.71424327168,0.00000000512],
    width => 4096,
    height => 4096
);

# $cmd =
# BBOXES="10018754.17139461632,-626172.13571215872,10644926.30710678016,0.00000000512
# 10644926.30710678016,-626172.13571215872,11271098.442818944,0.00000000512
# 11271098.442818944,-626172.13571215872,11897270.57853110784,0.00000000512
# 11897270.57853110784,-626172.13571215872,12523442.71424327168,0.00000000512
# 10018754.17139461632,-1252344.27142432256,10644926.30710678016,-626172.13571215872
# 10644926.30710678016,-1252344.27142432256,11271098.442818944,-626172.13571215872
# 11271098.442818944,-1252344.27142432256,11897270.57853110784,-626172.13571215872
# 11897270.57853110784,-1252344.27142432256,12523442.71424327168,-626172.13571215872
# 10018754.17139461632,-1878516.4071364864,10644926.30710678016,-1252344.27142432256
# 10644926.30710678016,-1878516.4071364864,11271098.442818944,-1252344.27142432256
# 11271098.442818944,-1878516.4071364864,11897270.57853110784,-1252344.27142432256
# 11897270.57853110784,-1878516.4071364864,12523442.71424327168,-1252344.27142432256
# 10018754.17139461632,-2504688.54284865024,10644926.30710678016,-1878516.4071364864
# 10644926.30710678016,-2504688.54284865024,11271098.442818944,-1878516.4071364864
# 11271098.442818944,-2504688.54284865024,11897270.57853110784,-1878516.4071364864
# 11897270.57853110784,-2504688.54284865024,12523442.71424327168,-1878516.4071364864"
#
# Wms2work "path/image_several_requests" "png" "tif" "4 4" "250000" "http://localhost/wms-vector?LAYERS=BDD_WLD_WM&SERVICE=WMS&VERSION=1.3.0&REQUEST=getMap&FORMAT=image/png&CRS=EPSG:3857&WIDTH=1024&HEIGHT=1024&STYLES=line&BGCOLOR=0x80BBDA&TRANSPARENT=0X80BBDA" $BBOXES

Attributes’ testers

isWmsFormat

sub isWmsFormat

Tests if format value is allowed.

Parameters (list)

wmsformatstring - Format value to test

Getters - Setters

getURL

sub getURL

getVersion

sub getVersion

getRequest

sub getRequest

getFormat

sub getFormat

getLayers

sub getLayers

getOptions

sub getOptions

Export methods

exportForDebug

sub exportForDebug

Returns all harvesting’s components.  Useful for debug.

Example

my %WMS
Define allowed values for attribute wms_format.
my %DEFAULT
Define default values for attributes.
sub new
Harvesting constructor.
sub _init
Checks and stores attributes’ values.
sub doRequestUrl
From an bbox, determine the request to send to obtain what we want.
sub getCommandWms2work
Compose the BBoxes’ array and the Wms2work call (bash function), used to obtain wanted image.
sub isWmsFormat
Tests if format value is allowed.
sub getURL
sub getVersion
sub getRequest
sub getFormat
sub getLayers
sub getOptions
sub exportForDebug
Returns all harvesting’s components.
Close