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

Add NOT NULL checks for latitude and longitude #86

Merged
merged 5 commits into from
Nov 9, 2015
Merged

Conversation

jensb
Copy link
Contributor

@jensb jensb commented Nov 6, 2015

... otherwise nonsense values are being returned for distance calculations involving such objects.
Added a test fixture without latitude and longitude to make existing tests fail if they do not test for NULL lat/lng values.

…lues are being returned for distance calculations involving such objects.
end

def not_null
where("#{qualified_lat_column_name} IS NOT NULL AND #{qualified_lng_column_name} IS NOT NULL")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [102/80]

@@ -137,7 +137,11 @@ def by_distance(options = {})
bounds = extract_bounds_from_options(options)
distance_column_name = distance_sql(origin, units, formula)
#geo_scope(options).order("#{distance_column_name} asc")
order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}")
not_null_latlng.order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [94/80]

@@ -140,7 +140,11 @@ def by_distance(options = {})
bounds = extract_bounds_from_options(options)
distance_column_name = distance_sql(origin, units, formula)
#geo_scope(options).order("#{distance_column_name} asc")
order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}")
with_latlng.order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [90/80]

@jensb
Copy link
Contributor Author

jensb commented Nov 7, 2015

Please look at the Travis CI failures, they are not caused by my code. Thanks!

mnoack pushed a commit that referenced this pull request Nov 9, 2015
Add NOT NULL checks for latitude and longitude
@mnoack mnoack merged commit db1d280 into geokit:master Nov 9, 2015
@mnoack
Copy link
Member

mnoack commented Nov 9, 2015

You're right. I tried to have a quick look at the CI failures but it seems it's getting rather complex and I'll need to spend some time ensuring it works correctly in all ruby/rails versions before I release the next version of the gem.

@jensb
Copy link
Contributor Author

jensb commented Nov 9, 2015

Good :-), because I have another PR pending (add bounding box around within) and I wanted to make sure this is finished to avoid conflicts. Thank you!

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

Successfully merging this pull request may close these issues.

None yet

3 participants