Skip to content

Commit 25cc892

Browse files
committed
Do some cleaning
1 parent 80a92db commit 25cc892

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

baremaps-raster/src/main/java/org/apache/baremaps/raster/elevation/ChaikinSmoother.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ protected CoordinateSequence transformCoordinates(
3939
return smooth(coordinateSequence, iterations, factor);
4040
}
4141

42-
public static LinearRing smooth(LinearRing linearRing, int iterations, double factor) {
43-
CoordinateSequence coordinateSequence =
44-
smooth(linearRing.getCoordinateSequence(), iterations, factor);
45-
return linearRing.getFactory().createLinearRing(coordinateSequence);
46-
}
47-
48-
public static LineString smooth(LineString lineString, int iterations, double factor) {
49-
CoordinateSequence coordinateSequence =
50-
smooth(lineString.getCoordinateSequence(), iterations, factor);
51-
return lineString.getFactory().createLineString(coordinateSequence);
52-
}
53-
54-
public static Coordinate[] smooth(Coordinate[] coordinates, int iterations, double factor) {
55-
return smooth(new CoordinateArraySequence(coordinates), iterations, factor).toCoordinateArray();
56-
}
57-
5842
public static CoordinateSequence smooth(CoordinateSequence coordinateSequence, int iterations,
5943
double factor) {
6044
if (CoordinateSequences.isRing(coordinateSequence)) {

baremaps-raster/src/test/java/org/apache/baremaps/raster/elevation/ContourRenderer.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
import java.util.stream.Stream;
2525
import javax.imageio.ImageIO;
2626
import javax.swing.*;
27-
import org.locationtech.jts.geom.Coordinate;
2827
import org.locationtech.jts.geom.Geometry;
29-
import org.locationtech.jts.geom.GeometryFactory;
28+
import org.locationtech.jts.geom.util.AffineTransformation;
3029

3130
public class ContourRenderer {
3231

@@ -45,28 +44,22 @@ public static void main(String[] args) throws IOException {
4544
double[] grid = ElevationUtils.imageToGrid(image, ElevationUtils::pixelToElevationStandard);
4645

4746
List<Geometry> contour =
48-
new ContourTracer(grid, image.getWidth(), image.getHeight(), true, true)
47+
new ContourTracer(grid, image.getWidth(), image.getHeight(), true, false)
4948
.traceContours(0, 9000, 100);
5049

5150
// Scale the image back to its original size
5251
image = RasterUtils.resizeImage(image, image.getWidth() * 16, image.getHeight() * 16);
5352

5453
// Scale the contour back to its original size
54+
AffineTransformation transformation = AffineTransformation.scaleInstance(16, 16);
5555
contour = contour.stream()
56-
.map(polygon -> {
57-
var coordinates = Stream.of(polygon.getCoordinates())
58-
.map(c -> new Coordinate(c.getX() * 16, c.getY() * 16))
59-
.toArray(Coordinate[]::new);
60-
return (Geometry) new GeometryFactory().createPolygon(coordinates);
61-
})
56+
.map(transformation::transform)
6257
.toList();
6358

6459
// Smooth the contour with the Chaikin algorithm
60+
ChaikinSmoother smoother = new ChaikinSmoother(1, 0.25);
6561
contour = contour.stream()
66-
.map(polygon -> {
67-
var coordinates = ChaikinSmoother.smooth(polygon.getCoordinates(), 2, 0.25);
68-
return (Geometry) new GeometryFactory().createPolygon(coordinates);
69-
})
62+
.map(smoother::transform)
7063
.toList();
7164

7265
// Create a frame to display the contours

baremaps-server/src/main/resources/raster/hillshade.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
maxZoom: 18,
7575
maxPitch: 85
7676
}));
77-
77+
7878
map.addControl(
7979
new maplibregl.NavigationControl({
8080
visualizePitch: false,

0 commit comments

Comments
 (0)