goware / geotools

Geo-location lookup library / service built on Google Maps API
MIT License
2 stars 1 forks source link

Address and AddressComponents #9

Open pkieltyka opened 8 years ago

pkieltyka commented 8 years ago

I think it would be better if we're explicit on the data structure of a "place", as in lets make the components actual fields.

xiam commented 8 years ago

The Google Maps API returns an array of address_components that looks like this:

     "address_components" : [
         {
            "long_name" : "48",
            "short_name" : "48",
            "types" : [ "street_number" ]
         },
         {
            "long_name" : "Pirrama Road",
            "short_name" : "Pirrama Road",
            "types" : [ "route" ]
         },
         {
            "long_name" : "Pyrmont",
            "short_name" : "Pyrmont",
            "types" : [ "locality", "political" ]
         },
         {
            "long_name" : "NSW",
            "short_name" : "NSW",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "AU",
            "short_name" : "AU",
            "types" : [ "country", "political" ]
         },
         {
            "long_name" : "2009",
            "short_name" : "2009",
            "types" : [ "postal_code" ]
         }
      ],

I'm going to add a new field like this one:

type AddressComponent struct {
  LongName string
  ShortName string
  Types []string
}

AddressComponents []AdressComponent
pkieltyka commented 8 years ago

interesting. Perhaps we can normalize this into a struct something like...


type Place struct {
    Name string
    Address Address
}
Address struct {
    Street string
    City string
    State string
    Country string
}

doing a quick search I even found someone with a similar story.. http://brizzled.clapper.org/blog/2012/02/14/simple-address-standardization/

xiam commented 8 years ago

And nothing has changed much since then, the Google Maps API still uses the same format. If we stick to the values you are suggesting it won't be that difficult, we can try to copy the initial mapping from that article and keep making adjustments when necessary.

pkieltyka commented 8 years ago

Yes please

On Jan 12, 2016, at 9:27 PM, José Carlos notifications@github.com wrote:

And nothing has changed much since then, the Google Maps API still uses the same format. If we stick to the values you are suggesting it won't be that difficult, we can try to copy the initial mapping from that article and keep making adjustments when necessary.

— Reply to this email directly or view it on GitHub.