Methods
(static) exports.asFeature(geometry) → {number}
- Source:
- See:
-
- turf CONSTANT
- https://turfjs.org/docs/#feature
Encapsulates turf function https://turfjs.org/docs/#feature to create a GeoJSON feature from a GeoJSON geometry.
Parameters:
| Name | Type | Description |
|---|---|---|
geometry |
Geometry | a GeoJSON Geometry (consisting of attributes |
Returns:
a GeoJSON feature wrapping the submitted GeoJSON geometry.
- Type
- number
(static) exports.asFeatureCollection(features) → {number}
- Source:
- See:
-
- turf CONSTANT
- https://turfjs.org/docs/#featureCollection
Encapsulates turf function https://turfjs.org/docs/#featureCollection to create a GeoJSON featureCollection from an array of GeoJSON features.
Parameters:
| Name | Type | Description |
|---|---|---|
features |
Array.<Feature> | an array of GeoJSON features. |
Returns:
a GeoJSON FeatureCollection containing all the submitted features.
- Type
- number
(static) exports.getAggregationWeight(feature, weightValue) → {Feature}
Add a new weight-specific property ('aggregationWeight') to the feature. It can be utilized when aggregating lower spatial units to higher spatial units,
where relevant features might be weighted differently in an average-based aggretation process.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature, which must contain a |
weightValue |
object | the value of the aggregation weight |
Returns:
returns the submitted feature which was enriched with the submitted weight property (the property is available via feature.properties['aggregationWeight']
or via )
- Type
- Feature
(static) exports.getBaseIndicatorById(indicatorId, baseIndicatorsMap) → {FeatureCollection.<Polygon>
Acquires the base indicator with the id indicatorId from the submitted baseIndicatorsMap.
Parameters:
| Name | Type | Description |
|---|---|---|
indicatorId |
string | the name of the base indicator |
baseIndicatorsMap |
map.<string, FeatureCollection.<Polygon>> | Map containing all indicators, whereas key='meaningful name or id of the indicator' and value='indicator as GeoJSON object' (it contains duplicate entries, one for the indicator name and one for the indicator id) |
Throws:
-
if the
baseIndicatorsMapdoes not contain an entry withkey=indicatorId - Type
- Error
Returns:
returns the base indicator as FeatureCollection.<Polygon> or throws an error if the baseIndicatorsMap does not contain an entry with key=indicatorId
- Type
- FeatureCollection.<Polygon>
(static) exports.getBaseIndicatorByName(indicatorName, baseIndicatorsMap) → {FeatureCollection.<Polygon>}
Acquires the base indicator with the name indicatorName from the submitted baseIndicatorsMap.
Parameters:
| Name | Type | Description |
|---|---|---|
indicatorName |
string | the name of the base indicator |
baseIndicatorsMap |
map.<string, FeatureCollection.<Polygon>> | Map containing all indicators, whereas key='meaningful name or id of the indicator' and value='indicator as GeoJSON object' (it contains duplicate entries, one for the indicator name and one for the indicator id) |
Throws:
-
if the
baseIndicatorsMapdoes not contain an entry withkey=indicatorName - Type
- Error
Returns:
returns the base indicator as FeatureCollection.<Polygon> or throws an error if the baseIndicatorsMap does not contain an entry with key=indicatorName
- Type
- FeatureCollection.<Polygon>
(static) exports.getGeoresourceById(georesourceId, georesourcesMap) → {FeatureCollection.<(Polygon|LineString|Point)>}
Acquires the georesource with the id georesourceId from the submitted georesourcesMap.
Parameters:
| Name | Type | Description |
|---|---|---|
georesourceId |
string | the id of the georesources |
georesourcesMap |
map.<string, FeatureCollection.<(Polygon|LineString|Point)>> | Map containing all georesources, whereas key='meaningful name or id of the georesource' and value='georesourc as GeoJSON object' (it contains duplicate entries, one for the georesource's name and one for the georesource's id) |
Throws:
-
if the
georesourcesMapdoes not contain an entry withkey=georesourceId - Type
- Error
Returns:
returns the georesource as LineString|Point> or throws an error if the georesourcesMap does not contain an entry with key=georesourceId
- Type
- FeatureCollection.<(Polygon|LineString|Point)>
(static) exports.getGeoresourceByName(georesourceName, georesourcesMap) → {FeatureCollection.<(Polygon|LineString|Point)>}
Acquires the georesource with the name georesourceName from the submitted georesourcesMap.
Parameters:
| Name | Type | Description |
|---|---|---|
georesourceName |
string | the name of the georesources |
georesourcesMap |
map.<string, FeatureCollection.<(Polygon|LineString|Point)>> | Map containing all georesources, whereas key='meaningful name or id of the georesource' and value='georesourc as GeoJSON object' (it contains duplicate entries, one for the georesource's name and one for the georesource's id) |
Throws:
-
if the
georesourcesMapdoes not contain an entry withkey=georesourceName - Type
- Error
Returns:
returns the georesource as LineString|Point> or throws an error if the georesourcesMap does not contain an entry with key=georesourceName
- Type
- FeatureCollection.<(Polygon|LineString|Point)>
(static) exports.getIndicatorIdValueMap(featureCollection, targetDate) → {Map.<string, number>|null}
Aquire a map of all indicator id and value pairs for the specified targetDate, where key=id and value=indicatorValue.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection |
FeatureCollection | a valid GeoJSON FeatureCollection, whose features must contain a |
targetDate |
string | string representing the target date for which the indicator id value map shall be extracted, following the pattern |
Returns:
returns map of all indicator id and value pairs for the specified targetDate, where key=id and value=indicatorValue; or null if the features do not contain an indicator value for the specified date.
- Type
- Map.<string, number> | null
(static) exports.getIndicatorValue(feature, targetDate) → {number|null}
Aquire the feature's indicator value for the specified targetDate.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature, which must contain a |
targetDate |
string | string representing the target date for which the indicator value shall be extracted, following the pattern |
Returns:
returns the indicator value for the specified targetDate or null if the feature does not contain an indicator value for the specified date.
- Type
- number | null
(static) exports.getIndicatorValueArray(featureCollection, targetDate) → {Array.<number>|null}
Aquire the array of indicator values for the specified targetDate.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection |
FeatureCollection | a valid GeoJSON FeatureCollection, whose features must contain a |
targetDate |
string | string representing the target date for which the indicator value array shall be extracted, following the pattern |
Returns:
returns the indicator values of all features of the featureCollection for the specified targetDate or null if the features do not contain an indicator value for the specified date.
- Type
- Array.<number> | null
(static) exports.getIndicatorValueArray_fromIdValueMap(indicatorIdValueMap) → {Array.<number>}
Aquire the array of indicator values for the specified targetDate.
Parameters:
| Name | Type | Description |
|---|---|---|
indicatorIdValueMap |
Map.<string, number> | map of all indicator id and value pairs where key=id and value=indicatorValue |
Returns:
returns all numeric indicator values of all features of the indicatorIdValueMap.
- Type
- Array.<number>
(static) exports.getProcessParameterByName_asBoolean(parameterName, processParameters) → {Object.<(true|false)>}
Acquires the process parameter with the name parameterName from the submitted processParametersObject.
Parameters:
| Name | Type | Description |
|---|---|---|
parameterName |
string | the name of the process parameter |
processParameters |
Array.<Object.<string, (string|number|boolean)>> | an array containing objects representing variable additional process parameters that are required to perform the indicator computation. Each entry has properties Object.name and Object.value for name and value of the parameter. |
Throws:
-
if the
processParametersarray does not contain an entry withObject.name=parameterNameor if the parsing of the value from--> Numberthrows an error. - Type
- Error
Returns:
returns the value of the requested process parameter as String. The value is parsed as false) and returned.
Throws an error if the processParameters array does not contain an entry with Object.name=parameterName or if the parsing of the value from --> Number throws an error.
- Type
- Object.<(true|false)>
(static) exports.getProcessParameterByName_asNumber(parameterName, processParameters) → {Object.<Number>}
Acquires the process parameter with the name parameterName from the submitted processParametersObject.
Parameters:
| Name | Type | Description |
|---|---|---|
parameterName |
string | the name of the process parameter |
processParameters |
Array.<Object.<string, (string|number|boolean)>> | an array containing objects representing variable additional process parameters that are required to perform the indicator computation. Each entry has properties Object.name and Object.value for name and value of the parameter. |
Throws:
-
if the
processParametersarray does not contain an entry withObject.name=parameterNameor if the parsing of the value from--> Numberthrows an error. - Type
- Error
Returns:
returns the value of the requested process parameter as String. The value is parsed as Number and returned.
Throws an error if the processParameters array does not contain an entry with Object.name=parameterName or if the parsing of the value from --> Number throws an error.
- Type
- Object.<Number>
(static) exports.getProcessParameterByName_asString(parameterName, processParameters) → {Object.<String>}
Acquires the process parameter with the name parameterName from the submitted processParametersObject.
Parameters:
| Name | Type | Description |
|---|---|---|
parameterName |
string | the name of the process parameter |
processParameters |
Array.<Object.<string, (string|number|boolean)>> | an array containing objects representing variable additional process parameters that are required to perform the indicator computation. Each entry has properties Object.name and Object.value for name and value of the parameter. |
Throws:
-
if the
processParametersarray does not contain an entry withObject.name=parameterName - Type
- Error
Returns:
returns the value of the requested process parameter as String. Users should know the real type (i.e. number).
Throws an error if the processParameters array does not contain an entry with Object.name=parameterName
- Type
- Object.<String>
(static) exports.getPropertyValue(feature, propertyName) → {number|null}
Aquire the feature's property value for the specified propertyName.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature, which must contain a |
propertyName |
string | string representing the name of the queried property |
Returns:
returns the property value for the specified propertyName or null if the feature does not contain the relevant property.
- Type
- number | null
(static) exports.getPropertyValueArray(featureCollection, propertyName) → {Array.<Object>|null}
Aquire the array of property values for the specified propertyName.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection |
FeatureCollection | a valid GeoJSON FeatureCollection, whose features must contain a |
propertyName |
string | string representing the propertyName for which the value array shall be extracted |
Returns:
returns the property values of all features of the featureCollection for the specified propertyName or null if the features do not contain the propertyName.
- Type
- Array.<Object> | null
(static) exports.getSpatialUnitFeatureIdValue(feature) → {string}
Acquires the unique id of the submitted GeoJSON feature representing a spatial unit (i.e. city districts, building blocks, etc).
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
GeoJSONFeature.<Polygon> | the GeoJSON feature representing a spatial unit (i.e. city districts, building blocks, etc), which must accord to the KomMonitor specific data model. It then has a property named |
Returns:
returns the unique id of the submitted GeoJSON feature.
- Type
- string
(static) exports.getSpatialUnitFeatureNameValue(feature) → {string}
Acquires the unique name of the submitted GeoJSON feature representing a spatial unit (i.e. city districts, building blocks, etc).
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
GeoJSONFeature.<Polygon> | the GeoJSON feature representing a spatial unit (i.e. city districts, building blocks, etc), which must accord to the KomMonitor specific data model. It then has a property named |
Returns:
returns the unique name of the submitted GeoJSON feature.
- Type
- string
(static) exports.getTargetDateWithPropertyPrefix(targetDate) → {string}
Concatenates indicator date property prefix and submitted targetDate. I.e, for exemplar targetDate="2018-01-01" it produces targetDateWithPrefix="DATE_2018-01-01". This is necessary in order to query timeseries property values from an indicator feature.
indicatorFeature.properties[targetDate] --> null indicatorFeature.properties[targetDateWithPrefix] --> indicator value, (if timestamp is present)
Parameters:
| Name | Type | Description |
|---|---|---|
targetDate |
string | string representing the target date for which the indicator shall be computed, following the pattern |
Returns:
the targetDate string with additional prefix from constant indicator_date_prefix --> i.e. DATE_2018-01-01
- Type
- string
(static) exports.hasMultiLineString(featureCollection_geoJSON) → {boolean}
Inspects the submitted GeoJSON FeatureCollection for any features of type MultiLineString.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection_geoJSON |
FeatureCollection.<(LineString|MultiLineString)> | valid GeoJSON FeatureCollection with line geometries |
Returns:
returns true, if the featureCollection contains any features of type MultiLineString; false otherwise
- Type
- boolean
(static) exports.hasMultiPolygon(featureCollection_geoJSON) → {boolean}
Inspects the submitted GeoJSON FeatureCollection for any features of type MultiPolygon.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection_geoJSON |
FeatureCollection.<(Polygon|MultiPolygon)> | valid GeoJSON FeatureCollection with polygonal geometries |
Returns:
returns true, if the featureCollection contains any features of type MultiPolygon; false otherwise
- Type
- boolean
(static) exports.indicatorValueIsNoDataValue(feature, targetDate) → {boolean}
Checks if the features indicator value for the specified targetDate is a NoData value.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature |
targetDate |
string | string representing the target date, following the pattern |
Returns:
returns true if indicator value is NoData value (i.e. null, null or undefined)
- Type
- boolean
(static) exports.isGeoJSONFeature(feature)
Checks whether the submitted object is a valid GeoJSON feature.
The feature must contain a property "type"="Feature" and a property named geometry, which must have a coordinates array and type property.
The method does not check, if the feature contains a properties attribute.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Object | a candidate for a GeoJSON feature. |
Returns:
returns true if the object is a valid GeoJSON feature; false otherwise
(static) exports.isGeoJSONFeatureCollection(featureCollection)
Checks whether the submitted object is a valid GeoJSON FeatureCollection.
The featureCollection must contain a property "type"="FeatureCollection" and a property named features, which must have an array of valid feature objects.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection |
Object | a candidate for a GeoJSON FeatureCollection. |
Returns:
returns true if the object is a valid GeoJSON feature; false otherwise
(static) exports.isGeoJSONLineStringFeature(feature)
Checks whether the submitted object is a valid GeoJSON feature with geometryType LineString or MultiLineString.
The feature must contain a property "type"="Feature" and a property named geometry, which must have a coordinates array and MultiLineString property.
The method does not check, if the feature contains a properties attribute.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Object | a candidate for a GeoJSON LineString|MultiLineString feature. |
Returns:
returns true if the object is a valid GeoJSON LineString|MultiLineString feature; false otherwise
(static) exports.isGeoJSONPointFeature(feature)
Checks whether the submitted object is a valid GeoJSON feature with geometryType Point.
The feature must contain a property "type"="Feature" and a property named geometry, which must have a coordinates array and type=Point property.
The method does not check, if the feature contains a properties attribute.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Object | a candidate for a GeoJSON point feature. |
Returns:
returns true if the object is a valid GeoJSON point feature; false otherwise
(static) exports.isGeoJSONPolygonFeature(feature)
Checks whether the submitted object is a valid GeoJSON feature with geometryType Polygon or MultiPolygon.
The feature must contain a property "type"="Feature" and a property named geometry, which must have a coordinates array and MultiPolygon property.
The method does not check, if the feature contains a properties attribute.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Object | a candidate for a GeoJSON Polygon|MultiPolygon feature. |
Returns:
returns true if the object is a valid GeoJSON Polygon|MultiPolygon feature; false otherwise
(static) exports.isNoDataValue(value) → {boolean}
Checks if the value is a NoData value.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
object | the value object to be inspected |
Returns:
returns true if value is NoData value (i.e. null, null or undefined)
- Type
- boolean
(static) exports.log(logMessage)
Logs a custom message (i.e. to console).
Parameters:
| Name | Type | Description |
|---|---|---|
logMessage |
string | message that shall be logged. |
(static) exports.logError(logMessage)
Logs a custom error message (i.e. to console).
Parameters:
| Name | Type | Description |
|---|---|---|
logMessage |
string | message that shall be logged. |
(static) exports.minMaxNormalization_fromIdValueMap(indicatorIdValueMap) → {Map.<string, number>}
Implements a min max normalization algorithm using the formula - min) / (max - min); for an indicator id value map.
Parameters:
| Name | Type | Description |
|---|---|---|
indicatorIdValueMap |
Map.<string, number> | map of all indicator id and value pairs where key=id and value=indicatorValue |
Returns:
returns the same map object, but instead of the original indicator value the respective normalized value is set as map value for each id value map entry.
- Type
- Map.<string, number>
(static) exports.minMaxNormalization_inverted_fromIdValueMap(indicatorIdValueMap) → {Map.<string, number>}
Implements an inverted min max normalization algorithm using the formula - ((value - min) / (max - min)); for an indicator id value map.
Parameters:
| Name | Type | Description |
|---|---|---|
indicatorIdValueMap |
Map.<string, number> | map of all indicator id and value pairs where key=id and value=indicatorValue |
Returns:
returns the same map object, but instead of the original indicator value the respective normalized value is set as map value for each id value map entry.
- Type
- Map.<string, number>
(static) exports.rank_fromIdValueMap(indicatorIdValueMap) → {Map.<string, number>}
Encapsulates jStat's function https://jstat.github.io/all.html#rank to compute the corresponding ranks of the submitted indicator values for an indicator id value map.
Parameters:
| Name | Type | Description |
|---|---|---|
indicatorIdValueMap |
Map.<string, number> | map of all indicator id and value pairs where key=id and value=indicatorValue |
Returns:
returns the same map object, but instead of the original indicator value the respective rank is set as map value for each id value map entry.
- Type
- Map.<string, number>
(static) exports.replaceMultiLineStringsByLineStrings(featureCollection_geoJSON) → {FeatureCollection.<LineString>}
Replaces any feature of type MultiLineString of the submitted featureCollection by the individual features of type LineString.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection_geoJSON |
FeatureCollection.<(LineString|MultiLineString)> | valid GeoJSON FeatureCollection with line geometries (MultiLineStrings will be replaced by multiple lines). |
Returns:
the GeoJSON FeatureCollection where features of type MultiLineString have been replaced by multiple features of type LineString.
- Type
- FeatureCollection.<LineString>
(static) exports.replaceMultiPolygonsByPolygons(featureCollection_geoJSON) → {FeatureCollection.<Polygon>}
Replaces any feature of type MultiPolygon of the submitted featureCollection by the individual features of type Polygon.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection_geoJSON |
FeatureCollection.<(Polygon|MultiPolygon)> | valid GeoJSON FeatureCollection with polygonal geometries (MultiPolygons will be replaced by multiple polygons). |
Returns:
the GeoJSON FeatureCollection where features of type MultiPolygon have been replaced by multiple features of type Polygon.
- Type
- FeatureCollection.<Polygon>
(static) exports.setAggregationWeight(feature, weightValue) → {Feature}
Add a new weight-specific property ('aggregationWeight') to the feature. It can be utilized when aggregating lower spatial units to higher spatial units,
where relevant features might be weighted differently in an average-based aggretation process
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature, which must contain a |
weightValue |
object | the value of the aggregation weight - if submitted value is |
Returns:
returns the submitted feature which was enriched with the submitted weight property (the property is available via feature.properties['aggregationWeight']
or via )
- Type
- Feature
(static) exports.setIndicatorValue(feature, targetDate, value) → {Feature
Set the feature's indicator value for the specified targetDate with the specified value.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature |
targetDate |
string | string representing the target date for which the indicator value shall be set, following the pattern |
value |
number | a numeric value which shall be set as the |
Returns:
returns the GeoJSON Feature
- Type
- Feature
(static) exports.setIndicatorValue_asNoData(feature, targetDate) → {Feature}
Set the feature's indicator value for the specified targetDate s so-called DATA value, i.e. as null. I.e. if there are data protection mechanisms
that mark a certain feature's indicator value as too low, then the value must be set as NoData. Or another reason could be, that when performing spatial analysis, certain Features
simply do not contain the queried elements. To distuinguish between features whose indicator value is actually {@linkode 0}, one might set the value as {@linkode NoData}. Which can be very important when average-aggregating
indicaors from lower spatial units to upper spatial units, as {@linkode NoData} means somenhing different than {@linkode 0}.
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature |
targetDate |
string | string representing the target date for which the indicator value shall be set, following the pattern |
Returns:
returns the GeoJSON Feature
- Type
- Feature
(static) exports.setIndicatorValues_fromIdValueMap(targetFeatureCollection, targetDate, indicatorIdValueMap) → {Feature}
Set the feature's indicator value for all features of the targetFeatureCollection for the specified targetDate with the respective indicator value from the input indicatorIdValueMap.
Parameters:
| Name | Type | Description |
|---|---|---|
targetFeatureCollection |
Feature | a valid GeoJSON FeatureCollection containing all target features |
targetDate |
string | string representing the target date for which the indicator value shall be set, following the pattern |
indicatorIdValueMap |
number | a map of indicator features (key=featureId, value=indicatorValue) whose values shall be set as the respective target features indicator value for the specified |
Returns:
returns the GeoJSON FeatureCollection
- Type
- Feature
(static) exports.setPropertyValue(feature, propertyName, propertyValue) → {Feature}
Add a new property to the feature
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
Feature | a valid GeoJSON Feature, which must contain a |
propertyName |
string | string representing the name of the property |
propertyValue |
object | the value of the property |
Returns:
returns the submitted feature which was enriched with the submitted property (the property is available via feature.properties[propertyName])
- Type
- Feature
(static) exports.throwError(message)
Utility method to throw an Error object with custom message.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string | the message that the |
Throws:
-
throws an
Errorobject with custom error message - Type
- Error
(static) exports.transformMultiLineStringToLineStrings(featureCollection_geoJSON) → {Object}
Inspects the submitted GeoJSON FeatureCollection for any features of type MultiLineString and replaces them by the individual features of type LineString.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection_geoJSON |
FeatureCollection.<(LineString|MultiLineString)> | valid GeoJSON FeatureCollection with line geometries (MultiLineStrings will be transformed to multiple lines). |
Returns:
the GeoJSON FeatureCollection without any features of type MultiLineString. It may have an increased number of total features,
if any MultiLineString was replaced by its individual features of type LineString.
- Type
- Object
(static) exports.transformMultiPolygonsToPolygons(featureCollection_geoJSON) → {Object}
Inspects the submitted GeoJSON FeatureCollection for any features of type MultiPolygon and replaces them by the individual features of type Polygon.
Parameters:
| Name | Type | Description |
|---|---|---|
featureCollection_geoJSON |
FeatureCollection.<(Polygon|MultiPolygon)> | valid GeoJSON FeatureCollection with polygonal geometries (MultiPolygons will be transformed to multiple polygons). |
Returns:
the GeoJSON FeatureCollection without any features of type MultiPolygon. It may have an increased number of total features,
if any MultiPolygon was replaced by its individual features of type Polygon.
- Type
- Object