diff --git a/extra/geobytes/authors.txt b/extra/geobytes/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/extra/geobytes/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/extra/geobytes/geobytes.factor b/extra/geobytes/geobytes.factor new file mode 100644 index 0000000000..bbd16b7ff4 --- /dev/null +++ b/extra/geobytes/geobytes.factor @@ -0,0 +1,90 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: combinators combinators.smart csv io.encodings.8-bit +math.parser memoize sequences kernel unicode.categories money ; +IN: geobytes + +! GeoBytes is not free software. +! Please read their license should you choose to use it. +! This is just a binding to the GeoBytes CSV files. +! Download and install GeoBytes yourself should you wish to use it. +! http://www.geobytes.com/GeoWorldMap.zip + +CONSTANT: geobytes-cities-path "resource:GeoWorldMap/Cities.txt" +CONSTANT: geobytes-countries-path "resource:GeoWorldMap/Countries.txt" +CONSTANT: geobytes-regions-path "resource:GeoWorldMap/Regions.txt" +CONSTANT: geobytes-version-path "resource:GeoWorldMap/version.txt" + +TUPLE: country country-id country fips104 iso2 iso3 ison internet capital map-reference +nationality-singular nationality-plural currency currency-code population title +comment ; + +TUPLE: region region-id country-id region code adm1-code ; + +TUPLE: city city-id country-id region-id city longitude latitude timezone code ; + +TUPLE: version component version rows ; + +MEMO: load-countries ( -- seq ) + geobytes-countries-path latin1 file>csv rest-slice [ + [ + { + [ string>number ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ ] + [ string>number ] + [ ] + [ ] + } spread country boa + ] inputcsv rest-slice [ + [ + { + [ string>number ] + [ string>number ] + [ ] + [ ] + [ [ blank? ] trim ] + } spread region boa + ] inputcsv rest-slice [ + [ + { + [ string>number ] + [ string>number ] + [ string>number ] + [ ] + [ parse-decimal ] + [ parse-decimal ] + [ ] + [ string>number ] + } spread city boa + ] inputcsv rest-slice [ + [ + { + [ ] + [ ] + [ string>number ] + } spread version boa + ] input