geo

package
v0.0.0-...-d078246 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTileSize = 256
	DefaultMinZoom  = 0
	DefaultMaxZoom  = 23
)
View Source
const (
	// E Eccentricity of Earth ellipsoid
	E                = 0.0818191908426
	MajorEarthRadius = 6378137.0
	SubRadius        = 1 / MajorEarthRadius
	Equator          = 2 * math.Pi * MajorEarthRadius
	HalfEquator      = Equator / 2
	SubEquator       = 1 / Equator
	HalfPi           = math.Pi / 2
	Rad2Deg          = 180 / math.Pi

	MaxLat = 90.0
	MinLat = -90.0
	MaxLon = 180.0
	MinLon = -180.0

	EGS3857MinLat = -85.0840
	EGS3857MaxLat = 85.0840
)
View Source
const DegreesToRadiansFactor = math.Pi / 180
View Source
const RadiansToDegreesFactor = 180 / math.Pi

Variables

View Source
var DefaultGeoSystemConfig = &Config{
	ProjectionType: WGS84,
	MinZoom:        DefaultMinZoom,
	MaxZoom:        DefaultMaxZoom,
	TileSize:       DefaultTileSize,
}

Functions

func Bits

func Bits(val int64) string

func Colorize

func Colorize(color string, s interface{}) string

func CycleRestrict

func CycleRestrict(value, min, max float64) float64

func DegreesToRadians

func DegreesToRadians(x float64) float64

func FromWKT

func FromWKT(s string) geom.T

func GlobalPixelsToWGS84WithGD

func GlobalPixelsToWGS84WithGD(gpx, gpy float64, zoom int64) (lat, lon float64)

GlobalPixelsToWGS84WithGD GD - https://en.wikipedia.org/wiki/Gudermannian_function

func ParseAsFloatArray

func ParseAsFloatArray(line string) ([]float64, error)

func ParseAsInt64Array

func ParseAsInt64Array(line string) ([]int64, error)

func RadiansToDegrees

func RadiansToDegrees(x float64) float64

func Restrict

func Restrict(value, min, max float64) float64

func RoundToDigit

func RoundToDigit(v float64, n int) float64

RoundToDigit rounds number to N digits after dot

func ToWKT

func ToWKT(g Primitive) string

Types

type AbstractGeographic

type AbstractGeographic struct {
	SRID
	geom.T
}

func (*AbstractGeographic) Scan

func (g *AbstractGeographic) Scan(input interface{}) error

func (AbstractGeographic) Value

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

type BBox

type BBox struct {
	XMin float64
	XMax float64
	YMin float64
	YMax float64
}

func NewBBox

func NewBBox(coordsStr string) (BBox, error)

func (*BBox) AsPolygon

func (r *BBox) AsPolygon() *GeographicPolygon

type Config

type Config struct {
	TileSize       int64 `json:"tile_size" yaml:"tile_size"`
	MinZoom        int64 `json:"min_zoom" yaml:"min_zoom"`
	MaxZoom        int64 `json:"max_zoom" yaml:"max_zoom"`
	ProjectionType SRID  `json:"projection_type" yaml:"projection_type"`
}

type Data

type Data interface {
	Scan(input interface{}) error
	Value() (driver.Value, error)
}

type DataSource

type DataSource interface {
	LoadMapView(ctx context.Context, mr *MapRequest, fc *FeatureCollection) error
	StoreGeoData(ctx context.Context, d interface{}) error
}

type FeatureCollection

type FeatureCollection struct {
	geojson.FeatureCollection
}

func NewFeatureCollection

func NewFeatureCollection() *FeatureCollection

func (*FeatureCollection) Add

func (f *FeatureCollection) Add(id interface{}, geo interface{}, properties map[string]interface{}) error

func (*FeatureCollection) MarshalToJSONP

func (f *FeatureCollection) MarshalToJSONP(callbackID string) ([]byte, error)

type Geographic

type Geographic interface {
	SRID() int
}

type GeographicCollection

type GeographicCollection struct {
	SRID
	Figures []Primitive
}

func (*GeographicCollection) FromGeom

func (p *GeographicCollection) FromGeom(t geom.T) error

func (*GeographicCollection) Scan

