updated constructor

This commit is contained in:
Francesco Mangiacrapa 2022-11-11 15:55:01 +01:00
parent 1098365d62
commit 8f911c2ab2
1 changed files with 45 additions and 13 deletions

View File

@ -3,6 +3,9 @@ package org.gcube.application.geoportalcommon.shared.geoportal.materialization.i
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BBOXDV implements Serializable { public class BBOXDV implements Serializable {
/** /**
@ -23,10 +26,52 @@ public class BBOXDV implements Serializable {
private HashMap<String, Double> bbox = new HashMap<String, Double>(); private HashMap<String, Double> bbox = new HashMap<String, Double>();
private static final Logger LOG = LoggerFactory.getLogger(BBOXDV.class);
public BBOXDV() { public BBOXDV() {
} }
public BBOXDV(Double maxX, Double minX, Double maxY, Double minY) {
setMaxX(maxX);
setMinX(minX);
setMaxY(maxY);
setMinY(minY);
}
public BBOXDV(Double maxX, Double minX, Double maxY, Double minY, Double maxZ, Double minZ) {
this(maxX, minX, maxY, minY);
setMaxZ(maxZ);
setMinZ(minZ);
}
public BBOXDV(HashMap<String, Object> hash) {
setMaxX(toDouble(hash.get(MAX_X)));
setMaxY(toDouble(hash.get(MAX_Y)));
setMinX(toDouble(hash.get(MIN_X)));
setMinY(toDouble(hash.get(MIN_Y)));
setMinZ(toDouble(hash.get(MIN_Z)));
setMaxZ(toDouble(hash.get(MAX_Z)));
}
private Double toDouble(Object toDouble) {
try {
if (toDouble != null) {
return new Double((double) toDouble);
}
} catch (Exception e) {
LOG.warn(toDouble + " is not castable to " + Double.class.getSimpleName());
}
return null;
}
public static final BBOXDV fromGeoJSON(double[] coords) { public static final BBOXDV fromGeoJSON(double[] coords) {
BBOXDV toReturn = new BBOXDV(); BBOXDV toReturn = new BBOXDV();
toReturn.setMaxX(coords[0]); toReturn.setMaxX(coords[0]);
@ -45,19 +90,6 @@ public class BBOXDV implements Serializable {
return toReturn; return toReturn;
} }
public BBOXDV(Double maxX, Double minX, Double maxY, Double minY, Double maxZ, Double minZ) {
this(maxX, minX, maxY, minY);
setMaxZ(maxZ);
setMinZ(minZ);
}
public BBOXDV(Double maxX, Double minX, Double maxY, Double minY) {
setMaxX(maxX);
setMinX(minX);
setMaxY(maxY);
setMinY(minY);
}
public BBOXDV setMaxX(Double d) { public BBOXDV setMaxX(Double d) {
this.bbox.put(MAX_X, d); this.bbox.put(MAX_X, d);
return this; return this;