plzfinder

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 7 Imported by: 0

README

plzfinder

Finds and returns surrounding PLZ (postal code) in GERMANY with a specific radius around a PLZ

go get github.com/karl1b/plzfinder
// init: run this once for your service to load the data from csv into ram
// point to the csv file location.
plzfinder.LoadCSV("zipcodes.de.csv")

// tbis is how you search for all PLZ in 5km radius around 06110 
orte, err := plzfinder.FindeOrte("06110", 5)
if err != nil {
	// handle error
}

I got the DATA from HERE: https://github.com/zauberware/postal-codes-json-xml-csv

Thanks matey! ;-)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Locations []PlzLoc // The Locations are stored in the RAM during runtime

Global Variables

Functions

func LoadCSV

func LoadCSV(filename string)

In the init function the data is read from CSV. This will only run once so no need to speed up. Data can easily be udpated by changing the CSV content.

func ReturnNearestAvailablePLZ added in v1.0.6

func ReturnNearestAvailablePLZ(requestPLZ string, maxIterations int) (string, error)

Types

type ByDist added in v1.0.3

type ByDist []PlzLoc

func (ByDist) Len added in v1.0.3

func (a ByDist) Len() int

Implement sort.Interface for ByDist

func (ByDist) Less added in v1.0.3

func (a ByDist) Less(i, j int) bool

func (ByDist) Swap added in v1.0.3

func (a ByDist) Swap(i, j int)

type PlzLoc

type PlzLoc struct {
	Plz  string
	Lat  float64
	Lon  float64
	LatR float64 // This will be calculated 1time to speed the code up
	LonR float64
	Dist float64 // This will be the distdance.
}

func FindeOrte

func FindeOrte(plz string, radius int) ([]PlzLoc, error)

Jump to

Keyboard shortcuts

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