Giter Club home page Giter Club logo

rgeo-activerecord's Introduction

RGeo

Gem Version CI

RGeo is a geospatial data library for Ruby.

Contributors Wanted!

If you use RGeo and are interested in contributing, please check out our open issues to see if there's anything you're able to help with.

Summary

RGeo is a key component for writing location-aware applications in the Ruby programming language. At its core is an implementation of the industry standard OGC Simple Features Specification, which provides data representations of geometric objects such as points, lines, and polygons, along with a set of geometric analysis operations. This makes it ideal for modeling geolocation data. It also supports a suite of optional add-on modules that provide various geolocation-related services.

Use the core rgeo gem to:

  • Represent spatial and geolocation data objects such as points, lines, and polygons in your Ruby application.
  • Perform standard spatial analysis operations such as finding intersections, creating buffers, and computing lengths and areas.
  • Correctly handle spherical geometry, and compute geographic projections for map display and data analysis.
  • Read and write location data in the WKT and WKB representations used by spatial databases.

Dependencies

RGeo works with the following Ruby implementations:

  • MRI Ruby 2.6.0 or later.
  • Partial support for JRuby 9.0 or later. The FFI implementation of GEOS is available (ffi-geos gem required) but CAPI is not.
  • See earlier versions for support for older ruby versions.

Some features also require the following:

  • GEOS 3.2 or later is highly recommended. (3.3.3 or later preferred.) Some functions will not be available without it. This C/C++ library may be available via your operating system's package manager (sudo aptitude install libgeos-dev for debian based Linux distributions, yum install geos geos-devel for redhat based Linux distributions), or you can download it from http://trac.osgeo.org/geos
  • On some platforms, you should install the ffi-geos gem (version 1.2.0 or later recommended.) JRuby requires this gem to link properly with Geos, and Windows builds probably do as well.

Installation

Install the RGeo gem:

gem install rgeo

or include it in your Gemfile:

gem "rgeo"

If you are using proj.4 extensions, include rgeo-proj4:

gem "rgeo-proj4"

Upgrading to Version 3.0

See doc/Upgrading-to-v3.md for a checklist of changes to make before upgrading to RGeo 3.0.

For a brief overview of the changes, see NEWS.md.

For a comprehensive list of all changes, see History.md.

Extensions

The RGeo organization provides several gems that extend RGeo:

Proj4 extensions

Read and write GeoJSON

Read ESRI shapefiles

ActiveRecord connection adapter for PostGIS, based on postgresql (pg gem)

ActiveRecord connection adapter for MySQL Spatial Extensions, based on mysql2

ActiveRecord connection adapter for SpatiaLite, based on sqlite3 (*not maintained)

Development and support

RDoc Documentation is available at https://www.rubydoc.info/gems/rgeo

Contributions are welcome. Please read the Contributing guidelines.

Support may be available on the rgeo-users google group or on Stack Overflow.

Documentation

You can see more in-depth documentation in the doc folder. Factories and methods are documented inline, you should consider checking https://rubydoc.info/gems/rgeo with the version you are currently using. Or generate documentation locally if you're working on RGeo: yardoc server.

Here's the current list of available topics:

You can see an exhaustive and up to date list at https://rubydoc.info/gems/rgeo/index.

Acknowledgments

Daniel Azuma created RGeo. Tee Parham is a former maintainer. Keith Doggett, Ulysse Buonomo are current maintainers.

Development is supported by:

RGeo calls the GEOS library to handle most Cartesian geometric calculations, and the Proj4 library to handle projections and coordinate transformations. These libraries are maintained by the Open Source Geospatial Foundation; more information is available on OSGeo's web site.

JRuby support is made possible by the ffi-geos (and upcoming ffi-proj4) gems, by J Smith.

License

Copyright (c) Daniel Azuma, Tee Parham

License

rgeo-activerecord's People

Contributors

andreasknoepfle avatar buonomo avatar corneverbruggen avatar dazuma avatar gravitystorm avatar gui avatar jayvarner avatar keithdoggett avatar marinosb avatar matthewrudy avatar petergoldstein avatar tagliala avatar teeparham avatar ugisozols avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rgeo-activerecord's Issues

