Skip to content

Add ChildrenInZoomRange method#133

Merged
paulmach merged 2 commits intopaulmach:masterfrom
peitili:master
Jul 16, 2023
Merged

Add ChildrenInZoomRange method#133
paulmach merged 2 commits intopaulmach:masterfrom
peitili:master

Conversation

@peitili
Copy link
Copy Markdown

@peitili peitili commented Jul 5, 2023

Add a utility method to generate all children tiles of a tile.

@peitili
Copy link
Copy Markdown
Author

peitili commented Jul 5, 2023

@paulmach would you please take a look?

maptile/tile.go Outdated

// ChildrenInZoomRange returns all the children tiles of tile from ranges [zoomStart, zoomEnd], both ends inclusive.
func ChildrenInZoomRange(tile Tile, zoomStart, zoomEnd Zoom) Tiles {
if zoomStart < tile.Z || zoomEnd < tile.Z {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think this should be two checks

if !(zoomStart <= zoomEnd) {
  panic("zoomStart must be <= zoomEnd")
}

Then

if !(tile.Z <= zoomStart) {
  panic("tile.Z must be <= zoomStart")
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in the next commit.

maptile/tile.go Outdated
for d := zDeltaStart; d <= zDeltaEnd; d++ {
xTopLeft := tile.X << d
yTopLeft := tile.Y << d
dim := uint32(math.Pow(2, float64(d)))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

is this not

dim := 1 << d

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, fixed in next commit.

maptile/tile.go Outdated
res := make([]Tile, 0)

for d := zDeltaStart; d <= zDeltaEnd; d++ {
xTopLeft := tile.X << d
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

this variable seems more like left or xStart

Then the next one is more like top or yStart

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in next commit.

@paulmach paulmach merged commit ebd7887 into paulmach:master Jul 16, 2023
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.

3 participants