mercator

package module
v0.0.0-...-fca336d Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: MIT Imports: 1 Imported by: 29

README

mercator

Mercator coordinate system conversions

Golang port of the code from http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

Install

go get github.com/davvo/mercator

Usage

package main

import (
	"github.com/davvo/mercator"
)

var x, y, z = 1569604.8201851572, 8930630.669201756, 10
var lat, lon = mercator.MetersToLatLon(x, y)
var px, py = mercator.MetersToPixels(x, y, z)
var tx, ty = mercator.LatLonToTile(lat, lon, z)

fmt.Printf("Meters: %f, %f\n", x, y)
fmt.Printf("Lat Lon: %f, %f\n", lat, lon)
fmt.Printf("Pixels (zoom %d): %f, %f\n", z, px, py)
fmt.Printf("Tile (zoom %d): %d, %d\n", z, tx, ty)

Documentation

https://godoc.org/github.com/davvo/mercator

License

MIT

Documentation

Overview

Package mercator contains conversion tools for the Spherical Mercator coordinate system See http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LatLonToMeters

func LatLonToMeters(lat, lon float64) (float64, float64)

LatLonToMeters converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:900913

func LatLonToPixels

func LatLonToPixels(lat, lon float64, zoom int) (float64, float64)

LatLonToPixels converts given lat/lon in WGS84 Datum to pixel coordinates in given zoom level

func LatLonToTile

func LatLonToTile(lat, lon float64, zoom int) (int, int)

LatLonToTile returns tile for given lat/lon coordinates

func MetersToLatLon

func MetersToLatLon(x, y float64) (float64, float64)

MetersToLatLon converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum

func MetersToPixels

func MetersToPixels(x, y float64, zoom int) (float64, float64)

MetersToPixels converts EPSG:900913 to pixel coordinates in given zoom level

func MetersToTile

func MetersToTile(x, y float64, zoom int) (int, int)

MetersToTile returns tile for given mercator coordinates

func PixelsToLatLon

func PixelsToLatLon(px, py float64, zoom int) (float64, float64)

PixelsToLatLon converts pixel coordinates in given zoom level to lat/lon in WGS84 Datum

func PixelsToMeters

func PixelsToMeters(px, py float64, zoom int) (float64, float64)

PixelsToMeters converts pixel coordinates in given zoom level of pyramid to EPSG:900913

func PixelsToTile

func PixelsToTile(px, py float64) (int, int)

PixelsToTile returns a tile covering region in given pixel coordinates

func Resolution

func Resolution(zoom int) float64

Resolution calculates the resolution (meters/pixel) for given zoom level (measured at Equator)

func Zoom

func Zoom(resolution float64) int

Zoom gives the zoom level for given resolution (measured at Equator)

Types

This section is empty.

Jump to

Keyboard shortcuts

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