Registering a factory for only a subset of conditions

I am working with a client whose system needs to use the uses_lenient_assertions option when constructing RGeo objects. (They've got some bad data in the DB and cleaning it out is a whole other project, which obviously does need to happen at some point, but isn't happening now.)

To handle that, I thought I'd try and target just objects with the SRID 4326:

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  config.register(
    RGeo::Geographic.spherical_factory(srid: 4326, uses_lenient_assertions: true),
    srid: 4326)
end

But it turns out that this actually registers the factory with all the default conditions, except the srid condition is set to 4326. So this didn't match because the column is a geography and not a geometry (the default value for sql_type in config.register).

It'd be nice if there were a way to instead have the above code cause this factory to be used for any column with an SRID of 4326 (maybe with lower priority than a factory registered with > 1 condition or something).

At the very least, though, I would have appreciated it if the docs were a little clearer on what config.register actually does. I had to do some digging in the source to understand why the code above wasn't working.

rake aborted on db:create, rails 4.2.1, activerecord-postgis-adapter 3.0.0

Hi,

I'm trying to follow the instructions from http://daniel-azuma.com/articles/georails/part-2. But I hit a wall up to the point when I either try to "rake db:create" or simply "rake -T". I get this result:

rake aborted!
LoadError: cannot load such file -- active_record/connection_adapters/postgis_adapter/railtie
/Users/user/Desktop/rails_project/heatmap/config/application.rb:4:in require' /Users/user/Desktop/rails_project/heatmap/config/application.rb:4:in<top (required)>'
/Users/user/Desktop/rails_project/heatmap/Rakefile:4:in require' /Users/user/Desktop/rails_project/heatmap/Rakefile:4:in<top (required)>'
/Users/user/.rvm/gems/ruby-2.1.2@rails4gemset/bin/ruby_executable_hooks:15:in eval' /Users/user/.rvm/gems/ruby-2.1.2@rails4gemset/bin/ruby_executable_hooks:15:in

'
(See full trace by running task with --trace)

Any idea what's causing this? I have the following environment: Ruby 2.1.2, Rails 4.2.1, PG 9.4, Postgis 2.0, Geos 3.4.2, Proj 4.9.1 running on Mac OS X Yosemite.

Thanks for your time.

Column has M dimension but geometry does not

When point is defined as:
t.point :point, :srid => 4326 , :has_z => true, :has_m => true

and the factory is defined as:
RGeo::Geographic.simple_mercator_factory(:has_z_coordinate => true, :has_m_coordinate => true, :uses_lenient_assertions => true,)

points produced by the factory have 4 dimensions, but as soon as they are assigned to the AR object, they lose the M coordinate. Attempting to save the objects results in the error listed in:
ActiveRecord::StatementInvalid: PG::Error: ERROR: Column has M dimension but geometry does not

Rather confounding given that everything :has_m_coordinate.

Construct an Arel node instead message

Hi! I'm trying to investigate why RGeo features are supported in simple arel functions like = but not as arguments for functions:

2.3.3 (main):0[22] > location = Building.arel_table[:location];
2.3.3 (main):0[23] > point = RGeo::Geographic.spherical_factory(srid: 4326).point(1, 2);
2.3.3 (main):0[24] > location.eq(point).to_sql
=> "\"buildings\".\"location\" = '0020000001000010e63ff00000000000004000000000000000'"
2.3.3 (main):0[25] > location.st_function('ST_DWithin', point, 1, [false, true, true, false]).to_sql
Arel::Visitors::UnsupportedVisitError: Unsupported argument type: RGeo::Geographic::SphericalPointImpl. Construct an Arel node instead.

I'm using point.to_s in function and it wraps value with ST_GeomFromEWKT. Is it the right way or should RGeo features be used in queries without .to_s?

Let drop support for rgeo prior 3.0

@keithdoggett @BuonOmo ,
I think it will be beneficial to drop support for rgeo prior 3.x, that will make maintenance easier for future versions.

We could also drop support for unsupported version of active record.

