module Charta::EwktSerializer
Public Class Methods
object_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 5 def object_to_ewkt(hash) type = hash[:type] || hash['type'] send("#{type.gsub(/(.)([A-Z])/, '\1_\2').downcase}_to_ewkt", hash) end
Private Class Methods
feature_collection_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 12 def feature_collection_to_ewkt(hash) return 'GEOMETRYCOLLECTION EMPTY' if hash['features'].nil? 'GEOMETRYCOLLECTION(' + hash['features'].collect do |feature| object_to_ewkt(feature) end.join(', ') + ')' end
feature_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 28 def feature_to_ewkt(hash) object_to_ewkt(hash['geometry']) end
geometry_collection_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 20 def geometry_collection_to_ewkt(hash) return 'GEOMETRYCOLLECTION EMPTY' if hash['geometries'].nil? 'GEOMETRYCOLLECTION(' + hash['geometries'].collect do |feature| object_to_ewkt(feature) end.join(', ') + ')' end
line_string_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 38 def line_string_to_ewkt(hash) return 'LINESTRING EMPTY' if hash['coordinates'].nil? 'LINESTRING(' + hash['coordinates'].collect do |point| point.join(' ') end.join(', ') + ')' end
multi_line_string_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 64 def multi_line_string_to_ewkt(hash) return 'MULTILINESTRING EMPTY' if hash['coordinates'].nil? 'MULTILINESTRING(' + hash['coordinates'].collect do |line| '(' + line.collect do |point| point.join(' ') end.join(', ') + ')' end.join(', ') + ')' end
multi_point_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 56 def multi_point_to_ewkt(hash) return 'MULTIPOINT EMPTY' if hash['coordinates'].nil? 'MULTIPOINT(' + hash['coordinates'].collect do |point| '(' + point.join(' ') + ')' end.join(', ') + ')' end
multi_polygon_to_ewkt(hash)
click to toggle source
for PostGIS ST_ASGeoJSON compatibility
# File lib/charta/ewkt_serializer.rb, line 87 def multi_polygon_to_ewkt(hash) return 'MULTIPOLYGON EMPTY' if hash['coordinates'].nil? 'MULTIPOLYGON(' + hash['coordinates'].collect do |polygon| '(' + polygon.collect do |hole| '(' + hole.collect do |point| point.join(' ') end.join(', ') + ')' end.join(', ') + ')' end.join(', ') + ')' end
multipolygon_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 74 def multipolygon_to_ewkt(hash) return 'MULTIPOLYGON EMPTY' if hash['coordinates'].nil? 'MULTIPOLYGON(' + hash['coordinates'].collect do |polygon| '(' + polygon.collect do |hole| '(' + hole.collect do |point| point.join(' ') end.join(', ') + ')' end.join(', ') + ')' end.join(', ') + ')' end
point_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 32 def point_to_ewkt(hash) return 'POINT EMPTY' if hash['coordinates'].nil? 'POINT(' + hash['coordinates'].join(' ') + ')' end
polygon_to_ewkt(hash)
click to toggle source
# File lib/charta/ewkt_serializer.rb, line 46 def polygon_to_ewkt(hash) return 'POLYGON EMPTY' if hash['coordinates'].nil? 'POLYGON(' + hash['coordinates'].collect do |hole| '(' + hole.collect do |point| point.join(' ') end.join(', ') + ')' end.join(', ') + ')' end