@Test public void testEncoderClipping() throws Exception { MapBoxTileBuilderFactory builderFact = new MapBoxTileBuilderFactory(); Rectangle screenSize = new Rectangle(256, 256); ReferencedEnvelope mapArea = new ReferencedEnvelope(); MapBoxTileBuilder tileBuilder = builderFact.newBuilder(screenSize, mapArea); Geometry line = geom("LINESTRING(-100 -100,300 300)"); //box is 0 to 256, so this is outside the box Map<String, Object> lineProps = ImmutableMap.<String, Object> of("name", "line1"); tileBuilder.addFeature("Lines", "unused", "unused", line, lineProps); WMSMapContent mapContent = mock(WMSMapContent.class); RawMap map = tileBuilder.build(mapContent); ListMultimap<String, Feature> features = decode(map); assertEquals(1, features.size()); assertEquals(ImmutableSet.of( "Lines"), features.keySet()); Feature lineFeature = features.get("Lines").get(0); assertTrue(lineFeature.getGeometry() instanceof LineString); assertEquals(line, lineFeature.getGeometry()); // line should not be clipped }
assertTrue(lineFeature.getGeometry() instanceof LineString); assertEquals(line, lineFeature.getGeometry()); // line should not be clipped
@Test public void testMapBoxTileBuilder() throws Exception { MapBoxTileBuilderFactory builderFact = new MapBoxTileBuilderFactory(); Rectangle screenSize = new Rectangle(256, 256); ReferencedEnvelope mapArea = new ReferencedEnvelope(); MapBoxTileBuilder tileBuilder = builderFact.newBuilder(screenSize, mapArea); Geometry point = geom("POINT(1 10)"); Map<String, Object> pointProps = ImmutableMap.<String, Object>of("name", "point1"); Geometry line = geom("LINESTRING(0 0, 1 1, 2 2)"); Map<String, Object> lineProps = ImmutableMap.<String, Object>of("name", "line1"); tileBuilder.addFeature("Points", "unused", "unused", point, pointProps); tileBuilder.addFeature("Lines", "unused", "unused", line, lineProps); WMSMapContent mapContent = mock(WMSMapContent.class); RawMap map = tileBuilder.build(mapContent); ListMultimap<String, Feature> features = decode(map); assertEquals(2, features.size()); assertEquals(ImmutableSet.of("Points", "Lines"), features.keySet()); Feature pointFeature = features.get("Points").get(0); Feature lineFeature = features.get("Lines").get(0); assertTrue(pointFeature.getGeometry() instanceof Point); assertEquals(point, pointFeature.getGeometry()); assertEquals(pointProps, pointFeature.getAttributes()); assertTrue(lineFeature.getGeometry() instanceof LineString); assertEquals(line, lineFeature.getGeometry()); assertEquals(lineProps, lineFeature.getAttributes()); }
@Test public void testMapBoxTileBuilder() throws Exception { MapBoxTileBuilderFactory builderFact = new MapBoxTileBuilderFactory(); Rectangle screenSize = new Rectangle(256, 256); ReferencedEnvelope mapArea = new ReferencedEnvelope(); MapBoxTileBuilder tileBuilder = builderFact.newBuilder(screenSize, mapArea); Geometry point = geom("POINT(1 10)"); Map<String, Object> pointProps = ImmutableMap.<String, Object> of("name", "point1"); Geometry line = geom("LINESTRING(0 0, 1 1, 2 2)"); Map<String, Object> lineProps = ImmutableMap.<String, Object> of("name", "line1"); tileBuilder.addFeature("Points", "unused", "unused", point, pointProps); tileBuilder.addFeature("Lines", "unused", "unused", line, lineProps); WMSMapContent mapContent = mock(WMSMapContent.class); RawMap map = tileBuilder.build(mapContent); ListMultimap<String, Feature> features = decode(map); assertEquals(2, features.size()); assertEquals(ImmutableSet.of("Points", "Lines"), features.keySet()); Feature pointFeature = features.get("Points").get(0); Feature lineFeature = features.get("Lines").get(0); assertTrue(pointFeature.getGeometry() instanceof Point); assertEquals(point, pointFeature.getGeometry()); assertEquals(pointProps, pointFeature.getAttributes()); assertTrue(lineFeature.getGeometry() instanceof LineString); assertEquals(line, lineFeature.getGeometry()); assertEquals(lineProps, lineFeature.getAttributes()); }