Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnumGeoType ¶
func EnumGeoType() (e struct { Point GeoType LineString GeoType Polygon GeoType MultiPoint GeoType MultiLineString GeoType MultiPolygon GeoType })
EnumGeoType Example: if geoType == EnumGeoType().xxx {...}
func EnumGeoTypeExampleSwitch ¶
func EnumGeoTypeExampleSwitch()
func EnumGeoTypeSwitch ¶
func EnumGeoTypeSwitch() ( point struct{ Point GeoType }, lineString struct{ LineString GeoType }, polygon struct{ Polygon GeoType }, multiPoint struct{ MultiPoint GeoType }, multiLineString struct{ MultiLineString GeoType }, multiPolygon struct{ MultiPolygon GeoType }, )
EnumGeoTypeSwitch safe switch of all values example: m.EnumGeoTypeExampleSwitch()
Types ¶
type BD09 ¶
type GCJ02 ¶
type GCJ02 struct { Longitude float64 `json:"longitude" note:"经度"` Latitude float64 `json:"latitude" note:"纬度"` }
func (GCJ02) LatCommaLngString ¶
LatCommaLngString 返回 "纬度,经度" 格式字符串 可能所有人都至少一次踩过这个坑:地理坐标点用字符串形式表示时是纬度在前,经度在后( "latitude,longitude" ), 而数组形式表示时是经度在前,纬度在后( [longitude,latitude] )—顺序刚好相反。
type GeoType ¶
type GeoType string
GeoType Source enums: {"name":"GeoType","type":"string","items":[{"field":"Point","value":"Point","tailed":", ","label":"点"},{"field":"LineString","value":"LineString","label":"线","tailed":", "},{"field":"Polygon","value":"Polygon","label":"面","tailed":", "},{"field":"MultiPoint","value":"MultiPoint","label":"多点","tailed":", "},{"field":"MultiLineString","value":"MultiLineString","label":"多线","tailed":", "},{"field":"MultiPolygon","value":"MultiPolygon","label":"多面"}]}
func NewGeoType ¶
NewGeoType Create GeoType by string
type LineString ¶
type LineString struct { Type string `json:"type" bson:"type"` Coordinates [][2]float64 `json:"coordinates" bson:"coordinates"` }
LineString GeoJSON 支持 mongo bson mysql GeoJson规范(RFC 7946)全文翻译: https://zhuanlan.zhihu.com/p/141554586 xgeo.NewLineString()
func NewLineString ¶
func NewLineString(points []Point) LineString
func NewLineStringFormRaw ¶
func NewLineStringFormRaw(lngAndLat [][2]float64) LineString
func (*LineString) Scan ¶
func (p *LineString) Scan(data interface{}) (err error)
Scan implements the SQL driver.Scanner interface and will scan the
func (LineString) String ¶
func (p LineString) String() string
String returns the WKT (Well Known Text) representation of the point. LINESTRING(1.5 2.45,3.21 4)
func (LineString) Validator ¶
func (p LineString) Validator(custom ...error) (err error)
type Point ¶
type Point struct { Type string `json:"type" bson:"type"` // []float64{longitude, latitude} []float64{经度, 纬度} // 可能所有人都至少一次踩过这个坑:地理坐标点用字符串形式表示时是纬经( "latitude,longitude" ), // 而数组形式表示时是经度在前,纬度在后( [longitude,latitude] )—顺序刚好相反。 Coordinates [2]float64 `json:"coordinates" bson:"coordinates"` }
Point GeoJSON 支持 mongo bson mysql GeoJson规范(RFC 7946)全文翻译: https://zhuanlan.zhihu.com/p/141554586 xgeo.NewPoint(xgeo.WGS84{121.48294,31.2328}) // WGS84{经度,纬度}
func NewPointFormRaw ¶
func (Point) DistanceInMeters ¶
type Polygon ¶
type Polygon struct { Type string `json:"type" bson:"type"` Coordinates [][][2]float64 `json:"coordinates" bson:"coordinates"` }
Polygon GeoJSON 支持 mongo bson GeoJson规范(RFC 7946)全文翻译: https://zhuanlan.zhihu.com/p/141554586 xgeo.NewPolygon([]xgeo.WGS84{{-1,-1}, {1, -1}, {1, 1}, {-1, -1}) // WGS84{经度,纬度}