I have a branch that I can open a PR here.

Method missing: undefined method `rgeo_factory_generator='

Hi!

If I run my application in production mode I get this error:

/activerecord-4.2.2/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `rgeo_factory_generator=' for #<Class:0x000000071b99
f8> (NoMethodError)

The error is on line 2:

class Address < ActiveRecord::Base
  self.rgeo_factory_generator = RGeo::Geos.factory_generator(srid: 4326)
  set_rgeo_factory_for_column :coordinates, RGeo::Geographic.spherical_factory(srid: 4326)
...

On development mode all works fine. I use rgeo v0.3.20 and rgeo-activerecord v4.0.0 and rails 4.2.2! Any idea?

EDIT

If I set config.eager_load in production environment to false, all works fine! Why?

Locations within a radius

Hi @teeparham, I was wondering if there is method or recommended approach to queries where you are looking for records in a certain radius of a point? I tried looking thru the docs but couldn't find the right solution.

I assume this is a common case, so if there is a recommended solution that is not documented, I'm happy to PR the docs.

Thank you!

Support for Rails 5

The gemspec file locks activerecord at 4.x but rails 5 uses 5.x.
Do you have plans to update the gem to work with rails 5 before it becomes stable?

Best way to group by distance with a minimum number of ocurrances?

I'm dipping my toes into spatial queries for a personal project, wondering what's the best way to group locations that are within a certain distance of eachother with a minimum amount of locations.

So if there are 20 locations within 1000m of eachother I'd want the result to be an array containing those locations for example.

I'm thinking of using ST_ClusterWithin or ST_ClusterDBSCAN and been scouting the Rails resources for doing such a thing. What would be the recomended way of approaching this?

Edit:

Using something like Location.select("*, ST_ClusterDBSCAN(coordinates, eps := 1000, minpoints := 20) over () AS cid").to_a.group_by(&:cid) works, but I'm wondering if I can do it in a cleaner manner.

Curiously enough ChatGPT suggests both cluster and .cluster_by_distance methods, I however could find no information about either online. So I'm thinking it mght be just wrong.

Load issue on rails 3.2 & 0.6.0

Getting this issue on load with the new version:

/Users/james/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load': cannot load such file -- active_record/connection_adapters/postgis_adapter/shared/railtie (LoadError)
  from /Users/james/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `block in load'
  from /Users/james/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/james/.rvm/gems/ruby-1.9.3-p194-perf/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
  from /Users/james/.rvm/gems/ruby-1.9.3-p194-perf/gems/activerecord-postgis-adapter-0.6.0/lib/active_record/connection_adapters/postgis_adapter.rb:91:in `<top (required)>'
  from /Users/james/.rvm/gems/ruby-1.9.3-p194-perf/gems/activerecord-postgis-adapter-0.6.0/lib/active_record/connection_adapters/postgis_adapter/railtie.rb:38:in `require'
  from /Users/james/.rvm/gems/ruby-1.9.3-p194-perf/gems/activerecord-postgis-adapter-0.`6.0/lib/active_record/connection_adapters/postgis_adapter/railtie.rb:38:in `<top (required)>'
  from /Users/james/projects/ap/config/application.rb:12:in `require'

The offending line in config/application.rb is

require 'active_record/connection_adapters/postgis_adapter/railtie'

Seen this issue at all?

edit: oops, this is the wrong repo. Would you like me to move it to activerecord-postgis-adapter issues? (I was looking at them both, seeing what had changed..)

Arel dropped Visitors::DepthFirst -> Rails 6.1.0.alpha support broken

See topic, and: https://github.com/rails/rails/commits/master/activerecord/lib/arel/visitors.rb
Crash occurs upon rails s on development for rails 6.1.0.alpha (and possibly others) using activerecord-postgis-adapter-6.0.0.

Since its rather clear why the name error occurs, I only included parts of the stack trace to help others track down this error.

rgeo-activerecord-6.2.1/lib/rgeo/active_record/arel_spatial_queries.rb:89:in <module:ActiveRecord>' ... gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in block in load_missing_constant': uninitialized constant Arel::Visitors::DepthFirst (NameError)

