2424 * Utility class for geodesic distance calculations on Earth's surface.
2525 * This class handles the conversion between meters and degrees of latitude/longitude,
2626 * accounting for the curvature of the Earth using the WGS84 ellipsoid model.
27+ *
28+ * <p><strong>Note:</strong> This is an interim implementation. A future enhancement
29+ * (see <a href="https://github.com/nitrite/nitrite-java/issues/1126">issue #1126</a>)
30+ * will introduce explicit GeoPoint types and separate GeoNearFilter to provide better
31+ * type safety and avoid the ambiguity of auto-detection.</p>
2732 *
2833 * @since 4.0
2934 * @author Anindya Chatterjee
@@ -36,6 +41,17 @@ class GeodesicUtils {
3641 * This is a heuristic check based on valid lat/long ranges:
3742 * - Latitude: -90 to 90
3843 * - Longitude: -180 to 180
44+ *
45+ * <p><strong>Limitation:</strong> This heuristic may incorrectly classify:</p>
46+ * <ul>
47+ * <li>Cartesian coordinates that happen to fall within ±90°/±180° range
48+ * (e.g., game world or CAD coordinates)</li>
49+ * <li>Invalid geographic coordinates (e.g., lat=0, lon=200 would pass the check
50+ * but lon=200, lat=0 would fail)</li>
51+ * </ul>
52+ *
53+ * <p>A future enhancement will use explicit GeoPoint types to avoid this ambiguity.
54+ * See <a href="https://github.com/nitrite/nitrite-java/issues/1126">issue #1126</a>.</p>
3955 *
4056 * @param center the coordinate to check
4157 * @return true if the coordinate appears to be geographic, false otherwise
@@ -53,6 +69,14 @@ static boolean isGeographic(Coordinate center) {
5369 * Calculates the approximate radius in degrees for a given distance in meters
5470 * at a specific geographic coordinate. This accounts for the fact that one degree
5571 * of longitude varies with latitude.
72+ *
73+ * <p><strong>Accuracy Note:</strong> This method returns the maximum of the
74+ * latitude and longitude degree differences to ensure circular coverage. This
75+ * means the resulting bounding box may be slightly larger than necessary,
76+ * potentially including some points outside the actual geodesic circle.</p>
77+ *
78+ * <p>A future enhancement (see <a href="https://github.com/nitrite/nitrite-java/issues/1126">issue #1126</a>,
79+ * Task 4) will implement two-pass query execution to eliminate these false positives.</p>
5680 *
5781 * @param center the center coordinate (longitude, latitude)
5882 * @param radiusMeters the radius in meters
@@ -75,6 +99,7 @@ static double metersToDegreesRadius(Coordinate center, double radiusMeters) {
7599
76100 // Use the maximum of the two to ensure we cover the full circle
77101 // This creates a slightly larger search area but ensures we don't miss points
102+ // TODO: Consider two-pass filtering to eliminate false positives (see issue #1126, Task 4)
78103 return Math .max (lonDiff , latDiff );
79104 }
80105}
0 commit comments