coordinate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package coordinate provides functions to convert locations to different coordinate systems.

Index

Constants

View Source
const (
	StandardGPS  = Standard("WGS-84")
	StandardAmap = Standard("GCJ-02")
)

Variables

View Source
var (
	// ErrNotImplemented is returned when standard is not added, or conversion is not implemented.
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type Converter

type Converter interface {
	Convert(cord Coordinate, from, to Standard) (Coordinate, error)
	BatchConvert(cords []Coordinate, from, to Standard) ([]Coordinate, error)
}

type Coordinate

type Coordinate [2]float64

func BatchConvert

func BatchConvert(cs []Coordinate, from, to Standard) ([]Coordinate, error)

func Convert

func Convert(c Coordinate, from, to Standard) (Coordinate, error)

func MustBatchConvert

func MustBatchConvert(cs []Coordinate, from, to Standard) []Coordinate

MustBatchConvert same as MustBatchConvert(), but panics on error

func MustConvert

func MustConvert(c Coordinate, from, to Standard) Coordinate

MustConvert same as Convert(), but panics on error

func New

func New(lng, lat float64) Coordinate

func NewFromFloat32

func NewFromFloat32(lng, lat float32) Coordinate

func NewFromString

func NewFromString(lngstr, latstr string) (Coordinate, error)

func UTM2GPS

func UTM2GPS(in CoordinateUTM) (gps Coordinate, err error)

UTM2GPS convert Universal Transverse Mercator coordinates to a latitude and longitude

func (Coordinate) IsZero

func (s Coordinate) IsZero() bool

func (Coordinate) String

func (s Coordinate) String() string

type CoordinateUTM

type CoordinateUTM struct {
	Easting    float64
	Northing   float64
	ZoneNumber int
	ZoneLetter string
}

CoordinateUTM utm coordinate(Universal Transverse Mercator) https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

func GPS2UTM

func GPS2UTM(gps [2]float64, northern bool) (out CoordinateUTM, err error)

GPS2UTM convert latitude and longitude to Universal Transverse Mercator coordinates

type LocalConverter

type LocalConverter struct {
}

func (*LocalConverter) BatchConvert

func (c *LocalConverter) BatchConvert(cords []Coordinate, from, to Standard) ([]Coordinate, error)

func (*LocalConverter) Convert

func (c *LocalConverter) Convert(cord Coordinate, from, to Standard) (Coordinate, error)

type Standard

type Standard string

Jump to

Keyboard shortcuts

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