func (p *GeographicCollection) Scan(input interface{}) error

func (*GeographicCollection) ToGeom

func (p *GeographicCollection) ToGeom() (geom.T, error)

func (GeographicCollection) Value

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

type GeographicMultiPolygon

type GeographicMultiPolygon struct {
	SRID
	Polygons []*GeographicPolygon
}

func (*GeographicMultiPolygon) FromGeom

func (p *GeographicMultiPolygon) FromGeom(t geom.T) error

func (*GeographicMultiPolygon) Scan

func (p *GeographicMultiPolygon) Scan(input interface{}) error

func (*GeographicMultiPolygon) ToGeom

func (p *GeographicMultiPolygon) ToGeom() (geom.T, error)

func (GeographicMultiPolygon) Value

type GeographicPoint

type GeographicPoint struct {
	SRID
	Latitude  float64
	Longitude float64
}

func (*GeographicPoint) FromGeom

func (p *GeographicPoint) FromGeom(t geom.T) error

func (*GeographicPoint) Scan

func (p *GeographicPoint) Scan(input interface{}) error

func (*GeographicPoint) ToGeom

func (p *GeographicPoint) ToGeom() (geom.T, error)

func (GeographicPoint) Value

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

type GeographicPolygon

type GeographicPolygon struct {
	SRID
	Points []*GeographicPoint
}

func (*GeographicPolygon) FromGeom

func (p *GeographicPolygon) FromGeom(t geom.T) error

func (*GeographicPolygon) Scan

func (p *GeographicPolygon) Scan(input interface{}) error

func (*GeographicPolygon) ToGeom

func (p *GeographicPolygon) ToGeom() (geom.T, error)

func (GeographicPolygon) Value

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

type GeographicSystem

type GeographicSystem struct {
	TileSystem    *TileSystem
	QuadKeySystem *QuadKeySystem
	Projection    Projection
	// contains filtered or unexported fields
}

func NewGeographicSystem

func NewGeographicSystem(cfg *Config) *GeographicSystem

func (*GeographicSystem) CoordinatesToQuadKey

func (g *GeographicSystem) CoordinatesToQuadKey(lat, long float64) QuadKey

func (*GeographicSystem) DrawROMBBox

func (g *GeographicSystem) DrawROMBBox(mr *MapRequest, fc *FeatureCollection) error

func (*GeographicSystem) DrawROMTiles

func (g *GeographicSystem) DrawROMTiles(mr *MapRequest, fc *FeatureCollection) error

func (*GeographicSystem) MRToTiles

func (g *GeographicSystem) MRToTiles(mr *MapRequest) (tiles map[int64]Tile)

func (*GeographicSystem) TileIDToCenterPoint

func (g *GeographicSystem) TileIDToCenterPoint(tileID int64) (*GeographicPoint, error)

func (*GeographicSystem) TileXYToCenterPoint

func (g *GeographicSystem) TileXYToCenterPoint(tx, ty int64, z int64) *GeographicPoint

func (*GeographicSystem) TileXYToPoint

func (g *GeographicSystem) TileXYToPoint(tx, ty int64, z int64) *GeographicPoint

func (*GeographicSystem) TileXYToPolygon

func (g *GeographicSystem) TileXYToPolygon(tx, ty int64, zoom int64) *GeographicPolygon

type MapRequest

type MapRequest struct {
	TileBBox
	BBox
	Zoom         int64
	CallbackID   string
	Debug        bool
	ClusterDepth int64
}

func ParseMapRequest

func ParseMapRequest(coordsStr, tileStr, zoomStr, callbackID, debugStr, clusterDepthStr string) (*MapRequest, error)

ParseMapRequest from comma separated strings

type Point

type Point interface {
	X() float64
	Y() float64
}

type Primitive

type Primitive interface {
	ToGeom() (geom.T, error)
	FromGeom(t geom.T) error
}

func FromGeom

func FromGeom(g geom.T) (Primitive, error)

type Projection

type Projection interface {
	ToGlobalPixels(lat, lon float64, z int64) (gpx, gpy float64)
	FromGlobalPixels(gpx, gpy float64, z int64) (lat, lon float64)
}

type QuadKey

