Skip to content

Commit

Permalink
Fix minor formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis committed Jun 12, 2024
1 parent ef76b7d commit 7e927a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@
* from height data.
* <p>
*
* @see <a href="https://github.com/mapbox/martini">Martini GitHub
* @see <a href="https://github.com/mapbox/martini">Martini GitHub</a>
*/
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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 7e927a4

Please sign in to comment.