if (FALSE) {
# structured() requires an OpenSearch instance with structured support
# the following code will not work off the shelf
# refer to vignette("nominatim-import") for details
dir <- file.path(tempdir(), "photon")
photon <- new_photon(dir, opensearch = TRUE)
photon$import(password = "psql_password", structured = TRUE)
photon$start()
# check if structured() is supported
has_structured_support()
# structured() works on dataframes containing structurized data
place_data <- data.frame(
housenumber = c(NA, "77C", NA),
street = c("Falealilli Cross Island Road", "Main Beach Road", "Le Mafa Pass Road"),
state = c("Tuamasaga", "Tuamasaga", "Atua")
)
structured(place_data, limit = 1)
# countries must be specified as iso2 country codes
structured(data.frame(countrycode = "ws"))
# traditional parameters from geocode() can also be used but are much more niche
structured(data.frame(city = "Apia"), layer = "house") # matches nothing
# structured geocoding can discern small differences in places
safune <- data.frame(
city = c("Safune", "Safune"),
state = c("Gaga'ifomauga", "Tuamasaga")
)
structured(safune, limit = 1)
}
Run the code above in your browser using DataLab