Module: RGeo::ActiveRecord::SpatialExpressions
- Included in:
- SpatialConstantNode, SpatialNamedFunction
- Defined in:
- lib/rgeo/active_record/spatial_expressions.rb
Overview
A set of spatial expression builders. These methods can be chained off other spatial expressions to form complex expressions.
These functions require Arel 2.1 or later.
Instance Method Summary collapse
-
#st_area(units_ = nil) ⇒ Object
– Surface functions ++.
- #st_asbinary ⇒ Object
- #st_astext ⇒ Object
- #st_boundary ⇒ Object
- #st_buffer(distance_, units_ = nil) ⇒ Object
- #st_centroid ⇒ Object
- #st_contains(rhs_) ⇒ Object
- #st_convexhull ⇒ Object
- #st_crosses(rhs_) ⇒ Object
- #st_difference(rhs_) ⇒ Object
-
#st_dimension ⇒ Object
– Geometry functions ++.
- #st_disjoint(rhs_) ⇒ Object
- #st_distance(rhs_, units_ = nil) ⇒ Object
- #st_endpoint ⇒ Object
- #st_envelope ⇒ Object
- #st_equals(rhs_) ⇒ Object
-
#st_exteriorring ⇒ Object
– Polygon functions ++.
-
#st_function(function_, *args_) ⇒ Object
– Generic functions ++.
- #st_geometryn(n_) ⇒ Object
- #st_geometrytype ⇒ Object
- #st_interiorringn(n_) ⇒ Object
- #st_intersection(rhs_) ⇒ Object
- #st_intersects(rhs_) ⇒ Object
- #st_isclosed ⇒ Object
- #st_isempty ⇒ Object
- #st_isring ⇒ Object
- #st_issimple ⇒ Object
- #st_length(units_ = nil) ⇒ Object
- #st_m ⇒ Object
-
#st_numgeometries ⇒ Object
– GeometryCollection functions ++.
- #st_numinteriorrings ⇒ Object
-
#st_numpoints ⇒ Object
– LineString functions ++.
- #st_overlaps(rhs_) ⇒ Object
- #st_pointn(n_) ⇒ Object
- #st_pointonsurface ⇒ Object
- #st_relate(rhs_, matrix_ = nil) ⇒ Object
- #st_srid ⇒ Object
-
#st_startpoint ⇒ Object
– Curve functions ++.
- #st_symdifference(rhs_) ⇒ Object
- #st_touches(rhs_) ⇒ Object
- #st_union(rhs_) ⇒ Object
- #st_within(rhs_) ⇒ Object
-
#st_x ⇒ Object
– Point functions ++.
- #st_y ⇒ Object
- #st_z ⇒ Object
Instance Method Details
#st_area(units_ = nil) ⇒ Object
– Surface functions ++
202 203 204 205 206 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 202 def st_area(units_=nil) args_ = [self] args_ << units.to_s if units_ ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_StartPoint', args_, [false, true, false]) end |
#st_asbinary ⇒ Object
42 43 44 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 42 def st_asbinary ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_AsBinary', [self], [false, true]) end |
#st_astext ⇒ Object
38 39 40 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 38 def st_astext ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_AsText', [self], [false, true]) end |
#st_boundary ⇒ Object
58 59 60 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 58 def st_boundary ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Boundary', [self], [true, true]) end |
#st_buffer(distance_, units_ = nil) ⇒ Object
126 127 128 129 130 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 126 def st_buffer(distance_, units_=nil) args_ = [self, distance_.to_f] args_ << units.to_s if units_ ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Buffer', args_, [true, true, false]) end |
#st_centroid ⇒ Object
208 209 210 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 208 def st_centroid ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Centroid', [self], [true, true]) end |
#st_contains(rhs_) ⇒ Object
90 91 92 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 90 def st_contains(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Contains', [self, rhs_], [false, true, true]) end |
#st_convexhull ⇒ Object
132 133 134 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 132 def st_convexhull ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_ConvexHull', [self], [true, true]) end |
#st_crosses(rhs_) ⇒ Object
82 83 84 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 82 def st_crosses(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Crosses', [self, rhs_], [false, true, true]) end |
#st_difference(rhs_) ⇒ Object
114 115 116 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 114 def st_difference(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Difference', [self, rhs_], [true, true, true]) end |
#st_dimension ⇒ Object
– Geometry functions ++
30 31 32 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 30 def st_dimension ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Dimension', [self], [false, true]) end |
#st_disjoint(rhs_) ⇒ Object
70 71 72 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 70 def st_disjoint(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Disjoint', [self, rhs_], [false, true, true]) end |
#st_distance(rhs_, units_ = nil) ⇒ Object
104 105 106 107 108 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 104 def st_distance(rhs_, units_=nil) args_ = [self, rhs_] args_ << units.to_s if units_ ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Distance', args_, [false, true, true, false]) end |
#st_endpoint ⇒ Object
166 167 168 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 166 def st_endpoint ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_EndPoint', [self], [true, true]) end |
#st_envelope ⇒ Object
62 63 64 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 62 def st_envelope ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Envelope', [self], [true, true]) end |
#st_equals(rhs_) ⇒ Object
66 67 68 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 66 def st_equals(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Equals', [self, rhs_], [false, true, true]) end |
#st_exteriorring ⇒ Object
– Polygon functions ++
220 221 222 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 220 def st_exteriorring ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_ExteriorRing', [self], [true, true]) end |
#st_function(function_, *args_) ⇒ Object
– Generic functions ++
21 22 23 24 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 21 def st_function(function_, *args_) spatial_info_ = args_.last.is_a?(::Array) ? args_.pop : [] ::RGeo::ActiveRecord::SpatialNamedFunction.new(function_, [self] + args_, spatial_info_) end |
#st_geometryn(n_) ⇒ Object
242 243 244 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 242 def st_geometryn(n_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_GeometryN', [self, n_.to_i], [true, true, false]) end |
#st_geometrytype ⇒ Object
34 35 36 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 34 def st_geometrytype ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_GeometryType', [self], [false, true]) end |
#st_interiorringn(n_) ⇒ Object
230 231 232 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 230 def st_interiorringn(n_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_InteriorRingN', [self, n_.to_i], [true, true, false]) end |
#st_intersection(rhs_) ⇒ Object
110 111 112 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 110 def st_intersection(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Intersection', [self, rhs_], [true, true, true]) end |
#st_intersects(rhs_) ⇒ Object
74 75 76 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 74 def st_intersects(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Intersects', [self, rhs_], [false, true, true]) end |
#st_isclosed ⇒ Object
170 171 172 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 170 def st_isclosed ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsClosed', [self], [false, true]) end |
#st_isempty ⇒ Object
50 51 52 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 50 def st_isempty ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsEmpty', [self], [false, true]) end |
#st_isring ⇒ Object
174 175 176 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 174 def st_isring ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsRing', [self], [false, true]) end |
#st_issimple ⇒ Object
54 55 56 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 54 def st_issimple ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsSimple', [self], [false, true]) end |
#st_length(units_ = nil) ⇒ Object
178 179 180 181 182 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 178 def st_length(units_=nil) args_ = [self] args_ << units.to_s if units_ ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Length', args_, [false, true, false]) end |
#st_m ⇒ Object
153 154 155 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 153 def st_m ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_M', [self], [false, true]) end |
#st_numgeometries ⇒ Object
– GeometryCollection functions ++
238 239 240 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 238 def st_numgeometries ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_NumGeometries', [self], [false, true]) end |
#st_numinteriorrings ⇒ Object
224 225 226 227 228 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 224 def st_numinteriorrings # Note: the name difference is intentional. The standard # names this function incorrectly. ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_NumInteriorRing', [self], [false, true]) end |
#st_numpoints ⇒ Object
– LineString functions ++
189 190 191 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 189 def st_numpoints ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_NumPoints', [self], [false, true]) end |
#st_overlaps(rhs_) ⇒ Object
94 95 96 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 94 def st_overlaps(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Overlaps', [self, rhs_], [false, true, true]) end |
#st_pointn(n_) ⇒ Object
193 194 195 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 193 def st_pointn(n_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_PointN', [self, n_.to_i], [true, true, false]) end |
#st_pointonsurface ⇒ Object
212 213 214 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 212 def st_pointonsurface ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_PointOnSurface', [self], [true, true]) end |
#st_relate(rhs_, matrix_ = nil) ⇒ Object
98 99 100 101 102 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 98 def st_relate(rhs_, matrix_=nil) args_ = [self, rhs_] args_ << matrix.to_s if matrix_ ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Relate', args_, [false, true, true, false]) end |
#st_srid ⇒ Object
46 47 48 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 46 def st_srid ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_SRID', [self], [false, true]) end |
#st_startpoint ⇒ Object
– Curve functions ++
162 163 164 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 162 def st_startpoint ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_StartPoint', [self], [true, true]) end |
#st_symdifference(rhs_) ⇒ Object
122 123 124 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 122 def st_symdifference(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_SymDifference', [self, rhs_], [true, true, true]) end |
#st_touches(rhs_) ⇒ Object
78 79 80 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 78 def st_touches(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Touches', [self, rhs_], [false, true, true]) end |
#st_union(rhs_) ⇒ Object
118 119 120 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 118 def st_union(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Union', [self, rhs_], [true, true, true]) end |
#st_within(rhs_) ⇒ Object
86 87 88 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 86 def st_within(rhs_) ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Within', [self, rhs_], [false, true, true]) end |
#st_x ⇒ Object
– Point functions ++
141 142 143 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 141 def st_x ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_X', [self], [false, true]) end |
#st_y ⇒ Object
145 146 147 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 145 def st_y ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Y', [self], [false, true]) end |
#st_z ⇒ Object
149 150 151 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 149 def st_z ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Z', [self], [false, true]) end |