postgis

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: MIT Imports: 7 Imported by: 0

README

go-postgis

PostGIS support for Go. Works with any Postgres driver.

Example

package main

import (
	"database/sql"
	"fmt"

	"github.com/cridenour/go-postgis"
	_ "github.com/lib/pq"
)

func main() {
	db, _ := sql.Open("postgres", "database=pqgotest sslmode=disable")

	point := postgis.PointS{4326, -84.5014, 39.1064}
	var newPoint postgis.PointS

	// Ensure we have PostGIS on the table
	db.Exec("CREATE EXTENSION IF NOT EXISTS postgis")

	// Demonstrate both driver.Valuer and sql.Scanner support
	db.QueryRow("SELECT GeomFromEWKB($1);", point).Scan(&newPoint)

	if point == newPoint {
		fmt.Println("Point returned equal from PostGIS!")
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal added in v1.0.4

func Marshal(g Geometry) ([]byte, error)

Types

type Geometry

type Geometry interface {
	sql.Scanner
	driver.Valuer
	GetType() uint32
	Write(*bytes.Buffer) error
}

type Point

type Point struct {
	X, Y float64
}

Structs respresenting varying types of points

func (Point) GetType

func (p Point) GetType() uint32

func (*Point) Scan

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

* Point functions *

func (Point) Value

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

func (Point) Write

func (p Point) Write(buffer *bytes.Buffer) error

type PointM

type PointM struct {
	X, Y, M float64
}

func (PointM) GetType

func (p PointM) GetType() uint32

func (*PointM) Scan

func (p *PointM) Scan(value interface{}) error

* PointM functions *

func (PointM) Value

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

func (PointM) Write

func (p PointM) Write(buffer *bytes.Buffer) error

type PointMS

type PointMS struct {
	SRID    int32
	X, Y, M float64
}

func (PointMS) GetType

func (p PointMS) GetType() uint32

func (*PointMS) Scan

func (p *PointMS) Scan(value interface{}) error

* PointMS functions *

func (PointMS) Value

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

func (PointMS) Write

func (p PointMS) Write(buffer *bytes.Buffer) error

type PointS

type PointS struct {
	SRID int32
	X, Y float64
}

func (PointS) GetType

func (p PointS) GetType() uint32

func (*PointS) Scan

func (p *PointS) Scan(value interface{}) error

* PointS functions *

func (PointS) Value

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

func (PointS) Write

func (p PointS) Write(buffer *bytes.Buffer) error

type PointZ

type PointZ struct {
	X, Y, Z float64
}

func (PointZ) GetType

func (p PointZ) GetType() uint32

func (*PointZ) Scan

func (p *PointZ) Scan(value interface{}) error

* PointZ functions *

func (PointZ) Value

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

func (PointZ) Write

func (p PointZ) Write(buffer *bytes.Buffer) error

type PointZM

type PointZM struct {
	X, Y, Z, M float64
}

func (PointZM) GetType

func (p PointZM) GetType() uint32

func (*PointZM) Scan

func (p *PointZM) Scan(value interface{}) error

* PointZM functions *

func (PointZM) Value

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

func (PointZM) Write

func (p PointZM) Write(buffer *bytes.Buffer) error

type PointZMS

type PointZMS struct {
	SRID       int32
	X, Y, Z, M float64
}

func (PointZMS) GetType

func (p PointZMS) GetType() uint32

func (*PointZMS) Scan

func (p *PointZMS) Scan(value interface{}) error

* PointZMS functions *

func (PointZMS) Value

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

func (PointZMS) Write

func (p PointZMS) Write(buffer *bytes.Buffer) error

type PointZS

type PointZS struct {
	SRID    int32
	X, Y, Z float64
}

func (PointZS) GetType

func (p PointZS) GetType() uint32

func (*PointZS) Scan

func (p *PointZS) Scan(value interface{}) error

* PointZS functions *

func (PointZS) Value

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

func (PointZS) Write

func (p PointZS) Write(buffer *bytes.Buffer) error

Jump to

Keyboard shortcuts

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