georm

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: BSD-2-Clause, MIT Imports: 10 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GEOrm

Библиотека была создана для адаптации типов геометрии в GORM

georm изначально создан для работы с PostGIS (PostgreSQL) и может не подойти для работы с другими СУБД.

Основой для географических / геометрических типов является библиотека go-geom

Для обмена геоданными используется ewkb формат, серилизация и десерилизация происходит при помощи библиотеки go-geom/encoding

Features

  • Работающая авто-миграция для таблиц с геометрическими типами.
  • Возможность создания и получения записей без написания sql, используя только gorm методы.
  • Использование бинарного формата в SQL запросах, увеличивает производительность и уменьшает объем трафика
  • Метод String, возвращает данные о геометрии в человеко читаемом wkt формате

Geometry types

  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection

License

Released under the MIT Licence

Relation: go-geom under the BSD-2-Clause

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedGeometryType = errors.New("unexpected geometry type")
	ErrUnexpectedValueType    = errors.New("unexpected value type")
)
View Source
var SRID = 4326

Functions

This section is empty.

Types

type Geometry

type Geometry[T geom.T] struct{ Geom T }

func New

func New[T geom.T](geom T) Geometry[T]

func (Geometry[T]) GormDataType

func (g Geometry[T]) GormDataType() string

GormDataType impl schema.GormDataTypeInterface

func (*Geometry[T]) Scan

func (g *Geometry[T]) Scan(value interface{}) (err error)

Scan impl sql.Scanner

func (Geometry[T]) String

func (g Geometry[T]) String() string

String returns geometry formatted using WKT format

Example
point := Geometry[geom.T]{
	Geom: geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{42, 42}),
}

polygon := Geometry[geom.T]{
	Geom: geom.NewPolygon(geom.XY).MustSetCoords(
		[][]geom.Coord{{{42, 42}, {1, 1}, {2, 2}, {42, 42}}}),
}

fmt.Println(point.String())
fmt.Println(polygon.String())
Output:
POINT (42 42)
POLYGON ((42 42, 1 1, 2 2, 42 42))

func (Geometry[T]) Value

func (g Geometry[T]) Value() (driver.Value, error)

Value impl driver.Valuer

type GeometryCollection

type GeometryCollection = Geometry[*geom.GeometryCollection]

type LineString

type LineString = Geometry[*geom.LineString]

type MultiLineString

type MultiLineString = Geometry[*geom.MultiLineString]

type MultiPoint

type MultiPoint = Geometry[*geom.MultiPoint]

type MultiPolygon

type MultiPolygon = Geometry[*geom.MultiPolygon]

type Point

type Point = Geometry[*geom.Point]

type Polygon

type Polygon = Geometry[*geom.Polygon]

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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