DenisCarriere / geocoder

:earth_asia: Python Geocoder
http://geocoder.readthedocs.org
MIT License
1.63k stars 288 forks source link

Opencage 'street' not picking up all aliases #256

Closed nyejon closed 7 years ago

nyejon commented 7 years ago

Hi,

I have modfied the opencage.py so that it picks up all of the street aliases as specified in the https://github.com/OpenCageData/address-formatting/blob/master/conf/components.yaml

Previously it only picked up the 'road' alias and was missing many of my queries for street address.

Can I submit a PR for the addition? I have added the following lines to opencage.py:

@property
def street(self):
    street = self.parse['components'].get('street')
    if street:
        return street
    elif self.footway:
        return self.footway
    elif self.road:
        return self.road
    elif self.street_name:
        return self.street_name
    elif self.residential:
        return self.residential
    elif self.path:
        return self.path
    elif self.pedestrian:
        return self.pedestrian

@property
def footway(self):
    return self.parse['components'].get('footway')

@property
def road(self):
    return self.parse['components'].get('road')

@property
def street_name(self):
    return self.parse['components'].get('street_name')

@property
def residential(self):
    return self.parse['components'].get('residential')

@property
def path(self):
    return self.parse['components'].get('path')

@property
def pedestrian(self):
    return self.parse['components'].get('pedestrian')
mtmail commented 7 years ago

@nyejon I wrote a PR https://github.com/DenisCarriere/geocoder/pull/257

DenisCarriere commented 7 years ago

👍 Awesome thanks!