Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Pass resolution when requesting features in an extent #1812

Closed
wants to merge 3 commits into from

2 participants

@twpayne

This PR is opened for discussion. The goal is to explore options for supporting tiled and server-simplified vector data.

In a tiled vector scheme, it is likely that the tiles covering large areas will contain simplified versions of the features compared to tiles covering small areas. If tiles covering large areas contained fully detailed features they could become very large indeed. This means that a single feature will be present in multiple tiles, and at different resolutions. This means that when rendering the feature, we have to somehow decide which version to use.

Similarly, when requesting vector data it can be helpful to specify the desired resolution so that the server can perform simplification.

There are multiple possibilities:

  • As features are loaded with a tiling strategy, replace features with the same if the newly-loaded feature is more detailed, and then rely on ol3's existing client-side simplification.
  • Maintain multiple R-Trees, say one per discrete resolution, and preferably return features from the R-Tree with the resolution corresponding to the requested resolution. Features from other resolutions can be returned if none is found at the desired resolution. This would be the vector equivalent of interim tiles.

This PR suggests a new function (currently stubbed out) forEachFeatureInExtentAtResolution to allow renderers to communicate the desired resolution to the vector source.

Comments welcome. It's not obvious to me what the best approach is here.

@twpayne twpayne referenced this pull request
Merged

ol.source.RemoteVector #1744

@twpayne

Does anyone have any comments on this? It's needed for supporting vector tiles in #1744.

@fredj
Owner

LGTM

@twpayne

Thanks for the review @fredj, I've merged the code into #1744 where it was needed for the initial tile-vector implementation.

@twpayne twpayne closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  src/ol/renderer/canvas/canvasvectorlayerrenderer.js
@@ -203,7 +203,8 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
var tolerance = frameStateResolution / (2 * pixelRatio);
var replayGroup = new ol.render.canvas.ReplayGroup(tolerance, extent,
frameStateResolution);
- vectorSource.forEachFeatureInExtent(extent,
+ vectorSource.forEachFeatureInExtentAtResolution(
+ extent, frameStateResolution / pixelRatio,
/**
* @param {ol.Feature} feature Feature.
*/
View
3  src/ol/source/imagevectorsource.js
@@ -115,7 +115,8 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
resolution);
var loading = false;
- this.source_.forEachFeatureInExtent(extent,
+ this.source_.forEachFeatureInExtentAtResolution(
+ extent, resolution / pixelRatio,
/**
* @param {ol.Feature} feature Feature.
*/
View
15 src/ol/source/vectorsource.js
@@ -197,6 +197,21 @@ ol.source.Vector.prototype.forEachFeatureInExtent =
/**
+ * @param {ol.Extent} extent Extent.
+ * @param {number} resolution Resolution.
+ * @param {function(this: T, ol.Feature): S} f Callback.
+ * @param {T=} opt_this The object to use as `this` in `f`.
+ * @return {S|undefined}
+ * @template T,S
+ * @todo stability experimental
+ */
+ol.source.Vector.prototype.forEachFeatureInExtentAtResolution =
+ function(extent, resolution, f, opt_this) {
+ return this.forEachFeatureInExtent(extent, f, opt_this);
+};
+
+
+/**
* @return {Array.<ol.Feature>} Features.
* @todo stability experimental
*/
Something went wrong with that request. Please try again.