new RegionProvider(regionType, propertiesopt, corsProxy)
- Source:
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. |
Members
_idIndex :Object
- Source:
Look-up table of attributes, for speed.
Type:
- Object
aliases :Array.<String>
- Source:
List of aliases which will be matched against if found as column headings.
Type:
- Array.<String>
analyticsWmsLayerName :String
- Source:
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
analyticsWmsServer :String
- Source:
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
bbox :Array.<Number>|undefined
- Source:
Bounding box of vector geometry [w,s,e,n] (only defined for MVT providers)
Type:
- Array.<Number> | undefined
dataReplacements :Array.<Array>
- Source:
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>
description :String
- Source:
A text description of this region type, which may feature in the user interface.
Type:
- String
disambigProp
- Source:
The property within the same WFS region that can be used for disambiguation.
layerName :String
- Source:
Name of the WMS or MVT layer where these regions are found.
Type:
- String
nameProp :String
- Source:
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
nameProp :string
- Source:
Returns the name of a field which is used to name the region in feature info.
Type:
- string
regionDisambigIdsFile :String
- Source:
JSON file for disambiguation attribute, as per regionIdsFile.
Type:
- String
regionIdsFile :String
- Source:
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
regionNames :Array.<String>
- Source:
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>
regionProp :String
- Source:
WMS attribute whose value will correspond to each region's code.
Type:
- String
regions :Array.<Object>
- Source:
Array of attributes of each region, once retrieved from the server.
Type:
- Array.<Object>
regionType :String
- Source:
String uniquely identifying this type of region (eg, 'sa4')
Type:
- String
server :String
- Source:
URL of the WMS or MVT server
Type:
- String
serverMaxNativeZoom :Number
- Source:
Maximum zoom which the server serves tiles at
Type:
- Number
serverMaxZoom :Number
- Source:
Maximum zoom which the maximum native zoom tiles can be rendered at
Type:
- Number
serverMinZoom :Number
- Source:
Minimum zoom which the server serves tiles at
Type:
- Number
serverReplacements :Array.<Array>
- Source:
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>
serverSubdomains :Array.<String>|undefined
- Source:
List of subdomains for requests to be sent to (only defined for MVT providers)
Type:
- Array.<String> | undefined
serverType :String
- Source:
Server type (either 'WMS' or 'MVT')
Type:
- String
textCode :Boolean
- Source:
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
uniqueIdProp :string
- Source:
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
Methods
findDisambigVariable(varNames) → {String}
- Source:
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. |
Returns:
The name of the first column that matches any of the given disambiguation aliases.
- Type
- String
findRegionVariable(varNames) → {String}
- Source:
Returns the region variable of the given name, matching against the aliases provided.
Parameters:
Name | Type | Description |
---|---|---|
varNames |
String | Array of variable names. |
Returns:
The name of the first column that matches any of the given aliases.
- Type
- String
getColorLookupFunc(regionValues, colorFunction) → {function}
- Source:
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. |
Returns:
Function of type f(regionIndex) { return [r,g,b,a]; } which may return undefined.
- Type
- function
getRegionFeature(region, possibleFeature) → {Promise}
- Source:
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. |
Returns:
A promise for the feature.
- Type
- Promise
loadRegionIDs() → {Promise}
- Source:
Given an entry from the region mapping config, load the IDs that correspond to it, and possibly to disambiguation properties.
Returns:
Promise with no return value.
- Type
- Promise
loadRegionNames() → {Promise}
- Source:
Load names of regions. Used for analytics region picker.
Returns:
Promise resolving to region names
- Type
- Promise
mapRegionsToIndicesInto(regionArray, disambigValuesopt, failedMatchesopt, ambiguousMatchesopt, timeIntervalsopt, timeopt) → {Array}
- Source:
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 |
time |
JulianDate |
<optional> |
The time at which to do the mapping. If undefined, the data is not time-varying. |
Returns:
Indices into this.region.
- Type
- Array
Type Definitions
colorFunction(value) → {Array.<Number>}
- Source:
Function which maps region values to color arrays.
Parameters:
Name | Type | Description |
---|---|---|
value |
Number | The value for this region. |
Returns:
Returns a colorArray in the form [r, g, b, a].
- Type
- Array.<Number>