Class: FrOData::Properties::Geography::Polygon

Inherits:
Base show all
Defined in:
lib/frodata/properties/geography/polygon.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_SRID

Instance Attribute Summary

Attributes inherited from Base

#srid

Attributes inherited from FrOData::Property

#name, #options, #value

Instance Method Summary collapse

Methods inherited from Base

#crs, #crs_name, from_xml, #initialize, #json_value, #srs_name, #to_xml, #url_value, #value=

Methods inherited from FrOData::Property

#==, #allows_nil?, #concurrency_mode, from_xml, #initialize, #json_value, #strict?, #to_xml, #url_value

Constructor Details

This class inherits a constructor from FrOData::Properties::Geography::Base

Instance Method Details

#coords_from_s(str) ⇒ Object



13
14
15
16
# File 'lib/frodata/properties/geography/polygon.rb', line 13

def coords_from_s(str)
  str.gsub(/[()]/, '')
     .split(',').map { |pos| pos.split(' ').map(&:to_f) }
end

#coords_to_sObject



9
10
11
# File 'lib/frodata/properties/geography/polygon.rb', line 9

def coords_to_s
  '(' + value.map { |pos| pos.join(' ') }.join(',') + ')'
end

#typeObject



5
6
7
# File 'lib/frodata/properties/geography/polygon.rb', line 5

def type
  'Edm.GeographyPolygon'
end

#xml_valueObject



18
19
20
21
22
23
24
25
26
# File 'lib/frodata/properties/geography/polygon.rb', line 18

def xml_value
  {
    exterior: {
      LinearRing: value.map do |coords|
        { pos: coords.join(' ') }
      end
    }
  }
end