Giter Club home page Giter Club logo

pgeo.latlng's Introduction

pgeo.latlng

This package is identical to pgeo except that Point is defined as Point{ Lat, Lng } instead of Point{ X, Y }

Package pgeo implements geometric types for Postgres

It uses Scanner and Valuer interfaces from database/sql

Types

//Points are the fundamental two-dimensional building block for geometric types.
//Lat and Lng are the respective coordinates, as floating-point numbers
type Point struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

//Circles are represented by a center point and radius.
type Circle struct {
	Point
	Radius float64 `json:"radius"`
}

//Line represents a infinite line with the linear equation Ax + By + C = 0, where A and B are not both zero.
type Line struct {
	A float64 `json:"a"`
	B float64 `json:"b"`
	C float64 `json:"c"`
}

//Paths are represented by lists of connected points.
//Paths can be open, where the first and last points in the list are considered not connected,
//or closed, where the first and last points are considered connected.
type Path struct {
	Points []Point
	Closed bool `json:"closed"`
}

//Boxes are represented by pairs of points that are opposite corners of the box.
type Box [2]Point

//Line segments are represented by pairs of points that are the endpoints of the segment.
type Lseg [2]Point

//Polygons are represented by lists of points (the vertexes of the polygon).
type Polygon []Point

Null Types

type NullPoint struct {
	Point
	Valid bool `json:"valid"`
}

//Same for others...

Functions

Create Types

NewPoint(Lat, Lng float64) Point

NewLine(A, B, C float64) Line

NewLseg(A, B Point) Lseg

NewBox(A, B Point) Box

NewPath(P []Point, Closed bool) Path

NewPolygon(P []Point) Polygon

NewCircle(P Point, Radius float64) Circle

Null Types

NewNullPoint(P Point, valid bool) NullPoint

NewNullLine(L Line, valid bool) NullLine

NewNullLseg(L Lseg, valid bool) NullLseg

NewNullBox(B Box, valid bool) NullBox

NewNullPath(P Path, valid bool) NullPath

NewNullPolygon(P Polygon, valid bool) NullPolygon

NewNullCircle(C Circle, valid bool) NullCircle

Rand Types

NewRandPoint() Point

NewRandLine() Line

NewRandLseg() Lseg

NewRandBox() Box

NewRandPath() Path

NewRandPolygon() Polygon

NewRandCircle() Circle

Zero Point

//Returns a Point Lat=0, Lng=0
NewZeroPoint() Point

pgeo.latlng's People

Contributors

saulortega avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.