Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output cartesian coordinates instead of lon/lat #70

Closed
wants to merge 1 commit into from

Conversation

jesusbotella
Copy link

@jesusbotella jesusbotella commented Feb 4, 2020

I’m trying to use CARTESIAN coordinate system with Deck.gl, and that’s why I am modifying this code to return unprojected coordinates in toUnprojectedJSON as a test.

So, to provide some context, in our MVTTileLayer PR, they suggested us to use CARTESIAN coordinate system to avoid projecting and unprojecting points, and use common space positions when rendering our layer.

To support that, they made a PR to support pre-projected positions in Deck.gl which is this one: visgl/deck.gl#4140.

So, taking into account those changes, I am changing the code to get MVT points without converting coordinates into WGS84, and get those X, Y points from coordinates’ origin.

I modified loadGeometry method and created another one named getFlatGeometryAndHoles which returns geometry points from (0,0) taking into account tile index as you can see here:
https://github.com/mapbox/vector-tile-js/pull/70/files#diff-eb2dc36e72f5c177fb8b5df20dc67768R77-R78

I made a little test with Deck.gl PolygonLayer and it’s not working as expected.

I tried without updating Deck.gl with the latest changes first (because I forgot to update), and the polygons were kinda there but much closer to null island than where they should be.

After updating, I see no geometries.

So there’s something that I’m definitely missing. This PR is very WIP, so try not to be bothered by method names.

Researching a bit more on the library, it uses this function to project the points: https://github.com/CartoDB/vector-tile-js/blob/master/lib/vectortilefeature.js#L137-L145. And it sums the points with the tile coordinate origin.

I guess that I’m not getting that common space positions right :(

@jesusbotella jesusbotella changed the title Test for cartesian coordenates Output cartesian coordinates instead of lon/lat Feb 4, 2020
@jesusbotella
Copy link
Author

The "cartesian" coordinates that I get are like:

{ x: 2542, y: 6150 }
{ x: 2543, y: 6144 }

Which are higher numbers for a dataset containing polygons in the US.

This is what I get when trying with values like:

{ x: 10, y: 10 }
{ x: 50, y: 30 }
{ x: 300, y: 250 }
{ x: 10, y: 10 }

Screenshot 2020-02-04 at 16 23 35

So the cartesian coordinates are much higher that what they should be.

@jesusbotella
Copy link
Author

Sorry, that was meant for our fork!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant