geography

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 9 Imported by: 0

README

geom

GoDoc Widget Build Status codecov Go Report Card

WIP

Geometry helpers base on .

package database

import (
	"gitee.com/go-genie/geography"
)

type Geom struct {
		ID              string                    `db:"F_id"`
    	Point           geography.Point           `db:"F_point,null"`
    	MultiPoint      geography.MultiPoint      `db:"F_multi_point,null"`
    	LineString      geography.LineString      `db:"F_line_string,null"`
    	MultiLineString geography.MultiLineString `db:"F_multi_line_string,null"`
    	Polygon         geography.Polygon         `db:"f_polygon,null"`
    	MultiPolygon    geography.MultiPolygon    `db:"f_multi_polygon,null"`
    	Geometry        geography.Geometry        `db:"f_geometry,null"`
}
  • 3857 in db
  • 4326 in go

Documentation

Index

Constants

View Source
const (
	// https://epsg.io/3857
	SRS3857 = 3857
	// https://epsg.io/4326
	SRS4326 = 4326
)
View Source
const (
	EPSLN     = 1.0e-10
	D2R       = math.Pi / 180.0
	R2D       = 180.0 / math.Pi
	A         = 6378137.0
	MAXEXTENT = 20037508.342789244
)

Variables

This section is empty.

Functions

func PseudoMercatorToWGS84

func PseudoMercatorToWGS84(x, y float64) (lon, lat float64)

func TileXYToLonLat

func TileXYToLonLat(x, y float64, zoom uint32) (lon, lat float64)

func WGS84ToPseudoMercator

func WGS84ToPseudoMercator(lon, lat float64) (x, y float64)

Types

type Bound

type Bound struct {
	Min Point
	Max Point
}

func (Bound) AsPolygon

func (b Bound) AsPolygon() *Polygon

func (Bound) Bottom

func (b Bound) Bottom() float64

func (Bound) Bound

func (b Bound) Bound() Bound

func (Bound) Cap

func (b Bound) Cap() int

func (Bound) Center

func (b Bound) Center() Point

func (Bound) Clip

func (b Bound) Clip(bound Bound) Geom

func (Bound) Contains

func (b Bound) Contains(point Point) bool

func (Bound) DataType

func (Bound) DataType(driverName string) string

func (Bound) Equal

func (b Bound) Equal(g Geom) bool

func (Bound) Extend

func (b Bound) Extend(point Point) Bound

func (Bound) Geometry

func (b Bound) Geometry() []uint32

func (Bound) Intersects

func (b Bound) Intersects(bound Bound) bool

func (Bound) IsEmpty

func (b Bound) IsEmpty() bool

func (Bound) Left

func (b Bound) Left() float64

func (Bound) LeftTop

func (b Bound) LeftTop() Point

func (Bound) Pad

func (b Bound) Pad(d float64) Bound

func (Bound) Project

func (b Bound) Project(transform Transform) Geom

func (Bound) Right

func (b Bound) Right() float64

func (Bound) RightBottom

func (b Bound) RightBottom() Point

func (Bound) ToGeom

func (b Bound) ToGeom() Geom

func (Bound) Top

func (b Bound) Top() float64

func (Bound) Type

func (Bound) Type() string

func (Bound) Union

func (b Bound) Union(other Bound) Bound

type Geom

type Geom interface {
	Clip(b Bound) Geom
	Project(transform Transform) Geom

	Type() string

	ToGeom() Geom
	Geometry() []uint32

	Bound() Bound
	Equal(g Geom) bool
}

type Geometry

type Geometry struct {
	Geom
}

func ToGeometry

func ToGeometry(g Geom) Geometry

func (Geometry) DataType

func (g Geometry) DataType(driverName string) string

func (Geometry) MarshalWKT

func (g Geometry) MarshalWKT(w *wkt.WKTWriter)

func (*Geometry) Scan

func (g *Geometry) Scan(src interface{}) error

func (Geometry) ToGeom

func (g Geometry) ToGeom() Geom

func (*Geometry) UnmarshalWKB

func (g *Geometry) UnmarshalWKB(r *wkb.WKBReader, order binary.ByteOrder, tpe wkb.GeometryType) error

func (Geometry) Value

func (g Geometry) Value() (driver.Value, error)

func (Geometry) ValueEx

func (Geometry) ValueEx() string

type LineString

type LineString []Point

func (LineString) Bound

func (ls LineString) Bound() Bound

func (LineString) Cap

func (ls LineString) Cap() int

