Skip to content

Commit e471282

Browse files
committed
[CONSYS] Fix handling of feature type / QName
1 parent 92c2a40 commit e471282

File tree

4 files changed

+27
-31
lines changed

4 files changed

+27
-31
lines changed

sensorhub-service-consys/src/test/java/org/sensorhub/impl/service/consys/TestFois.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,28 +220,28 @@ public void testAddSystemFoisAndFilterByProps() throws Exception
220220
{
221221
var uid1 = String.format(UID_FORMAT, 1);
222222
var url1 = addFoi(null, 1, true, ImmutableMap.<String, Object>builder()
223-
.put("type", "building")
223+
.put("featureType", "building")
224224
.put("height", 53)
225225
.put("width", 10)
226226
.build());
227227

228228
var uid2 = String.format(UID_FORMAT, 2);
229229
var url2 = addFoi(null, 2, true, ImmutableMap.<String, Object>builder()
230-
.put("type", "vehicle")
230+
.put("featureType", "vehicle")
231231
.put("make", "ford")
232232
.put("length", 4.2)
233233
.put("width", 1.5)
234234
.build());
235235

236236
var uid3 = String.format(UID_FORMAT, 3);
237237
var url3 = addFoi(null, 3, true, ImmutableMap.<String, Object>builder()
238-
.put("type", "river")
238+
.put("featureType", "river")
239239
.put("usgs_id", "R1256")
240240
.build());
241241

242242
var uid4 = String.format(UID_FORMAT, 4);
243243
var url4 = addFoi(null, 4, true, ImmutableMap.<String, Object>builder()
244-
.put("type", "river")
244+
.put("featureType", "river")
245245
.put("usgs_id", "R2212")
246246
.build());
247247

@@ -250,33 +250,33 @@ public void testAddSystemFoisAndFilterByProps() throws Exception
250250
checkId(url2, items.get(0));
251251
checkFoiUid(uid2, items.get(0));
252252

253-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=building", 1);
253+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=building", 1);
254254
checkId(url1, items.get(0));
255255
checkFoiUid(uid1, items.get(0));
256256

257257
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:usgs_id=R2212", 1);
258258
checkId(url4, items.get(0));
259259
checkFoiUid(uid4, items.get(0));
260260

261-
// match one with AND
262-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=*&p:length=4.2", 1);
261+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:length=4.2", 1);
263262
checkId(url2, items.get(0));
264263
checkFoiUid(uid2, items.get(0));
265264

266-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=building&p:height=*", 1);
265+
// match one with AND
266+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=building&p:height=*", 1);
267267
checkId(url1, items.get(0));
268268
checkFoiUid(uid1, items.get(0));
269269

270-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=river&p:usgs_id=R1256", 1);
270+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=river&p:usgs_id=R1256", 1);
271271
checkId(url3, items.get(0));
272272
checkFoiUid(uid3, items.get(0));
273273

274274
// match several
275-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=river", 2);
275+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=river", 2);
276276
checkCollectionItemIds(Set.of(url3, url4), items);
277277

278278
// match several with OR
279-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=river,build*", 3);
279+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=river,building", 3);
280280
checkCollectionItemIds(Set.of(url1, url3, url4), items);
281281

282282
// match several with wildcard
@@ -287,7 +287,7 @@ public void testAddSystemFoisAndFilterByProps() throws Exception
287287
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:prop2=nothing", 0);
288288
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:prop=*", 0);
289289
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:make=nothing", 0);
290-
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=building&p:height=8", 0);
290+
sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=building&p:height=8", 0);
291291
}
292292

293293

