nationalgrid

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 7 Imported by: 0

README

Go-Nationalgrid

Go-Nationalgrid - Go library for ordnance survey gridref calculations

Author

This software was engineered by David Boyle @ Rockwell Consultants Ltd. admin@rockwellconsultants.co.uk / david@davidboyle.co.uk

Documentation

Index

Constants

View Source
const (
	SquareSize    = osShpFileSize
	SubSquareSize = SquareSize / 10
	QuadrantSize  = SubSquareSize / 2
)

the dimension of the source (osdata) shapefile (100KM).

Variables

View Source
var NationalGridSquares = map[string][]float64{
	"HP": {
		4,
		12,
	},
	"HT": {
		3,
		11,
	},
	"HU": {
		4,
		11,
	},
	"HW": {
		1,
		10,
	},
	"HX": {
		2,
		10,
	},
	"HY": {
		3,
		10,
	},
	"HZ": {
		4,
		10,
	},
	"NA": {
		0,
		9,
	},
	"NB": {
		1,
		9,
	},
	"NC": {
		2,
		9,
	},
	"ND": {
		3,
		9,
	},
	"NF": {
		0,
		8,
	},
	"NG": {
		1,
		8,
	},
	"NH": {
		2,
		8,
	},
	"NJ": {
		3,
		8,
	},
	"NK": {
		4,
		8,
	},
	"NL": {
		0,
		7,
	},
	"NM": {
		1,
		7,
	},
	"NN": {
		2,
		7,
	},
	"NO": {
		3,
		7,
	},
	"NR": {
		1,
		6,
	},
	"NS": {
		2,
		6,
	},
	"NT": {
		3,
		6,
	},
	"NU": {
		4,
		6,
	},
	"NW": {
		1,
		5,
	},
	"NX": {
		2,
		5,
	},
	"NY": {
		3,
		5,
	},
	"NZ": {
		4,
		5,
	},
	"OV": {
		5,
		5,
	},
	"SD": {
		3,
		4,
	},
	"SE": {
		4,
		4,
	},
	"TA": {
		5,
		4,
	},
	"SH": {
		2,
		3,
	},
	"SJ": {
		3,
		3,
	},
	"SK": {
		4,
		3,
	},
	"TF": {
		5,
		3,
	},
	"TG": {
		6,
		3,
	},
	"SM": {
		1,
		2,
	},
	"SN": {
		2,
		2,
	},
	"SO": {
		3,
		2,
	},
	"SP": {
		4,
		2,
	},
	"TL": {
		5,
		2,
	},
	"TM": {
		6,
		2,
	},
	"SR": {
		1,
		1,
	},
	"SS": {
		2,
		1,
	},
	"ST": {
		3,
		1,
	},
	"SU": {
		4,
		1,
	},
	"TQ": {
		5,
		1,
	},
	"TR": {
		6,
		1,
	},
	"SV": {
		0,
		0,
	},
	"SW": {
		1,
		0,
	},
	"SX": {
		2,
		0,
	},
	"SY": {
		3,
		0,
	},
	"SZ": {
		4,
		0,
	},
	"TV": {
		5,
		0,
	},
}

Functions

func DoOverlap

func DoOverlap(tl1, br1, tl2, br2 []float64) bool

func GetGridLatLon

func GetGridLatLon(ref string) (float64, float64, error)

func GetSubSquares

func GetSubSquares(g *geos.Bounds) map[string][]int

determine which squares / subsquares a geometry from a shapefile is within.

func ValidateGridRef

func ValidateGridRef(ref string) error

func ValidateSquare

func ValidateSquare(square string) error

Types

type Bounds

type Bounds struct {
	Xmin float64
	Xmax float64
	Ymin float64
	Ymax float64
}

func (Bounds) ToPolygon

func (b Bounds) ToPolygon() string

type GridRef

type GridRef struct {
	Square    string
	SubSquare string
	Quadrant  Quadrant
}

func ParseGridRef

func ParseGridRef(ref string) (GridRef, error)

type GridSquare

type GridSquare struct {
	Geom *geos.Geom
	MinX float64
	MinY float64
}

type LatLon

type LatLon struct {
	Lat float64
	Lon float64
}

type Location

type Location struct {
	Type    string
	LatLon  LatLon
	GridRef string
}

func (Location) ToOSGB36

func (c Location) ToOSGB36() OSGB36LatLon

type LocationType

type LocationType int
const (
	WGS84 LocationType = iota
	OSGB36
	NATIONALGRID
)

func (LocationType) String

func (l LocationType) String() string

type OSGB36LatLon

type OSGB36LatLon struct {
	LatLon LatLon
}

func (OSGB36LatLon) ToString

func (c OSGB36LatLon) ToString() string

type Quadrant

type Quadrant string
const (
	NE Quadrant = "NE"
	NW Quadrant = "NW"
	SE Quadrant = "SE"
	SW Quadrant = "SW"
)

func (Quadrant) String

func (l Quadrant) String() string

Jump to

Keyboard shortcuts

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