Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: SpatialIndex

dojo.require("esri.process.SpatialIndex")

Description

(Added at v3.9)
Builds and maintains a spatial index of feature geometry in one or more FeatureLayer.

Samples

Search for samples that use this class.

Class hierarchy

esri/process.Processor
|_esri/process.SpatialIndex

Constructors

NameSummary
new esri.process.SpatialIndex(options?)Creates a SpatialIndex.

Properties

NameTypeSummary
drawFeaturesBooleanAllow the feature layer to draw the features.
fetchWithWorkerBooleanShould features be fetched through the Worker.
layersFeatureLayer[]Layer(s) connected to the processor.
passFeaturesBooleanPass features back to layer without delay before processing.
requireWorkerSupportBooleanRequire support for Worker in order to use this processor.

Methods

NameReturn typeSummary
addLayer(layer)NoneAdd layer to processor.
intersects(test, layerId?, getRects?)PromiseSearches index for items which intersect the test object.
nearest(criteria, layerId?)PromiseSearches for the nearest point(s) to the passed point within the specified criteria.
removeLayer(layer)NoneRemove layer from processor.
setMap(map)NoneSynchronize the layers the processor handles with the map's GraphicsLayer and GraphicsLayer subclasses (FeatureLayer etc).
start()NoneStart the processor.
stop()NoneStop the processor.
unsetMap()NoneUnset the map and detach processor from all layers.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
startFires when the processor is started.
stopFires when the processor is stopped.
Constructor Details

new esri.process.SpatialIndex(options?)

Creates a SpatialIndex.
Parameters:
<Object> options Optional Configuration options for the processor.
options properties:
<Boolean> autostart Optional Start processing features immediately. Default is true.
<Boolean> drawFeatures Optional Whether the processor allow the feature layer to draw its features. Default is true.
<Boolean> fetchWithWorkers Optional Whether the processor do the layer's I/O via a worker. Default is false.
<Object> indexOptions Optional Index system specific options.
<String> indexType Optional The indexing system to use. Either "rtree" or "kdtree". "kdtree" is only used for points. Default is "rtree".
<FeatureLayer[]> layers Optional A FeatureLayer or array of FeatureLayers to attach the processor to. Ignored if map is provided.
<Map> map Optional Uses all FeatureLayers associated with the map in the processor. Remains in sync with the map's layers. Takes precedence over layer option.
<Boolean> passFeatures Optional Whether the processor pass the features through without modification or delay to the FeatureLayer. Default is true.
<Boolean> requireWorkerSupport Optional Whether the processor require Workers to function properly. Default is true.
Property Details

<Boolean> drawFeatures

Allow the feature layer to draw the features. This interacts with the passFeatures option. If both are true, then the layer will behave normally. If both are false, then the layer won't receive the features until the processor is finished and then won't draw them. The other combinations will either cause the features to be passed immediately, but not drawn; or passed only after processing but then drawn as normal.
Known values: true | false
Default value: true

<Boolean> fetchWithWorker

Should features be fetched through the Worker. In OnDemandMode, it is almost always faster to fetch the features via the main thread and then allow the processor to pass them to the process worker.
Known values: true | false
Default value: false
Layer(s) connected to the processor.

<Boolean> passFeatures

Pass features back to layer without delay before processing.
Known values: true | false
Default value: true

<Boolean> requireWorkerSupport

Require support for Worker in order to use this processor. The default is true. If this is the case and the client's browser does not support Workers then this process won't attach or start and the feature layer will be unaffected by this process. You should only modify this value to false with very careful consideration. Use false with extreme caution. A value of false could cause significant slow downs and even crashes on older browsers.
Known values: true | false
Default value: true
Method Details

addLayer(layer)

Add layer to processor.
Parameters:
<FeatureLayer> layer Required FeatureLayer to be added.

intersects(test, layerId?, getRects?)

Searches index for items which intersect the test object. This is a bounding box search.
Return type: Promise
Parameters:
<Point | Graphic | Extent | Number[]> test Required The point or area to intersect.
<String> layerId Optional ID assigned to the layer.
<Boolean> getRects Optional Whether to get the rectangle object with data in leaf, otherwise just get the stored data.

nearest(criteria, layerId?)

Searches for the nearest point(s) to the passed point within the specified criteria.
Return type: Promise
Parameters:
<Object> criteria Required See the object specifications table below for the structure of the criteria object.
<String> layerId Optional ID assigned to the layer.
Object Specifications:
<criteria>
<Number> count Optional The maximum number of nearest points to return.
<Number> distance Optional The maximum distance from the search point to return points.
<Function> filter Optional A function which determines if the point should be included in the results.
<Point | Number[] | Graphic> point Required (Required) The point to find the nearest neighbors.

removeLayer(layer)

Remove layer from processor.
Parameters:
<FeatureLayer> layer Required FeatureLayer to be removed.

setMap(map)

Synchronize the layers the processor handles with the map's GraphicsLayer and GraphicsLayer subclasses (FeatureLayer etc).
Parameters:
<Map> map Required The map instance to synchronize layers with.

start()

Start the processor. Normally occurs automatically. Fires the start event.

stop()

Stop the processor. Fires the stop event.

unsetMap()

Unset the map and detach processor from all layers.
Event Details
[ On Style Events | Connect Style Event ]

start

Fires when the processor is started.

stop

Fires when the processor is stopped.
Show Modal