-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from aodn/feature/query-real-data
query real data
- Loading branch information
Showing
9 changed files
with
197 additions
and
11 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
server/src/main/java/au/org/aodn/ogcapi/server/core/model/DatasetModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package au.org.aodn.ogcapi.server.core.model; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
@Data | ||
@Builder | ||
public class DatasetModel { | ||
private String uuid; | ||
private List<DatumModel> data; | ||
} |
57 changes: 57 additions & 0 deletions
57
server/src/main/java/au/org/aodn/ogcapi/server/core/model/DatasetSearchResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package au.org.aodn.ogcapi.server.core.model; | ||
|
||
import au.org.aodn.ogcapi.features.model.*; | ||
import au.org.aodn.ogcapi.server.core.model.enumeration.FeatureProperty; | ||
import lombok.Getter; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Getter | ||
public class DatasetSearchResult { | ||
|
||
private final FeatureCollectionGeoJSON dataset; | ||
|
||
public DatasetSearchResult() { | ||
this.dataset = new FeatureCollectionGeoJSON(); | ||
initDataset(); | ||
} | ||
|
||
private void initDataset() { | ||
dataset.setType(FeatureCollectionGeoJSON.TypeEnum.FEATURECOLLECTION); | ||
dataset.setFeatures(new ArrayList<>()); | ||
} | ||
|
||
public void addDatum(DatumModel datum) { | ||
|
||
if (datum == null) { | ||
throw new IllegalArgumentException("Datum cannot be null"); | ||
} | ||
|
||
var feature = new FeatureGeoJSON(); | ||
feature.setType(FeatureGeoJSON.TypeEnum.FEATURE); | ||
var geometry = new PointGeoJSON(); | ||
geometry.setType(PointGeoJSON.TypeEnum.POINT); | ||
var coordinates = new ArrayList<BigDecimal>(); | ||
|
||
// Don't use null checks here because it is a list and even if it is null, | ||
// it still needs "null" to occupy the space | ||
coordinates.add(datum.getLongitude()); | ||
coordinates.add(datum.getLatitude()); | ||
|
||
geometry.setCoordinates(coordinates); | ||
feature.setGeometry(geometry); | ||
|
||
// Please add more properties if needed | ||
Map<String, Object> properties = new HashMap<>(); | ||
properties.put(FeatureProperty.TIME.getValue(), datum.getTime()); | ||
properties.put(FeatureProperty.DEPTH.getValue(), datum.getDepth()); | ||
properties.put(FeatureProperty.COUNT.getValue(), datum.getCount()); | ||
|
||
feature.setProperties(properties); | ||
dataset.getFeatures().add(feature); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
server/src/main/java/au/org/aodn/ogcapi/server/core/model/DatumModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package au.org.aodn.ogcapi.server.core.model; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.math.BigDecimal; | ||
|
||
@Data | ||
@Builder | ||
public class DatumModel { | ||
|
||
private String time; | ||
private BigDecimal latitude; | ||
private BigDecimal longitude; | ||
private BigDecimal depth; | ||
|
||
private long count; | ||
} |
19 changes: 19 additions & 0 deletions
19
server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/FeatureProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package au.org.aodn.ogcapi.server.core.model.enumeration; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum FeatureProperty { | ||
TIME("time"), | ||
DEPTH("depth"), | ||
COUNT("count"), | ||
UUID("uuid") | ||
; | ||
|
||
private final String value; | ||
|
||
FeatureProperty(String value) { | ||
this.value = value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters