mercantile

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 4 Imported by: 15

README

Mercantile - Simple Conversion of points to tile x,y,z.

GoDoc

This project is a port from a mercantile implementation in python.

Usage

package main

import m "github.com/murphy214/mercantile"
import "fmt"


func main() {
   long,lat := -90.0,40.0
   point := []float64{long,lat}


   // getting a tile id
   tileid := m.Tile(point[0],point[1],10)
   fmt.Printf("%+v\n",tileid)
   // {X:256 Y:387 Z:10}

   // getting Bounds
   bds := m.Bounds(tileid)
   fmt.Printf("%+v\n",bds)
   // {W:-90 E:-89.6484375 N:40.17887331434696 S:39.909736234537185}

   // getting children of a given tileid
   children := m.Children(tileid)
   fmt.Println(children)
   // [{512 774 11} {513 774 11} {513 775 11} {512 775 11}]

   // getting parent
   parent := m.Parent(tileid)
   fmt.Println(parent)
   // {128 193 9}

   // getting center
   center := m.Center(tileid)
   fmt.Println(center)	
   // [-89.82421875 40.04430477444207]

   // getting a string tile
   tilestr := m.Tilestr(tileid)
   fmt.Println(tilestr)
   // 256/387/10

   // getting a string tile
   strtile := m.Strtile(tilestr)
   fmt.Println(strtile)
   // {256 387 10}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Center

func Center(tileid TileID) []float64

Returns the center of a given tileid.

func IsEqual

func IsEqual(t1, t2 TileID) bool

checks to see if two tiles are equal

func PolygonTile

func PolygonTile(tileid TileID) [][][]float64

returns a polygon from a given tile

func QuadKey

func QuadKey(tileid TileID) string

tile id to quadkey copied from python mercantile library

func Tile_Geohash

func Tile_Geohash(lng float64, lat float64, zoom int) string

Returns in string format like a geohash would be

func Tilestr

func Tilestr(tileid TileID) string

Converts a tileid to tilestr representation

func TilestrFile

func TilestrFile(tileid TileID) string

Converts a tileid to tilestr representation however this str conversion can be used for filenames

Types

type Extrema

type Extrema struct {
	W float64
	E float64
	N float64
	S float64
}

Extrema structure (Bounding Box)

func Bounds

func Bounds(tileid TileID) Extrema

Returns the (lon, lat) bounding box of a tile.

type Point

type Point struct {
	X float64
	Y float64
}

Point represents a point in space.

func Ul

func Ul(tileid TileID) Point

Returns the upper left (lon, lat) of a tile.

type TileID

type TileID struct {
	X int64
	Y int64
	Z uint64
}

TileID represents the id of the tile.

func Children

func Children(tile TileID) []TileID

Returns gets the children of a given child id.

func Parent

func Parent(tileid TileID) TileID

Returns the parent of a given tileid.

func QuadkeyToTile

func QuadkeyToTile(quadkey string) TileID

takes a quadkey and converts it back to a tile value copied from python mercantile library

func Strtile

func Strtile(tileid string) TileID

From a tilestr representation back to a tileid

func Tile

func Tile(lng float64, lat float64, zoom int) TileID

Returns the (x, y, z) tile.

func TileFromString

func TileFromString(val string) TileID

this function handles one of the many formats tilestr can be in basically every delimitter that could be withina raw text tileid XYZ

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL