Class: Terragona::ConcaveHull
- Inherits:
-
Object
- Object
- Terragona::ConcaveHull
- Defined in:
- lib/terragona/concave_hull.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ConcaveHull
constructor
A new instance of ConcaveHull.
- #perform(points, tags, id) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ConcaveHull
Returns a new instance of ConcaveHull.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/terragona/concave_hull.rb', line 6 def initialize( = {}) @projection = [:projection] || 4326 @table = [:table] || 'concave_hull' @target_percent = [:target_percent] || 0.8 @allow_holes = [:allow_holes] @allow_holes = false if @allow_holes.nil? @max_distance_ratio = [:max_distance_ratio] || 1.6 ={ :database=> [:db_name], :user=> [:db_username], :password=> [:db_password], :host=> [:db_host] || 'localhost', :port=> [:db_port] || 5432, :max_connections=> [:db_max_connections] || 10 } @db = Sequel.postgres() create_table end |
Instance Method Details
#perform(points, tags, id) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/terragona/concave_hull.rb', line 28 def perform(points,,id) filtered_points=filter_points_by_distance(points) points_stringified=stringify_points(filtered_points) query = %Q{ ST_ConcaveHull( ST_GeomFromText( 'MULTIPOINT( #{points_stringified} )', #{@projection} ), #{@target_percent}, #{@allow_holes}) } create_concave_hull(query,,filtered_points.count,id) end |