Convert readme to markdown

I plan to drop the custom rdoc & gh-pages site. The documentation will be on GitHub. Also http://rdoc.info will have the full rdoc from gem releases, so I don't feel like maintaining a separate documentation site is useful.

Create Scopes with Arel st_functions

It should be possible to create scopes on ActiveRecord models from the SpatialNamedFunctions. This would be in an optional module a user could include into their ActiveRecord model and it would allow access to these scopes.

This would make the SpatialNamedFunctions more accessible for users that are unfamiliar with Arel.

This would allow you to go from this:

pt = RGeo::Geos.factory.point(1,2)
locations = Location.arel_table
Location.select(:id, :geom).where(locations[:geom].st_contains(pt))

to:

pt = RGeo::Geos.factory.point(1,2)
Location.select(:id, :geom).st_contains(:geom, pt)

ActiveRecord rake tasks don't know about new adapter names

ActiveRecord has a bunch of internal rake tasks used to, e.g. set up test databases, dump schemas, and so forth. Each of these tasks generally includes a big switch statement that does something different based on the adapter name. So they fail with the RGeo adapters (e.g. activerecord-postgis-adapter) because their names are not recognized. As a result, it is not possible to run "rake test" or "rake db:schema:dump" or similar tasks in a Rails project.

Add license type to .gemspec?

Hi rgeo folks 👋🏻

Thanks for these gems. We use them and accept the terms of the licenses.

But to make it simpler for our CI automation tools to recognize that this license is compliant with the ones that we are cool with, can you add it to the .gemspec please? Whether its BSD or MIT or whatever.


For example…

https://github.com/pivotal/LicenseFinder#a-plea-to-package-authors-and-maintainers

Gem::Specification.new do |s|
  s.name = "my_great_gem"
  s.license = "MIT"
end

rgeo 0.4.0?

Can we use the latest version of rgeo-activerecord with newly updated rgeo (0.4.0)?

WKT parsing failures on spatial columns should add to `errors` instead of exception

I am writing some tests of the validation, and I am running into the problem that trying to set a spatial column to an invalid value raises an exception before validators can run. For example, I have a spec like this:

post :create, :model => {:pos => 'POINT(1 )'}
should have(1).error_on(:pos)

which tries to create a Model with the invalid WKT string "POINT(1 )". I expect to get an entry in model.errors, but an exception is raised, causing the spec to fail. There should be a way to have this problem show up as an entry in errors rather than an exception, since Rails has an easier time dealing with the former.

As a workaround, I overrode the pos= method with the following:

def pos=(pos_)
  begin
    super pos_
  rescue RGeo::Error::ParseError
    errors.add(:pos, "has an invalid format")
  end
end

Which simply turns the exception into an entry in errors.

SpatialConstantNode does not support RGeo::Feature objects

The documentation for Arel.spatial indicates "This node wraps a spatial value (such as an RGeo feature or a text string in WKT format)."

And the code for visit_in_spatial_context seems to check for RGeo::Feature::Instance.

However, trying to actually use this functionality does not work.

Example:

def test_arel_visit_spatial_constant_node_rgeo_feature
  visitor = arel_visitor
  point = RGeo::Cartesian.preferred_factory().point(1.0, 2.0)
  sql = visitor.accept(Arel.spatial(point), Arel::Collectors::PlainString.new)
  assert_equal("ST_WKTToSQL('POINT (1.0 2.0)')", sql.value)
end

fails with

RuntimeError: unsupported: RGeo::Geos::CAPIPointImpl

default factory overrides other registered factories?

i'm using the factory example from the docs:

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  # By default, use the GEOS implementation for spatial columns.
  config.default = RGeo::Geos.factory_generator

  # But use a geographic implementation for point columns.
  config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end

and my column in the db is:

    lnglat geography(Point,4326)

with the above configuration, my model never uses the spherical factory i registered:

