From 7e927a48d9b05637ef1168add50dcca8e0c17576 Mon Sep 17 00:00:00 2001 From: Bertil Chapuis Date: Wed, 12 Jun 2024 14:13:11 +0200 Subject: [PATCH] Fix minor formatting issues --- .../org/apache/baremaps/martini/Martini.java | 28 +++++++++++++++++-- .../apache/baremaps/martini/MartiniTest.java | 7 ++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/baremaps-martini/src/main/java/org/apache/baremaps/martini/Martini.java b/baremaps-martini/src/main/java/org/apache/baremaps/martini/Martini.java index 5152e83cc..3be8074fc 100644 --- a/baremaps-martini/src/main/java/org/apache/baremaps/martini/Martini.java +++ b/baremaps-martini/src/main/java/org/apache/baremaps/martini/Martini.java @@ -22,16 +22,20 @@ * from height data. *

* - * @see Martini GitHub + * @see Martini GitHub */ public class Martini { private final int gridSize; private final int numTriangles; private final int numParentTriangles; - private final int[] baseCoords; + /** + * Constructs a new {@code Martini} instance with the specified grid size. + * + * @param gridSize the grid size + */ public Martini(int gridSize) { this.gridSize = gridSize; @@ -78,10 +82,19 @@ public Martini(int gridSize) { } } + /** + * Creates a new {@code Tile} instance with the specified terrain data. + * + * @param terrain the terrain data + * @return the tile + */ public Tile createTile(float[] terrain) { return new Tile(terrain, gridSize, numTriangles, numParentTriangles, baseCoords); } + /** + * The {@code Tile} class represents a tile of terrain data. + */ public static class Tile { private final int gridSize; @@ -133,6 +146,12 @@ private Tile(float[] terrain, int gridSize, int numTriangles, int numParentTrian } } + /** + * Returns the mesh of the tile with the specified maximum error. + * + * @param maxError the maximum error + * @return the mesh + */ public Mesh getMesh(float maxError) { int max = gridSize - 1; @@ -194,12 +213,15 @@ private void processTriangle(int ax, int ay, int bx, int by, int cx, int cy, flo } } + /** + * The {@code Mesh} class represents a mesh of vertices and triangles. + */ public static class Mesh { private final int[] vertices; private final int[] triangles; - public Mesh(int[] vertices, int[] triangles) { + private Mesh(int[] vertices, int[] triangles) { this.vertices = vertices; this.triangles = triangles; } diff --git a/baremaps-martini/src/test/java/org/apache/baremaps/martini/MartiniTest.java b/baremaps-martini/src/test/java/org/apache/baremaps/martini/MartiniTest.java index 9177bd4a1..f2819a7b5 100644 --- a/baremaps-martini/src/test/java/org/apache/baremaps/martini/MartiniTest.java +++ b/baremaps-martini/src/test/java/org/apache/baremaps/martini/MartiniTest.java @@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import java.awt.image.BufferedImage; import java.io.IOException; import java.nio.file.Path; import javax.imageio.ImageIO; @@ -29,12 +28,12 @@ public class MartiniTest { @Test public void generateAMesh() throws IOException { - BufferedImage png = ImageIO.read( + var png = ImageIO.read( Path.of("") .toAbsolutePath() - .resolveSibling("baremaps-geotiff/src/test/resources/fuji.png") + .resolveSibling("baremaps-martini/src/test/resources/fuji.png") .toAbsolutePath().toFile()); - float[] terrainGrid = MartiniUtils.mapboxTerrainToGrid(png); + var terrainGrid = MartiniUtils.mapboxTerrainToGrid(png); var martini = new Martini(png.getWidth() + 1); var tile = martini.createTile(terrainGrid); var mesh = tile.getMesh(500);