-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
WIP - support for non-mercator projections #1466
Conversation
Braindump of thoughts here:
In terms of geographical projections - the bigger fish to fry with many more holes to fall down, I think it'd look like:
This is a sizeable can of worms: there's more complexity than I can communicate in one note, and I'm sure the rest of the gl-js team can also chip in that there are performance implications of this process and data implications with the projection-related simplification that we do. |
Building on @tmcw 's comment, another thought on this: Mapbox vector tiles really encode already-projected geometries. So, given a way to build a set of vector tiles where coordinates are projected with something other than 3857, the "reproject, and then re-tile" step need not happen in gl-js, and thus need not incur a perf hit. (This assumes, however, that all the VT sources being used are encoded in the same projection.) See mapbox/tippecanoe#217 for one potential approach to building non-web-mercator vector tiles. Since GeoJSON sources rely on geojson-vt to encode users' geojson data into a vector-tile-based data structure, using GeoJSON in this approach would require adapting geojson-vt and GeoJSONSource to handle alternate an alternate projection function. On the API-side of things, a question for the Mapbox team: is it plausible that this could be limited to providing alternate implementations for |
Hmm, maybe also the |
Per chat with @anandthakker, next steps to experiment with this would be to:
I think the only invariant that we have to assume is that the projection scales logarithmically (size doubles with 1 zoom level). |
Quick update --
Did this quite easily thanks to tippecanoe's new Just used |
PSA: if you use the |
Heh, this was indeed a bit simplistic: in web mercator, x is a function of lng only and y is a function of lat only, but this is not true of other (most?) projections. So, to make this work, we'll need to remove the independent methods |
The option to constrain the map to a lnglat bounding box also only makes sense in a projection like web mercator where lnglat rectangles are projected into rectangles |
d7371c5
to
ac92d09
Compare
I think it sorta works! Check out Updating the top of the ticket with a couple of additional tasks.
|
Having mulled on this a bit, I think a fairly complete solution would be:
|
We've been thinking about changing the behaviour of
This solution looks great! 👍 |
@lucaswoj oh, shoot -- reading that ticket re: pitch/rotate made me realize that my proposal actually isn't complete after all: the So I guess we would need a |
👀 |
I am closing this PR because it has been inactive for a long time. The branch isn't going anywhere so please keep working on this feature and re-open the PR when it is ready! Let me know if you have any questions. |
👍 I do plan to return to this and follow the plan outlined above, but it may be a couple weeks, so keeping closed until then SGTM |
Editing this comment because I stupidly made this PR by "converting" the original issue. The post (and all comments) from the original issue are preserved below. ( --@anandthakker )
Steps in this quest:
debug/projection.html
and things seem to work...)constrain
option (see WIP - support for non-mercator projections #1466 (comment) )fitBounds
geojson
sources (upstream: Support multiple projections geojson-vt#57)original issue comment:
Hey mapbox team! I first want to say I'm truly blown away by what you've built here. This is really, really impressive.
Anyhow, I'm curious to know if there is any interest in support non-mercator projections? I checked out the transformation logic and the projection appears to be hard-coded.
I'm sure there are optimizations to be had by assuming a single projection, but it would be really neat to be able to provide mapbox-gl with custom projection functions: not only would this enable other "common" map formats, but would open the door for some really creative visualizations (check out this and this).
It would also make mapbox-gl an ideal candidate for non-geo-based maps, like a cross-section of a human body with organs, circulatory system, nervous system, etc.
Thanks again for all the cool tech, and for developing in the open!
Cheers,
Mike