deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Ability to specify local/WGS84 coordinates for MVTLayer

Open NgoKnows opened this issue 4 years ago • 0 comments

Target Use case

So right now MVTLayer does some logic internally to determine if the coordinates should be local or WGS84 (not clear on what this.context.viewport.resolution represents). Which I understand is done for performance reasons. However that means within accessors the coordinates are in local format, and as far as I can see there is no way to get access to the tile that the feature belongs to while within an accessor to do any sort of conversion to WGS84. So needing to do anything with the coordinates like checking if they intersect with a geometry that is in WGS84 wouldn't be possible.

Proposed feature

I would propose allowing users to be able to easily configure the format and potentially opting out of the performance improvements associated with using local coordinates.

I would suggest first pulling out the isWGS84 logic in mvt-layer.js into a getter, like this

get isWGS84() {
  return this.context.viewport.resolution;
}

then using this getter in the various spots where this check is being used in mvt-layer.js. Which I think is probably a worthwhile change regardless. Then this would also allow for users to extend MVTLayer, and do something like

get isWGS84() {
  return true;
}

An additional change could be adding a coordinateFormat property to MVTLayer that allows for users to specify the format that gets passed to MVTLoader.

I was able to accomplish this in userland by extending MVTLayer, but needed to essentially overwrite (but mostly copy) the logic for getTileData and getPickingInfo. But that's a bit hacky and not resilient to future updates to mvt-layer.

To Do List

  • [ ] Add label and assign to milestone
  • [ ] Coding
  • [ ] Doc update
  • [ ] What’s new update
  • [ ] Test

NgoKnows avatar Jul 22 '21 19:07 NgoKnows