use of eu.esdihumboldt.hale.io.shp.reader.internal.ShapeSchemaReader in project hale by halestudio.
the class FilterTest method simpleSchemaTestCQL.
@Test
public void simpleSchemaTestCQL() throws Exception {
ShapeSchemaReader schemaReader = new ShapeSchemaReader();
schemaReader.setSource(new DefaultInputSupplier(getClass().getResource("/testdata/GN_Point/GN_Point.shp").toURI()));
schemaReader.validate();
IOReport report = schemaReader.execute(null);
assertTrue(report.isSuccess());
Schema schema = schemaReader.getSchema();
ShapeInstanceReader instanceReader = new ShapeInstanceReader();
instanceReader.setSource(new DefaultInputSupplier(getClass().getResource("/testdata/GN_Point/GN_Point.shp").toURI()));
instanceReader.setSourceSchema(schema);
instanceReader.validate();
report = instanceReader.execute(null);
assertTrue(report.isSuccess());
InstanceCollection instances = instanceReader.getInstances();
assertFalse(instances.isEmpty());
ResourceIterator<Instance> ri = instances.iterator();
try {
boolean foundIt = false;
boolean stayFalse = false;
boolean stayFalseToo = false;
Filter cqlfilter = new FilterGeoCqlImpl("NEV = 'Piritulus'");
Filter foulfilter = new FilterGeoCqlImpl("HERP = 'DERP'");
Filter foulfilter1 = new FilterGeoCqlImpl("NEV = 'HURR'");
while (ri.hasNext()) {
Instance inst = ri.next();
assertNotNull(inst);
if (cqlfilter.match(inst)) {
foundIt = true;
}
if (foulfilter.match(inst)) {
stayFalse = true;
}
if (foulfilter1.match(inst)) {
stayFalseToo = true;
}
}
assertTrue(foundIt);
assertFalse(stayFalse);
assertFalse(stayFalseToo);
} finally {
ri.close();
}
}
use of eu.esdihumboldt.hale.io.shp.reader.internal.ShapeSchemaReader in project hale by halestudio.
the class FilterTest method simpleSchemaTestECQL.
@Test
public void simpleSchemaTestECQL() throws Exception {
ShapeSchemaReader schemaReader = new ShapeSchemaReader();
schemaReader.setSource(new DefaultInputSupplier(getClass().getResource("/testdata/GN_Point/GN_Point.shp").toURI()));
schemaReader.validate();
IOReport report = schemaReader.execute(null);
assertTrue(report.isSuccess());
Schema schema = schemaReader.getSchema();
ShapeInstanceReader instanceReader = new ShapeInstanceReader();
instanceReader.setSource(new DefaultInputSupplier(getClass().getResource("/testdata/GN_Point/GN_Point.shp").toURI()));
instanceReader.setSourceSchema(schema);
instanceReader.validate();
report = instanceReader.execute(null);
assertTrue(report.isSuccess());
InstanceCollection instances = instanceReader.getInstances();
assertFalse(instances.isEmpty());
ResourceIterator<Instance> ri = instances.iterator();
try {
boolean foundIt = false;
boolean stayFalse = false;
boolean stayFalseToo = false;
Filter cqlfilter = new FilterGeoECqlImpl("NEV = 'Piritulus'");
Filter foulfilter = new FilterGeoECqlImpl("HERP = 'DERP'");
Filter foulfilter1 = new FilterGeoECqlImpl("NEV = 'HURR'");
while (ri.hasNext()) {
Instance inst = ri.next();
assertNotNull(inst);
if (cqlfilter.match(inst)) {
foundIt = true;
}
if (foulfilter.match(inst)) {
stayFalse = true;
}
if (foulfilter1.match(inst)) {
stayFalseToo = true;
}
}
assertTrue(foundIt);
assertFalse(stayFalse);
assertFalse(stayFalseToo);
} finally {
ri.close();
}
}
Aggregations