[2] pry(main)> l.lnglat
=> #<RGeo::Geos::CAPIPointImpl:0x3fe12993c4e4 "POINT (-96.8027 33.0348)">
[3] pry(main)> l.lnglat.factory
=> #<RGeo::Geos::CAPIFactory:0x3fe12993c5fc srid=4326 bufres=1 flags=8>

however - if i remove the default factory then the registered factory works:

[2] pry(main)> l.lnglat
=> #<RGeo::Geographic::SphericalPointImpl:0x3feb8a940c90 "POINT (-96.8027 33.0348)">
[3] pry(main)> l.lnglat.factory
=> #<RGeo::Geographic::Factory:0x00007fd715282028
 @buffer_resolution=1,
 @coord_sys=
  #<RGeo::CoordSys::CS::GeographicCoordinateSystem:0x3feb92ea8a40 GEOGCS["Popular Visualisation CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137.0,0.0,AUTHORITY["EPSG","7059"]],TOWGS84[0.0,0.0,0.0,0.0,0.0,0.0,0.0],AUTHORITY["EPSG","6055"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]]>,
 @geometry_collection_class=RGeo::Geographic::SphericalGeometryCollectionImpl,
 @impl_prefix="Spherical",
 @lenient_assertions=false,
 @line_class=RGeo::Geographic::SphericalLineImpl,
 @line_string_class=RGeo::Geographic::SphericalLineStringImpl,
 @linear_ring_class=RGeo::Geographic::SphericalLinearRingImpl,
 @multi_line_string_class=RGeo::Geographic::SphericalMultiLineStringImpl,
 @multi_point_class=RGeo::Geographic::SphericalMultiPointImpl,
 @multi_polygon_class=RGeo::Geographic::SphericalMultiPolygonImpl,
 @point_class=RGeo::Geographic::SphericalPointImpl,
 @polygon_class=RGeo::Geographic::SphericalPolygonImpl,
 @proj4=nil,
 @projector=nil,
 @srid=4326,
 @support_m=false,
 @support_z=false,
 @wkb_generator=#<RGeo::WKRep::WKBGenerator:0x00007fd715281e20 @emit_ewkb_srid=false, @hex_format=false, @little_endian=false, @type_format=:wkb11>,
 @wkb_parser=
....etc

Example setup not compatible with RGeo 3.0

The readme says:

Here is an example setup:

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  # By default, use the GEOS implementation for spatial columns.
  config.default = RGeo::Geos.factory_generator

  # But use a geographic implementation for point columns.
  config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end

However, in RGeo 3.0 RGeo::Geos.factory_generator has been removed see: rgeo/rgeo#314

I don't understand what config.default = RGeo::Geos.factory_generator was doing, or how to upgrade.

Could you kindly advise on if rgeo-activerecord is compatible with RGeo 3.0 and if so what should be done to remedy the above?

Lost rgeo_factory_for_column after reconnect

Hi! Thankyou for the great gems!

But if found an issue with rgeo_factory_settings which are lost after reconnecting to database

For example my irb session:

irb(main):020:0> OsmBuilding.rgeo_factory_settings
=> #<RGeo::ActiveRecord::RGeoFactorySettings:0x7f60f4a60318 @column_factories={"osm_buildings"=>{"geometry"=>#<RGeo::Geos::Factory:0x3fb07a54d070 srid=900913 bufres=1 flags=8>}}, @factory_generators={}>

irb(main):021:0> ActiveRecord::Base.establish_connection

irb(main):022:0> OsmBuilding.rgeo_factory_settings
=> #<RGeo::ActiveRecord::RGeoFactorySettings:0x7f60f44bb700 @column_factories={}, @factory_generators={}>

As you can see, all factory settings are lost.

Reconnection to database is a common practive when using some ruby servers (unicorn in my case) which preload applications and then fork workers.

Are there any reasons to bind factory settings to connection pool? Why not activerecord class?

Where should I put factory setup?

I've tried to put it in application.rb and initializer, but it raises uninitialized constant RGeo::ActiveRecord::SpatialFactoryStore

Active record default validations doesn't work

After this merge: rails/rails#18937, running the following line

# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = true

will do something like:

ActiveRecord::Base.belongs_to_required_by_default = true

