Skip to content

Commit

Permalink
change srs to String
Browse files Browse the repository at this point in the history
  • Loading branch information
clausmichele committed Nov 19, 2024
1 parent ebd3a84 commit a5fcf00
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static Collection parseCollection(String coverageID, InputStream stream,
dim.setType(TypeEnum.SPATIAL); // FIXME this should be implicit

// int gridDim = Integer.parseInt(gridDims[index]) + 1;
int epsgCode = axisLabel2EpsgCode.get(label);
String epsgCode = axisLabel2EpsgCode.get(label).toString();
dim.setReferenceSystem(epsgCode);

// axis type: easting/northing/z ?
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/openeo/spring/model/BandSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class BandSummary {

@JsonProperty(value="center_wavelength", required=false)
private Double centerwavelength;


@JsonProperty(value="full_width_half_max", required=false)
private Double full_width_half_max;

@JsonProperty(value="gsd", required=false)
private Double gsd;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/openeo/spring/model/DimensionSpatial.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static AxisEnum fromValue(String value) {
private String unit = null;

@JsonProperty("reference_system")
private Integer referenceSystem = null;
private String referenceSystem = null;

public DimensionSpatial axis(AxisEnum axis) {
this.axis = axis;
Expand Down Expand Up @@ -195,7 +195,7 @@ public void setUnit(String unit) {
this.unit = unit;
}

public DimensionSpatial referenceSystem(Integer referenceSystem) {
public DimensionSpatial referenceSystem(String referenceSystem) {
this.referenceSystem = referenceSystem;
return this;
}
Expand All @@ -208,11 +208,11 @@ public DimensionSpatial referenceSystem(Integer referenceSystem) {

@Valid

public Integer getReferenceSystem() {
public String getReferenceSystem() {
return referenceSystem;
}

public void setReferenceSystem(Integer referenceSystem) {
public void setReferenceSystem(String referenceSystem) {
this.referenceSystem = referenceSystem;
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/openeo/spring/model/Link.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class Link {

@JsonProperty("title")
private String title;

@JsonProperty("method")
private String method;


public long getId() {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/openeo/wcps/WCPSQueryFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2839,7 +2839,7 @@ private void executeProcesses(String processID, String processNodeKey) {
collectionIDs.add(col);
Collection collection = collectionMap.get(collectionID);

int srs = getSRSFromCollection(collection);
String srs = getSRSFromCollection(collection);

JSONArray processDataCubeTempExt = new JSONArray();
JSONObject spatialExtentNode = new JSONObject();
Expand Down Expand Up @@ -2926,8 +2926,8 @@ else if (processID.equals("filter_bbox")) {
JSONObject processFilterArguments = processFilter.getJSONObject("arguments");
Collection collection = collectionMap.get(collectionID);

int srs = getSRSFromCollection(collection);
if (srs > 0) {
String srs = getSRSFromCollection(collection);
if (!srs.equals("")) {
createBoundingBoxFilterFromArgs(processFilterArguments, srs, collectionID, false);
}
}
Expand Down Expand Up @@ -3168,7 +3168,7 @@ private String readAll(Reader rd) throws IOException {
// }
// }

private void createBoundingBoxFilterFromArgs(JSONObject argsObject, int srs, String collectionID, Boolean spatNull) {
private void createBoundingBoxFilterFromArgs(JSONObject argsObject, String srs, String collectionID, Boolean spatNull) {
String left = null;
String right = null;
String top = null;
Expand Down Expand Up @@ -3244,14 +3244,14 @@ private void createBoundingBoxFilterFromArgs(JSONObject argsObject, int srs, Str
SpatialReference src = new SpatialReference();
src.ImportFromEPSG(4326);
SpatialReference dst = new SpatialReference();
dst.ImportFromEPSG(srs);
dst.ImportFromEPSG(new Integer(srs));
log.debug("SRS is :" + srs);
CoordinateTransformation tx = new CoordinateTransformation(src, dst);
double[] c1 = null;
double[] c2 = null;
c1 = tx.TransformPoint(Double.parseDouble(bottom), Double.parseDouble(left));
c2 = tx.TransformPoint(Double.parseDouble(top), Double.parseDouble(right));
if (srs==3035 || srs==4326) {
if (srs.equals("3035") || srs.equals("4326")) {
left = Double.toString(c1[1]);
bottom = Double.toString(c1[0]);
right = Double.toString(c2[1]);
Expand Down Expand Up @@ -3412,15 +3412,15 @@ else if (spatAxisUpperCase.contentEquals("N") || spatAxisUpperCase.contentEquals
SpatialReference src = new SpatialReference();
src.ImportFromEPSG(4326);
SpatialReference dst = new SpatialReference();
dst.ImportFromEPSG(srs);
dst.ImportFromEPSG(new Integer(srs));
log.debug("SRS is : " + srs);
CoordinateTransformation tx = new CoordinateTransformation(src, dst);
double[] c1 = null;
double[] c2 = null;
c1 = tx.TransformPoint(Double.parseDouble(bottom), Double.parseDouble(left));
c2 = tx.TransformPoint(Double.parseDouble(top), Double.parseDouble(right));
//TODO include other CRS exceptions of different axis order
if (srs==3035 || srs==4326) {
if (srs.equals("3035") || srs.equals("4326")) {
left = Double.toString(c1[1]);
bottom = Double.toString(c1[0]);
right = Double.toString(c2[1]);
Expand Down Expand Up @@ -3654,8 +3654,8 @@ else if (bandCommonName.equals("nir")) {
}
}

private int getSRSFromCollection(Collection collection) {
int srs = 0;
private String getSRSFromCollection(Collection collection) {
String srs = "";
for(Dimension dimension: collection.getCubeColonDimensions().values()) {
if(dimension.getType() == Dimension.TypeEnum.SPATIAL) {
srs = ((DimensionSpatial) dimension).getReferenceSystem();
Expand Down

0 comments on commit a5fcf00

Please sign in to comment.