region

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package utils implements functions to calculate tiles range according to the given coordinates.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrLvlParse = errors.New("cannot parse levels")

ErrLvlParse raises in case if the level string is incorrect.

View Source
var ErrLvlRange = errors.New("levels range is broken")

ErrLvlRange raises in case if one of the levels is out of range 0-16.

Functions

func FindTiles

func FindTiles(fromLvl, toLvl, accuracy int, fld float64, coords *Coordinates)

FindTiles calculates tiles range for given parameters and prints it.

Example
fromLvl, toLvl, accuracy := 10, 10, -1
fld := float64(5)
coords := &Coordinates{"maxLat": 60.120754, "maxLon": 30.699476, "minLat": 59.805323, "minLon": 30.024240}

FindTiles(fromLvl, toLvl, accuracy, fld, coords)
Output:

For level 10
y range = 4261 - 4270, x range = 5974 - 5993
Min coordinates: 59.80078125, 30.0234375
Max coordinates: 60.15234375, 30.7265625

func GetLvls

func GetLvls(s string) (int, int, error)

GetLvls parses levels from parameters.

Example
levels := "7 - 9"
fromLvl, toLvl, err := GetLvls(levels)
if err != nil {
	fmt.Println(err)
	return
}

fmt.Printf("from level: %d\nto level: %d\n", fromLvl, toLvl)
Output:

from level: 7
to level: 9

Types

type Coordinates

type Coordinates map[string]float64

Coordinates represents map with coordinates.

func GetCoordinates

func GetCoordinates(args []string) (*Coordinates, error)

GetCoordinates parses coordinates from the given parameters.

Jump to

Keyboard shortcuts

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