Methods
# static bboxToPointArray(bboxString, latFirst) → {Array}
Converts a bounding box string of format POLYGON((lng1 lat1, lng2 lat2,...)) (POLYGON or LINESTRING) into an
array of coordinates. The order of the latitude and longitude can be controlled by the latFirst parameter.
Parameters:
| Name | Type | Description |
|---|---|---|
bboxString |
Bounding box string to convert | |
latFirst |
True to produce LAT/LNG points, false to produce LNG/LAT points. |
array of points
Array
# static calculateAreaKmSq(geoJson) → {number}
Calculate the area of a given GeoJSON object in square kilometers. The GeoJSON object can be a FeatureCollection or a Feature.
For circle geometries, the Properties object must contain an attribute called Radius, with the radius in meters.
For features with a 'pid' property, the Properties object must contain an attribute called area_km with the area in square kilometers.
Parameters:
| Name | Type | Description |
|---|---|---|
geoJson |
Object
|
GeoJSON object to calculate the area for |
The calculated area in square kilometers
number
# static createIcon(iconUrl, iconOptions) → {Object}
Utility function to create a new marker icon with sensible defaults
Parameters:
| Name | Type | Description |
|---|---|---|
iconUrl |
String
|
The URL to the image for the marker. Mandatory. |
iconOptions |
Object
|
Object containing leaflet Icon configuration options to override the defaults. Optional. |
Leaflet Icon object
Object
# static createMarker(lat, lng, popup, markerOptions) → {Object}
Convenience utility for creating a new marker with optional configuration parameters and popup.
Parameters:
| Name | Type | Description |
|---|---|---|
lat |
Number
|
Latitude of the marker. Mandatory. |
lng |
Number
|
Longitude of the marker. Mandatory. |
popup |
String
|
Text or HTML to display in a popup when the marker is clicked. Optional. |
markerOptions |
Object
|
Standard Leaflet L.Marker configuration options. Optional. |
Leaflet L.Marker object
Object
# static getGeometryWithCirclesFromGeoJSON(geoJSON) → {*}
Utility method to take a standard GeoJSON object and change the geometry of Point types to Circle types (not
supported by the GeoJSON standard). This function assumes that the properties object of the circle features has
a property of 'point_type' with a value of 'circle', and a property of 'radius'.
I.e. this function will convert
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"point_type": "circle",
"radius": 1027747.8506951465
},
"geometry": {
"type": "Point",
"coordinates": [
122.51953124999999,
-13.410994034321702
]
}
}
]
}
into
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"point_type": "circle",
"radius": 1027747.8506951465
},
"geometry": {
"type": "Circle",
"coordinates": [
122.51953124999999,
-13.410994034321702
],
"centre": [
122.51953124999999,
-13.410994034321702
],
"radius": 1027747.8506951465
}
}
]
}
Parameters:
| Name | Type | Description |
|---|---|---|
geoJSON |
*
# static getStandardGeoJSONForCircleGeometry(geoJSON) → {GeoJSON}
Performs the opposite of #getGeometryWithCirclesFromGeoJSON to produce valid standard GeoJSON.
Parameters:
| Name | Type | Description |
|---|---|---|
geoJSON |
The modified GeoJSON to be converted back to the standard format. |
GeoJSON
# static wrapGeometryInGeoJSONFeatureCol(geometry) → {Object}
Takes a bare geoJSON geometry object, and wraps it in a full GeoJSON structure with type=FeatureCollection
Parameters:
| Name | Type | Description |
|---|---|---|
geometry |
The geoJSON geometry object to wrap |
Full GeoJSON structure with type=FeatureCollection
Object