-
Notifications
You must be signed in to change notification settings - Fork 111
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
Conversation
@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 { |
There was a problem hiding this comment.
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")
}
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in next commit.
Add a utility method to generate all children tiles of a tile.