SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. List<Number[]> edgeList = isochrone.searchEdges(qr.getClosestNode());
  2.  
  3.             IGeometryFilter acceptAllGeomFilter = geometry -> true;
  4.             // TODO: Your tile extent here
  5.             Envelope tileEnvelope = new Envelope(0d, 100d, 0d, 100d);
  6.             MvtLayerParams layerParams = new MvtLayerParams(); // Default extent
  7.             GeometryFactory geometryFactory = new GeometryFactory();
  8.             Geometry[] edgeListGeometry = new Geometry[edgeList.size()];
  9.             for (int edgeCounter = 0; edgeCounter < edgeList.size(); edgeCounter++) {
  10.                 Number[] edge = edgeList.get(edgeCounter);
  11.                 edgeListGeometry[edgeCounter] = geometryFactory.createLineString(
  12.                         new Coordinate[]{new Coordinate(edge[0].doubleValue(), edge[1].doubleValue()),
  13.                                 new Coordinate(edge[2].doubleValue(), edge[3].doubleValue())});
  14.             }
  15.  
  16.             logger.info("start encoding: " + resultStr + ", edges:" + edgeListGeometry.length);
  17.             TileGeomResult tileGeom = JtsAdapter.createTileGeom(
  18.                     geometryFactory.createGeometryCollection(edgeListGeometry),
  19.                     tileEnvelope,
  20.                     geometryFactory,
  21.                     layerParams,
  22.                     acceptAllGeomFilter);
  23.  
  24.             VectorTile.Tile.Layer.Builder layerBuilder = MvtLayerBuild.newLayerBuilder("myLayerName", layerParams);
  25.             MvtLayerProps layerProps = new MvtLayerProps();
  26.             IUserDataConverter userDataConverter = new UserDataKeyValueMapConverter();
  27.             List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(tileGeom.mvtGeoms, layerProps, userDataConverter);
  28.             MvtLayerBuild.writeProps(layerBuilder, layerProps);
  29.             VectorTile.Tile mvt = VectorTile.Tile.newBuilder().addLayers(layerBuilder.addAllFeatures(features).build()).build();
  30.             byte[] bytes = mvt.toByteArray();
  31.             String tookStr = "" + sw.stop().getSeconds() * 1000;
  32.             logger.info("took: " + tookStr);
  33.             return Response.fromResponse(Response.ok(bytes, new MediaType("application", "octet-stream")).build())
  34.                     .header("X-GH-Took", tookStr)
  35.                     .build();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top