File tree Expand file tree Collapse file tree
parquet-column/src/main/java/org/apache/parquet/column/statistics/geometry Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,9 +34,7 @@ public static void normalizeLongitude(Geometry geometry) {
3434 @ Override
3535 public void filter (CoordinateSequence seq , int i ) {
3636 double x = seq .getX (i );
37- // Normalize the longitude to be within -180 to 180 range
38- while (x > 180 ) x -= 360 ;
39- while (x < -180 ) x += 360 ;
37+ x = normalizeLongitude (x );
4038 seq .setOrdinate (i , CoordinateSequence .X , x );
4139 }
4240
@@ -53,4 +51,14 @@ public boolean isGeometryChanged() {
5351
5452 geometry .geometryChanged (); // Notify the geometry that its coordinates have been changed
5553 }
54+
55+ private static double normalizeLongitude (double lon ) {
56+ if (lon >= -180.0 && lon <= 180.0 ) {
57+ return lon ;
58+ } else if (lon > 180 ) {
59+ return (lon + 180.0 ) % 360.0 - 180.0 ;
60+ } else {
61+ return 180.0 - (180.0 - lon ) % 360.0 ;
62+ }
63+ }
5664}
You can’t perform that action at this time.
0 commit comments