Ejemplo n.º 1
0
def text_to_location(address_text, seed_location=None, allow_numberless=True):
    '''
    Attempts to resolve a raw text string into a Location using the Google
    Geocoding API.

    If Location object is provided as seed_location Location, the completed
    fields from it are used as hints to help resolving. These hints are more
    forgiving than those used in the Resolve API. Note that the Location's 
    address field will have no bearing on the results.

    If allow_numberless is False, the resolved location must be one more 
    specific that a neighborhood.

    Returns None if resolution was not possible.
    '''
    # if given a seed location, this is implemented by copying over the
    # seed location and inserting the given raw text into the Location's
    # field
    if seed_location:
        location = copy.deepcopy(seed_location)
    else:
        location = Location()
    location.address = address_text

    return resolve_location(location, allow_numberless)
Ejemplo n.º 2
0
def text_to_location(address_text,seed_location=None,allow_numberless=True):
    '''
    Attempts to resolve a raw text string into a Location using the Google
    Geocoding API.

    If Location object is provided as seed_location Location, the completed
    fields from it are used as hints to help resolving. These hints are more
    forgiving than those used in the Resolve API. Note that the Location's 
    address field will have no bearing on the results.

    If allow_numberless is False, the resolved location must be one more 
    specific that a neighborhood.

    Returns None if resolution was not possible.
    '''
    # if given a seed location, this is implemented by copying over the 
    # seed location and inserting the given raw text into the Location's 
    # field
    if seed_location:
        location = copy.deepcopy(seed_location)
    else:
        location = Location()
    location.address = address_text

    return resolve_location(location,allow_numberless)
Ejemplo n.º 3
0
 def _seeded_resolve(name=None,address=None,postcode=None,town=None,state=None):
     if seed_location:
         l = copy.deepcopy(seed_location)
     else:
         l = Location()
     if name:        l.name = name
     if address:     l.address = address
     if postcode:    l.postcode = postcode
     if town:        l.town = town
     if state:       l.state = state
     return resolve_place(Place(name=name,location=l))
Ejemplo n.º 4
0
 def _seeded_resolve(name=None,
                     address=None,
                     postcode=None,
                     town=None,
                     state=None):
     if seed_location:
         l = copy.deepcopy(seed_location)
     else:
         l = Location()
     if name: l.name = name
     if address: l.address = address
     if postcode: l.postcode = postcode
     if town: l.town = town
     if state: l.state = state
     return resolve_place(Place(name=name, location=l))