Git Product home page Git Product logo

gocoord's Introduction

gocoord

wercker status

在BD09,GCJ02,WGS84坐标系之间相互转换点的坐标。

  • 高德地图、腾讯地图以及谷歌**区地图使用的是GCJ-02坐标系;
  • 百度地图使用的是BD-09坐标系;
  • 底层接口(HTML5 Geolocation或iOS、安卓API)通过GPS设备获取的坐标使用的是WGS-84坐标系;

使用场景实例: 客户端或者远端的GPS设备上报GPS使用的WGS-84坐标系的点,从数据库中查找附近的点或者在百度地图或高德地图上显示某些点的位置。

可用方法

见文件gocoord_test.go

使用

go get github.com/suifengtec/gocoord

用例

源文件中导入并使用,下面是部分方法的使用示例:

package main

import (
	"fmt"
	"github.com/suifengtec/gocoord"
)

func main() {
	p := gocoord.Position{Lon: 113.739873, Lat: 34.356696}
	//gocoord.BD09ToGCJ02(p)
	// 谷歌地图显示为
	// 113.733355, 34.350604
	// 实际输出为gocoord.Position{Lon:113.73337197243862, Lat:34.350630274732744}
	fmt.Println("BD09转GCJ02")
	p2 := gocoord.BD09ToGCJ02(p)
	fmt.Printf("%#v\n", p2)

	//gocoord.BD09ToWGS84(p)
	// 实际输出为 gocoord.Position{Lon:113.7272281721665, Lat:34.351951705458674}
	fmt.Println("BD09转WGS84")
	p2 = gocoord.BD09ToWGS84(p)
	fmt.Printf("%#v\n", p2)

}

gocoord's People

Contributors

suifengtec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.