rgeo / rgeo-proj4

Proj4 extension for rgeo.
MIT License
13 stars 14 forks source link

proj_crs_get_geodetic_crs: Object is not a CRS #24

Closed ionosphere closed 1 year ago

ionosphere commented 2 years ago

Hi,

I have an issue when upgrading to 3.1.1 on starting rails server

gems/rgeo-proj4-3.1.1/lib/rgeo/coord_sys/proj4.rb:93:in `canonical_hash': undefined method `strip' for nil:NilClass (NoMethodError)

Full stack trace

from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-proj4-3.1.1/lib/rgeo/coord_sys/proj4.rb:45:in `eql?'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/geographic/factory.rb:87:in `eql?'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/feature/types.rb:193:in `cast'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/impl_helper/basic_line_string_methods.rb:15:in `block in initialize'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/impl_helper/basic_line_string_methods.rb:14:in `map'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/impl_helper/basic_line_string_methods.rb:14:in `initialize'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/geographic/factory.rb:326:in `new'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/geographic/factory.rb:326:in `line_string'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/wkrep/wkt_parser.rb:287:in `parse_line_string'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/wkrep/wkt_parser.rb:297:in `parse_polygon'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/wkrep/wkt_parser.rb:369:in `block in parse_multi_polygon'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/wkrep/wkt_parser.rb:368:in `loop'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/wkrep/wkt_parser.rb:368:in `parse_multi_polygon'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/wkrep/wkt_parser.rb:214:in `parse_type_tag'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/wkrep/wkt_parser.rb:133:in `parse'
11:57:34 web.1  |   from /home/djoulin/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rgeo-2.3.1/lib/rgeo/geographic/factory.rb:308:in `parse_wkt'
keithdoggett commented 2 years ago

Can you give me some more information like what factory you are using and what is being and perhaps what geometry you're trying to parse here?

Is there an error message saying "Object is not a CRS somewhere"?

EmmanuelleduColombier commented 2 years ago

Hello, I have exactly the same error message. This is the factory : +proj=lcc +lat_1=52.66666666666666 +lat_2=54.33333333333334 +lat_0=48 +lon_0=10 +x_0=815000 +y_0=0 +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs I do have the error "Object is not a CRS" when I open my console.

keithdoggett commented 2 years ago

Hi @EmmanuelleduColombier, in newer versions of the PROJ library you need to add "+type=crs" to proj strings to specify that it is a CRS. I've tested that with the string you've provided here and it worked for me. Let me know if that resolves it for you as well.

EmmanuelleduColombier commented 2 years ago

Hi @keithdoggett , it worked indeed ! Many thanks for your help.

viktorianer commented 2 years ago

@keithdoggett

I am in process to upgrade our RGeo gems too, and just updated rgeo-proj4

After upgrade of rgeo-proj4 to 3.x, on Rails 6.1.6 and Ruby 3.0.4 I got the same error:

proj_crs_get_geodetic_crs: Object is not a CRS
proj_create_operations: missing required input
~/.bundle/ruby/3.0.0/gems/rgeo-proj4-3.1.1/lib/rgeo/coord_sys/crs_to_crs.rb:14: [BUG] Segmentation fault at 0x0000000000000310
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]

Never saw Segmentation fault on Ruby, for the last ~5 years 🗡️ :).

newer versions of the PROJ library you need to add "+type=crs" to proj strings to specify that it is a CRS

That fixed it for me. Many thanks!

keithdoggett commented 2 years ago

@viktorianer yes this will be fixed soon (https://github.com/rgeo/rgeo-proj4/pull/26). We are doing some bigger changes to the proj gem in general so it's being tied in with those, but once that's done it won't allow you to try to run a projection without a valid crs!

keithdoggett commented 1 year ago

V4 adds a check for this now