Class: Vector

Mapspace.source. Vector

Extends ol.source.Vector to allow defining a projection for features and reproject features.


new Vector( [opt_options])

Parameters:
Name Type Argument Description
opt_options Mapspace.source.VectorOptions <optional>

Vector source options.

Source:
mapspace/source/vector.js

Extends

  • ol.source.Vector

Methods


addLocalFeature(feature)

Adds a feature as a local feature, and will be stored in local storage.

Parameters:
Name Type Description
feature ol.Feature

The feature.

Source:
mapspace/source/vector.js

addZValues(z)

Adds Z values to geometries, converting them to 3D. If any Z value is present in any geometry it is overwritten.

Parameters:
Name Type Description
z number

Z value.

Source:
mapspace/source/vector.js

clearLocalFeatures()

Clears the list of local features that will be stored in local storage.

Source:
mapspace/source/vector.js

createReprojected(projection)

Returns a Promise that creates a new Mapspace.source.Vector but with the features reprojected to a new projection.

Parameters:
Name Type Description
projection string | Mapspace.ProjectionInfo

Projection for the resulting features.

Source:
mapspace/source/vector.js
Returns:

A Promise that returns a Mapspace.source.Vector for the resolve function and an Error for the reject function.

Type
Promise

getLocalFeatures()

Returns the features that are stored in local storage.

Source:
mapspace/source/vector.js
Returns:
Type
Array.<ol.Feature>

hasAllZValuesZero()

Checks if this source contains Z values with all values equal to zero. This function requires to be called when hasNoZValues is true.

Source:
mapspace/source/vector.js
Returns:
Type
boolean

hasNoDegreesCoordinates()

Checks if all coordinates in the geometries of this source are suitable as degrees in EPSG:4326 WGS84 projection that any source has by default. A coordinate is a degree if X is inside the [-360,360] range and if Y is inside the [-90,90] range. The Z value is ignored in the checking. If any coordinate of any geometry inside a feature do not fit inside the ranges, then false is returned.

Source:
mapspace/source/vector.js
Returns:
Type
boolean

hasNoZValues()

Checks if this source contains Z values. If no Z values exist returns true.

Source:
mapspace/source/vector.js
Returns:
Type
boolean

isLocalFeature()

Returns true if the given feature is a local feature, stored in local storage.

Source:
mapspace/source/vector.js
Returns:
Type
boolean

loadFeaturesInLocalStorage(key)

Loads to the source any features in the local storage using the given key.

Parameters:
Name Type Description
key string

Key for the value to store.

Source:
mapspace/source/vector.js

notifyFeaturesChanged()

Triggers a FEATURESCHANGED event.

Source:
mapspace/source/vector.js

removeFeaturesInLocalStorage(key)

Removes the local features in the source from the local storage using the given key.

Parameters:
Name Type Description
key string

Key for the value to store.

Source:
mapspace/source/vector.js

removeLocalFeature(feature)

Removes a feature as a local feature, and won't be stored in local storage.

Parameters:
Name Type Description
feature ol.Feature

The feature.

Source:
mapspace/source/vector.js

removeZValues()

Removes Z values from geometries, converting them to 2D. This is here because the current lib for reading shapefiles, shp.js, has an issue reading polygons with holes that truncates Z values making them unusable. This method updates geometries so use it beafore making any reference to the geometry objects.

Source:
mapspace/source/vector.js

saveFeaturesInLocalStorage(key)

Saves the local features in the source to a local storage using the given key. Be aware that a typical feature stringyfied in JSON notation can take 1KB and that there are limitations in web browsers to local storage as explained in https://en.wikipedia.org/wiki/Web_storage.

Parameters:
Name Type Description
key string

Key for the value to store.

Source:
mapspace/source/vector.js

setFilter(filter, callback)

Sets the array of conditions for filtering features. As this is a time consuming operation, new filter should be compared with current to call only when the filter has changed. This function should not be called, and call Mapspace.layer.Vector#setFilter instead, that calls this function and also stores the filter.

Parameters:
Name Type Argument Description
filter Mapspace.Filter

The array of conditions that features must follow to be downloaded (if source is a Mapspace.layer.ServerVector) and/or rendered.

callback function <nullable>

An optional function to be called when the apply of the filter has finished.

Source:
mapspace/source/vector.js