rails_port_0.5: Merge rails_port.

This commit is contained in:
Gabriel Ebner 2007-09-29 17:44:17 +00:00
commit 26fb51c86e
6 changed files with 56 additions and 17 deletions

View file

@ -190,7 +190,7 @@ class Trace < ActiveRecord::Base
tp = Tracepoint.new
tp.lat = point['latitude'].to_f
tp.lng = point['longitude'].to_f
tp.lon = point['longitude'].to_f
tp.altitude = point['altitude'].to_f
tp.timestamp = point['timestamp']
tp.gpx_id = id

View file

@ -25,7 +25,7 @@ class Tracepoint < ActiveRecord::Base
self.latitude = (l * 10000000).round
end
def lng=(l)
def lon=(l)
self.longitude = (l * 10000000).round
end

View file

@ -29,6 +29,11 @@ Run this command in the db/functions directory:
$ make
The above command should work for linux and most other Unix systems
that use ELF shared objects. For MacOS X you will need to do:
$ make libquadtile.dylib
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
@ -45,6 +50,11 @@ $ mysql -u <uid> -p openstreetmap
> create function tile_for_point returns integer soname 'libquadtile.so';
> exit
or, for MacOS X:
> create function tile_for_point returns integer soname 'libquadtile.dylib';
> exit
Creating database skeleton tables
===================================

View file

@ -1,4 +1,10 @@
QTDIR=../../lib/quad_tile
libquadtile.so: quadtile.c ${QTDIR}/quad_tile.h
cc `mysql_config --include` -I${QTDIR} -fPIC -O3 -shared -o libquadtile.so quadtile.c
libquadtile.so: quadtile.o
cc -shared -o libquadtile.so quadtile.o
libquadtile.dylib: quadtile.o
libtool -dynamic quadtile.o -o libquadtile.dylib
quadtile.o: quadtile.c ${QTDIR}/quad_tile.h
cc `mysql_config --include` -I${QTDIR} -fPIC -O3 -c -o quadtile.o quadtile.c

View file

@ -4,10 +4,20 @@ class TileTracepoints < ActiveRecord::Migration
add_index "gps_points", ["tile"], :name => "points_tile_idx"
remove_index "gps_points", :name => "points_idx"
Tracepoint.update_all("latitude = latitude * 10, longitude = longitude * 10, tile = tile_for_point(latitude * 10, longitude * 10)")
begin
Tracepoint.update_all("latitude = latitude * 10, longitude = longitude * 10, tile = tile_for_point(latitude * 10, longitude * 10)")
rescue ActiveRecord::StatementInvalid => ex
Tracepoint.find(:all).each do |tp|
tp.latitude = tp.latitude * 10
tp.longitude = tp.longitude * 10
tp.save!
end
end
end
def self.down
Tracepoint.update_all("latitude = latitude / 10, longitude = longitude / 10")
add_index "gps_points", ["latitude", "longitude"], :name => "points_idx"
remove_index "gps_points", :name => "points_tile_idx"
remove_column "gps_points", "tile"

View file

@ -1,13 +1,26 @@
class TileNodes < ActiveRecord::Migration
def self.upgrade_table(from_table, to_table)
execute <<-END_SQL
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
user_id, visible, tags, timestamp,
tile_for_point(CAST(ROUND(latitude * 10000000) AS UNSIGNED),
CAST(ROUND(longitude * 10000000) AS UNSIGNED))
FROM #{from_table}
END_SQL
def self.upgrade_table(from_table, to_table, model)
begin
execute <<-END_SQL
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
user_id, visible, tags, timestamp,
tile_for_point(CAST(ROUND(latitude * 10000000) AS UNSIGNED),
CAST(ROUND(longitude * 10000000) AS UNSIGNED))
FROM #{from_table}
END_SQL
rescue ActiveRecord::StatementInvalid => ex
execute <<-END_SQL
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
user_id, visible, tags, timestamp, 0
FROM #{from_table}
END_SQL
model.find(:all).each do |n|
n.save!
end
end
end
def self.downgrade_table(from_table, to_table)
@ -40,8 +53,8 @@ class TileNodes < ActiveRecord::Migration
change_column "current_nodes", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
change_column "current_nodes", "tile", :integer, :null => false, :unsigned => true
upgrade_table "current_nodes_v5", "current_nodes"
upgrade_table "current_nodes_v5", "current_nodes", Node
drop_table "current_nodes_v5"
rename_table "nodes", "nodes_v5"
@ -63,7 +76,7 @@ class TileNodes < ActiveRecord::Migration
change_column "nodes", "tile", :integer, :null => false, :unsigned => true
upgrade_table "nodes_v5", "nodes"
upgrade_table "nodes_v5", "nodes", OldNode
drop_table "nodes_v5"
end