Search in sources :

Example 1 with MD

use of io.arlas.server.core.model.response.MD in project ARLAS-server by gisaia.

the class StacRESTService method getItem.

protected Item getItem(Feature feature, CollectionReference collection, UriInfo uriInfo) {
    List<StacLink> links = new ArrayList<>();
    links.add(getSelfLink(uriInfo));
    links.add(getRootLink(uriInfo));
    links.add(getRootLink(uriInfo));
    links.add(getLink(uriInfo, "collections/" + collection.collectionName, "parent", MediaType.APPLICATION_JSON));
    links.add(getLink(uriInfo, "collections/" + collection.collectionName, "collection", MediaType.APPLICATION_JSON));
    // add datetime https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#properties-object
    MD md = feature.getProperty(MD.class.getSimpleName().toLowerCase());
    feature.setProperty("datetime", ITU.formatUtc(OffsetDateTime.ofInstant(Instant.ofEpochMilli(md.timestamp), ZoneOffset.UTC)));
    Map<String, Object> assets = new HashMap<>();
    assets.put("geojson", getAggregateUrl(uriInfo, collection, "_geosearch", md.id));
    assets.put("shapefile", getAggregateUrl(uriInfo, collection, "_shapesearch", md.id));
    // https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#item-fields
    Item item = new Item().stacVersion(configuration.stacVersion).stacExtensions(new ArrayList<>()).id(md.id).geometry(feature.getGeometry()).bbox(GeoUtil.getBbox(feature.getGeometry())).properties(feature.getProperties()).links(links).assets(assets).collection(collection.collectionName);
    return item;
}
Also used : MD(io.arlas.server.core.model.response.MD) GeoJsonObject(org.geojson.GeoJsonObject)

Aggregations

MD (io.arlas.server.core.model.response.MD)1 GeoJsonObject (org.geojson.GeoJsonObject)1