Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
require 'rgeo'
# RGeo factory for spherical latlong points
rgeo_factory = RGeo::Geographic.spherical_factory(:srid => 4326)
coord = rgeo_factory.point(-111.500244140625, 40.84706035607122)
# => RGeo point "Point (-111.500244140625 40.84706035607122)"
point_text = true, type_format: :ewkb, emit_ewkb_srid: true).generate(coord)
# => "0020000001000010e6c05be0040000000040446c6c79478831" # this is what is stored in Postgres
new_coord =, support_ewkb: true, default_srid: 4326).parse(point_text)
# => RGeo point "Point (-111.500244140625 40.84706035607122)"
new_coord == coord # => true
class PointSerializer
FACTORY = RGeo::Geographic.spherical_factory(:srid => 4326)
def dump(point) true, type_format: :ewkb, emit_ewkb_srid: true).generate(point)
def self.load(value), support_ewkb: true, default_srid: 4326).parse(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.