Class: ActiveRecordMysqlSpatial::Geometry
- Inherits:
-
Object
- Object
- ActiveRecordMysqlSpatial::Geometry
- Defined in:
- lib/active_record_mysql_spatial/geometry.rb
Class Method Summary collapse
- .from_coordinates(coordinates, type: :linestring) ⇒ Object
- .from_geometries(geometries) ⇒ Object
- .from_text(value) ⇒ Object
- .geometrycollection?(value) ⇒ Boolean
- .linestring?(value) ⇒ Boolean
- .multilinestring?(value) ⇒ Boolean
- .multipoint?(value) ⇒ Boolean
- .multipolygon?(value) ⇒ Boolean
- .parse_bin(bin) ⇒ Object
- .point?(value) ⇒ Boolean
- .polygon?(value) ⇒ Boolean
- .valid_spatial?(value) ⇒ Boolean
Class Method Details
.from_coordinates(coordinates, type: :linestring) ⇒ Object
10 11 12 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 10 def from_coordinates(coordinates, type: :linestring) send("#{type}_from_coords", coordinates) end |
.from_geometries(geometries) ⇒ Object
14 15 16 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 14 def from_geometries(geometries) geometrycollection_from_geometries(geometries) end |
.from_text(value) ⇒ Object
18 19 20 21 22 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 18 def from_text(value) cartesian_factory.parse_wkt(value) rescue StandardError nil end |
.geometrycollection?(value) ⇒ Boolean
58 59 60 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 58 def geometrycollection?(value) /^geometrycollection*.\(/i.match?(value) end |
.linestring?(value) ⇒ Boolean
38 39 40 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 38 def linestring?(value) /^linestring*.\(/i.match?(value) end |
.multilinestring?(value) ⇒ Boolean
42 43 44 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 42 def multilinestring?(value) /^multilinestring*.\(/i.match?(value) end |
.multipoint?(value) ⇒ Boolean
46 47 48 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 46 def multipoint?(value) /^multipoint*.\(/i.match?(value) end |
.multipolygon?(value) ⇒ Boolean
54 55 56 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 54 def multipolygon?(value) /^multipolygon*.\(/i.match?(value) end |
.parse_bin(bin) ⇒ Object
6 7 8 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 6 def parse_bin(bin) parser.parse(bin[4..]) end |
.point?(value) ⇒ Boolean
34 35 36 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 34 def point?(value) /^point*.\(/i.match?(value) end |
.polygon?(value) ⇒ Boolean
50 51 52 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 50 def polygon?(value) /^polygon*.\(/i.match?(value) end |
.valid_spatial?(value) ⇒ Boolean
24 25 26 27 28 29 30 31 32 |
# File 'lib/active_record_mysql_spatial/geometry.rb', line 24 def valid_spatial?(value) point?(value) || linestring?(value) || multilinestring?(value) || multipoint?(value) || polygon?(value) || multipolygon?(value) || geometrycollection?(value) end |