func (LineString) Clip

func (ls LineString) Clip(b Bound) Geom

func (LineString) Closed

func (ls LineString) Closed() bool

func (LineString) DataType

func (LineString) DataType(driverName string) string

func (LineString) DrawFeature

func (ls LineString) DrawFeature(w *mvt.FeatureWriter)

func (LineString) Equal

func (ls LineString) Equal(g Geom) bool

func (LineString) Geometry

func (ls LineString) Geometry() []uint32

func (LineString) IsValid

func (ls LineString) IsValid() bool

func (LineString) MarshalWKT

func (ls LineString) MarshalWKT(w *wkt.WKTWriter)

func (LineString) Project

func (ls LineString) Project(transform Transform) Geom

func (*LineString) Scan

func (ls *LineString) Scan(src interface{}) error

func (LineString) ToGeom

func (ls LineString) ToGeom() Geom

func (LineString) Type

func (LineString) Type() string

func (*LineString) UnmarshalWKB

func (ls *LineString) UnmarshalWKB(r *wkb.WKBReader, order binary.ByteOrder, tpe wkb.GeometryType) error

func (LineString) Value

func (ls LineString) Value() (driver.Value, error)

func (LineString) ValueEx

func (LineString) ValueEx() string

type MultiLineString

type MultiLineString []LineString

func (MultiLineString) Bound

func (mls MultiLineString) Bound() Bound

func (MultiLineString) Cap

func (mls MultiLineString) Cap() int

func (MultiLineString) Clip

func (mls MultiLineString) Clip(b Bound) Geom

func (MultiLineString) DataType

func (MultiLineString) DataType(driverName string) string

func (MultiLineString) DrawFeature

func (mls MultiLineString) DrawFeature(w *mvt.FeatureWriter)

func (MultiLineString) Equal

func (mls MultiLineString) Equal(g Geom) bool

func (MultiLineString) Geometry

func (mls MultiLineString) Geometry() []uint32

func (MultiLineString) MarshalWKT

func (mls MultiLineString) MarshalWKT(w *wkt.WKTWriter)

func (MultiLineString) Project

func (mls MultiLineString) Project(transform Transform) Geom

func (*MultiLineString) Scan

func (mls *MultiLineString) Scan(src interface{}) error

func (MultiLineString) ToGeom

func (mls MultiLineString) ToGeom() Geom

func (MultiLineString) Type

func (MultiLineString) Type() string

func (*MultiLineString) UnmarshalWKB

func (mls *MultiLineString) UnmarshalWKB(r *wkb.WKBReader, order binary.ByteOrder, tpe wkb.GeometryType) error

func (MultiLineString) Value

func (mls MultiLineString) Value() (driver.Value, error)

func (MultiLineString) ValueEx

func (MultiLineString) ValueEx() string

type MultiPoint

type MultiPoint []Point

func (MultiPoint) Bound

func (mp MultiPoint) Bound() Bound

func (MultiPoint) Cap

func (mp MultiPoint) Cap() int

func (MultiPoint) Clip

func (mp MultiPoint) Clip(b Bound) Geom

func (MultiPoint) DataType

func (MultiPoint) DataType(driverName string) string

func (MultiPoint) DrawFeature

func (mp MultiPoint) DrawFeature(w *mvt.FeatureWriter)

func (MultiPoint) Equal

func (mp MultiPoint) Equal(g Geom) bool

func (MultiPoint) Geometry

func (mp MultiPoint) Geometry() []uint32

func (MultiPoint) MarshalWKT

func (mp MultiPoint) MarshalWKT(w *wkt.WKTWriter)

func (MultiPoint) Project

func (mp MultiPoint) Project(transform Transform) Geom

func (*MultiPoint) Scan

func (mp *MultiPoint) Scan(src interface{}) error

func (MultiPoint) ToGeom

func (mp MultiPoint) ToGeom() Geom

func (MultiPoint) Type

func (MultiPoint) Type() string

func (*MultiPoint) UnmarshalWKB

func (mp *MultiPoint) UnmarshalWKB(r *wkb.WKBReader, order binary.ByteOrder, tpe wkb.GeometryType) error

func (MultiPoint) Value

func (mp MultiPoint) Value() (driver.Value, error)

func (MultiPoint) ValueEx

func (MultiPoint) ValueEx() string

type MultiPolygon

type MultiPolygon []Polygon

func (MultiPolygon) Bound

func (mp MultiPolygon) Bound() Bound

func (MultiPolygon) Cap

