Class: ServerVector

Mapspace.source. ServerVector

Layer source that extract its features from a server connection. This class is not intended to be instantiated but to be used as a common base class to all the vector sources that connect to servers.

This source inherits from ol.source.Vector adding the default configuration needed.


<abstract> new ServerVector( [options])

Parameters:
Name Type Argument Description
options Mapspace.source.ServerVectorOptions <optional>

Options.

Source:
mapspace/source/servervector.js

Extends

  • ol.source.Vector

Methods


<static> loadingstrategyNone(extent, resolution)

Strategy function for never loading features based on extent. This is useful for oblique viewers, where the moment to load features must be set manually and not automatically controled by extent changes.

Parameters:
Name Type Description
extent ol.Extent

Extent.

resolution number

Resolution.

Source:
mapspace/source/servervector.js
Returns:

Returns an empty array.

Type
Array.<ol.Extent>

<static> loadingstrategyValid(extent, resolution)

Strategy function for only loading features that has a valid extent.

Parameters:
Name Type Description
extent ol.Extent

Extent.

resolution number

Resolution.

Source:
mapspace/source/servervector.js
Returns:

Returns an empty array.

Type
Array.<ol.Extent>

<static> loadingstrategyValidAnResolution(extent, resolution)

Strategy function for only loading features that has a valid extent and resolution.

Parameters:
Name Type Description
extent ol.Extent

Extent.

resolution number

Resolution.

Source:
mapspace/source/servervector.js
Returns:

Returns an empty array.

Type
Array.<ol.Extent>

clear( [opt_fast])

Remove all features from the source.

Parameters:
Name Type Argument Description
opt_fast boolean <optional>

Skip dispatching events.

Source:
mapspace/source/servervector.js

clearExtent(extent)

Remove all extents cached that overlap the given extent. This is useful to allow for a later reloading of features in the given extent. If this function is not called it is not guaranteed that loading of features is done because it depends on the extents cached.

Parameters:
Name Type Description
extent Mapspace.Extent

Extent.

Source:
mapspace/source/servervector.js

clearExtents()

Remove all extents cached. This is useful when it is wanted to force a new request no matter what previous extents have been done. For example, in 3D viewers.

Source:
mapspace/source/servervector.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/servervector.js
Returns:

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

Type
Promise

getFeatureType(viewType, resolution)

Gets the best feature type to show for the given resolution.

Parameters:
Name Type Argument Description
viewType Mapspace.ViewType

The type of viewer.

resolution number <nullable>

Optional resolution. If no resolution is provided then the last feature type in the list returned by getFeatureTypesForResolutions is used.

Source:
mapspace/source/servervector.js
Returns:
Type
string

getFeatureTypesForResolutions(viewType)

Gets the array of objects that define the feature types for different resolutions.

Parameters:
Name Type Description
viewType Mapspace.ViewType

The type of viewer.

Source:
mapspace/source/servervector.js
Returns:
Type
Array.<Mapspace.FeatureTypeResolution> | undefined

getLoadingStrategy(viewType)

Gets the function that determines the strategy to load features.

A function that takes an ol.Extent and a resolution as arguments, and returns an array of ol.Extent with the extents to load. Usually this is one of the standard ol.loadingstrategy strategies.

Parameters:
Name Type Description
viewType Mapspace.ViewType

The type of viewer.

Source:
mapspace/source/servervector.js
Returns:
Type
ol.LoadingStrategy | undefined

loadAllFeatures(extent, projection, callback)

This is a new method to load features that is only useful when this source is in a layer inside a Mapspace.oblique.Viewer or Mapspace.street.Viewer. so we can load all the needed features just in one call.

A callback must be provided so when loading ends some extra actions can be taken.

Parameters:
Name Type Description
extent ol.Extent

Extent.

projection ol.proj.Projection

Projection of the extent.

callback function

Function to call each time new features are loaded.

Source:
mapspace/source/servervector.js

loadFeatures(extent, resolution, projection, featureType, strategy, callback)

This is a overriden of the ol.source.Vector#loadFeatures method.

If featureType is provided each feature type mantains a different Rtree for the extents. This way the source doesn't find an extent as already loaded when a different feature type has been requested.

An optional callback can be provided so when loading ends some extra actions can be taken.

Parameters:
Name Type Argument Description
extent ol.Extent

Extent.

resolution number

Resolution.

projection ol.proj.Projection

Projection of the extent.

featureType string <nullable>

Optional feature type to use.

strategy ol.LoadingStrategy <nullable>

Optional loading strategy to use.

callback function | undefined

Optional function to call each time new features are loaded.

Source:
mapspace/source/servervector.js

notifyFeaturesChanged()

Triggers a FEATURESCHANGED event.

Source:
mapspace/source/servervector.js

resolutionToFeatureType(viewType, resolution)

Return the correct feature type name for a given resolution or null if feature types are not defined.

Parameters:
Name Type Description
viewType Mapspace.ViewType

The type of viewer.

resolution number

Resolution.

Source:
mapspace/source/servervector.js
Returns:

Feature type name or null.

Type
string

setFeatureTypesForResolutions(viewTypes, value)

Sets the array of objects that define the feature types for different resolutions.

Parameters:
Name Type Description
viewTypes Mapspace.ViewType | Array.<Mapspace.ViewType>

The types of viewer.

value Array.<Mapspace.FeatureTypeResolution> | undefined
Source:
mapspace/source/servervector.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/servervector.js

setLoadingStrategy(viewTypes, value)

Sets the function that determines the strategy to load features.

Parameters:
Name Type Description
viewTypes Mapspace.ViewType | Array.<Mapspace.ViewType>

The types of viewer.

value ol.LoadingStrategy | undefined
Source:
mapspace/source/servervector.js