Hi,
we are performing spatial queries on multiple feature layers at once. At some cases the given geometry is pretty big and causes performance issues.
I am looking for a way to limit the query in time or amount instead of waiting til end or aborting it at al.
This is my current code:
const bufferGeometry = bufferOperator.execute(centerFeature.geometry!, 200, { unit: "meters"});
const bufferSearchResult = await Promise.all(searchLayers.map((l: FeatureLayer) => {
const query = l.createQuery();
query.geometry = bufferGeometry
return l.queryFeatures(query);
}))
I could make a timeout on the promise, but that way I am not getting any result at all.
I could limit the results after the query has finisehd but this needs the query to fully perform.
Both is not suitable for us.
Best case we are looking for can:
- limit the query running in time and return all results found so far
- limit the query running by a maximum of results and return as soon as the maximum is reached
Hope to see some ideas, thanks.
Solved! Go to Solution.
Just found the num-property which does exactly what I was looking for, limiting the number of results and (hopefully) breaking the seach.
This indirectly affects the runtime, so a limitation over time may be optional.
Full code:
const bufferGeometry = bufferOperator.execute(centerFeature.geometry!, 200, { unit: "meters"});
const bufferSearchResult = await Promise.all(searchLayers.map((l: FeatureLayer) => {
const query = l.createQuery();
query.geometry = bufferGeometry;
return l.queryFeatures(query);
}))
Just found the num-property which does exactly what I was looking for, limiting the number of results and (hopefully) breaking the seach.
This indirectly affects the runtime, so a limitation over time may be optional.
Full code:
const bufferGeometry = bufferOperator.execute(centerFeature.geometry!, 200, { unit: "meters"});
const bufferSearchResult = await Promise.all(searchLayers.map((l: FeatureLayer) => {
const query = l.createQuery();
query.geometry = bufferGeometry;
return l.queryFeatures(query);
}))
Hi Sebastian,
If possible, instead of creating a buffer geometry yourself, use the Query.distance and Query.unit to send the buffer parameters to the server and let it do it.