Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't convert String into Float #1

Closed
donpdonp opened this issue Oct 12, 2010 · 3 comments
Closed

can't convert String into Float #1

donpdonp opened this issue Oct 12, 2010 · 3 comments

Comments

@donpdonp
Copy link

Since you were so quick to help before, i hope you dont mind another issue :). ive looked at the GeoRuby code in the backtrace and i'm a bit lost. I also hope this is enough information to be useful.
`

Location.create({:user_id=>51,"latitude"=>"45.51163136959076", "longitude"=>"-122.61863350868225", "altitude"=>"37.0", "accuracy"=>"16.0", "heading"=>"0.0", "velocity"=>"0.0", "timestamp"=>"2010-10-12T21:53:07+0000", "batterylevel"=>"43"}).errors.full_messages
TypeError: can't convert String into Float
from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/point.rb:133:in pack' from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/point.rb:133:inbinary_representation'
from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/geometry.rb:66:in as_ewkb' from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/geometry.rb:76:inas_hex_ewkb'
from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/postgis_adapter-0.7.8/lib/postgis_adapter.rb:114:in quote' from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:3033:inblock in attributes_with_quotes'
`

@donpdonp
Copy link
Author

i should add that the Location model has these helpers to make the #create call work.

def longitude=(new_longitude); geom_assign(:x, new_longitude); end def latitude=(new_latitude); geom_assign(:y, new_latitude); end def altitude=(new_altitude); geom_assign(:z, new_altitude); end

@donpdonp
Copy link
Author

the fix may be blindingly obvious. im trying geom_assign(:x, new_longitude.to_f) with success so far.

@donpdonp
Copy link
Author

that was it. i guess this changed in GeoRuby.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant