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

Add ChildrenInZoomRange method #133

Merged
merged 2 commits into from
Jul 16, 2023
Merged

Add ChildrenInZoomRange method #133

merged 2 commits into from
Jul 16, 2023

Conversation

peitili
Copy link

@peitili peitili commented Jul 5, 2023

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

@peitili
Copy link
Author

peitili commented Jul 5, 2023

@paulmach would you please take a look?

maptile/tile.go Outdated
@@ -226,6 +226,31 @@ func (t Tile) Children() Tiles {
}
}

// 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
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
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
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
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
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
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
2 checks passed
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.

None yet

3 participants