address

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package address contains tools for working with and comparing street addresses.

Index

Constants

View Source
const (
	StreetNumber             componentType = "street_number"
	Route                    componentType = "route"                       //street
	Subpremise               componentType = "subpremise"                  //unit number
	Locality                 componentType = "locality"                    //city
	AdministrativeAreaLevel1 componentType = "administrative_area_level_1" //state
	PostalCode               componentType = "postal_code"                 //zip
	Country                  componentType = "country"
)

Variables

This section is empty.

Functions

func NonOverlappingComponents

func NonOverlappingComponents(placeA, placeB Address) (uniqueToA, uniqueToB int)

func NormalizeSuffixes

func NormalizeSuffixes(s string) string

NormalizeSuffixes normalizes lowercase address suffixes to the standard format used by the United States Postal Service. i.e, "pkwy": "parkway", see http://www.pb.com/docs/us/pdf/sis/mail-services/usps-suffix-abbreviations.pdf

func NormalizedSharedComponentDistance

func NormalizedSharedComponentDistance(placeA, placeB *Address) (distance int)

NormalizedSharedComponentDistance performs heavy normalization on both addresses, then compares the distance.

func NormalizedSharedComponentDistanceSlice

func NormalizedSharedComponentDistanceSlice(placeA, placeB Address) (distances []int)

func NormalizedTotalDistance

func NormalizedTotalDistance(placeA, placeB *Address) (distance int)

NormalizedTotalDistance Performs heavy normalization on both addresses, then compares the distance.

func SharedComponentDistance

func SharedComponentDistance(placeA, placeB *Address) (distance int)

SharedComponentDistance returns the sum of the levenshtein distance of the shared components of the addresses

func SharedComponents

func SharedComponents(a, b Address) (Address, Address)

SharedComponents returns copies of a and b, except if a.component == "" || b.component == "", c.component == "" && d.component == ""

func TotalDistance

func TotalDistance(placeA, placeB *Address) (distance int)

TotalDistance returns the sum of the levenshtein distance of the components of the addresses.

Types

type Address

type Address struct {
	Street     string `json:"street,omitempty"`
	Extension  string `json:"extension,omitempty"`
	POBox      string `json:"po_box,omitempty"`
	Locality   string `json:"locality,omitempty"`
	Region     string `json:"region,omitempty"`
	PostalCode string `json:"post_code,omitempty"`
	Country    string `json:"country,omitempty"`
}

Address represents a physical location

func FromFactualRecord

func FromFactualRecord(factualRecord bson.M) Address

FromFactualRecord builds an address from a serialized record from factual

func FromGoogleAddressComponents

func FromGoogleAddressComponents(addressComponents []maps.AddressComponent, whitelist ...componentType) (address Address)

FromGoogleAddressComponents creates an Addresss from a slice of components, using the AddressCompoment.Types to discriminate.

func FromStringSlice

func FromStringSlice(s []string) (Address, bool)

FromStringSlice turns a length-7 string slice into an Address.

func (*Address) Array

func (a *Address) Array() [7]string

Array turns an address into a [7]string

func (*Address) Empty

func (a *Address) Empty() bool

Empty returns true if all components of the address are ""

func (*Address) NonEmptyComponents

func (a *Address) NonEmptyComponents() int

NonEmptyComponents is the number of nonempty components of a; that is, an address with only a steet has 1, street and locality is 2, ...

func (*Address) String

func (a *Address) String() string

func (*Address) StringSlice

func (a *Address) StringSlice() []string

StringSlice turns an address into a []string

func (*Address) StringSliceFromNonempty

func (a *Address) StringSliceFromNonempty() []string

StringSliceFromNonempty returns a stringslice of the non-empty components of a

Jump to

Keyboard shortcuts

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