Skip to content

Commit 5ec6546

Browse files
committed
add shouldNormalizeLongitude
1 parent 4cd8dfd commit 5ec6546

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

  • parquet-column/src/main/java/org/apache/parquet/column/statistics/geometry

parquet-column/src/main/java/org/apache/parquet/column/statistics/geometry/BoundingBox.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public double getMMax() {
8383
// Method to update the bounding box with the coordinates of a Geometry object
8484
// geometry can be changed by this method
8585
void update(Geometry geometry, String crs) {
86-
GeospatialUtils.normalizeLongitude(geometry);
86+
if (shouldNormalizeLongitude(crs)) {
87+
GeospatialUtils.normalizeLongitude(geometry);
88+
}
8789
Envelope envelope = geometry.getEnvelopeInternal();
8890
double minX = envelope.getMinX();
8991
double minY = envelope.getMinY();
@@ -184,6 +186,21 @@ private void updateXBounds(double minX, double maxX) {
184186
}
185187
}
186188

189+
/**
190+
* Determines if the longitude should be normalized based on the given CRS (Coordinate Reference System).
191+
* Normalization is required only when the CRS is set to OGC:CRS84, EPSG:4326, or SRID:4326 (case insensitive).
192+
*
193+
* @param crs the Coordinate Reference System string
194+
* @return true if the longitude should be normalized, false otherwise
195+
*/
196+
private boolean shouldNormalizeLongitude(String crs) {
197+
if (crs == null) {
198+
return false;
199+
}
200+
String normalizedCrs = crs.trim().toUpperCase();
201+
return "OGC:CRS84".equals(normalizedCrs) || "EPSG:4326".equals(normalizedCrs) || "SRID:4326".equals(normalizedCrs);
202+
}
203+
187204
public BoundingBox copy() {
188205
return new BoundingBox(xMin, xMax, yMin, yMax, zMin, zMax, mMin, mMax);
189206
}

0 commit comments

Comments
 (0)