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

Tile index shifting #9

Closed
Jule- opened this issue Nov 17, 2014 · 2 comments
Closed

Tile index shifting #9

Jule- opened this issue Nov 17, 2014 · 2 comments

Comments

@Jule-
Copy link
Contributor

Jule- commented Nov 17, 2014

Following #6 issue, I am trying to generate and use terrain in Cesium.

When I try to generate terrain for N24E032.hgt SRTM 3 file:

ctb-tile --output-dir test N24E032.hgt
0...10...20...30...40...50...60...70...80...90...100 - done.

I can find in generated directory tree th

e terrain tile test\0\2\1.terrain which must be test\0\1\0.terrain accordingly to heightmap-1.0 terrain format.

After some investigation it seems that there is a mistake in Grid.hpp file:

inline TilePoint
  pixelsToTile(const PixelPoint &pixel) const {
    i_tile tx = (i_tile) ceil(pixel.x / mTileSize),
      ty = (i_tile) ceil(pixel.y / mTileSize);

    return TilePoint(tx, ty);
  }

should be:

inline TilePoint
  pixelsToTile(const PixelPoint &pixel) const {
    i_tile tx = (i_tile) pixel.x / mTileSize,
      ty = (i_tile) pixel.y / mTileSize;

    return TilePoint(tx, ty);
  }

It seems to solve my issue.

homme pushed a commit that referenced this issue Nov 17, 2014
This addresses issue #9. Although this does not appear to be an issue on Linux
for some reason, it affected a Windows build and the logic appears sound e.g `50
/ 100` correctly resolves to tile `0` whereas `ceil(50.0 / 100)` resolves to
tile `1`.
@Jule-
Copy link
Contributor Author

Jule- commented Nov 19, 2014

Thank you!
I think I can explain this issue. On linux the method prototype ceil(int) must exist and logically it has to compile to no op while on Windows it doesn't exist so I have to force cast in float so I no longer have integer division but float division.
Well mystery solved!

@Jule- Jule- closed this as completed Nov 19, 2014
@homme
Copy link
Member

homme commented Nov 19, 2014

Ah yes, that would explain it, thanks!

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

No branches or pull requests

2 participants