]> git.openstreetmap.org Git - rails.git/commitdiff
Add a migration to upgrade gps_points for quad tile support.
authorTom Hughes <tom@compton.nu>
Wed, 12 Sep 2007 17:59:48 +0000 (17:59 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 12 Sep 2007 17:59:48 +0000 (17:59 +0000)
db/README
db/migrate/005_tile_tracepoints.rb [new file with mode: 0644]

index e3e210a43c440b4e90e7d188e92c7475bb7984c4..f4530f09008b3fa2edef36816da7dd4ffb8ae007 100644 (file)
--- a/db/README
+++ b/db/README
@@ -22,10 +22,33 @@ $ mysql -u <uid> -p
 > flush privileges;
 > exit
 
+Creating functions
+====================
+
+Run this command in the db/functions directory:
+
+$ make
+
+Make sure the db/functions directory is on the MySQL server's library
+path and restart the MySQL server. On linux the easiest way to do this
+is to create /etc/ld.so.conf.d/osm.conf and place the path to the
+db/functions directory in it and then run the following command as root:
+
+$ ldconfig
+
+Now create the functions as follows:
+
+$ mysql -u <uid> -p openstreetmap
+
+(change <uid> with appropriate username of administrative user eg. root )
+
+> create function tile_for_point returns integer soname 'libquadtile.so';
+> exit
+
 Creating database skeleton tables
 ===================================
 
-Run this command from the root of your rails direcotry:
+Run this command from the root of your rails directory:
 
 $ rake db:migrate
 
diff --git a/db/migrate/005_tile_tracepoints.rb b/db/migrate/005_tile_tracepoints.rb
new file mode 100644 (file)
index 0000000..d9d782d
--- /dev/null
@@ -0,0 +1,15 @@
+class TileTracepoints < ActiveRecord::Migration
+  def self.up
+    add_column "gps_points", "tile", :integer, :null => false, :options => "UNSIGNED"
+    add_index "gps_points", ["tile"], :name => "points_tile_idx"
+    remove_index "gps_points", :name => "points_idx"
+
+    Tracepoint.update_all("tile = tile_for_point(latitude, longitude)")
+  end
+
+  def self.down
+    add_index "gps_points", ["latitude", "longitude"], :name => "points_idx"
+    remove_index "gps_points", :name => "points_tile_idx"
+    remove_column "gps_points", "tile"
+  end
+end