location postgresql
This commit is contained in:
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.location
|
import freeflowuniverse.herolib.data.location
|
||||||
|
|
||||||
|
|||||||
46
examples/data/location/location_example_tcc.vsh
Executable file
46
examples/data/location/location_example_tcc.vsh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
|
|
||||||
|
import freeflowuniverse.herolib.data.location
|
||||||
|
|
||||||
|
// Create a new location instance
|
||||||
|
mut loc := location.new(false) or { panic(err) }
|
||||||
|
println('Location database initialized')
|
||||||
|
|
||||||
|
// Initialize the database (downloads and imports data)
|
||||||
|
// This only needs to be done once or when updating data
|
||||||
|
println('Downloading and importing location data (this may take a few minutes)...')
|
||||||
|
|
||||||
|
// the arg is if we redownload
|
||||||
|
loc.download_and_import(false) or { panic(err) }
|
||||||
|
println('Data import complete')
|
||||||
|
|
||||||
|
// // Example 1: Search for a city
|
||||||
|
// println('\nSearching for London...')
|
||||||
|
// results := loc.search('London', 'GB', 5, true) or { panic(err) }
|
||||||
|
// for result in results {
|
||||||
|
// println('${result.city.name}, ${result.country.name} (${result.country.iso2})')
|
||||||
|
// println('Coordinates: ${result.city.latitude}, ${result.city.longitude}')
|
||||||
|
// println('Population: ${result.city.population}')
|
||||||
|
// println('Timezone: ${result.city.timezone}')
|
||||||
|
// println('---')
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Example 2: Search near coordinates (10km radius from London)
|
||||||
|
// println('\nSearching for cities within 10km of London...')
|
||||||
|
// nearby := loc.search_near(51.5074, -0.1278, 10.0, 5) or { panic(err) }
|
||||||
|
// for result in nearby {
|
||||||
|
// println('${result.city.name}, ${result.country.name}')
|
||||||
|
// println('Distance from center: Approx ${result.similarity:.1f}km')
|
||||||
|
// println('---')
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Example 3: Fuzzy search in a specific country
|
||||||
|
// println('\nFuzzy searching for "New" in United States...')
|
||||||
|
// us_cities := loc.search('New', 'US', 5, true) or { panic(err) }
|
||||||
|
// for result in us_cities {
|
||||||
|
// println('${result.city.name}, ${result.country.name}')
|
||||||
|
// println('State: ${result.city.state_name} (${result.city.state_code})')
|
||||||
|
// println('Population: ${result.city.population}')
|
||||||
|
// println('---')
|
||||||
|
// }
|
||||||
Reference in New Issue
Block a user