nchaulet / node-geocoder

nodejs geocoding library
http://nchaulet.github.io/node-geocoder/
MIT License
931 stars 214 forks source link

HERE provider: add stateCode property #268

Open ruscon opened 5 years ago

ruscon commented 5 years ago

search address: 1200 E 89th St, Chicago, IL 60619, USA

HERE provider response:

{
  "Response": {
    "MetaInfo": {
      "Timestamp": "2019-02-14T22:22:52.180+0000"
    },
    "View": [
      {
        "_type": "SearchResultsViewType",
        "ViewId": 0,
        "Result": [
          {
            "Relevance": 0.99,
            "MatchLevel": "houseNumber",
            "MatchQuality": {
              "City": 1,
              "Street": [
                1
              ],
              "HouseNumber": 0.98
            },
            "MatchType": "interpolated",
            "Location": {
              "LocationId": "NT_.4F.1wbQ1kZP.RMjIh-x1A_xETO4A",
              "LocationType": "point",
              "DisplayPosition": {
                "Latitude": 41.7332549,
                "Longitude": -87.5953225
              },
              "NavigationPosition": [
                {
                  "Latitude": 41.73312,
                  "Longitude": -87.5953225
                }
              ],
              "MapView": {
                "TopLeft": {
                  "Latitude": 41.734379,
                  "Longitude": -87.5968289
                },
                "BottomRight": {
                  "Latitude": 41.7321307,
                  "Longitude": -87.5938161
                }
              },
              "Address": {
                "Label": "1198 E 89th St, Chicago, IL 60619, United States",
                "Country": "USA",
                "State": "IL",
                "County": "Cook",
                "City": "Chicago",
                "District": "Burnside",
                "Street": "E 89th St",
                "HouseNumber": "1198",
                "PostalCode": "60619",
                "AdditionalData": [
                  {
                    "value": "United States",
                    "key": "CountryName"
                  },
                  {
                    "value": "Illinois",
                    "key": "StateName"
                  },
                  {
                    "value": "Cook",
                    "key": "CountyName"
                  },
                  {
                    "value": "N",
                    "key": "PostalCodeType"
                  }
                ]
              }
            },
            "AdditionalData": [
              {
                "value": "true",
                "key": "houseNumberFallback"
              },
              {
                "value": "2",
                "key": "houseNumberFallbackDifference"
              }
            ]
          }
        ]
      }
    ]
  }
}

expected result:

[
  {
    "formattedAddress": "1198 E 89th St, Chicago, IL 60619, United States",
    "latitude": 41.7332549,
    "longitude": -87.5953225,
    "country": "United States",
    "countryCode": "US",
    "state": "Illinois",
    "stateCode": "IL", <--- new property
    "county": "Cook",
    "city": "Chicago",
    "zipcode": "60619",
    "district": "Burnside",
    "streetName": "E 89th St",
    "streetNumber": "1198",
    "building": null,
    "extra": {
      "herePlaceId": "NT_.4F.1wbQ1kZP.RMjIh-x1A_xETO4A",
      "confidence": 0.99
    },
    "administrativeLevels": {
      "level1long": "Illinois",
      "level2long": "Cook"
    },
    "provider": "here"
  }
]

actual result:

[
  {
    "formattedAddress": "1198 E 89th St, Chicago, IL 60619, United States",
    "latitude": 41.7332549,
    "longitude": -87.5953225,
    "country": "United States",
    "countryCode": "US",
    "state": "Illinois",
    // "stateCode": "IL", <------- undefined 
    "county": "Cook",
    "city": "Chicago",
    "zipcode": "60619",
    "district": "Burnside",
    "streetName": "E 89th St",
    "streetNumber": "1198",
    "building": null,
    "extra": {
      "herePlaceId": "NT_.4F.1wbQ1kZP.RMjIh-x1A_xETO4A",
      "confidence": 0.99
    },
    "administrativeLevels": {
      "level1long": "Illinois",
      "level2long": "Cook"
    },
    "provider": "here"
  }
]