Skip to content

Commit d3f0369

Browse files
authored
Merge pull request #243 from aodn/bugfix/7737-time-slider-issue
Bugfix/7737 time slider issue
2 parents e630e73 + 35e4e38 commit d3f0369

18 files changed

Lines changed: 421 additions & 132 deletions

File tree

server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/FeatureId.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public enum FeatureId {
44
summary("summary"),
55
wfs_fields("wfs_fields"), // Query field based on pure wfs and given layer
6+
wfs_field_value("wfs_field_value"),
67
wms_fields("wms_fields"), // Query field based on value from wms describe layer query
78
wave_buoy_first_data_available("wave_buoy_first_data_available"),
89
wave_buoy_latest_date("wave_buoy_latest_date"),

server/src/main/java/au/org/aodn/ogcapi/server/core/model/ogc/FeatureRequest.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
package au.org.aodn.ogcapi.server.core.model.ogc;
22

33
import io.swagger.v3.oas.annotations.media.Schema;
4-
import lombok.Builder;
5-
import lombok.Data;
6-
import lombok.EqualsAndHashCode;
4+
import lombok.*;
5+
import lombok.experimental.SuperBuilder;
76

87
import java.io.Serializable;
98
import java.math.BigDecimal;
109
import java.util.List;
1110

1211
@Schema(description = "Query parameters for feature requests")
1312
@Data
14-
@Builder
13+
@SuperBuilder
14+
@NoArgsConstructor(force = true, access = AccessLevel.PROTECTED) // Need when using @SuperBuilder
1515
@EqualsAndHashCode
1616
public class FeatureRequest implements Serializable {
17+
// Define a fix name for fields, the geoserver data have all sorts of different name,
18+
// map it here so that we hide the complexity of call from UI.
19+
public enum PropertyName {
20+
wildcard,
21+
time;
22+
23+
public static PropertyName fromString(String input) {
24+
if (input == null || "*".equals(input.trim())) {
25+
return wildcard; // or throw exception / return default
26+
}
27+
return valueOf(input.trim());
28+
}
29+
}
30+
1731
@Schema(description = "Property to be return")
18-
private List<String> properties;
32+
private List<PropertyName> properties;
1933

2034
@Schema(description = "Only records that have a geometry that intersects the bounding box are selected. The bounding box is provided as four or six numbers, depending on whether the coordinate reference system includes a vertical axis (height or depth): * Lower left corner, coordinate axis 1 * Lower left corner, coordinate axis 2 * Minimum value, coordinate axis 3 (optional) * Upper right corner, coordinate axis 1 * Upper right corner, coordinate axis 2 * Maximum value, coordinate axis 3 (optional) The coordinate reference system of the values is WGS 84 long/lat (http://www.opengis.net/def/crs/OGC/1.3/CRS84) unless a different coordinate reference system is specified in the parameter `bbox-crs`. For WGS 84 longitude/latitude the values are in most cases the sequence of minimum longitude, minimum latitude, maximum longitude and maximum latitude. However, in cases where the box spans the antimeridian the first value (west-most box edge) is larger than the third value (east-most box edge). If the vertical axis is included, the third and the sixth number are the bottom and the top of the 3-dimensional bounding box. If a record has multiple spatial geometry properties, it is the decision of the server whether only a single spatial geometry property is used to determine the extent or all relevant geometries.")
2135
private List<BigDecimal> bbox;
@@ -44,6 +58,7 @@ public class FeatureRequest implements Serializable {
4458
@Schema(description = "Enable or disable geoserver whitelist")
4559
@Builder.Default
4660
private Boolean enableGeoServerWhiteList = Boolean.TRUE;
61+
4762
/**
4863
* Make sure if json indicate null, we still return true by default
4964
* @return - Utility function with default

server/src/main/java/au/org/aodn/ogcapi/server/core/model/ogc/wfs/WFSFieldModel.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package au.org.aodn.ogcapi.server.core.model.ogc.wfs;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
@Data
9+
@Builder
10+
@EqualsAndHashCode
11+
public class WfsField {
12+
@JsonProperty("label")
13+
private String label;
14+
15+
@JsonProperty("name")
16+
private String name;
17+
18+
@JsonProperty("type")
19+
private String type;
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package au.org.aodn.ogcapi.server.core.model.ogc.wfs;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
7+
import java.util.List;
8+
9+
@Data
10+
@Builder
11+
public class WfsFields {
12+
13+
@JsonProperty("typename")
14+
private String typename;
15+
16+
@JsonProperty("fields")
17+
private List<WfsField> fields;
18+
}

server/src/main/java/au/org/aodn/ogcapi/server/core/service/ElasticSearch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import au.org.aodn.ogcapi.server.core.model.StacCollectionModel;
66
import au.org.aodn.ogcapi.server.core.model.SearchSuggestionsModel;
77
import au.org.aodn.ogcapi.server.core.model.enumeration.*;
8+
import au.org.aodn.ogcapi.server.core.model.ogc.FeatureRequest;
89
import au.org.aodn.ogcapi.server.core.parser.elastic.CQLToElasticFilterFactory;
910
import au.org.aodn.ogcapi.server.core.parser.elastic.QueryHandler;
1011
import co.elastic.clients.elasticsearch.ElasticsearchClient;
@@ -632,7 +633,7 @@ protected static FieldValue toFieldValue(String s) {
632633
// }
633634

634635
@Override
635-
public SearchResult<FeatureGeoJSON> searchFeatureSummary(String collectionId, List<String> properties, String filter) {
636+
public SearchResult<FeatureGeoJSON> searchFeatureSummary(String collectionId, List<FeatureRequest.PropertyName> properties, String filter) {
636637
try {
637638
SearchRequest searchRequest = new SearchRequest.Builder()
638639
.index(dataIndexName)

server/src/main/java/au/org/aodn/ogcapi/server/core/service/OGCApiService.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import au.org.aodn.ogcapi.server.core.model.enumeration.CQLCrsType;
77
import au.org.aodn.ogcapi.server.core.model.enumeration.FeatureId;
88
import au.org.aodn.ogcapi.server.core.model.enumeration.OGCMediaTypeMapper;
9+
import au.org.aodn.ogcapi.server.core.model.ogc.FeatureRequest;
910
import au.org.aodn.ogcapi.server.core.parser.stac.CQLToStacFilterFactory;
1011
import au.org.aodn.ogcapi.server.tile.RestApi;
1112
import org.geotools.filter.text.commons.CompilerUtil;
@@ -39,9 +40,9 @@ public abstract class OGCApiService {
3940
public abstract List<String> getConformanceDeclaration();
4041

4142
public ResponseEntity<FeatureCollectionGeoJSON> getFeature(String collectionId,
42-
FeatureId fid,
43-
List<String> properties,
44-
String filter) throws Exception {
43+
FeatureId fid,
44+
List<FeatureRequest.PropertyName> properties,
45+
String filter) throws Exception {
4546
switch(fid) {
4647
case summary -> {
4748
var result = search.searchFeatureSummary(collectionId, properties, filter);
@@ -160,9 +161,9 @@ else if (datetime.contains("/") && !datetime.contains("..")) {
160161
}
161162
/**
162163
* Convert the bbox parameter to CQL
163-
* @param bbox
164-
* @param filter
165-
* @return
164+
* @param bbox - Bounding box
165+
* @param filter - CQL filter string
166+
* @return - String format as cql
166167
*/
167168
public static String processBBoxParameter(String fieldName, List<BigDecimal> bbox, String filter) {
168169
String f = null;

server/src/main/java/au/org/aodn/ogcapi/server/core/service/Search.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import au.org.aodn.ogcapi.features.model.FeatureGeoJSON;
44
import au.org.aodn.ogcapi.server.core.model.StacCollectionModel;
55
import au.org.aodn.ogcapi.server.core.model.enumeration.CQLCrsType;
6+
import au.org.aodn.ogcapi.server.core.model.ogc.FeatureRequest;
67
import co.elastic.clients.transport.endpoints.BinaryResponse;
78
import org.springframework.http.ResponseEntity;
89

@@ -17,7 +18,7 @@ public interface Search {
1718
ElasticSearchBase.SearchResult<StacCollectionModel> searchCollections(String id);
1819
ElasticSearchBase.SearchResult<StacCollectionModel> searchCollections(List<String> ids, String sortBy);
1920
ElasticSearchBase.SearchResult<StacCollectionModel> searchAllCollections(String sortBy) throws Exception;
20-
ElasticSearchBase.SearchResult<FeatureGeoJSON>searchFeatureSummary(String collectionId, List<String> properties, String filter) throws Exception;
21+
ElasticSearchBase.SearchResult<FeatureGeoJSON>searchFeatureSummary(String collectionId, List<FeatureRequest.PropertyName> properties, String filter) throws Exception;
2122

2223
ElasticSearchBase.SearchResult<StacCollectionModel> searchByParameters(
2324
List<String> targets,

server/src/main/java/au/org/aodn/ogcapi/server/core/service/wfs/DownloadWfsDataService.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package au.org.aodn.ogcapi.server.core.service.wfs;
22

33
import au.org.aodn.ogcapi.server.core.model.ogc.FeatureRequest;
4-
import au.org.aodn.ogcapi.server.core.model.ogc.wfs.WFSFieldModel;
4+
import au.org.aodn.ogcapi.server.core.model.ogc.wfs.WfsField;
5+
import au.org.aodn.ogcapi.server.core.model.ogc.wfs.WfsFields;
56
import au.org.aodn.ogcapi.server.core.model.ogc.wms.DescribeLayerResponse;
67
import au.org.aodn.ogcapi.server.core.service.wms.WmsServer;
78
import au.org.aodn.ogcapi.server.core.util.DatetimeUtils;
@@ -42,17 +43,17 @@ public DownloadWfsDataService(
4243
/**
4344
* Build CQL filter for temporal and spatial constraints
4445
*/
45-
private String buildCqlFilter(String startDate, String endDate, Object multiPolygon, WFSFieldModel wfsFieldModel) {
46+
private String buildCqlFilter(String startDate, String endDate, Object multiPolygon, WfsFields wfsFieldModel) {
4647
StringBuilder cqlFilter = new StringBuilder();
4748

4849
if (wfsFieldModel == null || wfsFieldModel.getFields() == null) {
4950
return cqlFilter.toString();
5051
}
5152

52-
List<WFSFieldModel.Field> fields = wfsFieldModel.getFields();
53+
List<WfsField> fields = wfsFieldModel.getFields();
5354

5455
// Find temporal field
55-
Optional<WFSFieldModel.Field> temporalField = fields.stream()
56+
Optional<WfsField> temporalField = fields.stream()
5657
.filter(field -> "dateTime".equals(field.getType()) || "date".equals(field.getType()))
5758
.findFirst();
5859

@@ -66,7 +67,7 @@ private String buildCqlFilter(String startDate, String endDate, Object multiPoly
6667
}
6768

6869
// Find geometry field
69-
Optional<WFSFieldModel.Field> geometryField = fields.stream()
70+
Optional<WfsField> geometryField = fields.stream()
7071
.filter(field -> "geometrypropertytype".equals(field.getType()))
7172
.findFirst();
7273

@@ -106,22 +107,22 @@ public String prepareWfsRequestUrl(
106107

107108
String wfsServerUrl;
108109
String wfsTypeName;
109-
WFSFieldModel wfsFieldModel;
110+
WfsFields wfsFieldModel;
110111

111112
// Try to get WFS details from DescribeLayer first, then fallback to searching by layer name
112113
if (describeLayerResponse != null && describeLayerResponse.getLayerDescription().getWfs() != null) {
113114
wfsServerUrl = describeLayerResponse.getLayerDescription().getWfs();
114115
wfsTypeName = describeLayerResponse.getLayerDescription().getQuery().getTypeName();
115116

116-
wfsFieldModel = wfsServer.getDownloadableFields(uuid, FeatureRequest.builder().layerName(wfsTypeName).build(), wfsServerUrl);
117+
wfsFieldModel = wfsServer.getDownloadableFields(uuid, WfsServer.WfsFeatureRequest.builder().layerName(wfsTypeName).server(wfsServerUrl).build());
117118
log.info("WFSFieldModel by describeLayer: {}", wfsFieldModel);
118119
} else {
119120
Optional<String> featureServerUrl = wfsServer.getFeatureServerUrlByTitle(uuid, layerName);
120121

121122
if (featureServerUrl.isPresent()) {
122123
wfsServerUrl = featureServerUrl.get();
123124
wfsTypeName = layerName;
124-
wfsFieldModel = wfsServer.getDownloadableFields(uuid, FeatureRequest.builder().layerName(wfsTypeName).build(), wfsServerUrl);
125+
wfsFieldModel = wfsServer.getDownloadableFields(uuid, WfsServer.WfsFeatureRequest.builder().layerName(wfsTypeName).server(wfsServerUrl).build());
125126
log.info("WFSFieldModel by wfs typename: {}", wfsFieldModel);
126127
} else {
127128
throw new IllegalArgumentException("No WFS server URL found for the given UUID and layer name");

0 commit comments

Comments
 (0)