Skip to content

Commit

Permalink
Removed all references to unlicensed file
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis committed Nov 25, 2024
1 parent 4cef4e4 commit 67439f0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ public class ContourRenderer {

public static void main(String[] args) throws IOException {
// Load the image
var path = Path.of("")
.toAbsolutePath()
.resolveSibling("baremaps/baremaps-dem/src/test/resources/fuji.png")
.toAbsolutePath().toFile();
var image = ImageIO.read(path);

var file = Path.of("dem.png").toFile();
var image = ImageIO.read(file);

// Convert the image to a grid
double[] grid = ElevationUtils.imageToGrid(image, ElevationUtils::terrariumToElevation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import javax.imageio.ImageIO;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -48,24 +46,16 @@ void testGrid1() {
}

@Test
@DisplayName("Test Mount Fuji")
@Disabled("This test requires an internet connection")
@DisplayName("Test with file")
@Disabled("This test must be reworked as it relied on an unlicensed file")
void testMountFuji() throws IOException {

// Download the image to a temporary file
URI uri = URI.create(
"https://raw.githubusercontent.com/mapbox/martini/refs/heads/main/test/fixtures/fuji.png");
File file = File.createTempFile("fuji", ".png", Path.of("").toAbsolutePath().toFile());
file.deleteOnExit();
ImageIO.write(ImageIO.read(uri.toURL()), "png", file);

var fujiImage = ImageIO.read(file);
var fujiGrid = ElevationUtils.imageToGrid(fujiImage, ElevationUtils::rgbToElevation);
var fujiContours =
new ContourTracer(fujiGrid, fujiImage.getWidth(), fujiImage.getHeight(), false, true)
var file = new File("dem.png");
var image = ImageIO.read(file);
var grid = ElevationUtils.imageToGrid(image, ElevationUtils::rgbToElevation);
var contours =
new ContourTracer(grid, image.getWidth(), image.getHeight(), false, true)
.traceContours(500);

assertFalse(fujiContours.isEmpty());
assertFalse(contours.isEmpty());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ public HillShadeRenderer() throws IOException {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Load the image
originalImage = ImageIO.read(
Path.of("")
.toAbsolutePath()
.resolveSibling("baremaps/baremaps-dem/src/test/resources/fuji.png")
.toAbsolutePath().toFile());
originalImage = ImageIO.read(Path.of("dem.png").toFile());
grid = ElevationUtils.imageToGrid(originalImage, ElevationUtils::rgbToElevation);

// Create UI components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import javax.imageio.ImageIO;
import org.junit.jupiter.api.Disabled;
Expand All @@ -30,16 +28,9 @@
class MartiniTest {

@Test
@Disabled("This test requires an internet connection")
@Disabled("This test must be reworked as it relied on an unlicensed file")
void generateAMesh() throws IOException {
// Download the image to a temporary file
URI uri = URI.create(
"https://raw.githubusercontent.com/mapbox/martini/refs/heads/main/test/fixtures/fuji.png");
File file = File.createTempFile("fuji", ".png", Path.of("").toAbsolutePath().toFile());
file.deleteOnExit();
ImageIO.write(ImageIO.read(uri.toURL()), "png", file);

// The image is available in the mapbox/martini repository and can be downloaded manually.
var file = Path.of("dem.png").toFile();
var png = ImageIO.read(file);
var terrainGrid = Martini.createGrid(png);
var martini = new Martini(png.getWidth() + 1);
Expand Down

0 comments on commit 67439f0

Please sign in to comment.