+ Math.log((Math.tan(max) + (1.0 / Math.cos(max))) /
+ (Math.tan(min) + (1.0 / Math.cos(min)))) *
+ (128.0 * (2.0**zoom) / Math::PI)
+ end
+
+ # there are two forms used for bounds with and without an underscore,
+ # cater for both forms eg minlon and min_lon
+ def add_bounds_to(hash, underscore = "")
+ hash["min#{underscore}lat"] = format("%<lat>.7f", :lat => min_lat)
+ hash["min#{underscore}lon"] = format("%<lon>.7f", :lon => min_lon)
+ hash["max#{underscore}lat"] = format("%<lat>.7f", :lat => max_lat)
+ hash["max#{underscore}lon"] = format("%<lon>.7f", :lon => max_lon)
+ hash
+ end
+
+ def to_scaled
+ BoundingBox.new((min_lon * GeoRecord::SCALE),
+ (min_lat * GeoRecord::SCALE),
+ (max_lon * GeoRecord::SCALE),
+ (max_lat * GeoRecord::SCALE))
+ end
+
+ def to_unscaled
+ BoundingBox.new((min_lon / GeoRecord::SCALE),
+ (min_lat / GeoRecord::SCALE),
+ (max_lon / GeoRecord::SCALE),
+ (max_lat / GeoRecord::SCALE))
+ end
+
+ def to_a
+ [min_lon, min_lat, max_lon, max_lat]