Sha256: d6930eea89d4e0ef8109c5649f4c680f817cb4784d4cc3cecdfc385e5f6e0b8d
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Ropenlayer class Node < ActiveRecord::Base attr_accessor :geometry_string set_table_name :ropenlayer_nodes GEOMETRY_TYPES = %w( POINT LINESTRING POLYGON ) belongs_to :map, :polymorphic => true has_many :localizations, :class_name => 'Ropenlayer::Localization' has_one :icon, :class_name => 'Ropenlayer::Icon' has_one :category, :class_name => 'Ropenlayer::Category' 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ropenlayer-0.3.0 | lib/ropenlayer/node.rb |