Sha256: 02b13f076e7fa0d078f961dfc10bb6a1854cc1f0ed0531cfb6813a3c56d08acb
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true require_relative 'base' require_relative 'point' module ActiveRecordMysqlSpatial module ActiveRecord module MySQL class Linestring < Base attr_reader :items def type :linestring end def coordinates # TODO: remove later puts 'coordinates is deprecated. Please use items instead.' @items end def to_sql return nil if @items.blank? "LineString(#{to_coordinates_sql})" end def to_coordinates_sql @items.map(&:to_coordinate_sql).compact.join(', ') end def ==(other) return false if super == false items.each_with_index do |coord, index| return false if coord != other.items[index] end true end private def cast_value(value) @raw = value coordinates, create_raw = extract_coordinates(value) @raw = Geometry.from_coordinates(coordinates).as_binary if create_raw @items = coordinates.map do |coord| Point.new.send(:cast_value, coord) end self rescue StandardError => e handle_error(e) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_record_mysql_spatial-0.3.0 | lib/active_record_mysql_spatial/active_record/mysql/linestring.rb |