@Test public void testParseMaplinkAndLayersWithGeoJSONFromJsonTest() throws IOException, ParseException, com.vividsolutions.jts.io.ParseException { XMLConfiguration config = shared.getConfig(); TileLayer tileLayer = config.getTileLayer(layerTemplate); GridSubset gridSubset = tileLayer.getGridSubset(gridSubsetName); MapLayerJSONParser layerJsonParser = new MapLayerJSONParser(props); MaplinkGeoJsonParser parser = new MaplinkGeoJsonParser(); parser.setDebug(true); InputStream inp = MapProducer.class.getResourceAsStream("geojsPrintTest.json"); try { assertTrue(MapLinkGeoJsonParseContext.Default.getPm().buildMap); Map<String, ?> root = parser.parse(inp); assertTrue(root.size() != 0); assertTrue(root.get("layers") != null); assertTrue(root.get("maplink") != null); assertTrue(root.get("state") != null); assertTrue(root.get("layers") != null); MapLink mapLink = layerJsonParser.parseMapLinkJSON(root, shared.getGf(), gridSubset.getResolutions()); assertTrue(mapLink != null); } finally { inp.close(); } }
@Test @SuppressWarnings({"rawtypes", "unchecked"}) public void testParseMaplinkAndLayersWithGeoJSONFromJsonEmbedded() throws IOException, ParseException, com.vividsolutions.jts.io.ParseException { XMLConfiguration config = shared.getConfig(); TileLayer tileLayer = config.getTileLayer(layerTemplate); GridSubset gridSubset = tileLayer.getGridSubset(gridSubsetName); MapLayerJSONParser layerJsonParser = new MapLayerJSONParser(props); MaplinkGeoJsonParser parser = new MaplinkGeoJsonParser(); parser.setDebug(true); InputStream inp = MapProducer.class.getResourceAsStream("action_route_parcel.json"); try { assertTrue(MapLinkGeoJsonParseContext.Default.getPm().buildMap); Map<String, ?> root = parser.parse(inp); assertTrue(root.size() != 0); assertTrue(root.get("layers") != null); assertTrue(root.get("maplink") != null); assertTrue(root.get("state") != null); assertTrue(root.get("layers") != null); assertTrue(((List<Map<String, Object>>) root.get("layers")).size() == 11); assertTrue( "geojson".equals(((List<Map<String, Object>>) root.get("layers")).get(10).get("type"))); assertTrue( ((List<Map<String, Object>>) root.get("layers")).get(10).get(".data") instanceof FeatureCollection); FeatureCollection fc10 = (FeatureCollection) ((List<Map<String, Object>>) root.get("layers")).get(10).get(".data"); FeatureIterator fi = fc10.features(); assertTrue(fi.hasNext()); Feature f = fc10.features().next(); assertTrue(f != null); assertTrue(f.getProperty("prop0") != null); assertTrue(f.getProperty("prop0").getValue() != null); Object pv = f.getProperty("prop0").getValue(); assertTrue(pv instanceof String); assertTrue("value0forPoints".equals(pv)); assertTrue(f.getDefaultGeometryProperty() != null); GeometryAttribute g = f.getDefaultGeometryProperty(); assertTrue(g.getValue() != null); Object gv = g.getValue(); assertTrue(gv instanceof Point); Point pt = (Point) gv; System.out.println(pt.toText()); Style style = null; new FeatureLayer(fc10, style); MapLink mapLink = layerJsonParser.parseMapLinkJSON(root, shared.getGf(), gridSubset.getResolutions()); /* assertions */ assertTrue(mapLink != null); assertTrue(mapLink.getScale() != null); assertTrue(mapLink.getCentre() != null); assertTrue(Double.valueOf(530163).equals(mapLink.getCentre().getX())); assertTrue(Double.valueOf(6754057).equals(mapLink.getCentre().getY())); assertTrue(Integer.valueOf(11).equals(mapLink.getZoom())); assertTrue(mapLink.getMapLinkLayers() != null); assertTrue(mapLink.getMapLinkLayers().size() == 4); assertTrue("base_35".equals(mapLink.getMapLinkLayers().get(0).getLayerid())); assertTrue(mapLink.getMapLinkLayers().get(0).getGeom() == null); } finally { inp.close(); } }