func (mp MultiPolygon) Cap() int

func (MultiPolygon) Clip

func (mp MultiPolygon) Clip(b Bound) Geom

func (MultiPolygon) DataType

func (MultiPolygon) DataType(driverName string) string

func (MultiPolygon) DrawFeature

func (mp MultiPolygon) DrawFeature(w *mvt.FeatureWriter)

func (MultiPolygon) Equal

func (mp MultiPolygon) Equal(g Geom) bool

func (MultiPolygon) Geometry

func (mp MultiPolygon) Geometry() []uint32

func (MultiPolygon) MarshalWKT

func (mp MultiPolygon) MarshalWKT(w *wkt.WKTWriter)

func (MultiPolygon) Project

func (mp MultiPolygon) Project(transform Transform) Geom

func (*MultiPolygon) Scan

func (mp *MultiPolygon) Scan(src interface{}) error

func (MultiPolygon) ToGeom

func (mp MultiPolygon) ToGeom() Geom

func (MultiPolygon) Type

func (MultiPolygon) Type() string

func (*MultiPolygon) UnmarshalWKB

func (mp *MultiPolygon) UnmarshalWKB(r *wkb.WKBReader, order binary.ByteOrder, tpe wkb.GeometryType) error

func (MultiPolygon) Value

func (mp MultiPolygon) Value() (driver.Value, error)

func (MultiPolygon) ValueEx

func (MultiPolygon) ValueEx() string

type Point

type Point [2]float64

func (Point) Bound

func (p Point) Bound() Bound

func (Point) Cap

func (Point) Cap() int

func (Point) Clip

func (p Point) Clip(bound Bound) Geom

func (Point) DataType

func (Point) DataType(driverName string) string

func (Point) DrawFeature

func (p Point) DrawFeature(w *mvt.FeatureWriter)

func (Point) Equal

func (p Point) Equal(geom Geom) bool

func (Point) Geometry

func (p Point) Geometry() []uint32

func (Point) IsZero

func (p Point) IsZero() bool

func (Point) Lat

func (p Point) Lat() float64

func (Point) Lon

func (p Point) Lon() float64

func (Point) MarshalWKT

func (p Point) MarshalWKT(w *wkt.WKTWriter)

func (Point) Project

func (p Point) Project(transform Transform) Geom

func (*Point) Scan

func (p *Point) Scan(src interface{}) error

func (Point) ToGeom

func (p Point) ToGeom() Geom

func (Point) Type

func (Point) Type() string

func (*Point) UnmarshalWKB

func (p *Point) UnmarshalWKB(r *wkb.WKBReader, order binary.ByteOrder, tpe wkb.GeometryType) error

func (Point) Value

func (p Point) Value() (driver.Value, error)

func (Point) ValueEx

func (Point) ValueEx() string

func (Point) X

func (p Point) X() float64

func (Point) Y

func (p Point) Y() float64

type Polygon

type Polygon []LineString

Polygon is a closed area. The first Polygon is the outer ring. The others are the holes. Each Polygon is expected to be closed ie. the first point matches the last.

func (Polygon) Bound

func (p Polygon) Bound() Bound

func (Polygon) Cap

func (p Polygon) Cap() int

func (Polygon) Clip

func (p Polygon) Clip(b Bound) Geom

func (Polygon) DataType

func (Polygon) DataType(driverName string) string

func (Polygon) DrawFeature

func (p Polygon) DrawFeature(w *mvt.FeatureWriter)

func (Polygon) Equal

func (p Polygon) Equal(g Geom) bool

func (Polygon) Geometry

func (p Polygon) Geometry() []uint32

func (Polygon) MarshalWKT

func (p Polygon) MarshalWKT(w *wkt.WKTWriter)

func (Polygon) Project

func (p Polygon) Project(transform Transform) Geom

func (*Polygon) Scan

func (p *Polygon) Scan(src interface{}) error

func (Polygon) ToGeom

func (p Polygon) ToGeom() Geom

func (Polygon) Type

func (Polygon) Type() string

func (*Polygon) UnmarshalWKB

func (p *Polygon) UnmarshalWKB(r *wkb.WKBReader, order binary.ByteOrder, tpe wkb.GeometryType) error

func (Polygon) Value

func (p Polygon) Value() (driver.Value, error)

func (Polygon) ValueEx

func (Polygon) ValueEx() string

type Transform

type Transform func(point Point) Point

Directories

Path Synopsis
encoding
mvt
wkb
wkt

Jump to

Keyboard shortcuts

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