Class: RegionProvider

RegionProvider(regionType, propertiesopt, corsProxy)

new RegionProvider(regionType, propertiesopt, corsProxy)

Instantiate a region provider by giving it an entry from the region mapping JSON file.

Parameters:
Name Type Attributes Description
regionType String

Unique text identifier.

properties Object <optional>

Properties as given in configuration file.

corsProxy CorsProxy

an instance of CorsProxy for making ajax calls.

Source:

Members

_idIndex :Object

Look-up table of attributes, for speed.

Type:
  • Object
Source:

aliases :Array.<String>

List of aliases which will be matched against if found as column headings.

Type:
  • Array.<String>
Source:

analyticsWmsLayerName :String

Name of the layer on the WMS server. Needed if the layer is a MVT layer, but the layer is also used for analytics region picker (analytics section uses WMS/WFS)

Type:
  • String
Source:

analyticsWmsServer :String

URL of WMS server. Needed if the layer is a MVT layer, but the layer is also used for analytics region picker (analytics section uses WMS/WFS)

Type:
  • String
Source:

bbox :Array.<Number>|undefined

Bounding box of vector geometry [w,s,e,n] (only defined for MVT providers)

Type:
  • Array.<Number> | undefined
Source:

dataReplacements :Array.<Array>

Array of [regex, replacement] arrays which will be applied to each user-provided ID element before matching is attempted. For example, [ [ ' (.)$' ], '' ] will convert 'Baw Baw (S)' to 'Baw Baw'

Type:
  • Array.<Array>
Source:

description :String

A text description of this region type, which may feature in the user interface.

Type:
  • String
Source:

disambigProp

The property within the same WFS region that can be used for disambiguation.

Source:

layerName :String

Name of the WMS or MVT layer where these regions are found.

Type:
  • String
Source:

nameProp :String

WMS attribute whose value can be used as a user-facing name for the region. If this property is undefined, the regions do not have names.

Type:
  • String
Source:

nameProp :string

Returns the name of a field which is used to name the region in feature info.

Type:
  • string
Source:

regionDisambigIdsFile :String

JSON file for disambiguation attribute, as per regionIdsFile.

Type:
  • String
Source:

regionIdsFile :String

The URL of a pre-generated JSON file containing just a long list of IDs for a given layer attribute, in the order of ascending feature IDs (fids). If defined, it will be used in preference to requesting those attributes from the WFS server.

Type:
  • String
Source:

regionNames :Array.<String>

Array of names of each region, once retrieved from the server. Each item in RegionProvider#regions has a corresponding item in this array at the same index. To populate this array, call RegionProvider#loadRegionNames.

Type:
  • Array.<String>
Source:

regionProp :String

WMS attribute whose value will correspond to each region's code.

Type:
  • String
Source:

regions :Array.<Object>

Array of attributes of each region, once retrieved from the server.

Type:
  • Array.<Object>
Source:

regionType :String

String uniquely identifying this type of region (eg, 'sa4')

Type:
  • String
Source:

server :String

URL of the WMS or MVT server

Type:
  • String
Source:

serverMaxNativeZoom :Number

Maximum zoom which the server serves tiles at

Type:
  • Number
Source:

serverMaxZoom :Number

Maximum zoom which the maximum native zoom tiles can be rendered at

Type:
  • Number
Source:

serverMinZoom :Number

Minimum zoom which the server serves tiles at

Type:
  • Number
Source:

serverReplacements :Array.<Array>

Array of [regex, replacement] arrays which will be applied to each ID element on the server side before matching is attempted. For example, [ [ ' (.)$' ], '' ] will convert 'Baw Baw (S)' to 'Baw Baw'

Type:
  • Array.<Array>
Source:

serverSubdomains :Array.<String>|undefined

List of subdomains for requests to be sent to (only defined for MVT providers)

Type:
  • Array.<String> | undefined
Source:

serverType :String

Server type (either 'WMS' or 'MVT')

Type:
  • String
Source:

textCode :Boolean

Whether this region type uses text codes, rather than numeric. It matters because numeric codes are treated differently by the CSV handling models.

Type:
  • Boolean
Source:

uniqueIdProp :string

Returns the name of a field which uniquely identifies each region. This field is not necessarily used for matching, or of interest to the user, but is needed for reverse lookups. This field must count from zero, and features must be returned in sorted order.

Type:
  • string
Source:

Methods

findDisambigVariable(varNames) → {String}

If a disambiguation column is known for this provider, return a column matching its description.

Parameters:
Name Type Description
varNames String

Array of variable names.

Source:
Returns:

The name of the first column that matches any of the given disambiguation aliases.

Type
String

findRegionVariable(varNames) → {String}

Returns the region variable of the given name, matching against the aliases provided.

Parameters:
Name Type Description
varNames String

Array of variable names.

Source:
Returns:

The name of the first column that matches any of the given aliases.

Type
String

getColorLookupFunc(regionValues, colorFunction) → {function}

Pre-generates a function which quickly turns a value into a colour.

Parameters:
Name Type Description
regionValues Array.<Number>

Array of values, the same length as this.regions, giving a value to each region.

colorFunction RegionProvider~colorFunction

A function which maps region values to color arrays.

Source:
Returns:

Function of type f(regionIndex) { return [r,g,b,a]; } which may return undefined.

Type
function

getRegionFeature(region, possibleFeature) → {Promise}

Gets the feature associated with a given region.

Parameters:
Name Type Description
region Object

The region.

possibleFeature Object

A feature that possibly corresponds to the region. If it does, it will be returned. Otherwise, the matching feature will be requested from the region mapping server.

Source:
Returns:

A promise for the feature.

Type
Promise

loadRegionIDs() → {Promise}

Given an entry from the region mapping config, load the IDs that correspond to it, and possibly to disambiguation properties.

Source:
Returns:

Promise with no return value.

Type
Promise

loadRegionNames() → {Promise}

Load names of regions. Used for analytics region picker.

Source:
Returns:

Promise resolving to region names

Type
Promise

mapRegionsToIndicesInto(regionArray, disambigValuesopt, failedMatchesopt, ambiguousMatchesopt, timeIntervalsopt, timeopt) → {Array}

Maps this.regions to indices into the provided regionArray. Eg. If regionArray = ['Vic', 'Qld', 'NSW'], and this.regions = ['NSW', 'Vic', 'Qld', 'WA'], then returns [2, 0, 1, undefined].

Parameters:
Name Type Attributes Description
regionArray Array

An array of the regions (eg. the column of State values from a csv file). Could be Strings or Numbers.

disambigValues Array <optional>

An array of disambiguating names/numbers for when regions alone are insufficient. Could be Strings or Numbers.

failedMatches Array <optional>

An optional empty array. If provided, indices of failed matches are appended to the array.

ambiguousMatches Array <optional>

An optional empty array. If provided, indices of matches which duplicate prior matches are appended to the array. (Eg. these are not relevant if at different times.)

timeIntervals Array.<TimeInterval> <optional>

The time intervals during which each value in regionArray applies. If undefined, the data is not time-varying.

time JulianDate <optional>

The time at which to do the mapping. If undefined, the data is not time-varying.

Source:
Returns:

Indices into this.region.

Type
Array

Type Definitions

colorFunction(value) → {Array.<Number>}

Function which maps region values to color arrays.

Parameters:
Name Type Description
value Number

The value for this region.

Source:
Returns:

Returns a colorArray in the form [r, g, b, a].

Type
Array.<Number>