]> gitweb.factorcode.org Git - factor.git/commitdiff
support for geobytes city/country/region database
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 13 Mar 2009 04:15:42 +0000 (23:15 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 13 Mar 2009 04:15:42 +0000 (23:15 -0500)
extra/geobytes/authors.txt [new file with mode: 0644]
extra/geobytes/geobytes.factor [new file with mode: 0644]
extra/geobytes/summary.txt [new file with mode: 0644]
extra/geobytes/tags.txt [new file with mode: 0644]

diff --git a/extra/geobytes/authors.txt b/extra/geobytes/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -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 (file)
index 0000000..bbd16b7
--- /dev/null
@@ -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
+        ] input<sequence 
+    ] map ;
+
+MEMO: load-regions ( -- seq )
+    geobytes-regions-path latin1 file>csv rest-slice [
+        [
+            {
+                [ string>number ]
+                [ string>number ]
+                [ ]
+                [ ]
+                [ [ blank? ] trim ]
+            } spread region boa
+        ] input<sequence 
+    ] map ;
+
+MEMO: load-cities ( -- seq )
+    geobytes-cities-path latin1 file>csv rest-slice [
+        [
+            {
+                [ string>number ]
+                [ string>number ]
+                [ string>number ]
+                [ ]
+                [ parse-decimal ]
+                [ parse-decimal ]
+                [ ]
+                [ string>number ]
+            } spread city boa
+        ] input<sequence 
+    ] map ;
+
+MEMO: load-version ( -- seq )
+    geobytes-version-path latin1 file>csv rest-slice [
+        [
+            {
+                [ ]
+                [ ]
+                [ string>number ]
+            } spread version boa
+        ] input<sequence 
+    ] map ;
diff --git a/extra/geobytes/summary.txt b/extra/geobytes/summary.txt
new file mode 100644 (file)
index 0000000..50fd51f
--- /dev/null
@@ -0,0 +1 @@
+City, country, region database using database from http://www.geobytes.com/GeoWorldMap.zip
diff --git a/extra/geobytes/tags.txt b/extra/geobytes/tags.txt
new file mode 100644 (file)
index 0000000..0aef4fe
--- /dev/null
@@ -0,0 +1 @@
+enterprise