Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geocoding and Search API v7 #52

Closed
dpprdan opened this issue Aug 18, 2020 · 2 comments
Closed

Geocoding and Search API v7 #52

dpprdan opened this issue Aug 18, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@dpprdan
Copy link
Contributor

dpprdan commented Aug 18, 2020

HERE launched a new Geocoding and Search API v7 (apparently already some time ago).

The Geocoder, Geocoder Autocomplete (and Places) APIs have been placed "in maintenance":

Note: This service is no longer being actively developed. We will only provide critical fixes for this service in future. Instead, use the new Geocoding and Search API v7 service.

From https://developer.here.com/documentation/geocoder/dev_guide/topics/what-is.html

I have not found out the EOL of the "old" APIs, so cannot say how urgent it is to act on this.

Apparently the response format also changed. Here are the geocoding results for "Schweighofstrasse 190, Zurich, Switzerland"

v6.2
{
  "Response": {
    "MetaInfo": {
      "Timestamp": "2020-08-18T14:34:00.522+0000"
    },
    "View": [
      {
        "_type": "SearchResultsViewType",
        "ViewId": 0,
        "Result": [
          {
            "Relevance": 1,
            "MatchLevel": "houseNumber",
            "MatchQuality": {
              "Country": 1,
              "City": 1,
              "Street": [
                1
              ],
              "HouseNumber": 1
            },
            "MatchType": "interpolated",
            "Location": {
              "LocationId": "NT_wqJFy0LBrbr0VLs1azqsVB_xkDM",
              "LocationType": "point",
              "DisplayPosition": {
                "Latitude": 47.3596988,
                "Longitude": 8.5075278
              },
              "NavigationPosition": [
                {
                  "Latitude": 47.35959,
                  "Longitude": 8.50741
                }
              ],
              "MapView": {
                "TopLeft": {
                  "Latitude": 47.3608229,
                  "Longitude": 8.5058683
                },
                "BottomRight": {
                  "Latitude": 47.3585746,
                  "Longitude": 8.5091873
                }
              },
              "Address": {
                "Label": "Schweighofstrasse 190, 8045 Zürich Zürich, Schweiz",
                "Country": "CHE",
                "State": "ZH",
                "County": "Zürich",
                "City": "Zürich",
                "District": "Kreis 3",
                "Street": "Schweighofstrasse",
                "HouseNumber": "190",
                "PostalCode": "8045",
                "AdditionalData": [
                  {
                    "value": "Schweiz",
                    "key": "CountryName"
                  },
                  {
                    "value": "Zürich",
                    "key": "StateName"
                  },
                  {
                    "value": "Zürich",
                    "key": "CountyName"
                  }
                ]
              }
            }
          }
        ]
      }
    ]
  }
}
v7
{
  "items": [
    {
      "title": "Schweighofstrasse 190, 8045 Zürich Zürich, Schweiz",
      "id": "here:af:streetsection:c9lD-AuiFGH7e4vmkB0XDB:EAIaAzE5MChk",
      "resultType": "houseNumber",
      "houseNumberType": "interpolated",
      "address": {
        "label": "Schweighofstrasse 190, 8045 Zürich Zürich, Schweiz",
        "countryCode": "CHE",
        "countryName": "Schweiz",
        "state": "Zürich",
        "county": "Zürich",
        "city": "Zürich",
        "district": "Kreis 3",
        "street": "Schweighofstrasse",
        "postalCode": "8045",
        "houseNumber": "190"
      },
      "position": {
        "lat": 47.35955,
        "lng": 8.50769
      },
      "access": [
        {
          "lat": 47.35948,
          "lng": 8.50752
        }
      ],
      "mapView": {
        "west": 8.50636,
        "south": 47.35865,
        "east": 8.50902,
        "north": 47.36045
      },
      "scoring": {
        "queryScore": 1,
        "fieldScore": {
          "country": 1,
          "city": 1,
          "streets": [
            1
          ],
          "houseNumber": 1
        }
      }
    }
  ]
}
@munterfi munterfi self-assigned this Aug 19, 2020
@munterfi munterfi added the enhancement New feature or request label Aug 19, 2020
@munterfi
Copy link
Owner

Many thanks for reporting!

The update of the API versions is planned for the release of {hereR} v0.5.0. Apart from the Geocoding API v6.2 also the Routing API v7.2 and the Public Transit API v3 could be upgraded.

The reason for being a bit delayed with upgrading the API versions in the {hereR} package is that HERE has switched to a new encoding of LINESTRINGs "flexible polyline encoding" (which is not relevant in the case of the Geocoder API but it is for the Routing and Public Transit API) and there hasn't been an implementation in R for decoding polylines encoded in this format. Therefore, the {flexpolyline} package had to make its way to CRAN first.

The release of v0.5.0 is planned for mid or end of September.

@munterfi
Copy link
Owner

munterfi commented Aug 23, 2020

The Geocoder API used in geocode() is now upgraded from v6.2 to v7 in the {hereR} dev version:

library(hereR)
set_key("<API KEY>")
set_verbose(TRUE)

