Open kwerle opened 8 years ago
module Geokit
module ActsAsMappable
module ClassMethods
# Returns the distance calculation to be used as a display column or a condition. This
# is provide for anyone wanting access to the raw SQL.
def distance_sql(origin, units=default_units, formula=default_formula)
case formula
when :sphere
sql = sphere_distance_sql(origin, units)
when :flat
sql = flat_distance_sql(origin, units)
when :neanderthal
sql = neanderthal_distance_sql(origin, units)
end
sql
end
# Returns the distance SQL using the really flat-world formula (Phythagorean Theory).
def neanderthal_distance_sql(origin, units)
adapter.flat_distance_sql(origin, 1.0, 1.0)
end
end
end
end
@kwerle If you can do this in the form of a pull request which passes the tests and doesn't reduce coverage I'll likely be happy to merge.
OK, I'll take a stab at it in the near future. Thanks!
@mnoack How do you run tests for this? It looks like rake test should work (and do sqlite testing), but it does not seem to do so:
root@46a5710ea34d:/tmp/src# rake test
/usr/local/bin/ruby -w -I"lib:lib:test" -I"/usr/local/bundle/gems/rake-11.2.2/lib" "/usr/local/bundle/gems/rake-11.2.2/lib/rake/rake_test_loader.rb" "test/*_test.rb"
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:468: warning: method redefined; discarding old find_spec_for_exe
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems.rb:261: warning: previous definition of find_spec_for_exe was here
/usr/local/bundle/gems/activesupport-5.0.0.1/lib/active_support/core_ext/time/calculations.rb:243: warning: method redefined; discarding old +
/usr/local/bundle/gems/activesupport-5.0.0.1/lib/active_support/core_ext/time/calculations.rb:253: warning: method redefined; discarding old -
/usr/local/bundle/gems/activesupport-5.0.0.1/lib/active_support/core_ext/time/calculations.rb:263: warning: method redefined; discarding old -
/usr/local/bundle/gems/simplecov-rcov-0.2.3/lib/simplecov-rcov.rb:25: warning: assigned but unused variable - generated_on
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
/usr/local/bundle/gems/geokit-1.10.0/lib/geokit/geo_loc.rb:66: warning: method redefined; discarding old state
/usr/local/bundle/gems/geokit-1.10.0/lib/geokit/geo_loc.rb:82: warning: method redefined; discarding old full_address
/usr/local/bundle/gems/geokit-1.10.0/lib/geokit/geo_loc.rb:87: warning: method redefined; discarding old street_number
/usr/local/bundle/gems/geokit-1.10.0/lib/geokit/geo_loc.rb:93: warning: method redefined; discarding old street_name
/usr/local/bundle/gems/geokit-1.10.0/lib/geokit/geo_loc.rb:99: warning: method redefined; discarding old formatted_address
/usr/local/bundle/gems/geokit-1.10.0/lib/geokit/geo_loc.rb:115: warning: method redefined; discarding old city=
/usr/local/bundle/gems/geokit-1.10.0/lib/geokit/geo_loc.rb:121: warning: method redefined; discarding old street_address=
DEPRECATION WARNING: use_transactional_fixtures= is deprecated and will be removed from Rails 5.1 (use use_transactional_tests= instead) (called from <class:GeokitTestCase> at /tmp/src/test/test_helper.rb:46)
/usr/local/bundle/gems/simplecov-rcov-0.2.3/lib/simplecov-rcov.rb:97: warning: instance variable @asset_output_path not initialized
Coverage report Rcov style generated for Unit Tests to /tmp/src/coverage/rcov
[Coveralls] Outside the CI environment, not sending data.
Ping. I'd really like a hand running tests. When I run rake test_sqlite It does (essentially) the above. If I change tests (so that they should fail) I get no change. If I add runtime errors to the tests, I get no change. I'm stumped.
I have to be bug for bug compatible with some existing code. default_formula: :flat still looks at the earth as a sphere - just a rougher one. I need default_formula: :neanderthal
Sigh.