But when usingrgeo-activerecord:

ActiveRecord::Base.belongs_to_required_by_default
#=> nil

I couldn't dig enough to suggest a solution.

Error on AR Base#inspect in Rails 3.2.x

I get this error consistently with all instances loaded from the database with postgis types:

1.9.2-p290 :011 > c = c.reload
(0.7ms) SELECT * FROM geometry_columns WHERE f_table_name='custom_regions'
CustomRegion Load (0.4ms) SELECT "custom_regions".* FROM "custom_regions" WHERE "custom_regions"."id" = $1 LIMIT 1 [["id", 36]](Object doesn't support #inspect)
=>
1.9.2-p290 :012 > c.inspect
NoMethodError: undefined method rgeo_factory_settings' for Module:Class from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/activerecord-3.2.1/lib/active_record/attribute_methods/read.rb:82:intemp'
from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/activerecord-3.2.1/lib/active_record/attribute_methods/read.rb:46:in type_cast_attribute' from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/activerecord-3.2.1/lib/active_record/attribute_methods/read.rb:126:inread_attribute'
from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/activerecord-3.2.1/lib/active_record/attribute_methods.rb:178:in attribute_for_inspect' from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/activerecord-3.2.1/lib/active_record/base.rb:638:inblock in inspect'
from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/activerecord-3.2.1/lib/active_record/base.rb:636:in collect' from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/activerecord-3.2.1/lib/active_record/base.rb:636:ininspect'
from (irb):12
from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/railties-3.2.1/lib/rails/commands/console.rb:47:in start' from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/railties-3.2.1/lib/rails/commands/console.rb:8:instart'
from /Users/vitalvu/.rvm/gems/ruby-1.9.2-p290@mapping_update/gems/railties-3.2.1/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'

Note that I am able to retrieve the postgis values however:

1.9.2-p290 :002 > c1.polygon
=> #<RGeo::Geographic::SphericalPolygonImpl:0x3fe22eb15ea4 "POLYGON ((-98.087890625 32.349828805324314, -99.23046875 30.09526388408803, -97.2529296875 29.63796020894551, -95.978515625 32.01508914316767, -98.087890625 32.349828805324314))">

Here are my relevant gems:

  • activerecord (3.2.1)
  • activerecord-postgis-adapter (0.4.0)
  • activeresource (3.2.1)
  • activesupport (3.2.1)
  • archive-tar-minitar (0.5.2)
  • arel (3.0.0)
    ...
  • pg (0.12.2)
    ...
  • rgeo (0.3.3)
  • rgeo-activerecord (0.4.2)

No guide about v7.0.x in README.md

I encountered the following error when using activerecord-postgis-adapter v7.1.1.

Bundler could not find compatible versions for gem "rgeo-activerecord":
  In Gemfile:
    rgeo-activerecord (~> 6.2.2)

    activerecord-postgis-adapter (~> 7.1.1) was resolved to 7.1.1, which depends on
      rgeo-activerecord (~> 7.0.0)

I think that it's better to mention v7.0.x in README.md.

Can't dump schemas on spatial indexes

When you call indexes on a connection with a spatial adapter, you get a SpatialIndexDefinition back, like this:

=> #<struct RGeo::ActiveRecord::SpatialIndexDefinition
 table="saved_searches",
 name="index_saved_searches_on_user_id",
 unique=false,
 columns=["user_id"],
 lengths=[nil],
 orders=false,
 where=nil,
 spatial=nil>

as defined in common_adapter_elements.rb:

    class SpatialIndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths, :orders, :where, :spatial)
    end

Unfortunately as of this patch ActiveRecord::SchemaDumper expects to also call the using method on an index object. (And similarly for the type method.)

Because there aren't using or type methods in this struct, rake db:schema:dump fails horribly with the following error which I reproduce for future Googlers:

# Could not dump table "<whatever>" because of following NoMethodError
#   undefined method `using' for #<RGeo::ActiveRecord::SpatialIndexDefinition:0x00000008386e88>

Adding :using, :type to that definition above allows the database to be dumped properly, although I'm not sure that's a perfect solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.