tegola icon indicating copy to clipboard operation
tegola copied to clipboard

tegola.Tile returns a Tile even if given coordinates outside of the projection

Open jamesyarrington opened this issue 7 years ago • 2 comments

To Reproduce: Run this go program:

package main

import (
	"fmt"

	tegola "github.com/terranodo/tegola"
)

func main() {
	zoom := 14
	var lon, lat float64
	lon = 0
	lat = 85.1
	tile := tegola.Tile{Z: zoom, Long: lon, Lat: lat}
	x, y := tile.Deg2Num()

	fmt.Printf("The x coodinate of this tile is %v.\n", x)
	fmt.Printf("The y coodinate of this tile is %v.\n", y)
}

Expected Result: tegola.Tile should either throw an error, or return a Tile object within the bounds of the projection.

Actual Result The program runs without error, returning a negative value for the y-coordinate.

The x coodinate of this tile is 8192.
The y coodinate of this tile is -26.
Success: process exited with code 0.

jamesyarrington avatar Dec 15 '17 13:12 jamesyarrington

I think the solution here is to make the Deg2Num() return an error. This is especially important with #225 which creates a new set of New functions that should be used to init a tile.

gdey avatar Dec 15 '17 20:12 gdey

I updated Deg2Num() & Num2Deg(), but @jamesyarrington's suggestion that things like this be caught at the time of tile creation also makes a lot of sense, perhaps time for a constructor function?

JivanAmara avatar Dec 25 '17 23:12 JivanAmara