Skip to content

Commit

Permalink
V1.0.0 (#18)
Browse files Browse the repository at this point in the history
* Initial 1.0.0 commit

* fixed conformance

* Added CORS config

* tiny typo (#17)

Saw a tiny typo and wanted to get on the board.  Great stuff

* Removed properties from collections

Co-authored-by: zachrouseFE <[email protected]>
  • Loading branch information
joshfix and zachrouseFE authored Jun 3, 2021
1 parent 29f64f1 commit 95e69c7
Show file tree
Hide file tree
Showing 30 changed files with 127 additions and 213 deletions.
100 changes: 4 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## About

Staccato is a server that enables browsing and search of geospatial assets like satellite imagery. It implements the
SpatioTemporal Asset Catalog (STAC) v0.8.0 standard and is backed by [Elasticsearch](https://www.elastic.co/products/elasticsearch).
SpatioTemporal Asset Catalog (STAC) v1.0.0 standard and is backed by [Elasticsearch](https://www.elastic.co/products/elasticsearch).
In addition to the core STAC catalog browsing and search functionality, it includes support for transactions, statistics,
auto-generated schemas, [gRPC](https://grpc.io/) endpoints and [Kafka](https://kafka.apache.org/) ingestion.

Expand Down Expand Up @@ -55,31 +55,6 @@ Any of the following methods are acceptable ways of running Staccato

## Endpoints

### API Endpoints

- GET /search - dynamic catalog endpoint
- GET /search/{id} - returns an item by ID

### Collection Endpoints

- GET /collection/{collection_id} - retrieves a collection by ID
- GET /collection/{collection_id}/items - retrieves a collection of items belonging to a collection
- GET /collection/{collection_id}/items/{id} - retrieves an item by ID from a collection

### Catalog Endpoints

- GET / - retrieves the root catalog
- GET /stac/{catalog_id} - retrieves a catalog by ID
- GET /stac/{catalog_id}/items - retrieves a collection of items belonging to a collection
- GET /stac/{collection_id}/items/{id} - retrieves an item by ID from a collection

### Transaction Endpoints

- POST /collection/{collection_id}/items - creates a new item
- PUT /collection/{collection_id}/items/{item_id} - creates a new item
- PATCH /collection/{collection_id}/items/{item_id} - updates an item item
- DELETE /collection/{collection_id}/items/{item_id} - deletes an item

### Stats Endpoints

- GET /stats - retrieves aggregations for all collections
Expand All @@ -94,72 +69,6 @@ Any of the following methods are acceptable ways of running Staccato

- GET /actuator - returns a list of utility endpoints for the application

### Query Parameters (all optional)
- **limit** the maximum number of items to return, example limit=100
- **page** to paginate, example page=2 (for the second page of results)
- **time** implicit range query, example time=1995-01-01T00:00:2005-01-01T00:00:00
- **bbox** implicit intersects query, example bbox=-180,-90,180,90
- **intersects** a valid GeoJSON geometry
- **query** a Common Query Language text string to query properties of the catalog entry (see below for examples)
- **ids** a list of comma separated IDs to be returned
- **collections** a list of comma separated collection IDs on which to filter the results
- **fields** a comma separated list of json field names to include in the result; fields to be excluded can be prefixed with "-"
- **sortby** a comma separated list of fields to sort by

Examples:
_GET_
- <https://stac.boundlessgeo.io/search?fields.include=id,bbox>
- [https://stac.boundlessgeo.io/search?query=landsat:wrs_path=105 AND landsat:wrs_row=83](https://stac.boundlessgeo.io/stac/search?query=landsat:wrs_path=105%20AND%20landsat:wrs_row=83)
- <https://stac.boundlessgeo.io/search?ids=LC81050832019135LGN00,LC81050822019135LGN00&collections=landsat-8-l1>
- [https://stac.boundlessgeo.io/search?limit=20&page=2&query=eo:cloud_cover<0.1&bbox=27.3245,29.85465,30.5214,31.8685&time=2018-02-12T00:00:00Z/2019-06-12T00:00:00Z](https://stac.boundlessgeo.io/stac/search?limit=20&page=2&query=eo:cloud_cover%3C.1&bbox=27.3245,29.85465,30.5214,31.8685&time=2018-02-12T00:00:00Z/2019-06-12T00:00:00Z)

_POST_

```json
{
"fields": {
"include": ["id", "bbox"]
}
}
```
```json
{
"query": "landsat:wrs_path=105 AND landsat:wrs_row=83"
}
```
```json
{
"ids": ["LC81050832019135LGN00", "LC81050822019135LGN00"],
"collections": ["landsat-8-l1"]
}
```
```json
{
"limit": 2,
"query": "eo:cloud_cover<0.1",
"time": "2018-02-12T00:00:00Z/2019-06-12T00:00:00Z",
"intersects": {
"type": "Polygon",
"coordinates": [[
[-77.08248138427734, 38.788612962793636], [-77.01896667480469, 38.788612962793636],
[-77.01896667480469, 38.835161408189364], [-77.08248138427734, 38.835161408189364],
[-77.08248138427734, 38.788612962793636]
]]
},
"sort": [
{
"field": "properties.eo:cloud_cover",
"direction": "desc"
},
{
"field": "properties.landsat:image_quality_tirs",
"direction": "asc"
}
]
}
```


## Configuration

The STAC API has several properties that are configurable from the command line, as environment properties in the
Expand All @@ -178,7 +87,7 @@ staccato.es.host | localhost | The hostname of the Elasticsearch aggregationServ
staccato.es.port | 9200 | The Elasticsearch aggregationService port
staccato.es.number-of-shards | 5 | The number of shards used when auto-initializing an Elasticsearch index
staccato.es.number-of-replicas | 0 | The number of replicas used when auto-initializing an Elasticsearch index
staccato.es.type | _doc | The Elasticsearch document type. It is not recommended to change this from it's default value as "_doc" will be the only value supported in ES7
staccato.es.type | _doc | The Elasticsearch document type. It is not recommended to change this from its default value as "_doc" will be the only value supported in ES7
staccato.es.max-reconnection-attempts | 10 | The number of reconnection attempts to the Elasticsearch aggregationService
staccato.es.rest-client-max-connections-total | 200 | The Elasticsearch client threadpool size. This is the maximum number of connections a single STAC instance may have open to Elasticsearch.
staccato.es.rest-client-max-connections-per-route | 200 | The maximum number of Elasticsearch client connections per route.
Expand Down Expand Up @@ -310,7 +219,7 @@ It is also important to note that this implementation currently relies on implem
the `collection` field in every item. Because each collection will have a different properties implementation that may
implement several different extension interfaces or custom fieldsExtension, Jackson cannot deserialize Item classes without
more information on which properties class to deserialize to. Having the "collections" field in each item provides an
extremely convenient 1:1 relationship between the item and it's properties implementation. The Jackson configuration
extremely convenient 1:1 relationship between the item and its properties implementation. The Jackson configuration
for this can be found [here](./staccato-application/src/main/java/com/planet/staccato/config/ExtensionConfig.java).

### Custom annotations
Expand All @@ -331,7 +240,6 @@ methods with this annotation and build a subcatalog link containing the field na
containing all unique values in Elasticsearch for that field. After all eligible subcatalog fieldsExtension have been
traversed, the links section will be populated with links to all items that match the selected subcatalog values.


## Elasticsearch

### Automatic Initialization
Expand Down Expand Up @@ -414,7 +322,7 @@ Elasticsearch to rollover the index. When the criteria has been met, Elasticsea
index named `my-index-name-000002`. Because this name matches the pattern `my-index-name-*` that was established in
our template, all of the shard, read replica, mapping, etc configuration will automatically be applied. In addition,
the `my-index-name` write alias will automatically be changed to point to `my-index-name-000002`, and the search alias
`my-index-name-search` will add to it's list. `my-index-name-000002`. When executing searches against the search
`my-index-name-search` will add to its list. `my-index-name-000002`. When executing searches against the search
alias `my=index-name-search`, Elasticsearch will return matches from both indexes, `my-index-name-000001` and
`my-index-name-000002`. The one important note: if a record needs to be updated, you need to first determine which
actual index it belongs to and update it on that index.
Expand Down
36 changes: 4 additions & 32 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

<groupId>com.planet.staccato</groupId>
<artifactId>staccato</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
<packaging>pom</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<version>2.4.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR1</version>
<version>Hoxton.SR11</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -131,34 +131,6 @@
<enabled>false</enabled>
</snapshots>
</repository>
<!--
<repository>
<id>boundless</id>
<name>Boundless Maven Repository</name>
<url>https://repo.boundlessgeo.com/main</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>boundless-release</id>
<name>Boundless Maven Repository</name>
<url>https://repo.boundlessgeo.com/release/</url>
</repository>
<repository>
<id>boundless-snapshot</id>
<name>Boundless Maven Repository</name>
<url>https://repo.boundlessgeo.com/snapshot/</url>
</repository>
<repository>
<id>boundless_ext</id>
<name>Boundless Maven Repository</name>
<url>https://repo.boundlessgeo.com/ext-release-local/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
-->
<repository>
<id>osgeo</id>
<name>OSGeo Repository</name>
Expand Down Expand Up @@ -193,7 +165,7 @@
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<url>https://repo1.maven.org/maven2</url>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
Expand Down
5 changes: 3 additions & 2 deletions staccato-application/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ MAINTAINER [email protected]
ARG JAR_NAME
ENV JAR_NAME $JAR_NAME

COPY target/${JAR_NAME} /${JAR_NAME}
#COPY target/${JAR_NAME} /${JAR_NAME}
ADD target/${JAR_NAME} /${JAR_NAME}

ENTRYPOINT java -jar /$JAR_NAME
ENTRYPOINT ["java", "-jar", "/staccato-1.0.0.jar"]
#ENTRYPOINT java "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" -jar /$JAR_NAME
7 changes: 4 additions & 3 deletions staccato-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<parent>
<groupId>com.planet.staccato</groupId>
<artifactId>staccato</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<dockerfile-maven-version>1.4.4</dockerfile-maven-version>
<dockerfile-maven-version>1.4.13</dockerfile-maven-version>
</properties>

<dependencies>
Expand Down Expand Up @@ -177,7 +177,8 @@
</execution>
</executions>
<configuration>
<repository>quay.io/boundlessgeo/staccato</repository>
<!--<repository>quay.io/boundlessgeo/staccato</repository>-->
<repository>gcr.io/focus-cargo-315523/staccato</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_NAME>staccato-${project.version}.jar</JAR_NAME>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import lombok.Data;
import lombok.RequiredArgsConstructor;

import java.util.List;

@Data
@RequiredArgsConstructor
public class RootCatalog extends Catalog {

protected Object conformsTo;
protected String[] conformsTo;

public Catalog conformsTo(Object conformsTo) {
public Catalog conformsTo(String[] conformsTo) {
setConformsTo(conformsTo);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void init() {

mapper.addMixIn(Item.class, ItemMixin.class);
collectionMetadataList.forEach(metadata -> {
metadata.setVersion(configProps.getVersion());
metadata.setStacVersion(configProps.getVersion());
NamedType namedType = new NamedType(metadata.getProperties().getClass(), metadata.getId());
mapper.registerSubtypes(namedType);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;

import java.util.HashMap;
import java.util.List;
Expand All @@ -28,4 +31,18 @@ public Map<String, CollectionMetadata> collectionMetadataMap() {
return metadataMap;
}

@Bean
public CorsWebFilter corsWebFilter() {
CorsConfiguration corsConfig = new CorsConfiguration();
corsConfig.setAllowedOrigins(List.of("*"));
corsConfig.setMaxAge(8000L);
corsConfig.addAllowedMethod("*");

UrlBasedCorsConfigurationSource source =
new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfig);

return new CorsWebFilter(source);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.planet.staccato.filters;

import com.planet.staccato.config.LinksConfigProps;
import com.planet.staccato.config.StacConfigProps;
import com.planet.staccato.config.StaccatoMediaType;
import com.planet.staccato.dto.api.SearchRequest;
import com.planet.staccato.model.Item;
import com.planet.staccato.model.Link;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
* We do not want to store links in the database, as the deployed hostname/DNS is subject to change. This class will
* dynamically build links using the configured protocol/host/port.
*
* @author joshfix
* Created on 2/12/18
*/
@Component
@RequiredArgsConstructor
public class VersionFilter implements ItemSearchFilter {

private final StacConfigProps stacConfigProps;
private final static Set<String> types = new HashSet<>(Arrays.asList("*"));

@Override
public Set<String> types() {
return types;
}

@Override
public Item doFilter(Item item, SearchRequest request) {
return item.stacVersion(stacConfigProps.getVersion());
}
}
Loading

0 comments on commit 95e69c7

Please sign in to comment.