geo

package
v0.0.0-...-a5a65f0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2017 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Package geo provides utilities helping with geographic coordinates in the map aspect of the Camlistore web UI.

Index

Constants

View Source
const (
	LocPredicatePrefix     = "loc"
	LocAreaPredicatePrefix = "locrect"
	LocMapPredicatePrefix  = "map"
)

Variables

This section is empty.

Functions

func HandleLocAreaPredicate

func HandleLocAreaPredicate(predicate string, handleCoordinatesFound func(*camtypes.LocationBounds)) bool

HandleLocAreaPredicate checks whether predicate is a location area predicate (locrect). If so, it runs asynchronously handleCoordinatesFound on the given coordinates, and returns true. Otherwise, it returns false.

func HandleZoomPredicate

func HandleZoomPredicate(predicate string, handleCoordinatesFound func(*camtypes.LocationBounds)) bool

HandleLocAreaPredicate checks whether predicate contains a map location predicate (map:). If so, it runs asynchronously handleCoordinatesFound on the given coordinates, and returns true. Otherwise, it returns false.

func IsLocMapPredicate

func IsLocMapPredicate(predicate string) bool

IsLocMapPredicate returns whether predicate is a map location predicate.

func IsLocPredicate

func IsLocPredicate(predicate string) bool

IsLocPredicate returns whether the given predicate is a simple (as in, not composed) location predicate, such as the one supported by the Camlistore search handler (e.g. "loc:seattle").

func Lookup

func Lookup(location string, handleCoordinatesFound func(*camtypes.LocationBounds))

Lookup searches for the coordinates of the given location, and passes the found zone (a rectangle), if any, to handleCoordinatesFound.

Types

type EastWest

type EastWest struct {
	E float64
	W float64
}

EastWest is returned by WrapAntimeridian. It exists only because there's no multi-valued returns with javascript functions, so we need WrapAntimeridian to return some sort of struct, that gets converted to a javascript object by gopherjs.

func WrapAntimeridian

func WrapAntimeridian(east, west float64) EastWest

WrapAntimeridian determines if the shortest geodesic between east and west goes over the antimeridian. If yes, it converts one of the two to the closest equivalent value out of the [-180, 180] range. The choice of which of the two to convert is such as to maximize the part of the geodesic that stays in the [-180, 180] range. The reason for that function is that leaflet.js cannot handle drawing areas that cross the antimeridian if both corner are in the [-180, 180] range. https://github.com/Leaflet/Leaflet/issues/82

type Location

type Location struct {
	Lat  float64 // -90 (south) to 90 (north)
	Long float64 // -180 (west) to 180 (east)
}

Location is a geographical coordinate, specified by its latitude and its longitude.

func LocationCenter

func LocationCenter(north, south, west, east float64) Location

LocationCenter returns the center of the rectangle defined by the given coordinates.

Jump to

Keyboard shortcuts

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