Beispiel #1
0
	def geocoderUsGeocoder(self,locationString):
		logging.info("#### gMapsGeocoder.geocoderUsGeocoder["+locationString+"]")
		request = {}
		request['url'] = 'http://rpc.geocoder.us/service/csv?address='+locationString.replace(' ','+')
		request['format'] = 'text'
		logging.info(request['url'])
		_result = api.make_api_request(request)
		logging.info(_result)
		_output = _result
		return _output
Beispiel #2
0
	def gMapsGeocode(self,locationString):
		logging.info("#### gMapsGeocoder.gMapsGeocode["+locationString+"]")
		request = {}
		request['url'] = 'http://maps.google.com/maps/api/geocode/json?address='+locationString.replace(' ','+')+'&sensor=false'
		logging.info(request['url'])
		_result = api.make_api_request(request)
		_output = {}
		if 'json' in _result:
			if 'status' in _result['json']:
				if _result['json']['status'] == 'OK':
					if 'results' in _result['json']:
						if 'formatted_address' in _result['json']['results'][0]:
							_output['name'] = _result['json']['results'][0]['formatted_address']
						if 'geometry' in _result['json']['results'][0]:
							if 'location' in _result['json']['results'][0]['geometry']:
								_output['latlng'] = _result['json']['results'][0]['geometry']['location']
				else:
					logging.info("#### gMapsGeocoder.geocode FAILED: "+str(_result['json']['status']))
					return False
		return _output