2.0 KiB
Nearest Analysis Worker
Processes nearest neighbor analysis jobs between two datasets.
Overview
The nearest analysis worker finds the nearest features from a target dataset for each feature in a source dataset.
Job Type
nearest
Input Parameters
{
"source_dataset_id": 123,
"target_dataset_id": 124,
"max_distance": 5000,
"limit": 1
}
Parameters
source_dataset_id(required): Source dataset IDtarget_dataset_id(required): Target dataset IDmax_distance(optional): Maximum search distance in dataset unitslimit(optional): Maximum neighbors per feature (default: 1)
Output
Creates a new dataset with nearest neighbor results:
- Original source feature geometry
- Nearest target feature information
- Distance to nearest neighbor
- Attributes from both source and target features
Algorithm
The worker uses PostGIS functions to:
- For each source feature, find nearest target features
- Calculate distances using spatial indexes
- Apply distance and limit constraints
- Join attributes from both datasets
- Store results in output table
Example
# Enqueue a nearest analysis job via API
curl -X POST "https://example.com/api/nearest_run.php" \
-H "Content-Type: application/json" \
-d '{
"source_dataset_id": 123,
"target_dataset_id": 124,
"max_distance": 5000,
"limit": 1
}'
# Worker processes the job automatically
Background Jobs
This analysis runs as a background job. The worker:
- Fetches queued
nearestjobs - Validates input parameters
- Executes PostGIS nearest neighbor queries
- Creates output dataset
- Marks job as completed
Performance Considerations
- Processing time depends on dataset sizes
- Spatial indexes are critical for performance
- Large max_distance values may slow processing
- Consider limiting results per feature
PostGIS
Mobile
QGIS
MapBender
GeoServer
GeoNode
GeoNetwork
Novella
Solutions