improved toSpatialReference method

This commit is contained in:
Francesco Mangiacrapa 2023-05-04 16:10:24 +02:00
parent 39f084b5c5
commit 6b63090ec4
2 changed files with 23 additions and 13 deletions

View File

@ -23,6 +23,7 @@ import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo; import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
import org.gcube.application.geoportal.common.model.document.accounting.PublicationInfo; import org.gcube.application.geoportal.common.model.document.accounting.PublicationInfo;
import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference; import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference;
import org.gcube.application.geoportal.common.model.document.identification.SpatialReference;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
import org.gcube.application.geoportal.common.model.document.relationships.Relationship; import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration; import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
@ -527,8 +528,8 @@ public class ConvertToDataValueObjectModel {
project.getProfileVersion() != null ? project.getProfileVersion().getValue() : ""); project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
theProject.setVersion(project.getVersion() != null ? project.getVersion().getValue() : ""); theProject.setVersion(project.getVersion() != null ? project.getVersion().getValue() : "");
theProject.setTheDocument(toGenericDocumentDV(project.getId(), project.getTheDocument(), DocumentDV.class,
theProject.setTheDocument(toGenericDocumentDV(project.getId(), project.getTheDocument(), DocumentDV.class, projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap())); projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
List<Relationship> relations = project.getRelationships(); List<Relationship> relations = project.getRelationships();
@ -608,18 +609,22 @@ public class ConvertToDataValueObjectModel {
return null; return null;
GeoJSON geoJson = null; GeoJSON geoJson = null;
try { try {
geoJson = new GeoJSON(); geoJson = new GeoJSON();
JSONObject jsonObject = new JSONObject(geoJSONObject).getJSONObject("geoJSON"); JSONObject jsonObject = new JSONObject(geoJSONObject).getJSONObject(SpatialReference.GEO_JSON);
geoJson.setType(jsonObject.getString("type")); geoJson.setType(jsonObject.getString(GeoJSON.TYPE));
geoJson.setBbox(GisUtil.fromJSONArray(jsonObject.getJSONArray("bbox"))); geoJson.setBbox(GisUtil.fromJSONArray(jsonObject.getJSONArray(GeoJSON.BBOX)));
Crs crs = org.gcube.application.geoportal.client.utils.Serialization Crs crs = org.gcube.application.geoportal.client.utils.Serialization
.read(jsonObject.getJSONObject("crs").toString(), Crs.class); .read(jsonObject.getJSONObject(GeoJSON.CRS).toString(), Crs.class);
geoJson.setCrs(crs); geoJson.setCrs(crs);
geoJson.setGeoJSON(jsonObject.toString()); geoJson.setGeoJSON(jsonObject.toString());
LOG.debug("toSpatialReference returning " + geoJson); 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
+ ". Is it empty?");
LOG.debug("toSpatialReference error: ", e);
} }
return geoJson; return geoJson;
@ -1004,8 +1009,9 @@ public class ConvertToDataValueObjectModel {
} }
} }
//Casting to String, in order to avoid GWT serialization issue, see #24537#note-9 and #24432 // Casting to String, in order to avoid GWT serialization issue, see
String valueString = value!=null?value+"":null; // #24537#note-9 and #24432
String valueString = value != null ? value + "" : null;
documentAsMap.put(key, valueString); documentAsMap.put(key, valueString);
return documentAsMap; return documentAsMap;

View File

@ -6,6 +6,10 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.in
public class GeoJSON implements Serializable { public class GeoJSON implements Serializable {
public static final String TYPE = "type";
public static final String BBOX = "bbox";
public static final String CRS = "crs";
public static final String COORDINATES = "coordinates";
/** /**
* *
*/ */