Added spatialReference to ResultDocumentDV

This commit is contained in:
Francesco Mangiacrapa 2022-10-27 15:08:02 +02:00
parent abc5466f71
commit 8891ec4fb2
2 changed files with 21 additions and 31 deletions

View File

@ -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<IdentificationReference> 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()));

View File

@ -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<RelationshipDV> 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<RelationshipDV> 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();
}