type QuadKey []rune

func NewQuadKeyFromInt64

func NewQuadKeyFromInt64(val int64) QuadKey

func (QuadKey) Bits

func (q QuadKey) Bits() string

func (QuadKey) Copy

func (q QuadKey) Copy() QuadKey

func (QuadKey) Int64

func (q QuadKey) Int64() int64

func (QuadKey) Len

func (q QuadKey) Len() int64

func (QuadKey) String

func (q QuadKey) String() string

func (QuadKey) View

func (q QuadKey) View() string

type QuadKeySystem

type QuadKeySystem struct {
	// contains filtered or unexported fields
}

func NewQuadKeySystem

func NewQuadKeySystem(minZoom int64, maxZoom int64) *QuadKeySystem

func (*QuadKeySystem) BitDelta

func (q *QuadKeySystem) BitDelta(len int64) int64

func (*QuadKeySystem) Contains

func (q *QuadKeySystem) Contains(point QuadKey, tile QuadKey) bool

func (*QuadKeySystem) CreateMask

func (q *QuadKeySystem) CreateMask(qk QuadKey, zoom int64, clusterLevel int64) QuadKey

func (*QuadKeySystem) QuadKeyRange

func (q *QuadKeySystem) QuadKeyRange(quadKey QuadKey) (min QuadKey, max QuadKey)

func (*QuadKeySystem) QuadKeyToTileXY

func (q *QuadKeySystem) QuadKeyToTileXY(quadKey QuadKey) (tileX, tileY int64, err error)

func (*QuadKeySystem) TileXYToQuadKey

func (q *QuadKeySystem) TileXYToQuadKey(tx, ty int64, zoom int64) QuadKey

type SRID

type SRID int
const (
	WGS84       SRID = 4326
	WebMercator SRID = 3857
)

func DefaultSRID

func DefaultSRID(srid SRID) SRID

type Tile

type Tile struct {
	ID         int64
	X          int64
	Y          int64
	Zoom       int64
	QuadKey    QuadKey
	MinQuadKey QuadKey
	MaxQuadKey QuadKey
}

type TileBBox

type TileBBox struct {
	TileXMin int64
	TileXMax int64
	TileYMin int64
	TileYMax int64
}

func NewTileBBox

func NewTileBBox(tileStr string) (TileBBox, error)

func (*TileBBox) IterateTiles

func (r *TileBBox) IterateTiles(cb func(x, y int64) error) error

func (*TileBBox) TilesNumber

func (r *TileBBox) TilesNumber() int64

type TileSystem

type TileSystem struct {
	// contains filtered or unexported fields
}

TileSystem allow transform any coordinate to TileXY

func NewTileSystem

func NewTileSystem(minZoom, maxZoom int64, tileSize int64) *TileSystem

func (*TileSystem) GlobalPixelsToTileXY

func (t *TileSystem) GlobalPixelsToTileXY(gpx, gpy float64) (tx, ty int64)

func (*TileSystem) TileXYToGlobalPixels

func (t *TileSystem) TileXYToGlobalPixels(tx, ty int64) (gpx, gpy float64)

func (*TileSystem) TileXYToGlobalPixelsCenter

func (t *TileSystem) TileXYToGlobalPixelsCenter(tx, ty int64) (gpx, gpy float64)

type YandexGPConverter

type YandexGPConverter struct {
	E float64
}

YandexGPConverter https://yandex.ru/dev/maps/tiles/doc/dg/concepts/about-tiles.html#get-tile-number https://yastatic.net/s3/front-maps-static/maps-front-jsapi-v2-1/2.1.79-41/build/debug/full-f444800dea2e3f74c30f6b13a88f1a6a7b7eb78a.js

func NewYandexGPConverter

func NewYandexGPConverter(e float64) *YandexGPConverter

func (YandexGPConverter) FromGlobalPixels

func (g YandexGPConverter) FromGlobalPixels(gpx, gpy float64, zoom int64) (lat, lon float64)

func (YandexGPConverter) ToGlobalPixels

func (g YandexGPConverter) ToGlobalPixels(lat, lon float64, zoom int64) (gpx, gpy float64)

Jump to

Keyboard shortcuts

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