class ToWkt::Adapter
Constants
- WKT_TYPES
Public Instance Methods
array_to_wkt(array, type)
click to toggle source
# File lib/to_wkt_/adapter.rb, line 7 def array_to_wkt(array, type) raise "invalid WKT type" unless WKT_TYPES.include?(type) make_prefix(type) + make_suffix(array, type) end
Private Instance Methods
line_string(point_list)
click to toggle source
# File lib/to_wkt_/adapter.rb, line 39 def line_string(point_list) output = "" point_list.each{ |p| output += "#{point_string( p )}," } output.chomp ',' end
make_prefix(type)
click to toggle source
# File lib/to_wkt_/adapter.rb, line 14 def make_prefix(type) type.to_s.tr('_', '').upcase end
make_suffix(array, type)
click to toggle source
# File lib/to_wkt_/adapter.rb, line 18 def make_suffix(array, type) output = '(' output += case type.to_sym when :point point_string(array) when :line_string, :multi_point line_string(array) when :polygon, :multi_line_string multi_line_string(array) when :multi_polygon multi_polygon_string(array) else raise "invalid WKT type" end output += ')' end
multi_line_string(line_list)
click to toggle source
# File lib/to_wkt_/adapter.rb, line 45 def multi_line_string(line_list) output = "" line_list.each{ |l| output += "(#{ line_string( l ) })," } output.chomp ',' end
multi_polygon_string(polygon_list)
click to toggle source
# File lib/to_wkt_/adapter.rb, line 51 def multi_polygon_string(polygon_list) output = "" polygon_list.each{ |p| output += "(#{ multi_line_string( p ) })," } output.chomp ',' end
point_string(tuple)
click to toggle source
# File lib/to_wkt_/adapter.rb, line 35 def point_string(tuple) "#{tuple[0]} #{tuple[1]}" end