App 2.39.0, server 2.7.0: Grid with map

A new Overview style: the Grid over the roads round the car from
OpenStreetMap, drawn in the floor's perspective, heading up, the bigger
roads glowing brighter, the car as a chevron.

Server: POST /v1/map/roads {z:14,x,y} fetches a tile's drivable roads
from Overpass (OVERPASS_URL; one request at a time, at least a second
apart), simplifies them to tile-local points in four classes, caches
them for 30 days and never logs the tile.

App: MapRoads keeps the 3x3 tiles round the car from its own cache or
the server; GPS only while the style is shown; bearing from the GPS or
from successive positions. Without GPS, server or roads the plain floor
says why. OSM attribution on screen and in LICENSE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-26 23:34:21 +01:00
co-authored by Claude Opus 5.5
parent 776a11b182
commit 65dc1ba847
24 changed files with 1312 additions and 18 deletions
@@ -0,0 +1,65 @@
package com.evsuite.abrp;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/** The Grid map's tile arithmetic and the server's road tiles — pure JVM. */
public class MapGeometryTest {
@Test
public void tilesMatchTheServer() {
// Alexanderplatz, Berlin: the tile the server tests use too.
assertEquals(8802, MapGeometry.tileX(13.4125));
assertEquals(5373, MapGeometry.tileY(52.5219));
long key = MapGeometry.key(8802, 5373);
assertEquals(8802, MapGeometry.keyX(key));
assertEquals(5373, MapGeometry.keyY(key));
}
@Test
public void metresPerUnitShrinkTowardsThePoles() {
// A zoom-14 tile is about 2.4 km across at the equator, in 4096 units.
assertEquals(0.597, MapGeometry.metresPerUnit(0), 0.001);
assertEquals(0.363, MapGeometry.metresPerUnit(52.52), 0.001);
}
@Test
public void unusablePositions() {
assertFalse(MapGeometry.usable(Double.NaN, 13));
assertFalse(MapGeometry.usable(0, 0)); // a GPS that has nothing yet
assertFalse(MapGeometry.usable(89, 13));
assertTrue(MapGeometry.usable(52.52, 13.41));
}
@Test
public void roadTilesParse() {
RoadTile t = RoadTile.parse("{\"z\":14,\"x\":8802,\"y\":5373,\"extent\":4096,\"ways\":["
+ "{\"c\":1,\"p\":[-115,1236,82,1080,100,1000]},{\"c\":3,\"p\":[0,0,10,10]}]}", 8802, 5373);
assertNotNull(t);
assertEquals(2, t.classes.length);
assertEquals(1, t.classes[0]);
assertEquals(6, t.points[0].length);
assertEquals(-115, t.bounds[0][0]);
assertEquals(1000, t.bounds[0][1]);
assertEquals(100, t.bounds[0][2]);
assertEquals(1236, t.bounds[0][3]);
}
@Test
public void badRoadTilesAreNoTile() {
String head = "{\"z\":14,\"x\":1,\"y\":2,\"extent\":4096,\"ways\":";
assertNotNull(RoadTile.parse(head + "[]}", 1, 2));
assertNull("another tile", RoadTile.parse(head + "[]}", 1, 3));
assertNull("another zoom", RoadTile.parse("{\"z\":13,\"x\":1,\"y\":2,\"extent\":4096,\"ways\":[]}", 1, 2));
assertNull("unknown class", RoadTile.parse(head + "[{\"c\":7,\"p\":[0,0,1,1]}]}", 1, 2));
assertNull("one point", RoadTile.parse(head + "[{\"c\":1,\"p\":[0,0]}]}", 1, 2));
assertNull("odd count", RoadTile.parse(head + "[{\"c\":1,\"p\":[0,0,1]}]}", 1, 2));
assertNull("far outside", RoadTile.parse(head + "[{\"c\":1,\"p\":[0,0,99999,1]}]}", 1, 2));
assertNull("not JSON", RoadTile.parse("<html>", 1, 2));
}
}
@@ -63,5 +63,8 @@ public class OverviewStyleTest {
assertEquals(R.style.ThemeOverlay_EV_Style_Retro,
StylePalette.appOverlay(OverviewStyle.RETRO, true, AccentColor.HOLBORN_BLUE));
assertEquals("original_colours_RETRO", OverviewStyle.RETRO.originalKey());
// Grid with map shares the Grid's choice.
assertEquals(OverviewStyle.GRID.originalKey(), OverviewStyle.GRID_MAP.originalKey());
assertEquals(StylePalette.overlay(OverviewStyle.GRID), StylePalette.overlay(OverviewStyle.GRID_MAP));
}
}