Skip to content

Commit

Permalink
Space implementation from geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
fvilla committed Sep 16, 2024
1 parent cda6263 commit 8f246f2
Show file tree
Hide file tree
Showing 11 changed files with 617 additions and 429 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.integratedmodelling.klab.api.geometry.impl.GeometryImpl.DimensionImpl;
import org.integratedmodelling.klab.api.knowledge.observation.scale.time.Time;
import org.integratedmodelling.klab.api.knowledge.observation.scale.time.TimeInstant;
import org.integratedmodelling.klab.api.lang.Quantity;

/**
* Builder for geometries to ease defining time and space extents in forms that
Expand Down Expand Up @@ -155,23 +156,28 @@ public SpaceBuilder size(long n) {
* Bounding box as a double[]{minX, maxX, minY, maxY}; lat/lon use lon as x axis
*/
public SpaceBuilder boundingBox(double x1, double x2, double y1, double y2) {
space.getParameters().put(GeometryImpl.PARAMETER_SPACE_BOUNDINGBOX, new double[] { x1, x2, y1, y2 });
space.getParameters().put(GeometryImpl.PARAMETER_SPACE_BOUNDINGBOX, List.of(x1, x2, y1, y2));
return this;
}

public SpaceBuilder shape(String wktb) {

space.getParameters().put(GeometryImpl.PARAMETER_SPACE_SHAPE, GeometryImpl.encodeForSerialization(wktb));
space.getParameters().put(GeometryImpl.PARAMETER_SPACE_SHAPE, wktb);
return this;
}

public SpaceBuilder urn(String urn) {
space.getParameters().put(GeometryImpl.PARAMETER_SPACE_RESOURCE_URN,
GeometryImpl.encodeForSerialization(urn));
space.getParameters().put(GeometryImpl.PARAMETER_SPACE_RESOURCE_URN, urn);
return this;
}

public SpaceBuilder resolution(Quantity gridResolution) {
space.setRegular(true);
space.getParameters().put(GeometryImpl.PARAMETER_SPACE_GRIDRESOLUTION, gridResolution);
return this;
}

public SpaceBuilder resolution(String gridResolution) {
space.setRegular(true);
space.getParameters().put(GeometryImpl.PARAMETER_SPACE_GRIDRESOLUTION, gridResolution);
return this;
}
Expand All @@ -187,7 +193,6 @@ public GeometryBuilder build() {
* by the EPSG: projection). The resulting
*
* @param urn
* @param resolution a string in the format "1 km"
* @return
*/
public GeometryBuilder region(String urn) {
Expand All @@ -202,7 +207,6 @@ public GeometryBuilder region(String urn) {
* resolution. The box is "straight" with the X axis specifying
* <em>longitude</em>.
*
* @param resolution a string in the format "1 km"
* @return
*/
public GeometryBuilder grid(double x1, double x2, double y1, double y2) {
Expand Down
Loading

0 comments on commit 8f246f2

Please sign in to comment.