From 8891ec4fb27d3cf5081a8e7cc0723f058d154950 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 27 Oct 2022 15:08:02 +0200 Subject: [PATCH] Added spatialReference to ResultDocumentDV --- .../ConvertToDataValueObjectModel.java | 18 +++++----- .../shared/geoportal/ResultDocumentDV.java | 34 +++++++------------ 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index 78a2039..fdfde50 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -606,6 +606,7 @@ public class ConvertToDataValueObjectModel { .read(jsonObject.getJSONObject("crs").toString(), Crs.class); geoJson.setCrs(crs); geoJson.setGeoJSON(jsonObject.toString()); + LOG.debug("toSpatialReference returning "+geoJson); } catch (JSONException | IOException e) { LOG.warn("Error on converting " + GeoJSON.class.getSimpleName() + " from : " + geoJSONObject, e); } @@ -638,17 +639,16 @@ public class ConvertToDataValueObjectModel { rd.setProfileID(project.getProfileID()); try { - Double centroidLat = project.getTheDocument().get(CENTROID_LAT, Double.class); - rd.setCentroidLat(centroidLat); - } catch (Exception e) { - // TODO: handle exception - } + + List ids = project + .getIdentificationReferenceByType(IdentificationReferencesTYPE.SPATIAL_REFERENCE.getType()); + if (ids != null && !ids.isEmpty()) { + GeoJSON geoJson = toSpatialReference(ids.get(0).toJson()); + rd.setSpatialReference(geoJson); + } - try { - Double centroidLong = project.getTheDocument().get(CENTROID_LONG, Double.class); - rd.setCentroidLong(centroidLong); } catch (Exception e) { - // TODO: handle exception + LOG.warn("Error occurred on reading spatial reference for the project: "+project.getId()); } rd.setPublicationInfo(toPublicationInfoDV(project.getInfo())); diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java index e5cc72b..98e6d78 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.LinkedHashMap; import java.util.List; +import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON; import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV; @@ -16,8 +17,7 @@ public class ResultDocumentDV extends DocumentDV implements Serializable { private PublicationInfoDV publicationInfoDV; private List listRelationshipDV; - private Double centroidLong; - private Double centroidLat; + private GeoJSON spatialReference; /** * @@ -64,14 +64,6 @@ public class ResultDocumentDV extends DocumentDV implements Serializable { this.listRelationshipDV = listRelationshipDV; } - public Double getCentroidLong() { - return centroidLong; - } - - public Double getCentroidLat() { - return centroidLat; - } - public void setPublicationInfoDV(PublicationInfoDV publicationInfoDV) { this.publicationInfoDV = publicationInfoDV; } @@ -80,14 +72,6 @@ public class ResultDocumentDV extends DocumentDV implements Serializable { this.listRelationshipDV = listRelationshipDV; } - public void setCentroidLong(Double centroidLong) { - this.centroidLong = centroidLong; - } - - public void setCentroidLat(Double centroidLat) { - this.centroidLat = centroidLat; - } - public List getListRelationshipDV() { return listRelationshipDV; } @@ -101,6 +85,14 @@ public class ResultDocumentDV extends DocumentDV implements Serializable { return publicationInfoDV; } + public GeoJSON getSpatialReference() { + return spatialReference; + } + + public void setSpatialReference(GeoJSON spatialReference) { + this.spatialReference = spatialReference; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -114,10 +106,8 @@ public class ResultDocumentDV extends DocumentDV implements Serializable { builder.append(publicationInfoDV); builder.append(", listRelationshipDV="); builder.append(listRelationshipDV); - builder.append(", centroidLong="); - builder.append(centroidLong); - builder.append(", centroidLat="); - builder.append(centroidLat); + builder.append(", spatialReference="); + builder.append(spatialReference); builder.append("]"); return builder.toString(); }