Skip to content

Commit

Permalink
minor update for printing map
Browse files Browse the repository at this point in the history
  • Loading branch information
beauof committed Feb 28, 2020
1 parent 97337a4 commit 6c81ecb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions src/main/java/de/rondiplomatico/nds/NDSEnvelope.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,40 @@ public NDSCoordinate getNorthWest() {
}

public int[] getMasterTileInfo(int maxLevels) {
NDSCoordinate point0 = getSouthWest();
NDSCoordinate point1 = getSouthEast();
NDSCoordinate point2 = getNorthEast();
NDSCoordinate point3 = getNorthWest();
NDSCoordinate point0 = getSouthWest();
NDSCoordinate point1 = getSouthEast();
NDSCoordinate point2 = getNorthEast();
NDSCoordinate point3 = getNorthWest();
return getMasterTileInfo(point0, point1, point2, point3, maxLevels);
}

public int[] getMasterTileInfo(NDSCoordinate point0, NDSCoordinate point1, NDSCoordinate point2, NDSCoordinate point3, int maxLevels) {
int masterTileLevel = -1;
int masterTileID = -1;
int masterTileID = -1;
for (int li = 0; li < maxLevels; li++) {
NDSTile currTile0 = new NDSTile(li, point0);
NDSTile currTile1 = new NDSTile(li, point1);
NDSTile currTile2 = new NDSTile(li, point2);
NDSTile currTile3 = new NDSTile(li, point3);
NDSTile currTile0 = new NDSTile(li, point0);
NDSTile currTile1 = new NDSTile(li, point1);
NDSTile currTile2 = new NDSTile(li, point2);
NDSTile currTile3 = new NDSTile(li, point3);
int currTileID0 = currTile0.getTileNumber();
int currTileID1 = currTile1.getTileNumber();
int currTileID2 = currTile2.getTileNumber();
int currTileID3 = currTile3.getTileNumber();
boolean singleTileID = (currTileID0 == currTileID1) && (currTileID0 == currTileID2) && (currTileID0 == currTileID3);
boolean singleTileID = (currTileID0 == currTileID1) && (currTileID0 == currTileID2) && (currTileID0 == currTileID3);
// if at least one tile ID is different, we discard the tile IDs and keep our previously detected tile ID (i.e. on the previous level)
if(!singleTileID) {
break;
}
// store tile info
masterTileLevel = li;
masterTileID = currTileID0;
masterTileID = currTileID0;
}
// check if valid result
if (masterTileID == -1) {
System.out.println(">>>ERROR: Invalid master tile ID.");
System.exit(1);
}
int[] masterTileInfo = {masterTileLevel, masterTileID};
int[] masterTileInfo = {masterTileLevel, masterTileID};
return masterTileInfo;
}
}
8 changes: 4 additions & 4 deletions src/main/java/de/rondiplomatico/nds/polygon.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,18 @@ public static double[][] refinePolygon(int level, double[][] polygonCoordinates,

public static int[] getTileNumbersOnLevel(int level, double[][] polygonCoordinates){
int numCoord = polygonCoordinates.length;
int[] tileNumbers = new int[numCoord];
int[] tileNumbers = new int[numCoord];
// loop over all coordinates to get map tile IDs
for (int idx = 0; idx < numCoord; idx++) {
NDSCoordinate currCoord = new NDSCoordinate(polygonCoordinates[idx][1], polygonCoordinates[idx][0]);
NDSCoordinate currCoord = new NDSCoordinate(polygonCoordinates[idx][0], polygonCoordinates[idx][1]);
NDSTile currTile = new NDSTile(level, currCoord);
tileNumbers[idx] = currTile.getTileNumber();
tileNumbers[idx] = currTile.getTileNumber();
}
return tileNumbers;
}

public static int[] getUniqueTileNumbersOnLevel(int level, double[][] polygonCoordinates){
int[] tileNumbers = getTileNumbersOnLevel(level, polygonCoordinates);
int[] tileNumbers = getTileNumbersOnLevel(level, polygonCoordinates);
return IntStream.of(tileNumbers).distinct().toArray();
}
}

0 comments on commit 6c81ecb

Please sign in to comment.