Sha256: 2763156a35e5d1f511785731a662fb21e0efe42ee33279bcb9757a369ce3f631
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Ropenlayer class Node < ActiveRecord::Base attr_accessor :geometry_string set_table_name :ropenlayer_nodes GEOMETRY_TYPES = %w( POINT LINESTRING POLYGON ) unless defined?(GEOMETRY_TYPES) belongs_to :map, :polymorphic => true has_many :localizations, :class_name => 'Ropenlayer::Localization' def geometry_string "#{ geometry }(#{ localizations.map{|l| "#{ l.longitude } #{ l.latitude }"}.join(',')})" end def geometry_string=(data) self.geometry = data.split('(').first localizations_split = data.split('(').last.gsub(')', '').split(',') self.localizations = [] order = 0 localizations_split.each do |data| self.localizations << self.localizations.new(:longitude => data.split.first, :latitude => data.split.last, :order => order = order.next) end end def main_latitude self.localizations.first ? self.localizations.first.latitude : nil end def main_longitude self.localizations.first ? self.localizations.first.longitude : nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ropenlayer-0.3.5 | lib/ropenlayer/node.rb |
ropenlayer-0.3.4 | lib/ropenlayer/node.rb |