Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Clarify TileID value semantics - #3834

Merged
kkaefer merged 7 commits into
masterfrom
3834-split-tileids
May 10, 2016
Merged

kkaefer merged 7 commits into
masterfrom
3834-split-tileids

Conversation

@kkaefer

@kkaefer kkaefer commented Mar 8, 2016

Copy link
Copy Markdown
Member

When overzooming tiles, we currently have TileID objects that have a z value that is out of sync with the x and y value. The real z value is stored in sourceZ, but all of the functions (like .children() or .isChildOf() aren't aware of that. Instead of changing these values, we should flip the semantics and store the overzoomed z value in field that is not z.

@jfirebaugh

Copy link
Copy Markdown
Contributor

#3529 is related.

@jfirebaugh jfirebaugh mentioned this pull request Feb 11, 2016
5 tasks done
@kkaefer

kkaefer commented Feb 11, 2016

Copy link
Copy Markdown
Member Author

I'm proposing something akin to

// Has integer z/x/y coordinates
// All tiles must be derived from 0/0/0 (=no tiles outside of the main tile pyramid)
// Used for requesting data
// z is never larger than the source's maxzoom
struct TileID {
  const uint16_t z;
  const uint32_t x;
  const uint32_t y;
};

// Has integer z/x/y coordinates
// w describes tiles that are left/right of the main tile pyramid, e.g. when wrapping the world
// Used for describing what position tiles are getting rendered at (= calc the matrix)
// z is never larger than the source's maxzoom
struct UnboundedTileID {
  const int16_t w;
  const uint16_t z;
  const uint32_t x;
  const uint32_t y;
};

// Has integer z/x/y coordinates
// overscaledZ describes the zoom level this tile is intented to represent, e.g. when parsing data
// z can be larger than the source's maxzoom
struct OverscaledTileID {
  const uint16_t z;
  const uint16_t overscaledZ;
  const uint32_t x;
  const uint32_t y;
};

// Has floating point z/x/y coordinates
// Used for computing the tiles that need to be visible in the viewport
struct TileCoordinate {
  const double z;
  const double x;
  const double y;
};

@jfirebaugh

Copy link
Copy Markdown
Contributor

That's pretty close to what I suggested in #3529 (comment). Do you like UnwrappedTileID or UnboundedTileID better?

Wherever we would use OverscaledTileID, can we just use TileID + uint16_t overscaledZ instead?

@brunoabinader

Copy link
Copy Markdown
Contributor

These changes are ongoing in #3873.

@brunoabinader brunoabinader self-assigned this Feb 22, 2016
@tmpsantos

Copy link
Copy Markdown
Contributor

Could this be related: #3978 ?

@kkaefer kkaefer assigned kkaefer and unassigned brunoabinader Mar 8, 2016
@kkaefer kkaefer added in progress ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Mar 8, 2016
@kkaefer
kkaefer force-pushed the 3834-split-tileids branch 3 times, most recently from a983db8 to 194614f Compare March 11, 2016 22:32
@kkaefer
kkaefer force-pushed the 3834-split-tileids branch from 194614f to 8f3fb0c Compare March 17, 2016 11:41
@kkaefer

kkaefer commented Mar 17, 2016

Copy link
Copy Markdown
Member Author

Remaining tasks here are:

  • Move tileCover to use the new IDs
  • Calculating the set of tiles to render currently relies on a combination of overscaled and unwrapped. We should get rid of this though by changing the workflow to first ensuring that all ideal tiles (=Overscaled) are getting loaded, then iterating through the Unwrapped covering tiles and selecting the best data (or generating new unwrapped tiles in case the data for an ideal unwrapped tile isn't loaded yet.

@kkaefer
kkaefer force-pushed the 3834-split-tileids branch 2 times, most recently from 958e9b7 to 310a3d2 Compare April 6, 2016 21:14
@kkaefer kkaefer added ✓ ready for review and removed ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Apr 6, 2016
@kkaefer
kkaefer force-pushed the 3834-split-tileids branch 3 times, most recently from 253cde3 to c1075db Compare April 7, 2016 17:49
@kkaefer
kkaefer force-pushed the 3834-split-tileids branch from c1075db to 28eb164 Compare April 26, 2016 10:25
@kkaefer

kkaefer commented Apr 26, 2016

Copy link
Copy Markdown
Member Author

@jfirebaugh @tmpsantos 👀

// std::cout << " stencils);" << std::endl;
// }

} // end namespace

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.

Do we need to keep this commented code?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I left it there for debugging purposes.

@jfirebaugh

Copy link
Copy Markdown
Contributor

Is now a good time to define hash functions for *TileID and switch to std::unordered_{map,set} where appropriate (#3980)?

@kkaefer

kkaefer commented Apr 28, 2016

Copy link
Copy Markdown
Member Author

@jfirebaugh Before we do that, we should check whether this actually makes sense; *TileIDs are only 3-4 numbers which should be sufficiently fast to compare.

@kkaefer
kkaefer force-pushed the 3834-split-tileids branch 3 times, most recently from 29ec6e4 to 135d16f Compare May 9, 2016 15:49
@kkaefer

kkaefer commented May 9, 2016

Copy link
Copy Markdown
Member Author

@jfirebaugh @tmpsantos can I please get a final review on the changes?

@tmpsantos

Copy link
Copy Markdown
Contributor

From my side, 🚢

@jfirebaugh

Copy link
Copy Markdown
Contributor

Offline wants the spiral loading order as well -- the assumption is that if downloading an offline region is interrupted, it's better to have the center of the region available than the outskirts.

@kkaefer

kkaefer commented May 9, 2016

Copy link
Copy Markdown
Member Author

@jfirebaugh Offline should use an iterator generator instead of holding all tile IDs in memory?

@jfirebaugh

Copy link
Copy Markdown
Contributor

Yes, it should. Is that something that looks feasible as part of this PR?

@kkaefer

kkaefer commented May 9, 2016

Copy link
Copy Markdown
Member Author

Hmm, I think that's out of scope for this one. It's been sitting around for quite a while and I'd like to finally get it merged to pave the way for #123

@jfirebaugh

Copy link
Copy Markdown
Contributor

Ok, so revert more fully to spiral order, than merge?

@kkaefer
kkaefer force-pushed the 3834-split-tileids branch 3 times, most recently from dc8bd85 to 9528300 Compare May 10, 2016 09:04
@kkaefer

kkaefer commented May 10, 2016

Copy link
Copy Markdown
Member Author

Added back spiral loading

@kkaefer
kkaefer force-pushed the 3834-split-tileids branch 2 times, most recently from f167f75 to e854e82 Compare May 10, 2016 11:28
kkaefer added 7 commits May 10, 2016 14:50
* CanonicalTileID has z, x, and y, with x/y being within the bounds z defines. z can be anything from 0-32.
* OverscaledTileID is composed of a z value, and a canonical tile. The z value indicates the zoom level the tile is intended for. It is primarily used for indexing overscaled data tiles.
* UnwrappedTileID is composed of a wrap value, and a canonical tile. The wrap value is used for representing tiles to the left and right of the main (0/0/0 based) tile pyramid. It is primarily used for indicating the position a tile should be rendered at.
@kkaefer
kkaefer force-pushed the 3834-split-tileids branch from e854e82 to 7332ae0 Compare May 10, 2016 12:51
@kkaefer
kkaefer merged commit 7332ae0 into master May 10, 2016
@kkaefer
kkaefer deleted the 3834-split-tileids branch May 10, 2016 13:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants