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); .read(jsonObject.getJSONObject("crs").toString(), Crs.class);
geoJson.setCrs(crs); geoJson.setCrs(crs);
geoJson.setGeoJSON(jsonObject.toString()); geoJson.setGeoJSON(jsonObject.toString());
LOG.debug("toSpatialReference returning "+geoJson);
} catch (JSONException | IOException e) { } catch (JSONException | IOException e) {
LOG.warn("Error on converting " + GeoJSON.class.getSimpleName() + " from : " + geoJSONObject, e); LOG.warn("Error on converting " + GeoJSON.class.getSimpleName() + " from : " + geoJSONObject, e);
} }
@ -638,17 +639,16 @@ public class ConvertToDataValueObjectModel {
rd.setProfileID(project.getProfileID()); rd.setProfileID(project.getProfileID());
try { try {
Double centroidLat = project.getTheDocument().get(CENTROID_LAT, Double.class);
rd.setCentroidLat(centroidLat); List<IdentificationReference> ids = project
} catch (Exception e) { .getIdentificationReferenceByType(IdentificationReferencesTYPE.SPATIAL_REFERENCE.getType());
// TODO: handle exception 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) { } catch (Exception e) {
// TODO: handle exception LOG.warn("Error occurred on reading spatial reference for the project: "+project.getId());
} }
rd.setPublicationInfo(toPublicationInfoDV(project.getInfo())); rd.setPublicationInfo(toPublicationInfoDV(project.getInfo()));

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; 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.BasicLifecycleInformationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
@ -16,8 +17,7 @@ public class ResultDocumentDV extends DocumentDV implements Serializable {
private PublicationInfoDV publicationInfoDV; private PublicationInfoDV publicationInfoDV;
private List<RelationshipDV> listRelationshipDV; private List<RelationshipDV> listRelationshipDV;
private Double centroidLong; private GeoJSON spatialReference;
private Double centroidLat;
/** /**
* *
@ -64,14 +64,6 @@ public class ResultDocumentDV extends DocumentDV implements Serializable {
this.listRelationshipDV = listRelationshipDV; this.listRelationshipDV = listRelationshipDV;
} }
public Double getCentroidLong() {
return centroidLong;
}
public Double getCentroidLat() {
return centroidLat;
}
public void setPublicationInfoDV(PublicationInfoDV publicationInfoDV) { public void setPublicationInfoDV(PublicationInfoDV publicationInfoDV) {
this.publicationInfoDV = publicationInfoDV; this.publicationInfoDV = publicationInfoDV;
} }
@ -80,14 +72,6 @@ public class ResultDocumentDV extends DocumentDV implements Serializable {
this.listRelationshipDV = listRelationshipDV; this.listRelationshipDV = listRelationshipDV;
} }
public void setCentroidLong(Double centroidLong) {
this.centroidLong = centroidLong;
}
public void setCentroidLat(Double centroidLat) {
this.centroidLat = centroidLat;
}
public List<RelationshipDV> getListRelationshipDV() { public List<RelationshipDV> getListRelationshipDV() {
return listRelationshipDV; return listRelationshipDV;
} }
@ -101,6 +85,14 @@ public class ResultDocumentDV extends DocumentDV implements Serializable {
return publicationInfoDV; return publicationInfoDV;
} }
public GeoJSON getSpatialReference() {
return spatialReference;
}
public void setSpatialReference(GeoJSON spatialReference) {
this.spatialReference = spatialReference;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -114,10 +106,8 @@ public class ResultDocumentDV extends DocumentDV implements Serializable {
builder.append(publicationInfoDV); builder.append(publicationInfoDV);
builder.append(", listRelationshipDV="); builder.append(", listRelationshipDV=");
builder.append(listRelationshipDV); builder.append(listRelationshipDV);
builder.append(", centroidLong="); builder.append(", spatialReference=");
builder.append(centroidLong); builder.append(spatialReference);
builder.append(", centroidLat=");
builder.append(centroidLat);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }