Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into IM-457-Merge-devel…
Browse files Browse the repository at this point in the history
…op-in-IM-384
  • Loading branch information
kristinaBc3 committed Dec 16, 2024
2 parents 765c9d8 + c501eac commit c361dc3
Show file tree
Hide file tree
Showing 24 changed files with 805 additions and 171 deletions.
28 changes: 28 additions & 0 deletions klab.engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,19 @@
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
<exclusion>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>${jts.version}</version>
</dependency>

<!-- all of a sudden, WCS parsing stops working unless this is added. -->
<dependency>
<groupId>xml-apis</groupId>
Expand Down Expand Up @@ -656,6 +666,12 @@
<groupId>org.orbisgis</groupId>
<artifactId>h2gis</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- https://mvnrepository.com/artifact/args4j/args4j startup options parser -->
Expand Down Expand Up @@ -732,11 +748,23 @@
<groupId>org.geotools</groupId>
<artifactId>gt-process</artifactId>
<version>${geotools.version}</version>
<exclusions>
<exclusion>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-process-raster</artifactId>
<version>${geotools.version}</version>
<exclusions>
<exclusion>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.locationtech.jts.geom.MultiPolygon;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.triangulate.polygon.PolygonTriangulator;

/**
* Simple, flexible rasterizer using an AWT image as a backend and closures to determine (a) the
Expand Down Expand Up @@ -131,9 +132,8 @@ public Collection<Coordinate> getCoordinates(IShape shape) {

Geometry geometry = ((Shape) shape).getJTSGeometry();
Color valueColor = new Color(255, 255, 255);
Color holeColor = new Color(0, 0, 0);

draw(geometry, valueColor, holeColor);
draw(geometry, valueColor);

int[] xy = new int[2];
for (int x = 0; x < this.raster.getWidth(); x++) {
Expand Down Expand Up @@ -165,36 +165,33 @@ public void add(IShape shape, Function<IShape, T> encoder) {
Geometry geometry = ((Shape) shape).getJTSGeometry();

int rgbVal = floatBitsToInt(encodeToFloat(value));
int holeVal = floatBitsToInt(Float.NaN);
Color valueColor = new Color(rgbVal, true);
Color holeColor = new Color(holeVal, true);

draw(geometry, valueColor, holeColor);
draw(geometry, valueColor);
}

private void draw(Geometry geometry, Color valueColor, Color holeColor) {
private void draw(Geometry geometry, Color valueColor) {

Geometries geomType = Geometries.get(geometry);
if (geomType == Geometries.MULTIPOLYGON || geomType == Geometries.MULTILINESTRING
|| geomType == Geometries.MULTIPOINT || geomType == Geometries.GEOMETRYCOLLECTION) {
final int numGeom = geometry.getNumGeometries();
for (int i = 0; i < numGeom; i++) {
Geometry geomN = geometry.getGeometryN(i);
draw(geomN, valueColor, holeColor);
draw(geomN, valueColor);
}
} else /* if (geometry.intersects(((Grid) extent).getShape().getJTSGeometry())) */ {

if (geometry.getClass().equals(Polygon.class)) {

for (int i = 0; i < geometry.getNumGeometries(); i++) {
Polygon poly = (Polygon) geometry.getGeometryN(i);
LinearRing lr = geoFactory.createLinearRing(poly.getExteriorRing().getCoordinates());
Polygon part = geoFactory.createPolygon(lr, null);
drawGeometry(part, valueColor);
for (int j = 0; j < poly.getNumInteriorRing(); j++) {
lr = geoFactory.createLinearRing(poly.getInteriorRingN(j).getCoordinates());
part = geoFactory.createPolygon(lr, null);
drawGeometry(part, holeColor);
boolean hasHoles = poly.getNumInteriorRing() > 0;
if (hasHoles) {
Geometry triangles = PolygonTriangulator.triangulate(poly);
draw(triangles, valueColor);
} else {
drawGeometry(poly, valueColor);
}
}
} else {
Expand Down
Loading

0 comments on commit c361dc3

Please sign in to comment.