Class: ActiveRoad::Boundary

Inherits:
Base
  • Object
show all
Defined in:
app/models/active_road/boundary.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_intersect(other) ⇒ Object



36
37
38
# File 'app/models/active_road/boundary.rb', line 36

def self.all_intersect(other)
  where("ST_Intersects(geometry, ST_GeomFromEWKT(E'#{other.as_hex_ewkb}'))")
end

.all_uniq_bordersObject

Return linear rings which delimit multi polygon area



8
9
10
11
# File 'app/models/active_road/boundary.rb', line 8

def self.all_uniq_borders
  borders = self.all.collect(&:geometry).collect(&:polygons).flatten(1).collect(&:rings).flatten(1).uniq
  GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(borders)
end

.first_contains(other) ⇒ Object

Contains not take object equals on a boundary border!!



32
33
34
# File 'app/models/active_road/boundary.rb', line 32

def self.first_contains(other)
  where("ST_Contains(geometry, ST_GeomFromEWKT(E'#{other.as_hex_ewkb}'))").first
end

Instance Method Details

#bordersObject

Return linear rings which delimit multi polygon area



14
15
16
# File 'app/models/active_road/boundary.rb', line 14

def borders
  geometry.polygons.collect(&:rings).flatten
end

#difference(other) ⇒ Object



23
24
25
# File 'app/models/active_road/boundary.rb', line 23

def difference(other)
  postgis_calculate(:difference, [self, other])
end

#intersection(other) ⇒ Object



18
19
20
# File 'app/models/active_road/boundary.rb', line 18

def intersection(other)
  postgis_calculate(:intersection, [self, other])
end

#sym_difference(other) ⇒ Object



27
28
29
# File 'app/models/active_road/boundary.rb', line 27

def sym_difference(other)
  postgis_calculate(:symDifference, [self, other])
end