Difference in distance is not constant for point moving along a horizontal line parallel to the x-axis at a constant speed

Open
#161 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start with SpatialContext.calcDistance, SpatialContext.GEO, and the Haversine distance calculator. Reproduce the reported samples and compare the calculated deltas with the expected geodesic behavior. Done means determining whether the varying distance changes are correct and documenting or correcting the behavior with a verified result.

Written by the indexing model from the issue text.

Description

question

Hi,
I am trying to find the distance between a moving point p1 and a fixed point p2. Both of them are on the same y-coordinate. Point p1 just travels along the y = b line (n is constant). However, I noticed that while p1 moved at a constant speed, the distance value returned by the SpatialContext.calcDistance(p, p2) didn't change at a constant rate. Below is a sample of my data:

 p1               p2         distance

-141.854 , 52.94 | -106.75 , 52.94 | 1257.386
-140.194 , 52.94 | -106.75 , 52.94 | 1199.061
-138.534 , 52.94 | -106.75 , 52.94 | 1140.57
-136.874 , 52.94 | -106.75 , 52.94 | 1081.92
-135.214 , 52.94 | -106.75 , 52.94 | 1023.121
-133.554 , 52.94 | -106.75 , 52.94 | 964.1811
-131.894 , 52.94 | -106.75 , 52.94 | 905.109
-130.234 , 52.94 | -106.75 , 52.94 | 845.913
-128.574 , 52.94 | -106.75 , 52.94 | 786.6017
-126.914 , 52.94 | -106.75 , 52.94 | 727.1834

As you can see, the change in the x-coordinates between each consecutive snapshot is a constant value of 1.66 degrees. However, the change in distance (1257.386 to 727.1834) between the moving point p1 and the fixed point p2 (-106.75, 52.94) is not a constant value. In fact, the difference is increasing slightly from 58.3245 to 59.4183 between each snapshot. By the way, I used SpatialContext.GEO and Harversine distance calculator for this since my model is geodesic. However, since my point is moving in parallel to the x-axis, I expect the distance delta to be the same. Am I missing something here or am I wrong to assume that? Thanks.

By the way, I forgot to mention that the distance posted is the distance in nautical miles (which I converted from the distance in degree by multiplying the result with DistanceUtils.DEG_TO_KM * KM_TO_NAUTICAL_MILE).

Dominant language
Java
Stars
961
Forks
172
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from locationtech/spatial4j

All issues in locationtech/spatial4j

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.