seven decimal places to given a worse case precision of about 1cm.
max_lon = Tracepoint.maximum('longitude', :conditions => ['gpx_id = ?', id])
min_lon = Tracepoint.minimum('longitude', :conditions => ['gpx_id = ?', id])
- max_lat = max_lat.to_f / 1000000
- min_lat = min_lat.to_f / 1000000
- max_lon = max_lon.to_f / 1000000
- min_lon = min_lon.to_f / 1000000
+ max_lat = max_lat.to_f / 10000000
+ min_lat = min_lat.to_f / 10000000
+ max_lon = max_lon.to_f / 10000000
+ min_lon = min_lon.to_f / 10000000
self.latitude = f_lat
self.longitude = f_lon
end
def lat=(l)
- self.latitude = (l * 1000000).round
+ self.latitude = (l * 10000000).round
end
def lng=(l)
- self.longitude = (l * 1000000).round
+ self.longitude = (l * 10000000).round
end
def lat
- return self.latitude.to_f / 1000000
+ return self.latitude.to_f / 10000000
end
def lon
- return self.longitude.to_f / 1000000
+ return self.longitude.to_f / 10000000
end
def to_xml_node
long long lat = *(long long *)args->args[0];
long long lon = *(long long *)args->args[1];
- return xy2tile(lon2x(lon / 1000000.0), lat2y(lat / 1000000.0));
+ return xy2tile(lon2x(lon / 10000000.0), lat2y(lat / 10000000.0));
}
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)")
+ Tracepoint.update_all("latitude = latitude * 10, longitude = longitude * 10, tile = tile_for_point(latitude * 10, longitude * 10)")
end
def self.down
# Return an SQL fragment to select a given area of the globe
def self.sql_for_area(minlat, minlon, maxlat, maxlon, prefix = nil)
tilesql = QuadTile.sql_for_area(minlat, minlon, maxlat, maxlon, prefix)
- minlat = (minlat * 1000000).round
- minlon = (minlon * 1000000).round
- maxlat = (maxlat * 1000000).round
- maxlon = (maxlon * 1000000).round
+ minlat = (minlat * 10000000).round
+ minlon = (minlon * 10000000).round
+ maxlat = (maxlat * 10000000).round
+ maxlon = (maxlon * 10000000).round
return "#{tilesql} AND #{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}"
end