class BoundingBox
Geographical Bounding Box¶ ↑
A bounding box is a geographical box determined by the configuration file.
It is currently not being implemented in queries because the import scripts are cutting the excess data away, so there is nothing outside of the bounding box in the database.
However, queries are capable of only querying within the bounding box, so it is possible to change the box throughout calculations to get a subset of the data – change to @active = true
Attributes
active[R]
bbox_array[R]
bottom_left[R]
top_right[R]
Public Class Methods
new(args=nil)
click to toggle source
# File models/AnalysisWindow.rb, line 257 def initialize(args=nil) if args.nil? @active = false elsif args[:bbox].is_a? String @bbox_array = args[:bbox].split(',') @bottom_left = [ bbox_array[0].to_f, bbox_array[1].to_f ] @top_right = [ bbox_array[2].to_f, bbox_array[3].to_f ] else @bottom_left = args[:bottom_left] @top_right = args[:top_right] end post_initialize end
Public Instance Methods
geojson_geometry()
click to toggle source
# File models/AnalysisWindow.rb, line 294 def geojson_geometry return {type: "Polygon", coordinates[[[ bottom_left, [bottom_left[0], top_right[1]], top_right, [top_right[0], bottom_left[1]], bottom_left ]]} end
geometry()
click to toggle source
Returns an array of the bounding box parameters.
# File models/AnalysisWindow.rb, line 290 def geometry mongo_format["$box"].flatten end
mongo_format()
click to toggle source
Going to need some pretty robust methods to pass to Mongo queries, but painless for now
# File models/AnalysisWindow.rb, line 283 def mongo_format h = {} h["$box"] = [bottom_left, top_right] return h end
post_initialize()
click to toggle source
# File models/AnalysisWindow.rb, line 274 def post_initialize unless (bottom_left.is_a? Array) and (top_right.is_a? Array) @active = false else @active = false #Active is always set to false and not incorporated in current queries end end