class Typero::PointType
for postgres - select st_asewkt(lon_lat) || st_astext(lon_lat) point = @object.class.xselect(“ST_AsText(#{field}) as #{field}”).where(id: @object.id).first
Public Instance Methods
db_schema()
click to toggle source
# File lib/typero/type/types/point_type.rb, line 21 def db_schema [:geography, {}] end
set()
click to toggle source
# File lib/typero/type/types/point_type.rb, line 5 def set if value.include?('/@') point = value.split('/@', 2).last.split(',') value { [point[0], point[1]].join(',') } end if !value.include?('POINT') && value.include?(',') point = value.sub(/,\s*/, ' ') value { 'SRID=4326;POINT(%s)' % point } end if value && value.include?(',') && !value =~ /^SRID=4326;POINT\(/ error_for(:unallowed_characters_error) end end