From 4d2c4078ff053070fe27fb360855166d928496c3 Mon Sep 17 00:00:00 2001 From: Mike Barry Date: Sun, 16 May 2021 06:53:37 -0400 Subject: [PATCH] multipoint test --- .../com/onthegomap/flatmap/FlatMapTest.java | 52 +++++++++++++++++++ .../com/onthegomap/flatmap/TestUtils.java | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/onthegomap/flatmap/FlatMapTest.java b/src/test/java/com/onthegomap/flatmap/FlatMapTest.java index 1edc70c4..093d1732 100644 --- a/src/test/java/com/onthegomap/flatmap/FlatMapTest.java +++ b/src/test/java/com/onthegomap/flatmap/FlatMapTest.java @@ -3,6 +3,7 @@ package com.onthegomap.flatmap; import static com.onthegomap.flatmap.TestUtils.assertSameJson; import static com.onthegomap.flatmap.TestUtils.assertSubmap; import static com.onthegomap.flatmap.TestUtils.feature; +import static com.onthegomap.flatmap.TestUtils.newMultiPoint; import static com.onthegomap.flatmap.TestUtils.newPoint; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -165,6 +166,57 @@ public class FlatMapTest { ); } + @Test + public void testMultiPoint() throws IOException, SQLException { + double x1 = 0.5 + Z14_WIDTH / 2; + double y1 = 0.5 + Z14_WIDTH / 2; + double x2 = x1 + Z13_WIDTH / 256d; + double y2 = y1 + Z13_WIDTH / 256d; + double lat1 = GeoUtils.getWorldLat(y1); + double lng1 = GeoUtils.getWorldLon(x1); + double lat2 = GeoUtils.getWorldLat(y2); + double lng2 = GeoUtils.getWorldLon(x2); + + var results = runWithReaderFeatures( + Map.of("threads", "1"), + List.of( + new ReaderFeature(newMultiPoint( + newPoint(lng1, lat1), + newPoint(lng2, lat2) + ), Map.of( + "attr", "value" + )) + ), + (in, features) -> { + features.point("layer") + .setZoomRange(13, 14) + .setAttr("name", "name value") + .inheritFromSource("attr"); + } + ); + + assertSubmap(Map.of( + TileCoord.ofXYZ(Z14_TILES / 2, Z14_TILES / 2, 14), List.of( + feature(newMultiPoint( + newPoint(128, 128), + newPoint(130, 130) + ), Map.of( + "attr", "value", + "name", "name value" + )) + ), + TileCoord.ofXYZ(Z13_TILES / 2, Z13_TILES / 2, 13), List.of( + feature(newMultiPoint( + newPoint(64, 64), + newPoint(65, 65) + ), Map.of( + "attr", "value", + "name", "name value" + )) + ) + ), results.tiles); + } + @Test public void testLabelGridLimit() throws IOException, SQLException { double y = 0.5 + Z14_WIDTH / 2; diff --git a/src/test/java/com/onthegomap/flatmap/TestUtils.java b/src/test/java/com/onthegomap/flatmap/TestUtils.java index 361b5177..c053dd6e 100644 --- a/src/test/java/com/onthegomap/flatmap/TestUtils.java +++ b/src/test/java/com/onthegomap/flatmap/TestUtils.java @@ -223,7 +223,7 @@ public class TestUtils { } public static ComparableFeature feature(Geometry geom, Map attrs) { - return new ComparableFeature(new TopoGeometry(geom), attrs); + return new ComparableFeature(new NormGeometry(geom), attrs); } public static Map toMap(FeatureCollector.Feature feature, int zoom) {