fix geopoint on collection

This commit is contained in:
Enrico Ottonello 2021-11-08 16:56:28 +01:00
parent 66a5677e88
commit 5d9ce6a5fd
2 changed files with 13 additions and 60 deletions

View File

@ -70,6 +70,17 @@ public class BulkUpload {
uri.setLabel(ace.getTypeLabel());
ace.setHas_type(uri);
if (ace.getSpatial()!=null) {
ace.getSpatial()
.stream()
.filter(s -> Objects.nonNull(s.getLat()) && Objects.nonNull(s.getLon()))
.forEach(s -> {
double lat = Double.parseDouble(s.getLat());
double lon = Double.parseDouble(s.getLon());
org.elasticsearch.common.geo.GeoPoint geopoint = new org.elasticsearch.common.geo.GeoPoint(lat, lon);
s.setGeopoint(geopoint);
});
}
if (isCollection) {
ace.setResourceType("collection");
if (ace.getSpatial()!=null) {
@ -80,9 +91,6 @@ public class BulkUpload {
s.setPolygon(s.getWkt());
});
}
// if (ace.getSpatial()==null) {
// ace.setSpatial(Arrays.asList(new Spatial()));
// }
}
else {
ace.setResourceType("dataset");
@ -95,15 +103,6 @@ public class BulkUpload {
});
}
if (ace.getSpatial()!=null) {
ace.getSpatial()
.stream()
.filter(s -> Objects.nonNull(s.getLat()) && Objects.nonNull(s.getLon()))
.forEach(s -> {
double lat = Double.parseDouble(s.getLat());
double lon = Double.parseDouble(s.getLon());
org.elasticsearch.common.geo.GeoPoint geopoint = new org.elasticsearch.common.geo.GeoPoint(lat, lon);
s.setGeopoint(geopoint);
});
ace.getSpatial()
.stream()
.filter(s -> Objects.nonNull(s.getBoundingBoxMaxLat())
@ -124,11 +123,6 @@ public class BulkUpload {
PolygonBuilder polygonBuilder = new PolygonBuilder(coordinatesBuilder);
String wkt = polygonBuilder.toWKT();
s.setBoundingbox(wkt);
// Coordinate topLeft = new Coordinate(minlon, maxlat);
// Coordinate bottomRight = new Coordinate(maxlon, minlat);
// EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(topLeft, bottomRight);
// String wkt = envelopeBuilder.toWKT();
// s.setBoundingbox(wkt);
});
ace.getSpatial()
.stream()
@ -140,10 +134,6 @@ public class BulkUpload {
Double.parseDouble(p.getLon()),
Double.parseDouble(p.getLat()));
});
// PolygonBuilder polygonBuilder = new PolygonBuilder(coordinatesBuilder);
// String wkt = polygonBuilder.toWKT();
// log.debug("POLYGON "+wkt);
// s.setPolygon(wkt);
});
ace.getSpatial()
.stream()
@ -166,39 +156,12 @@ public class BulkUpload {
ace.setSpatial(Arrays.asList(uniqueSpatial));
}
}
// else {
// if (ace.getSpatial()!=null) {
// Set<String> items = new HashSet<>();
// List<Spatial> spatialsNoDup = ace.getSpatial().stream()
// .filter(s -> !items.add(s.getPlaceName()))
// .collect(Collectors.toList());
// ace.getSpatial().clear();
// ace.setSpatial(spatialsNoDup);
// }
//
// }
List<Spatial> dedupSpatials = removeDuplicates(ace.getSpatial());
ace.getSpatial().clear();
ace.setSpatial(dedupSpatials);
// TODO update following check according to new model definition
// if (ace.getSpatial().size()>1) {
// ace.getSpatial().removeIf(s -> (s.getPlaceName()!=null&&s.getPlaceName().equals("Name not provided")&&Objects.isNull(s.getLocation())));
// }
}
// else {
// ace.setSpatial(Arrays.asList(new Spatial()));
// }
}
// if (ace.getTemporal()!=null) {
// ace.getTemporal().stream()
// .filter(t->t.getMatchingPeriodOName()!=null)
// .forEach(t->{
// t.setPeriodName(t.getMatchingPeriodOName());
// });
// }
if (!isCollection) {
String uniqueIsPartOf = ace.getUniqueIsPartOf();
if (uniqueIsPartOf != null) {

View File

@ -241,16 +241,6 @@ public class GraphDbReaderAndESIndexTest {
readAndIndexTest(isRecord, recordId, datasource, collectionId);
}
@Test
// @Ignore
public void uploadDIMEDigitalImageTest() throws Exception {
boolean isRecord = true;
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/DIME/F9398BD5-DECB-3FF5-8077-D96893D0D0C6";
String datasource = "aarhusdime";
String collectionId = "test";
readAndIndexTest(isRecord, recordId, datasource, collectionId);
}
@Test
// @Ignore
public void uploadFastiTest() throws Exception {
@ -345,9 +335,9 @@ public class GraphDbReaderAndESIndexTest {
// @Ignore
public void uploadDimeBoundingBoxTest() throws Exception {
boolean isRecord = true;
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/DIME/F9398BD5-DECB-3FF5-8077-D96893D0D0C6";
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/DIME/0E5FB5C7-6FCA-36AD-BEE5-03C9AFF393CD";
String datasource = "aarhusdime";
String collectionId = "test";
String collectionId = "oai";
readAndIndexTest(isRecord, recordId, datasource, collectionId);
}