Skip to content

Commit

Permalink
Fix blurred bounding box for obscured observations
Browse files Browse the repository at this point in the history
It was about 2x too tall & wide.
  • Loading branch information
JoeCohen committed Aug 18, 2024
1 parent 073c066 commit 27ab9b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions app/classes/inat_obs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,21 @@ def taxon_importable?

# ----- location-related

# These give a good approximation of the iNat blurred bounding box
def blurred_north
[lat + public_accuracy_in_degrees[:lat], 90].min
[lat + public_accuracy_in_degrees[:lat] / 2, 90].min
end

def blurred_south
[lat - public_accuracy_in_degrees[:lat], -90].max
[lat - public_accuracy_in_degrees[:lat] / 2, -90].max
end

def blurred_east
((lng + public_accuracy_in_degrees[:lng] + 180) % 360) - 180
((lng + public_accuracy_in_degrees[:lng] / 2 + 180) % 360) - 180
end

def blurred_west
((lng - public_accuracy_in_degrees[:lng] + 180) % 360) - 180
((lng - public_accuracy_in_degrees[:lng] / 2 + 180) % 360) - 180
end

def to_rad(degrees)
Expand Down
8 changes: 4 additions & 4 deletions test/models/inat_obs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ def test_obscured_location
user: rolf,
name: "Blurred Location",
north: mock_inat_obs.lat +
mock_inat_obs.public_accuracy_in_degrees[:lat],
mock_inat_obs.public_accuracy_in_degrees[:lat] / 2,
south: mock_inat_obs.lat -
mock_inat_obs.public_accuracy_in_degrees[:lat],
mock_inat_obs.public_accuracy_in_degrees[:lat] / 2,
east: mock_inat_obs.lng +
mock_inat_obs.public_accuracy_in_degrees[:lng],
mock_inat_obs.public_accuracy_in_degrees[:lng] / 2,
west: mock_inat_obs.lng -
mock_inat_obs.public_accuracy_in_degrees[:lng]
mock_inat_obs.public_accuracy_in_degrees[:lng] / 2
)

Location.create(
Expand Down

0 comments on commit 27ab9b2

Please sign in to comment.