apicrud.geocode

geocode.py

Geocode functions

created 7-mar-2020 by richb@instantlinux.net

Functions

lookup([address, neighborhood, city, state, …])

Geo-code an address and get its neighbhorhood name To make this compatible with any database, coordinates are stored as integers with 7-digit decimal precision to fit in 32 bits

with_privacy(record, access)

Convert a database record’s geo values for API response Input is a value from model as_dict.

apicrud.geocode.lookup(address=None, neighborhood=None, city=None, state=None, country=None)

Geo-code an address and get its neighbhorhood name To make this compatible with any database, coordinates are stored as integers with 7-digit decimal precision to fit in 32 bits

Parameters
  • address (str) – street address

  • neighborhood (str) – neighborhood name

  • city (str) – city

  • state (str) – state

  • country (str) – 2-letter country abbreviation

Returns

lat, long, neighborhood

Return type

tuple

apicrud.geocode.with_privacy(record, access)

Convert a database record’s geo values for API response Input is a value from model as_dict. Evaluates uid, geolat, geolong, address fields. If the record is private, last 4 digits are rounded off.

Parameters
  • record (dict) – dict of key/value pairs from database

  • access (str) – access required for full location disclosure

Returns

record geolat/geolong values removed and geo tuple added

Return type

dict