Skip to content

Resolve Z units to meters - #3509

Merged
lbud merged 4 commits into
fill-extrusion-typefrom
resolve-z-to-meters
Nov 1, 2016
Merged

lbud merged 4 commits into
fill-extrusion-typefrom
resolve-z-to-meters

Conversation

@lbud

@lbud lbud commented Nov 1, 2016

Copy link
Copy Markdown
Contributor

Fixes #3385.

I branched off the fill extrusion separate type branch and would like to merge this back into there. Lint tests are passing because of the new ESLint formatting — @mourner fixed this on master. I'd like to merge this (not passing) into the fill-extrusion-type branch and then just rebase once there.

My question is this: this line is affected when the map bearing is non-zero. Then here I'm introducing a z scaling in the same matrix. Effectively this means there is a single test in map.test.js failing here, as

      Error: should be equivalent
      + expected - actual

       [
         [
           "-49.7184455522"
      -    "0.0000000000"
      +    "-0.0000000000"
         ]
         [
           "49.7184455522"
      -    "0.0000000000"
      +    "-0.0000000000"
         ]
       ]

— before toFixed that number is something like -2-13, so it introduces a miniscule change. That's the only test that fails, and all non-extrusion render tests pass; is it okay to just update this test to parse/round a bit differently to make this test pass? Or should the matrix scaling happen elsewhere/will there be unintended consequences of scaling here (after the rotateZ)?

@ansis @jfirebaugh @lucaswoj

Comment thread js/geo/transform.js Outdated
mat4.translate(m, m, [-this.x, -this.y, 0]);
mat4.scale(m, m, [1, 1,
// scale vertically to meters per pixel (inverse of ground resolution)
(Math.pow(2, this.zoom) * 512) / (2 * Math.PI * 6378137 * Math.abs(Math.cos(this.center.lat * (Math.PI / 180)))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document or split this up a bit more? maybe replace 2 * Math.PI * 6378137 with a circumferenceOfEarth constant

@ansis

ansis commented Nov 1, 2016

Copy link
Copy Markdown
Contributor

This looks good. Have you checked this visually? If you make a cube from real-world distances does it get rendered as a cube?

is it okay to just update this test to parse/round a bit differently to make this test pass?

yeah, I think so

@lbud

lbud commented Nov 1, 2016

Copy link
Copy Markdown
Contributor Author

@ansis yep
image
perfect cube in NYC
image
perfectly square building face at the equator

@lbud
lbud merged commit cc77fbd into fill-extrusion-type Nov 1, 2016
@lbud
lbud deleted the resolve-z-to-meters branch November 1, 2016 21:56
lbud pushed a commit that referenced this pull request Nov 1, 2016
* Resolve Z units to meters (and move z scaling to transform for use in future other 3D types)
Fixes #3385.
lbud pushed a commit that referenced this pull request Nov 1, 2016
* Resolve Z units to meters (and move z scaling to transform for use in future other 3D types)
Fixes #3385.
lbud pushed a commit that referenced this pull request Nov 2, 2016
* Resolve Z units to meters (and move z scaling to transform for use in future other 3D types)
Fixes #3385.
lbud pushed a commit that referenced this pull request Nov 2, 2016
* Eliminate fill-extrude-{height,base} in favor of separate fill-extrusion type

* Resolve Z units to meters  (#3509)
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.

2 participants