Skip to content

Commit

Permalink
geocode: wordsmith usage text
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
jqnatividad committed Sep 6, 2023
1 parent 248c450 commit 43ff5b8
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/cmd/geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ geocode options:
For suggest, this will limit the search to the specified countries.
For reverse, this ensures that the returned city is in the specified
countries (especially when reverse geocoding coordinates near country borders).
If the coordinate is outside the specified countries, the returned city will
be the closest city as the crow flies in the specified countries.
countries (especially when geocoding coordinates near country borders).
If the coordinate is outside the specified countries, the returned city
will be the closest city as the crow flies in the specified countries.
SUGGEST only options:
--min-score <score> The minimum Jaro-Winkler distance score.
Expand All @@ -170,15 +170,16 @@ geocode options:
prefix (e.g. US.TX, US.NJ, US.CA), the country can be inferred from the
admin1 code (in this example - US), and the --country option is not required.
If specifying multiple admin1 filters, you can mix admin1 codes and names, and they
are matched in priority order.
Matches are made using a starts_with() comparison (i.e. "US" will match "US.NY", "US.NJ",
etc. for admin1 code. "New" will match "New York", "New Jersey", "Newfoundland", etc.
for admin1 name.)
If specifying multiple admin1 filters, you can mix admin1 codes and names,
and they are matched in priority order.
Matches are made using a starts_with() comparison (i.e. "US" will match "US.NY",
"US.NJ", etc. for admin1 code. "New" will match "New York", "New Jersey",
"Newfoundland", etc. for admin1 name.)
admin1 is the second priority filter, and will be applied after country filters.
See https://download.geonames.org/export/dump/admin1CodesASCII.txt for admin1 codes/names.
See https://download.geonames.org/export/dump/admin1CodesASCII.txt for
recognized admin1 codes/names.
REVERSE only option:
-k, --k_weight <weight> Use population-weighted distance for reverse subcommand.
Expand All @@ -187,7 +188,6 @@ geocode options:
If not set (default), the population is not used and the
nearest city is returned.
If not set, suggest will search all countries in the current loaded index.
-f, --formatstr=<string> The place format to use. The predefined formats are:
- '%city-state' - e.g. Brooklyn, New York
- '%city-country' - Brooklyn, US
Expand All @@ -206,26 +206,29 @@ geocode options:
- '%capital' - the capital
- '%population' - the population
- '%timezone' - the timezone
- '%+' - use the subcommand's default format. For suggest, '%location'.
For reverse, '%city-admin1'.
- '%+' - use the subcommand's default format.
suggest - '%location'
suggestnow - '{name}, {admin1} {country}: {latitude}, {longitude}'
reverse & reversenow - '%city-admin1'
If an invalid format is specified, it will be treated as '%+'.
Alternatively, you can use dynamic formatting to create a custom format.
To do so, set the --formatstr to a dynfmt template, enclosing field names
in curly braces.
The following ten fields are available:
id, name, latitude, longitude, country, admin1, admin2, capital, timezone, population
id, name, latitude, longitude, country, admin1, admin2, capital,
timezone, population
e.g. "City: {name}, State: {admin1}, Country: {country} - {timezone}"
If an invalid dynfmt template is specified, it will return "Invalid dynfmt template."
If an invalid template is specified, "Invalid dynfmt template" is returned.
Finally, you can use the special format "%dyncols:" to add columns to the CSV.
To do so, set the --formatstr to "%dyncols:" followed by a comma-delimited list
of key:value pairs enclosed in curly braces.
The key is the desired column name, and the value is are the same ten fields available
for dynamic formatting.
The key is the desired column name, and the value is are the same ten fields
available for dynamic formatting.
e.g. "%dyncols: {city_col:name}, {state_col:admin1}, {country_col:country}"
Expand Down Expand Up @@ -1171,6 +1174,7 @@ fn search_index(
return None;
}

/// "%dyncols:" formatstr used. Adds dynamic columns to CSV.
fn add_dyncols(
record: &mut csv::StringRecord,
cityrecord: &CitiesRecord,
Expand Down

0 comments on commit 43ff5b8

Please sign in to comment.