Merge pull request #541 from CartoDB/development
Python 0.21.1: Fix batch geocoder precision
This commit is contained in:
commit
f996cb35db
@ -8,7 +8,7 @@ from collections import namedtuple
|
|||||||
from requests.adapters import HTTPAdapter
|
from requests.adapters import HTTPAdapter
|
||||||
from cartodb_services import StreetPointBulkGeocoder
|
from cartodb_services import StreetPointBulkGeocoder
|
||||||
from cartodb_services.here import HereMapsGeocoder
|
from cartodb_services.here import HereMapsGeocoder
|
||||||
from cartodb_services.geocoder import geocoder_metadata, geocoder_error_response
|
from cartodb_services.geocoder import geocoder_metadata, geocoder_error_response, PRECISION_INTERPOLATED
|
||||||
from cartodb_services.metrics import Traceable
|
from cartodb_services.metrics import Traceable
|
||||||
from cartodb_services.tools.exceptions import ServiceException
|
from cartodb_services.tools.exceptions import ServiceException
|
||||||
|
|
||||||
@ -137,8 +137,8 @@ class HereMapsBulkGeocoder(HereMapsGeocoder, StreetPointBulkGeocoder):
|
|||||||
reader = csv.DictReader(root_zip.open(name), delimiter='|')
|
reader = csv.DictReader(root_zip.open(name), delimiter='|')
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if row['SeqNumber'] == '1': # First per requested data
|
if row['SeqNumber'] == '1': # First per requested data
|
||||||
precision = self.PRECISION_BY_MATCH_TYPE[
|
precision = self.PRECISION_BY_MATCH_TYPE.get(
|
||||||
row.get('matchType', 'pointAddress')]
|
row.get('matchType'), PRECISION_INTERPOLATED)
|
||||||
match_type = self.MATCH_TYPE_BY_MATCH_LEVEL.get(row['matchLevel'], None)
|
match_type = self.MATCH_TYPE_BY_MATCH_LEVEL.get(row['matchLevel'], None)
|
||||||
results.append((row['recId'],
|
results.append((row['recId'],
|
||||||
[row['displayLongitude'], row['displayLatitude']],
|
[row['displayLongitude'], row['displayLatitude']],
|
||||||
|
@ -143,8 +143,8 @@ class HereMapsGeocoder(Traceable):
|
|||||||
|
|
||||||
def _extract_metadata_from_result(self, result):
|
def _extract_metadata_from_result(self, result):
|
||||||
# See https://stackoverflow.com/questions/51285622/missing-matchtype-at-here-geocoding-responses
|
# See https://stackoverflow.com/questions/51285622/missing-matchtype-at-here-geocoding-responses
|
||||||
precision = self.PRECISION_BY_MATCH_TYPE[
|
precision = self.PRECISION_BY_MATCH_TYPE.get(
|
||||||
result.get('MatchType', 'pointAddress')]
|
result.get('MatchType'), PRECISION_INTERPOLATED)
|
||||||
match_type = self.MATCH_TYPE_BY_MATCH_LEVEL.get(result['MatchLevel'], None)
|
match_type = self.MATCH_TYPE_BY_MATCH_LEVEL.get(result['MatchLevel'], None)
|
||||||
return geocoder_metadata(
|
return geocoder_metadata(
|
||||||
result['Relevance'],
|
result['Relevance'],
|
||||||
|
@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name='cartodb_services',
|
name='cartodb_services',
|
||||||
|
|
||||||
version='0.21.0',
|
version='0.21.1',
|
||||||
|
|
||||||
description='CartoDB Services API Python Library',
|
description='CartoDB Services API Python Library',
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user