sensorhub-service-sweapi/src/test/java/org/sensorhub/impl/service/sweapi/TestSweApiFois.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,28 +220,28 @@ public void testAddSystemFoisAndFilterByProps() throws Exception
220220
{
221221
var uid1 = String.format(UID_FORMAT, 1);
222222
var url1 = addFoi(null, 1, true, ImmutableMap.<String, Object>builder()
223-
.put("type", "building")
223+
.put("featureType", "building")
224224
.put("height", 53)
225225
.put("width", 10)
226226
.build());
227227

228228
var uid2 = String.format(UID_FORMAT, 2);
229229
var url2 = addFoi(null, 2, true, ImmutableMap.<String, Object>builder()
230-
.put("type", "vehicle")
230+
.put("featureType", "vehicle")
231231
.put("make", "ford")
232232
.put("length", 4.2)
233233
.put("width", 1.5)
234234
.build());
235235

236236
var uid3 = String.format(UID_FORMAT, 3);
237237
var url3 = addFoi(null, 3, true, ImmutableMap.<String, Object>builder()
238-
.put("type", "river")
238+
.put("featureType", "river")
239239
.put("usgs_id", "R1256")
240240
.build());
241241

242242
var uid4 = String.format(UID_FORMAT, 4);
243243
var url4 = addFoi(null, 4, true, ImmutableMap.<String, Object>builder()
244-
.put("type", "river")
244+
.put("featureType", "river")
245245
.put("usgs_id", "R2212")
246246
.build());
247247

@@ -250,33 +250,33 @@ public void testAddSystemFoisAndFilterByProps() throws Exception
250250
checkId(url2, items.get(0));
251251
checkFoiUid(uid2, items.get(0));
252252

253-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=building", 1);
253+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=building", 1);
254254
checkId(url1, items.get(0));
255255
checkFoiUid(uid1, items.get(0));
256256

257257
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:usgs_id=R2212", 1);
258258
checkId(url4, items.get(0));
259259
checkFoiUid(uid4, items.get(0));
260260

261-
// match one with AND
262-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=*&p:length=4.2", 1);
261+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:length=4.2", 1);
263262
checkId(url2, items.get(0));
264263
checkFoiUid(uid2, items.get(0));
265264

266-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=building&p:height=*", 1);
265+
// match one with AND
266+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=building&p:height=*", 1);
267267
checkId(url1, items.get(0));
268268
checkFoiUid(uid1, items.get(0));
269269

270-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=river&p:usgs_id=R1256", 1);
270+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=river&p:usgs_id=R1256", 1);
271271
checkId(url3, items.get(0));
272272
checkFoiUid(uid3, items.get(0));
273273

274274
// match several
275-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=river", 2);
275+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=river", 2);
276276
checkCollectionItemIds(Set.of(url3, url4), items);
277277

278278
// match several with OR
279-
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=river,build*", 3);
279+
items = sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=river,building", 3);
280280
checkCollectionItemIds(Set.of(url1, url3, url4), items);
281281

282282
// match several with wildcard
@@ -287,7 +287,7 @@ public void testAddSystemFoisAndFilterByProps() throws Exception
287287
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:prop2=nothing", 0);
288288
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:prop=*", 0);
289289
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:make=nothing", 0);
290-
sendGetRequestAndGetItems(FOI_COLLECTION + "?p:type=building&p:height=8", 0);
290+
sendGetRequestAndGetItems(FOI_COLLECTION + "?featureType=building&p:height=8", 0);
291291
}
292292

293293

sensorhub-utils-kryo/src/main/java/org/sensorhub/impl/serialization/kryo/compat/v1/FeatureSerializerV1.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
package org.sensorhub.impl.serialization.kryo.compat.v1;
1616

1717
import javax.xml.namespace.QName;
18-
import org.vast.ogc.gml.GMLStaxBindings;
1918
import org.vast.ogc.gml.GenericTemporalFeatureImpl;
2019
import org.vast.ogc.gml.IFeature;
2120
import org.vast.util.TimeExtent;
2221
import com.esotericsoftware.kryo.Kryo;
2322
import com.esotericsoftware.kryo.Serializer;
2423
import com.esotericsoftware.kryo.io.Input;
2524
import com.esotericsoftware.kryo.io.Output;
26-
import net.opengis.gml.v32.AbstractFeature;
2725
import net.opengis.gml.v32.AbstractGeometry;
2826
import net.opengis.gml.v32.impl.GMLFactory;
2927

@@ -39,7 +37,6 @@
3937
public class FeatureSerializerV1 extends Serializer<IFeature>
4038
{
4139
static final int VERSION = 1;
42-
static final QName DEFAULT_QNAME = new QName(GMLStaxBindings.NS_URI, "Feature");
4340

4441
GMLFactory gmlFactory = new GMLFactory(true);
4542

@@ -53,7 +50,7 @@ public FeatureSerializerV1()
5350
public void write(Kryo kryo, Output output, IFeature f)
5451
{
5552
//output.writeString(f.getId());
56-
output.writeString(f instanceof AbstractFeature ? ((AbstractFeature)f).getQName().toString() : null);
53+
output.writeString(f.getType());
5754

5855
// common properties
5956
output.writeString(f.getUniqueIdentifier());
@@ -82,8 +79,7 @@ public void write(Kryo kryo, Output output, IFeature f)
8279
public IFeature read(Kryo kryo, Input input, Class<? extends IFeature> type)
8380
{
8481
String fType = input.readString();
85-
QName qname = fType != null ? QName.valueOf(fType) : DEFAULT_QNAME;
86-
var f = new GenericTemporalFeatureImpl(qname);
82+
var f = new GenericTemporalFeatureImpl(fType);
8783

8884
// common properties
8985
f.setUniqueIdentifier(input.readString());

0 commit comments

Comments
 (0)