@Override public MapReadResult readLabels(Tile tile) { switch (this.dataPolicy) { case RETURN_FIRST: for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { return mdb.readLabels(tile); } } return null; case RETURN_ALL: return readLabels(tile, false); case DEDUPLICATE: return readLabels(tile, true); } throw new IllegalStateException("Invalid data policy for multi map database"); }
@Override public MapReadResult readLabels(Tile upperLeft, Tile lowerRight) { switch (this.dataPolicy) { case RETURN_FIRST: for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(upperLeft)) { return mdb.readLabels(upperLeft, lowerRight); } } return null; case RETURN_ALL: return readLabels(upperLeft, lowerRight, false); case DEDUPLICATE: return readLabels(upperLeft, lowerRight, true); } throw new IllegalStateException("Invalid data policy for multi map database"); }
/** * Reads data for an area defined by the tile in the upper left and the tile in * the lower right corner. The default implementation combines the results from * all tiles, a possibly inefficient solution. * Precondition: upperLeft.tileX <= lowerRight.tileX && upperLeft.tileY <= lowerRight.tileY * * @param upperLeft tile that defines the upper left corner of the requested area. * @param lowerRight tile that defines the lower right corner of the requested area. * @return map data for the tile. */ public MapReadResult readLabels(Tile upperLeft, Tile lowerRight) { if (upperLeft.tileX > lowerRight.tileX || upperLeft.tileY > lowerRight.tileY) { new IllegalArgumentException("upperLeft tile must be above and left of lowerRight tile"); } MapReadResult result = new MapReadResult(); for (int x = upperLeft.tileX; x <= lowerRight.tileX; x++) { for (int y = upperLeft.tileY; y <= lowerRight.tileY; y++) { Tile current = new Tile(x, y, upperLeft.zoomLevel, upperLeft.tileSize); result.add(readLabels(current), false); } } return result; }
private MapReadResult readLabels(Tile tile, boolean deduplicate) { MapReadResult mapReadResult = new MapReadResult(); for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { MapReadResult result = mdb.readLabels(tile); if (result == null) { continue; } boolean isWater = mapReadResult.isWater & result.isWater; mapReadResult.isWater = isWater; mapReadResult.add(result, deduplicate); } } return mapReadResult; }
private MapReadResult readLabels(Tile upperLeft, Tile lowerRight, boolean deduplicate) { MapReadResult mapReadResult = new MapReadResult(); for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(upperLeft)) { MapReadResult result = mdb.readLabels(upperLeft, lowerRight); if (result == null) { continue; } boolean isWater = mapReadResult.isWater & result.isWater; mapReadResult.isWater = isWater; mapReadResult.add(result, deduplicate); } } return mapReadResult; }
@Override public synchronized List<MapElementContainer> getVisibleItems(Tile upperLeft, Tile lowerRight) { try { RendererJob rendererJob = new RendererJob(upperLeft, this.standardRenderer.mapDataStore, this.renderThemeFuture, this.displayModel, this.textScale, true, true); RenderContext renderContext = new RenderContext(rendererJob, new CanvasRasterer(standardRenderer.graphicFactory)); MapReadResult mapReadResult = standardRenderer.mapDataStore.readLabels(upperLeft, lowerRight); if (mapReadResult == null) { return new ArrayList<>(); } for (PointOfInterest pointOfInterest : mapReadResult.pointOfInterests) { renderContext.setDrawingLayers(pointOfInterest.layer); renderContext.rendererJob.renderThemeFuture.get().matchNode(standardRenderer, renderContext, pointOfInterest); } for (Way way : mapReadResult.ways) { PolylineContainer polylineContainer = new PolylineContainer(way, upperLeft, lowerRight); renderContext.setDrawingLayers(polylineContainer.getLayer()); if (polylineContainer.isClosedWay()) { renderContext.renderTheme.matchClosedWay(standardRenderer, renderContext, polylineContainer); } else { renderContext.renderTheme.matchLinearWay(standardRenderer, renderContext, polylineContainer); } } return renderContext.labels; } catch (Exception e) { return new ArrayList<>(); } }
@Override public MapReadResult readLabels(Tile tile) { switch (this.dataPolicy) { case RETURN_FIRST: for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { return mdb.readLabels(tile); } } return null; case RETURN_ALL: return readLabels(tile, false); case DEDUPLICATE: return readLabels(tile, true); } throw new IllegalStateException("Invalid data policy for multi map database"); }
@Override public MapReadResult readLabels(Tile upperLeft, Tile lowerRight) { switch (this.dataPolicy) { case RETURN_FIRST: for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(upperLeft)) { return mdb.readLabels(upperLeft, lowerRight); } } return null; case RETURN_ALL: return readLabels(upperLeft, lowerRight, false); case DEDUPLICATE: return readLabels(upperLeft, lowerRight, true); } throw new IllegalStateException("Invalid data policy for multi map database"); }
private MapReadResult readLabels(Tile upperLeft, Tile lowerRight, boolean deduplicate) { MapReadResult mapReadResult = new MapReadResult(); for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(upperLeft)) { MapReadResult result = mdb.readLabels(upperLeft, lowerRight); if (result == null) { continue; } boolean isWater = mapReadResult.isWater & result.isWater; mapReadResult.isWater = isWater; mapReadResult.add(result, deduplicate); } } return mapReadResult; }
private MapReadResult readLabels(Tile tile, boolean deduplicate) { MapReadResult mapReadResult = new MapReadResult(); for (MapDataStore mdb : mapDatabases) { if (mdb.supportsTile(tile)) { MapReadResult result = mdb.readLabels(tile); if (result == null) { continue; } boolean isWater = mapReadResult.isWater & result.isWater; mapReadResult.isWater = isWater; mapReadResult.add(result, deduplicate); } } return mapReadResult; }
/** * Reads data for an area defined by the tile in the upper left and the tile in * the lower right corner. The default implementation combines the results from * all tiles, a possibly inefficient solution. * Precondition: upperLeft.tileX <= lowerRight.tileX && upperLeft.tileY <= lowerRight.tileY * * @param upperLeft tile that defines the upper left corner of the requested area. * @param lowerRight tile that defines the lower right corner of the requested area. * @return map data for the tile. */ public MapReadResult readLabels(Tile upperLeft, Tile lowerRight) { if (upperLeft.tileX > lowerRight.tileX || upperLeft.tileY > lowerRight.tileY) { new IllegalArgumentException("upperLeft tile must be above and left of lowerRight tile"); } MapReadResult result = new MapReadResult(); for (int x = upperLeft.tileX; x <= lowerRight.tileX; x++) { for (int y = upperLeft.tileY; y <= lowerRight.tileY; y++) { Tile current = new Tile(x, y, upperLeft.zoomLevel, upperLeft.tileSize); result.add(readLabels(current), false); } } return result; }
Tile upperLeft = new Tile(tileXMin, tileYMin, this.mapView.getModel().mapViewPosition.getZoomLevel(), this.mapView.getModel().displayModel.getTileSize()); Tile lowerRight = new Tile(tileXMax, tileYMax, this.mapView.getModel().mapViewPosition.getZoomLevel(), this.mapView.getModel().displayModel.getTileSize()); MapReadResult mapReadResult = getMapFile().readLabels(upperLeft, lowerRight);
@Override public synchronized List<MapElementContainer> getVisibleItems(Tile upperLeft, Tile lowerRight) { try { RendererJob rendererJob = new RendererJob(upperLeft, this.standardRenderer.mapDataStore, this.renderThemeFuture, this.displayModel, this.textScale, true, true); RenderContext renderContext = new RenderContext(rendererJob, new CanvasRasterer(standardRenderer.graphicFactory)); MapReadResult mapReadResult = standardRenderer.mapDataStore.readLabels(upperLeft, lowerRight); if (mapReadResult == null) { return new ArrayList<>(); } for (PointOfInterest pointOfInterest : mapReadResult.pointOfInterests) { renderContext.setDrawingLayers(pointOfInterest.layer); renderContext.rendererJob.renderThemeFuture.get().matchNode(standardRenderer, renderContext, pointOfInterest); } for (Way way : mapReadResult.ways) { PolylineContainer polylineContainer = new PolylineContainer(way, upperLeft, lowerRight); renderContext.setDrawingLayers(polylineContainer.getLayer()); if (polylineContainer.isClosedWay()) { renderContext.renderTheme.matchClosedWay(standardRenderer, renderContext, polylineContainer); } else { renderContext.renderTheme.matchLinearWay(standardRenderer, renderContext, polylineContainer); } } return renderContext.labels; } catch (Exception e) { return new ArrayList<>(); } }