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

Optimize approximateTerrainHeights file for quicker page loads (Solves #6557) #7959

Merged
merged 14 commits into from
Sep 18, 2019

Conversation

tinco
Copy link
Contributor

@tinco tinco commented Jun 24, 2019

This solves #6557, it rounds the numbers in approximateTerrainHeights.json, I also added a script that performs this rounding in the Gulpfile, and left the original in approximateTerrainHeightsPrecise.json so if it ever needs updating or some other resolution that would be a simple change to the script.

@cesium-concierge
Copy link

Thank you so much for the pull request @tinco! I noticed this is your first pull request and I wanted to say welcome to the Cesium community!

The Pull Request Guidelines is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that.

  • ❌ Missing CONTRIBUTORS.md entry.
  • ❌ Missing CLA.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.
  • ❔ Unit tests were not updated.
    • Make sure you've updated tests to reflect your changes, added tests for any new code, and ran the code coverage tool.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@tinco
Copy link
Contributor Author

tinco commented Jun 25, 2019

I forgot to run the test suite, it actually tests some values with EPSILON10 which is a bit strict, but I updated the values.

Now one integration test fails that seems like I really did break something. I'm not sure what I should do to figure out what's wrong.

@tinco
Copy link
Contributor Author

tinco commented Jun 25, 2019

I tried increasing the resolution to 10cm instead of 1m, but it didn't fix it. Maybe someone could explain to me what this integration test does and we can figure it out from there.

@tinco
Copy link
Contributor Author

tinco commented Jun 25, 2019

Eh.. ok so apparently it only fails on my machine? Forget I said anything ;)

@OmarShehata
Copy link
Contributor

Thanks for doing this much needed cleanup @tinco ! We're in the middle of updating our CLA process - I'll get that sorted out in the next few days and then take a look at this.

@OmarShehata
Copy link
Contributor

Thanks for submitting a CLA @tinco ! You are officially the first person to sign using the new system 🎉

I'll try to get this reviewed sometime next week.

@OmarShehata
Copy link
Contributor

Thanks again @tinco ! A few thoughts:

  • I'm not sure if any other gulp task does not have a mirror package.json task, so perhaps add one for optimizeApproximateTerrainHeights so it can be run in the same way?
  • It might be worth adding a precision option so it can be easy to change (or that it's at least clear from a glance what it's using). Something like:
const precision = 1;
    return gulp.src('Source/Assets/approximateTerrainHeightsPrecise.json')
        .pipe(gulpJsonTransform(function(data, file) {
            Object.entries(data).forEach(function(entry) {
                var values = entry[1];
                data[entry[0]] = [Math.floor(values[0] * precision) / precision, Math.ceil(values[1] * precision) / precision ];
            });
            return data;
        }))
        .pipe(gulpRename('approximateTerrainHeights.json'))
        .pipe(gulp.dest('Source/Assets/'));
  • Perhaps add a comment in the code above the task to explain that this can be used if this file needs to be regenerated, and that this is an approximation that's used only when the terrain provider doesn't have this information etc. for context?
  • Can you fix the contributors.md merge conflict, and move CHANGES.md up to the right place? I did it in this commit b32e489 but I can't seem to push directly to this PR.

Otherwise, this looks like a pretty straightforward change that shaves off a good ~300 kb. @mramato when you get a chance, sometime before the next release, can you take a second look here? The extra dependency is only a dev dependency so I think it should be OK here.

@tinco
Copy link
Contributor Author

tinco commented Aug 8, 2019

Thanks, applied all the changes you suggested :) hadn't seen the package.json commands

@cesium-concierge
Copy link

Thanks again for your contribution @tinco!

No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy?

I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with @cesium-concierge stop. If you want me to start again, just delete the comment.

@hpinkos
Copy link
Contributor

hpinkos commented Sep 18, 2019

Works great @tinco, thanks! I executed your script to change approximateTerrainHeights.json to use 2 degrees of precision. This keeps it at centimeter precision but reduces the file size from 517KB to 268KB

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.

4 participants