This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits 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 69a2a1c8d6 feat(Shapefile): create identifiers conform to gml
requierements
69a2a1c8d6 is described below
commit 69a2a1c8d6b769dc70900c8d454e81baa4bbca34
Author: jsorel <[email protected]>
AuthorDate: Thu May 7 12:19:32 2026 +0200
feat(Shapefile): create identifiers conform to gml requierements
---
.../main/org/apache/sis/storage/shapefile/ShapefileStore.java | 9 +++++----
.../org/apache/sis/storage/shapefile/ShapefileStoreTest.java | 8 ++++----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java
index cec90869c2..499b13770a 100644
---
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java
+++
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/ShapefileStore.java
@@ -445,7 +445,7 @@ public final class ShapefileStore extends DataStore
implements WritableFeatureSe
//create a computed identifier field
if (readProperties == null ||
readProperties.contains(AttributeConvention.IDENTIFIER)) {
- ftb.addAttribute(Integer.class)
+ ftb.addAttribute(String.class)
.setName(AttributeConvention.IDENTIFIER_PROPERTY)
.addRole(AttributeRole.IDENTIFIER_COMPONENT);
}
@@ -503,6 +503,7 @@ public final class ShapefileStore extends DataStore
implements WritableFeatureSe
final boolean generateId = mustGenerateId();
final AtomicInteger nextId = new AtomicInteger();
+ final String baseId = type.getName().tip().toString() +".";
final Spliterator spliterator;
if (readShp && dbfPropertiesIndex.length > 0) {
@@ -528,7 +529,7 @@ public final class ShapefileStore extends DataStore
implements WritableFeatureSe
for (int i = 0; i < dbfPropertiesIndex.length;
i++) {
next.setPropertyValue(header.fields[dbfPropertiesIndex[i]].fieldName,
dbfRecord[i]);
}
- if (generateId)
next.setPropertyValue(AttributeConvention.IDENTIFIER, nextId.getAndIncrement());
+ if (generateId)
next.setPropertyValue(AttributeConvention.IDENTIFIER, baseId +
nextId.incrementAndGet());
action.accept(next);
return true;
@@ -551,7 +552,7 @@ public final class ShapefileStore extends DataStore
implements WritableFeatureSe
shpRecord.geometry.setSRID(geomSrid);
}
next.setPropertyValue(GEOMETRY_NAME,
shpRecord.geometry);
- if (generateId)
next.setPropertyValue(AttributeConvention.IDENTIFIER, nextId.getAndIncrement());
+ if (generateId)
next.setPropertyValue(AttributeConvention.IDENTIFIER, baseId +
nextId.incrementAndGet());
action.accept(next);
return true;
} catch (IOException ex) {
@@ -572,7 +573,7 @@ public final class ShapefileStore extends DataStore
implements WritableFeatureSe
for (int i = 0; i < dbfPropertiesIndex.length;
i++) {
next.setPropertyValue(header.fields[dbfPropertiesIndex[i]].fieldName,
dbfRecord[i]);
}
- if (generateId)
next.setPropertyValue(AttributeConvention.IDENTIFIER, nextId.getAndIncrement());
+ if (generateId)
next.setPropertyValue(AttributeConvention.IDENTIFIER, baseId +
nextId.incrementAndGet());
action.accept(next);
return true;
} catch (IOException ex) {
diff --git
a/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java
b/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java
index afd74e99a4..4d355a9c6c 100644
---
a/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java
+++
b/incubator/src/org.apache.sis.storage.shapefile/test/org/apache/sis/storage/shapefile/ShapefileStoreTest.java
@@ -290,7 +290,7 @@ public class ShapefileStoreTest {
assertEquals(1, result.length);
//because of incremental id, feature2 will now have sis:identifer=0
- feature2.setPropertyValue(AttributeConvention.IDENTIFIER, 0);
+ feature2.setPropertyValue(AttributeConvention.IDENTIFIER,
"test.1");
assertEquals(feature2, result[0]);
}
}
@@ -345,7 +345,7 @@ public class ShapefileStoreTest {
Iterator<Feature> iterator = stream.iterator();
assertTrue(iterator.hasNext());
Feature feature1 = iterator.next();
- assertEquals(0,
feature1.getPropertyValue(AttributeConvention.IDENTIFIER));
+ assertEquals("noid.1",
feature1.getPropertyValue(AttributeConvention.IDENTIFIER));
assertEquals("some text", feature1.getPropertyValue("text"));
assertFalse(iterator.hasNext());
@@ -369,7 +369,7 @@ public class ShapefileStoreTest {
private static Feature createFeature1(FeatureType type) {
Feature feature = type.newInstance();
feature.setPropertyValue("geometry", GF.createPoint(new
Coordinate(10,20)));
- feature.setPropertyValue(AttributeConvention.IDENTIFIER, 0);
+ feature.setPropertyValue(AttributeConvention.IDENTIFIER, "test.1");
feature.setPropertyValue("id", 1);
feature.setPropertyValue("text", "some text 1");
feature.setPropertyValue("integer", 123);
@@ -381,7 +381,7 @@ public class ShapefileStoreTest {
private static Feature createFeature2(FeatureType type) {
Feature feature = type.newInstance();
feature.setPropertyValue("geometry", GF.createPoint(new
Coordinate(30,40)));
- feature.setPropertyValue(AttributeConvention.IDENTIFIER, 1);
+ feature.setPropertyValue(AttributeConvention.IDENTIFIER, "test.2");;
feature.setPropertyValue("id", 2);
feature.setPropertyValue("text", "some text 2");
feature.setPropertyValue("integer", 456);