use of com.github.sebastianfrey.joa.models.Datetime in project joa by sebastianfrey.
the class GeoPackageQuery method buildDatetimeWhere.
public void buildDatetimeWhere(StringBuilder whereBuilder, List<String> whereArgs) {
// verify datetime
Datetime datetime = query.getDatetime();
if (datetime == null) {
return;
}
// get all datetime columns
List<FeatureColumn> columns = featureDao.getColumns().stream().filter((column) -> {
return column.getDataType().equals(GeoPackageDataType.DATETIME);
}).toList();
if (columns.isEmpty()) {
return;
}
for (FeatureColumn column : columns) {
whereBuilder.append(" AND (").append(column.getName());
switch(datetime.getType()) {
case DATETIME:
whereBuilder.append(" = ?");
whereArgs.add(datetime.getLower());
break;
case INTERVAL_CLOSED:
whereBuilder.append(" BETWEEN ? AND ?");
whereArgs.add(datetime.getLower());
whereArgs.add(datetime.getUpper());
break;
case INTERVAL_OPEN_START:
whereBuilder.append(" <= ?");
whereArgs.add(datetime.getUpper());
break;
case INTERVAL_OPEN_END:
whereBuilder.append(" >= ?");
whereArgs.add(datetime.getLower());
break;
}
whereBuilder.append(")");
}
}
use of com.github.sebastianfrey.joa.models.Datetime in project joa by sebastianfrey.
the class GeoPackageServiceTest method should_return_items_from_collection.
@Test
public void should_return_items_from_collection() throws Exception {
FeatureQueryRequest query = new FeatureQueryRequest().offset(Long.valueOf(0)).limit(10).datetime(new Datetime("2021-03-04T17:44:25.873Z")).bbox(new Bbox().minX(-180.0).minY(-90.0).maxX(80.0).maxY(90.0));
GeoPackageItems items = geoPackageService.getItems(TEST_SERVICE, TEST_COLLECTION_POINT, query);
assertThat(items).isNotNull();
assertThat(items.getServiceId()).isEqualTo("example");
assertThat(items.getCollectionId()).isEqualTo("point1");
assertThat(items.getFeatures()).isNotEmpty();
assertThat(items.getNumberMatched()).isGreaterThan(Long.valueOf(0));
assertThat(items.getNumberReturned()).isGreaterThan(0);
assertThatCode(() -> Instant.parse(items.getTimeStamp())).doesNotThrowAnyException();
}
Aggregations