[][src]Crate city_spellcheck

This crate provides a library for spell correction of city names using a fuzzy search scoring system that has optional weighting for distance.

What that means is that if you supply your current GPS coordinates, then the spelling correction suggested results takes your current location heavily into account when scoring each potential match.

Currently only supports USA and Canada, working on expanding to other countries ASAP.


To use this library just add city-spellcheck to your Cargo.toml file:

city-spellcheck = "0.1.0"

Now you can use it:

use city_spellcheck::*;

To take a look at a very simple RESTful API (with only one route) that uses this library, check out the City-Spellcheck Web Api

Example Use Case

use city_spellcheck::*;

let mut cities = CityData::new();
let london = Coordinate::new(42.98339, -81.23304);
let results = cities.search("London", Some(london));
    format!("{:?}", results),
    "[FuzzyResult { city: \"London, ON, CA\", latitude: 42.98339, longitude: -81.23304, score: 1.0 }, FuzzyResult { city: \"London, OH, US\", latitude: 39.88645, longitude: -83.44825, score: 0.6252391 }, FuzzyResult { city: \"London, KY, US\", latitude: 37.12898, longitude: -84.08326, score: 0.6250727 }, FuzzyResult { city: \"Lemont, IL, US\", latitude: 41.67364, longitude: -88.00173, score: 0.52094036 }, FuzzyResult { city: \"Brant, ON, CA\", latitude: 43.1334, longitude: -80.34967, score: 0.5208334 }]");

Please explore this documentation to learn more. Nearly all useful methods are on the CityData struct.



countries holds a country enum with valid countries


regions holds enums and implementations to display variants in english friendly string format



City is an abstraction above CityData holding information on a single city (stored at a specific index in CityData)


CityData holds all city data, each city is stored vertically across fields at a given index


Stores a GPS coordinate


FuzzyResult represents a result from our location weighted fuzzy search. Includes a score where 0 is worst and 1 is perfect match.