Try scripts from activerecord-postgis-adapter.