|
2 | 2 |
|
3 | 3 | import com.mapbox.geojson.Feature;
|
4 | 4 | import com.mapbox.geojson.FeatureCollection;
|
| 5 | +import com.mapbox.geojson.MultiPolygon; |
5 | 6 | import com.mapbox.geojson.Point;
|
6 | 7 | import com.mapbox.geojson.Polygon;
|
7 | 8 | import com.mapbox.mapboxsdk.geometry.LatLng;
|
@@ -78,7 +79,26 @@ public void startDrawingWithPoints() {
|
78 | 79 |
|
79 | 80 | @Test
|
80 | 81 | public void startDrawingWithExistingLayer() {
|
81 |
| - manager.startDrawing(getFillBoundaryLayer()); |
| 82 | + manager.startDrawing(getFillBoundaryLayer(true)); |
| 83 | + |
| 84 | + Assert.assertTrue(manager.isDrawingEnabled()); |
| 85 | + Assert.assertNull(manager.getCurrentKujakuCircle()); |
| 86 | + // Middle Circles created between each point |
| 87 | + Assert.assertEquals(8, manager.getKujakuCircles().size()); |
| 88 | + |
| 89 | + Assert.assertFalse(manager.getKujakuCircles().get(0).isMiddleCircle()); |
| 90 | + Assert.assertTrue(manager.getKujakuCircles().get(1).isMiddleCircle()); |
| 91 | + Assert.assertFalse(manager.getKujakuCircles().get(2).isMiddleCircle()); |
| 92 | + Assert.assertTrue(manager.getKujakuCircles().get(3).isMiddleCircle()); |
| 93 | + Assert.assertFalse(manager.getKujakuCircles().get(4).isMiddleCircle()); |
| 94 | + Assert.assertTrue(manager.getKujakuCircles().get(5).isMiddleCircle()); |
| 95 | + Assert.assertFalse(manager.getKujakuCircles().get(6).isMiddleCircle()); |
| 96 | + Assert.assertTrue(manager.getKujakuCircles().get(7).isMiddleCircle()); |
| 97 | + } |
| 98 | + |
| 99 | + @Test |
| 100 | + public void startDrawingWithExistingMultipolygonLayer() { |
| 101 | + manager.startDrawing(getFillBoundaryLayer(false)); |
82 | 102 |
|
83 | 103 | Assert.assertTrue(manager.isDrawingEnabled());
|
84 | 104 | Assert.assertNull(manager.getCurrentKujakuCircle());
|
@@ -206,18 +226,36 @@ public void areMiddleCircles() {
|
206 | 226 | Assert.assertTrue(manager.getKujakuCircles().get(7).isMiddleCircle());
|
207 | 227 | }
|
208 | 228 |
|
209 |
| - private FillBoundaryLayer getFillBoundaryLayer() { |
| 229 | + @Test |
| 230 | + public void unSetCurrentCircleDraggable() { |
| 231 | + manager.create(DrawingManager.getKujakuCircleOptions().withLatLng(new LatLng(1,1))); |
| 232 | + Circle circle = manager.getKujakuCircles().get(0).getCircle(); |
| 233 | + manager.setDraggable(true, circle); |
| 234 | + |
| 235 | + Assert.assertTrue(manager.getCurrentKujakuCircle().getCircle().isDraggable()); |
| 236 | + manager.unsetCurrentCircleDraggable(); |
| 237 | + Assert.assertNull(manager.getCurrentKujakuCircle()); |
| 238 | + } |
| 239 | + |
| 240 | + |
| 241 | + private FillBoundaryLayer getFillBoundaryLayer(boolean isPolygon) { |
210 | 242 | List<Feature> features = new ArrayList<Feature>();
|
211 | 243 | List<List<Point>> lists = new ArrayList<>();
|
212 | 244 | List<Point> points = new ArrayList<>();
|
| 245 | + Polygon polygon = null; |
213 | 246 |
|
214 | 247 | points.add(Point.fromLngLat(-11,15));
|
215 | 248 | points.add(Point.fromLngLat(-5,15));
|
216 | 249 | points.add(Point.fromLngLat(-5,11));
|
217 | 250 | points.add(Point.fromLngLat(-11,11));
|
218 | 251 | lists.add(points);
|
219 | 252 |
|
220 |
| - features.add(Feature.fromGeometry(Polygon.fromLngLats(lists))); |
| 253 | + polygon = Polygon.fromLngLats(lists); |
| 254 | + if (!isPolygon) { |
| 255 | + features.add(Feature.fromGeometry(polygon)); |
| 256 | + } else { |
| 257 | + features.add(Feature.fromGeometry(MultiPolygon.fromPolygon(polygon))); |
| 258 | + } |
221 | 259 |
|
222 | 260 | FeatureCollection featureCollection = FeatureCollection.fromFeatures(features);
|
223 | 261 | FillBoundaryLayer.Builder builder = new FillBoundaryLayer.Builder(featureCollection);
|
|
0 commit comments