Method: AIPP::Border.from_array

Defined in:
lib/aipp/border.rb

.from_array(array) ⇒ Object

New border object from array of points

The array must contain coordinate tuples in geographical order as latitude longitude separated by whitespace and/or commas.

Examples:

border = AIPP::Border.from_array([["45.1201332 6.00953165", "45.12006703 6.01574774"]])
border.geometries
# => [[#<AIXM::XY 45.12013320N 006.00953165E>, <AIXM::XY 45.12006703N 006.01574774E>]]

Parameters:



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/aipp/border.rb', line 71

def from_array(array)
  geometries = array.map do |collection|
    collection.map do |coordinates|
      lat, long = coordinates.split(/[\s,]+/)
      AIXM.xy(lat: lat.to_f, long: long.to_f)
    end
  end
  allocate.instance_eval do
    initialize(geometries)
    self
  end
end