Repository navigation
Use accurate meter size in Web Mercator projection - #6117
Merged
Merged
Conversation
Collaborator
Author
|
Since this is all done in the project module, I think it's possible to make this an opt-in change by introducing a new uniform. |
Pessimistress
force-pushed
the
x/project-size
branch
from
August 18, 2021 23:12
b900f07 to
849f22e
Compare
ibgreen
approved these changes
Aug 29, 2021
| // If geometry.position (vertex in common space) is populated, use it | ||
| // Otherwise use geometry.worldPosition (anchor in world space) | ||
|
|
||
| if (geometry.position.w == 0.0) { |
Collaborator
There was a problem hiding this comment.
Can this be precalculated so we don't need if statements (they tend to slow things down)?
Collaborator
Author
There was a problem hiding this comment.
Not without breaking existing layers.
This test will yield the same result for all vertices in a given layer, so there won't be any sync points.
|
|
||
| // used in printing a float into GLSL code, 1 will be 1.0 to avoid GLSL compile errors | ||
| const MAX_FRACTION_DIGITS = 5; | ||
| function getScalerType(a) { |
Collaborator
There was a problem hiding this comment.
Maybe slightly more descriptive name for this function, or some JSDoc?
Collaborator
|
As always it would be awesome to have a perf bench to measure actual performance impact on shaders. It looks fine, but we keep adding features and there is always a nagging concern. |
Pessimistress
force-pushed
the
x/project-size
branch
from
October 2, 2021 06:03
21200de to
23617ba
Compare
Pessimistress
marked this pull request as ready for review
October 2, 2021 06:05
Pessimistress
force-pushed
the
x/project-size
branch
from
October 2, 2021 06:06
23617ba to
fb2b980
Compare
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
…nd this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account a more precise latitude. The arrow layer requires a high degree of precision when placing icons. The project_size() function in deck.gl does not return a high enough level of precision. I use the latitude of the icon's position to improve accuracy and solve the issue. I tested at different latitudes and does not seem to impact performance.
antoinebhs
added a commit
to gridsuite/gridstudy-app
that referenced
this pull request
Oct 3, 2023
Regression was introduced with deck.gl 8.6 and in particular alpha4 and this commit (visgl/deck.gl#6117). In the release notes you can read that the way meters are projected in MapView has changed to take into account the Mercator projection (https://deck.gl/docs/upgrade-guide#meter-size-projection). They advise to use common units use views: new MapView({legacyMeterSizes: true}) to recover the previous behavior The legacyMeterSizes boolean does indeed restore the previous behavior, but will be removed for version 9.0. It would be possible to use common units for distanceBetweenLines, which allows offset between superimposed lines. If you do this, you'll have to modify code elsewhere to ensure that labels are correctly positioned w.r.t arrows/lines (you can't really control projections with deck.gl's TextLayer/IconLayer). Using common units, we could set the distance between lines to a distance independent of latitude. This works well, but this is problematic for the TextLayer and IconLayer, which take latitude into account. The solution adopted is to use another method than project_size() to switch from meters to common units, taking into account the arrow latitude when zoom < 12. I'm not sure why there is a change at zoomLevel = 12, but there seem to be some optimizations on the deck.gl side (see: https://github.com/visgl/deck.gl/blob/401d624c0529faaa62125714c376b3ba3b8f379f/dev-docs/RFCs/v6.1/improved-lnglat-projection-rfc.md?plain=1#L29). When zoom>12, we use the deck.gl project_size() method. I tested at different latitudes and it does not seem to impact performance.
mfrnd
added a commit
to mfrnd/deck.gl
that referenced
this pull request
Oct 1, 2026
For visgl#7064. Below zoom 12, getOffsetOrigin sets the geospatial origin to [0,0,0] for both 'lnglat' and 'cartesian' (since visgl#6117). Lnglat is corrected per vertex in the shader, but cartesian z (meters) is not, so it is scaled cos(latitude) too small, while from zoom 12 it uses the viewport latitude. Tiled TerrainLayer meshes are cartesian, so the terrain is too flat below zoom 12 (0.69 of its height at Mount St. Helens) and jumps at 12; TerrainExtension layers jump with it. In WEB_MERCATOR mode, keep the viewport center as geospatial origin for 'cartesian', so z is scaled as in WEB_MERCATOR_AUTO_OFFSET mode.
mfrnd
added a commit
to mfrnd/deck.gl
that referenced
this pull request
Oct 1, 2026
For visgl#7064. Below zoom 12, getOffsetOrigin sets the geospatial origin to [0,0,0] for both 'lnglat' and 'cartesian' (since visgl#6117). Lnglat is corrected per vertex in the shader, but cartesian z (meters) is not, so it is scaled cos(latitude) too small, while from zoom 12 it uses the viewport latitude. Tiled TerrainLayer meshes are cartesian, so the terrain is too flat below zoom 12 (0.69 of its height at Mount St. Helens) and jumps at 12; TerrainExtension layers jump with it. In WEB_MERCATOR mode, keep the viewport center as geospatial origin for 'cartesian', so z is scaled as in WEB_MERCATOR_AUTO_OFFSET mode. Update the terrain-layer and terrain-extension-drape golden images: their terrain is at zoom 11.5 and is now drawn at its true height.
mfrnd
added a commit
to mfrnd/deck.gl
that referenced
this pull request
Oct 2, 2026
For visgl#7064. Below zoom 12, getOffsetOrigin sets the geospatial origin to [0,0,0] for both 'lnglat' and 'cartesian' (since visgl#6117). Lnglat is corrected per vertex in the shader, but cartesian z (meters) is not, so it is scaled cos(latitude) too small, while from zoom 12 it uses the viewport latitude. Tiled TerrainLayer meshes are cartesian, so the terrain is too flat below zoom 12 (0.69 of its height at Mount St. Helens) and jumps at 12; TerrainExtension layers jump with it. In WEB_MERCATOR mode, keep the viewport center as geospatial origin for 'cartesian', so z is scaled as in WEB_MERCATOR_AUTO_OFFSET mode. Update the terrain-layer and terrain-extension-drape golden images: their terrain is at zoom 11.5 and is now drawn at its true height.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #6181 & discussion #6101
Before:
After:
I think the perf impact is acceptable (approximately 1 additional
cosinstruction per vertex at zoom < 12); the main question is how big of a breaking change this is. Is it major-release-worthy? All existing render tests pass as-is; the applications that will break visually are the ones using meter sizes on a global scale. @heshan0131 what is the default radius units in Kepler.gl?Change List
projectshader moduleproject_sizereturns result based on vertex positionWebMercatorViewport.projectPositionreturns result based on latitude*Units: 'pixels'and*Units: 'meters'by adjusting the*Scaleuniform. This no longer works if meter size is non-linear.TODO