Commit 2c7f4738 authored by Daniel Eggert's avatar Daniel Eggert
Browse files

applied usgs api changes

parent 7144a042
......@@ -59,7 +59,7 @@ public class MetadatacrawlerModule {
// DatasetMetadata aster_l1t = new DatasetMetadata();
// aster_l1t.id = 189;
// aster_l1t.name = "ASTER_L1T";
// crawlerTasks.put(usgs, Arrays.asList(landsat8c1));
crawlerTasks.put(usgs, Arrays.asList(landsat8c1));
// crawlerTasks.put(usgs, Arrays.asList(aster_l1t, landsat7, landsat8));
// crawl sentinel2 from esa' scientific data hub
......@@ -67,7 +67,7 @@ public class MetadatacrawlerModule {
DatasetMetadata s2 = new DatasetMetadata();
s2.id = 249;
s2.name = "Sentinel-2";
crawlerTasks.put(scihub, Arrays.asList(s2));
// crawlerTasks.put(scihub, Arrays.asList(s2));
final boolean queryLatestOnly = true;
......
......@@ -19,9 +19,11 @@ import de.potsdam.gfz.gms.metadatacrawler.model.SceneMetadata;
import de.potsdam.gfz.usgsapi.json.ErrorCode;
import de.potsdam.gfz.usgsapi.json.UsgsApi;
import de.potsdam.gfz.usgsapi.json.datamodels.Bounds;
import de.potsdam.gfz.usgsapi.json.datamodels.Coordinate;
import de.potsdam.gfz.usgsapi.json.datamodels.Dataset;
import de.potsdam.gfz.usgsapi.json.datamodels.InventoryScene;
import de.potsdam.gfz.usgsapi.json.datamodels.SearchResultOptions;
import de.potsdam.gfz.usgsapi.json.datamodels.TemporalFilter;
import de.potsdam.gfz.usgsapi.json.request.DatasetSearchRequest;
import de.potsdam.gfz.usgsapi.json.request.LoginRequest;
import de.potsdam.gfz.usgsapi.json.request.LogoutRequest;
......@@ -77,9 +79,10 @@ public class UsgsCrawler extends MetadataCrawler {
if (response == null) {
// initial request
if (start == null || end == null) {
searchRequest = new SceneSearchRequest(apiKey, dataset.name);
searchRequest = new SceneSearchRequest(apiKey, dataset.name, null, null, null, null, null, true);
} else {
searchRequest = new SceneSearchRequest(apiKey, dataset.name, start.toISO8601String(), end.toISO8601String());
searchRequest = new SceneSearchRequest(apiKey, dataset.name, new TemporalFilter(start.toISO8601String(), end.toISO8601String()), null, null, null, null,
true);
}
SearchResultOptions options = searchRequest.getSearchResultOptions();
options.maxResults = MAX_RESULTS_PER_QUERY;
......@@ -147,7 +150,7 @@ public class UsgsCrawler extends MetadataCrawler {
dbScene.endtime = Timestamp.parse(usgsScene.endTime);
dbScene.modifieddate = Timestamp.parse(usgsScene.modifiedDate);
// bounds
dbScene.bounds = toPolygon(usgsScene.bounds);
dbScene.bounds = toPolygon(usgsScene.spatialFootprint);
// urls
dbScene.browseurl = usgsScene.browseUrl;
dbScene.dataaccessurl = usgsScene.dataAccessUrl;
......@@ -169,6 +172,22 @@ public class UsgsCrawler extends MetadataCrawler {
} while (response.hasNextPage());
}
/**
* Converts a coordinate array to a postgis geometry polygon.<br>
*
* @param bounds
* @return
*/
private static PGgeometry toPolygon(Coordinate[] spatialFootprint) {
// convert points
Point[] points = new Point[spatialFootprint.length];
for (int i = 0; i < points.length; ++i) {
points[i] = new Point(spatialFootprint[i].lon, spatialFootprint[i].lat);
}
return new PGgeometry(new Polygon(new LinearRing[] { new LinearRing(points) }));
}
/**
* Converts a plain lat/lon array to a postgis geometry polygon.<br>
* <br>
......@@ -294,8 +313,8 @@ public class UsgsCrawler extends MetadataCrawler {
try {
// init request - skip timestamps if null
DatasetSearchRequest request = (start == null || end == null) ? new DatasetSearchRequest(apiKey)
: new DatasetSearchRequest(apiKey, start.toISO8601String(), end.toISO8601String());
DatasetSearchRequest request = (start == null || end == null) ? new DatasetSearchRequest(apiKey, null, null, null, null)
: new DatasetSearchRequest(apiKey, null, new TemporalFilter(start.toISO8601String(), end.toISO8601String()), null, null);
// submit request
DatasetSearchResponse response = UsgsApi.sendRequest(request);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment