You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by js...@apache.org on 2026/02/18 08:11:47 UTC

(sis) branch geoapi-4.0 updated: fix(NetCDF): fix dimension mismatch between geometry coordinates and it's declared CRS

This is an automated email from the ASF dual-hosted git repository.

jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 36ffa6594a fix(NetCDF): fix dimension mismatch between geometry coordinates and it's declared CRS
36ffa6594a is described below

commit 36ffa6594a04b8dbdc8f190305d4a2151ace0385
Author: jsorel <jo...@geomatys.com>
AuthorDate: Wed Feb 18 09:11:18 2026 +0100

    fix(NetCDF): fix dimension mismatch between geometry coordinates and it's declared CRS
---
 .../apache/sis/storage/netcdf/base/FeatureSet.java | 30 ++++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java
index 88592cbb8d..1195aca525 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/FeatureSet.java
@@ -842,14 +842,34 @@ makeGeom:   if (!isEmpty) {
                      */
                     if (isFloat) {
                         final float x = coordinateValues[0].floatValue(offset);
-                        final float y = coordinateValues[0].floatValue(offset);
-                        if (Float.isNaN(x) && Float.isNaN(y)) break makeGeom;
-                        geometry = factory.createPoint(x, y);
+                        final float y = coordinateValues[1].floatValue(offset);
+                        if (geometryDimension >= 3) {
+                            final float z = coordinateValues[2].floatValue(offset);
+                            if (Float.isNaN(x) && Float.isNaN(y) && Float.isNaN(z)) {
+                                break makeGeom;
+                            }
+                            geometry = factory.createPoint(x, y, z);
+                        } else {
+                            if (Float.isNaN(x) && Float.isNaN(y)) {
+                                break makeGeom;
+                            }
+                            geometry = factory.createPoint(x, y);
+                        }
                     } else {
                         final double x = coordinateValues[0].doubleValue(offset);
                         final double y = coordinateValues[1].doubleValue(offset);
-                        if (Double.isNaN(x) && Double.isNaN(y)) break makeGeom;
-                        geometry = factory.createPoint(x, y);
+                        if (geometryDimension >= 3) {
+                            final double z = coordinateValues[2].doubleValue(offset);
+                            if (Double.isNaN(x) && Double.isNaN(y) && Double.isNaN(z)) {
+                                break makeGeom;
+                            }
+                            geometry = factory.createPoint(x, y, z);
+                        } else {
+                            if (Double.isNaN(x) && Double.isNaN(y)) {
+                                break makeGeom;
+                            }
+                            geometry = factory.createPoint(x, y);
+                        }
                     }
                 }
                 feature.setPropertyValue(TRAJECTORY, geometry);