geo

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 6 Imported by: 0

README

geo

GoDoc

Customized types and functions for our geo needs.

NOTE: If you want a full-fledged geo library we recommend using https://github.com/twpayne/go-geom instead.

Basic usage

You can use the types of this package in your models structs when working with libs.altipla.consulting/database:

import (
  "libs.altipla.consulting/geo"
)

type MyModel struct {
  ID          int64      `db:"id,pk"`
  Location    geo.Point `db:"location"`
}

Documentation

Overview

Package geo implements customized types and functions for our geo needs.

If you want a full-fledged geo library we recommend using https://github.com/twpayne/go-geom instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DistanceToPoint

func DistanceToPoint(column string, point Point) database.Sorter

DistanceToPoint orders by distance to a geographic point.

Types

type NearCondition

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

NearCondition stores the point and distance to filter around

func Near

func Near(column string, point Point, value float64) *NearCondition

Near filters by distance around a geographic point

func (*NearCondition) SQL

func (cond *NearCondition) SQL() string

SQL returns the built SQL to apply the filter.

func (*NearCondition) Values

func (cond *NearCondition) Values() []interface{}

Values returns the SQL placeholders to apply the filter

type Point

type Point struct {
	Lng float64
	Lat float64
}

Point maps against MySQL geographical point.

func (*Point) Scan

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

Scan implements the SQL driver.Scanner interface and will scan the MySQL POINT(x y) into the Point struct.

func (Point) String

func (p Point) String() string

String returns the WKT (Well Known Text) representation of the point.

func (Point) Valid

func (p Point) Valid() bool

Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, 180] longitude.

func (Point) Value

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

Value implements the SQL driver.Valuer interface and will return the string representation of the Point struct by calling the String() method

Jump to

Keyboard shortcuts

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