(geocoded <- geocode(c("Schweighofstrasse 190, Zürich", "Zürich")))
#> Sending 2 request(s) to: 'https://geocode.search.hereapi.com/v1/geocode?...'
#> Received 2 response(s) with total size: 1.7 Kb
#> Simple feature collection with 2 features and 11 fields
#> Active geometry column: geometry
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: 8.50769 ymin: 47.35955 xmax: 8.53977 ymax: 47.377
#> geographic CRS: WGS 84
#>   id                                            address        type
#> 1  1 Schweighofstrasse 190, 8045 Zürich Zürich, Schweiz houseNumber 
#> 2  2                                    Zürich, Schweiz    locality
#>              street house_number postal_code district   city county  state
#> 1 Schweighofstrasse          190        8045  Kreis 3 Zürich Zürich Zürich
#> 2              <NA>         <NA>        8001     <NA> Zürich Zürich Zürich
#>   country      access                 geometry
#> 1 Schweiz POINT EMPTY POINT (8.50769 47.35955)
#> 2 Schweiz POINT EMPTY   POINT (8.53977 47.377)

Except for the new type column, all columns are identical. But the naming convention of the column names has changed from camelCase to snake_case. This will be implemented in the entire package during the process of upgrading further API versions.

Thanks again for your input!

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       macOS Catalina 10.15.6      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Zurich               
#>  date     2020-08-23                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source        
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.0)
#>  backports     1.1.8      2020-06-17 [1] CRAN (R 4.0.2)
#>  callr         3.4.3      2020-03-28 [1] CRAN (R 4.0.0)
#>  class         7.3-17     2020-04-26 [1] CRAN (R 4.0.2)
#>  classInt      0.4-3      2020-04-07 [1] CRAN (R 4.0.0)
#>  cli           2.0.2      2020-02-28 [1] CRAN (R 4.0.0)
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 4.0.0)
#>  curl          4.3        2019-12-02 [1] CRAN (R 4.0.1)
#>  data.table    1.13.0     2020-07-24 [1] CRAN (R 4.0.2)
#>  DBI           1.1.0      2019-12-15 [1] CRAN (R 4.0.0)
#>  desc          1.2.0      2018-05-01 [1] CRAN (R 4.0.0)
#>  devtools      2.3.1      2020-07-21 [1] CRAN (R 4.0.2)
#>  digest        0.6.25     2020-02-23 [1] CRAN (R 4.0.0)
#>  dplyr         1.0.2      2020-08-18 [1] CRAN (R 4.0.2)
#>  e1071         1.7-3      2019-11-26 [1] CRAN (R 4.0.0)
#>  ellipsis      0.3.1      2020-05-15 [1] CRAN (R 4.0.0)
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.0)
#>  fansi         0.4.1      2020-01-08 [1] CRAN (R 4.0.0)
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.0.2)
#>  generics      0.0.2      2018-11-29 [1] CRAN (R 4.0.0)
#>  glue          1.4.1      2020-05-13 [1] CRAN (R 4.0.0)
#>  hereR       * 0.4.1.9000 2020-08-23 [1] local         
#>  htmltools     0.5.0      2020-06-16 [1] CRAN (R 4.0.2)
#>  jsonlite      1.7.0      2020-06-25 [1] CRAN (R 4.0.2)
#>  KernSmooth    2.23-17    2020-04-26 [1] CRAN (R 4.0.2)
#>  knitr         1.29       2020-06-23 [1] CRAN (R 4.0.2)
#>  lifecycle     0.2.0      2020-03-06 [1] CRAN (R 4.0.0)
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 4.0.0)
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 4.0.0)
#>  pillar        1.4.6      2020-07-10 [1] CRAN (R 4.0.2)
#>  pkgbuild      1.1.0      2020-07-13 [1] CRAN (R 4.0.2)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.0.0)
#>  pkgload       1.1.0      2020-05-29 [1] CRAN (R 4.0.2)
#>  prettyunits   1.1.1      2020-01-24 [1] CRAN (R 4.0.0)
#>  processx      3.4.3      2020-07-05 [1] CRAN (R 4.0.2)
#>  ps            1.3.4      2020-08-11 [1] CRAN (R 4.0.2)
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.0)
#>  R6            2.4.1      2019-11-12 [1] CRAN (R 4.0.0)
#>  Rcpp          1.0.5      2020-07-06 [1] CRAN (R 4.0.2)
#>  remotes       2.2.0      2020-07-21 [1] CRAN (R 4.0.2)
#>  rlang         0.4.7      2020-07-09 [1] CRAN (R 4.0.2)
#>  rmarkdown     2.3        2020-06-18 [1] CRAN (R 4.0.2)
#>  rprojroot     1.3-2      2018-01-03 [1] CRAN (R 4.0.0)
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.0)
#>  sf            0.9-5      2020-07-14 [1] CRAN (R 4.0.2)
#>  stringi       1.4.6      2020-02-17 [1] CRAN (R 4.0.0)
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.0.2)
#>  testthat      2.3.2      2020-03-02 [1] CRAN (R 4.0.2)
#>  tibble        3.0.3      2020-07-10 [1] CRAN (R 4.0.2)
#>  tidyselect    1.1.0      2020-05-11 [1] CRAN (R 4.0.0)
#>  units         0.6-7      2020-06-13 [1] CRAN (R 4.0.2)
#>  usethis       1.6.1      2020-04-29 [1] CRAN (R 4.0.0)
#>  vctrs         0.3.2      2020-07-15 [1] CRAN (R 4.0.2)
#>  withr         2.2.0      2020-04-20 [1] CRAN (R 4.0.0)
#>  xfun          0.16       2020-07-24 [1] CRAN (R 4.0.2)
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.0)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants