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.
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 ++
196 197 198 199 200 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 196 def st_area(units = nil) args = [self] args << units.to_s if units SpatialNamedFunction.new("ST_Area", args, [false, true, false]) end |
#st_asbinary ⇒ Object
40 41 42 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 40 def st_asbinary SpatialNamedFunction.new("ST_AsBinary", [self], [false, true]) end |
#st_astext ⇒ Object
36 37 38 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 36 def st_astext SpatialNamedFunction.new("ST_AsText", [self], [false, true]) end |
#st_boundary ⇒ Object
56 57 58 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 56 def st_boundary SpatialNamedFunction.new("ST_Boundary", [self], [true, true]) end |
#st_buffer(distance, units = nil) ⇒ Object
124 125 126 127 128 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 124 def st_buffer(distance, units = nil) args = [self, distance.to_f] args << units.to_s if units SpatialNamedFunction.new("ST_Buffer", args, [true, true, false]) end |
#st_centroid ⇒ Object
202 203 204 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 202 def st_centroid SpatialNamedFunction.new("ST_Centroid", [self], [true, true]) end |
#st_contains(rhs) ⇒ Object
88 89 90 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 88 def st_contains(rhs) SpatialNamedFunction.new("ST_Contains", [self, rhs], [false, true, true]) end |
#st_convexhull ⇒ Object
130 131 132 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 130 def st_convexhull SpatialNamedFunction.new("ST_ConvexHull", [self], [true, true]) end |
#st_crosses(rhs) ⇒ Object
80 81 82 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 80 def st_crosses(rhs) SpatialNamedFunction.new("ST_Crosses", [self, rhs], [false, true, true]) end |
#st_difference(rhs) ⇒ Object
112 113 114 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 112 def st_difference(rhs) SpatialNamedFunction.new("ST_Difference", [self, rhs], [true, true, true]) end |
#st_dimension ⇒ Object
– Geometry functions ++
28 29 30 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 28 def st_dimension SpatialNamedFunction.new("ST_Dimension", [self], [false, true]) end |
#st_disjoint(rhs) ⇒ Object
68 69 70 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 68 def st_disjoint(rhs) SpatialNamedFunction.new("ST_Disjoint", [self, rhs], [false, true, true]) end |
#st_distance(rhs, units = nil) ⇒ Object
102 103 104 105 106 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 102 def st_distance(rhs, units = nil) args = [self, rhs] args << units.to_s if units SpatialNamedFunction.new("ST_Distance", args, [false, true, true, false]) end |
#st_endpoint ⇒ Object
162 163 164 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 162 def st_endpoint SpatialNamedFunction.new("ST_EndPoint", [self], [true, true]) end |
#st_envelope ⇒ Object
60 61 62 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 60 def st_envelope SpatialNamedFunction.new("ST_Envelope", [self], [true, true]) end |
#st_equals(rhs) ⇒ Object
64 65 66 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 64 def st_equals(rhs) SpatialNamedFunction.new("ST_Equals", [self, rhs], [false, true, true]) end |
#st_exteriorring ⇒ Object
– Polygon functions ++
214 215 216 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 214 def st_exteriorring SpatialNamedFunction.new("ST_ExteriorRing", [self], [true, true]) end |
#st_function(function, *args) ⇒ Object
– Generic functions ++
19 20 21 22 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 19 def st_function(function, *args) spatial_info = args.last.is_a?(::Array) ? args.pop : [] SpatialNamedFunction.new(function, [self] + args, spatial_info) end |
#st_geometryn(n) ⇒ Object
236 237 238 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 236 def st_geometryn(n) SpatialNamedFunction.new("ST_GeometryN", [self, n.to_i], [true, true, false]) end |
#st_geometrytype ⇒ Object
32 33 34 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 32 def st_geometrytype SpatialNamedFunction.new("ST_GeometryType", [self], [false, true]) end |
#st_interiorringn(n) ⇒ Object
224 225 226 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 224 def st_interiorringn(n) SpatialNamedFunction.new("ST_InteriorRingN", [self, n.to_i], [true, true, false]) end |
#st_intersection(rhs) ⇒ Object
108 109 110 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 108 def st_intersection(rhs) SpatialNamedFunction.new("ST_Intersection", [self, rhs], [true, true, true]) end |
#st_intersects(rhs) ⇒ Object
72 73 74 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 72 def st_intersects(rhs) SpatialNamedFunction.new("ST_Intersects", [self, rhs], [false, true, true]) end |
#st_isclosed ⇒ Object
166 167 168 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 166 def st_isclosed SpatialNamedFunction.new("ST_IsClosed", [self], [false, true]) end |
#st_isempty ⇒ Object
48 49 50 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 48 def st_isempty SpatialNamedFunction.new("ST_IsEmpty", [self], [false, true]) end |
#st_isring ⇒ Object
170 171 172 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 170 def st_isring SpatialNamedFunction.new("ST_IsRing", [self], [false, true]) end |
#st_issimple ⇒ Object
52 53 54 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 52 def st_issimple SpatialNamedFunction.new("ST_IsSimple", [self], [false, true]) end |
#st_length(units = nil) ⇒ Object
174 175 176 177 178 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 174 def st_length(units = nil) args = [self] args << units.to_s if units SpatialNamedFunction.new("ST_Length", args, [false, true, false]) end |
#st_m ⇒ Object
150 151 152 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 150 def st_m SpatialNamedFunction.new("ST_M", [self], [false, true]) end |
#st_numgeometries ⇒ Object
– GeometryCollection functions ++
232 233 234 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 232 def st_numgeometries SpatialNamedFunction.new("ST_NumGeometries", [self], [false, true]) end |
#st_numinteriorrings ⇒ Object
218 219 220 221 222 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 218 def st_numinteriorrings # Note: the name difference is intentional. The standard # names this function incorrectly. SpatialNamedFunction.new("ST_NumInteriorRing", [self], [false, true]) end |
#st_numpoints ⇒ Object
– LineString functions ++
184 185 186 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 184 def st_numpoints SpatialNamedFunction.new("ST_NumPoints", [self], [false, true]) end |
#st_overlaps(rhs) ⇒ Object
92 93 94 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 92 def st_overlaps(rhs) SpatialNamedFunction.new("ST_Overlaps", [self, rhs], [false, true, true]) end |
#st_pointn(n) ⇒ Object
188 189 190 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 188 def st_pointn(n) SpatialNamedFunction.new("ST_PointN", [self, n.to_i], [true, true, false]) end |
#st_pointonsurface ⇒ Object
206 207 208 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 206 def st_pointonsurface SpatialNamedFunction.new("ST_PointOnSurface", [self], [true, true]) end |
#st_relate(rhs, matrix = nil) ⇒ Object
96 97 98 99 100 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 96 def st_relate(rhs, matrix = nil) args = [self, rhs] args << matrix.to_s if matrix SpatialNamedFunction.new("ST_Relate", args, [false, true, true, false]) end |
#st_srid ⇒ Object
44 45 46 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 44 def st_srid SpatialNamedFunction.new("ST_SRID", [self], [false, true]) end |
#st_startpoint ⇒ Object
– Curve functions ++
158 159 160 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 158 def st_startpoint SpatialNamedFunction.new("ST_StartPoint", [self], [true, true]) end |
#st_symdifference(rhs) ⇒ Object
120 121 122 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 120 def st_symdifference(rhs) SpatialNamedFunction.new("ST_SymDifference", [self, rhs], [true, true, true]) end |
#st_touches(rhs) ⇒ Object
76 77 78 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 76 def st_touches(rhs) SpatialNamedFunction.new("ST_Touches", [self, rhs], [false, true, true]) end |
#st_union(rhs) ⇒ Object
116 117 118 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 116 def st_union(rhs) SpatialNamedFunction.new("ST_Union", [self, rhs], [true, true, true]) end |
#st_within(rhs) ⇒ Object
84 85 86 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 84 def st_within(rhs) SpatialNamedFunction.new("ST_Within", [self, rhs], [false, true, true]) end |
#st_x ⇒ Object
– Point functions ++
138 139 140 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 138 def st_x SpatialNamedFunction.new("ST_X", [self], [false, true]) end |
#st_y ⇒ Object
142 143 144 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 142 def st_y SpatialNamedFunction.new("ST_Y", [self], [false, true]) end |
#st_z ⇒ Object
146 147 148 |
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 146 def st_z SpatialNamedFunction.new("ST_Z", [self], [false, true]) end |