diff --git a/examples/data/location/location_example b/examples/data/location/location_example deleted file mode 100755 index a8d9e0cd..00000000 Binary files a/examples/data/location/location_example and /dev/null differ diff --git a/examples/data/location/location_example.vsh b/examples/data/location/location_example.vsh index 16e7e485..9e1731a7 100755 --- a/examples/data/location/location_example.vsh +++ b/examples/data/location/location_example.vsh @@ -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 diff --git a/examples/data/location/location_example_tcc.vsh b/examples/data/location/location_example_tcc.vsh new file mode 100755 index 00000000..5769ba99 --- /dev/null +++ b/examples/data/location/location_example_tcc.vsh @@ -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('---') +// }