protected static boolean isServiceVisible(DrawContext dc, PlaceNameService placeNameService) { //noinspection SimplifiableIfStatement if (!placeNameService.isEnabled()) return false; return (dc.getVisibleSector() != null) && placeNameService.getMaskingSector().intersects(dc.getVisibleSector()); // // return // placeNameService.getExtent(dc).intersects(dc.getView().getFrustumInModelCoordinates()); }
protected static boolean isNameVisible( DrawContext dc, PlaceNameService service, Position namePosition) { double elevation = dc.getVerticalExaggeration() * namePosition.getElevation(); Vec4 namePoint = dc.getGlobe() .computePointFromPosition( namePosition.getLatitude(), namePosition.getLongitude(), elevation); Vec4 eyeVec = dc.getView().getEyePoint(); double dist = eyeVec.distanceTo3(namePoint); return dist >= service.getMinDisplayDistance() && dist <= service.getMaxDisplayDistance(); }
protected Tile[] buildTiles(PlaceNameService placeNameService, NavigationTile navTile) { final Angle dLat = placeNameService.getTileDelta().getLatitude(); final Angle dLon = placeNameService.getTileDelta().getLongitude(); // Determine the row and column offset from the global tiling origin for the southwest tile // corner int firstRow = Tile.computeRow(dLat, navTile.navSector.getMinLatitude()); int firstCol = Tile.computeColumn(dLon, navTile.navSector.getMinLongitude()); int lastRow = Tile.computeRow(dLat, navTile.navSector.getMaxLatitude().subtract(dLat)); int lastCol = Tile.computeColumn(dLon, navTile.navSector.getMaxLongitude().subtract(dLon)); int nLatTiles = lastRow - firstRow + 1; int nLonTiles = lastCol - firstCol + 1; Tile[] tiles = new Tile[nLatTiles * nLonTiles]; Angle p1 = Tile.computeRowLatitude(firstRow, dLat); for (int row = 0; row <= lastRow - firstRow; row++) { Angle p2; p2 = p1.add(dLat); Angle t1 = Tile.computeColumnLongitude(firstCol, dLon); for (int col = 0; col <= lastCol - firstCol; col++) { Angle t2; t2 = t1.add(dLon); // Need offset row and column to correspond to total ro/col numbering tiles[col + row * nLonTiles] = new Tile(placeNameService, new Sector(p1, p2, t1, t2), row + firstRow, col + firstCol); t1 = t2; } p1 = p2; } return tiles; }
@Override protected void doRender(DrawContext dc) { this.referencePoint = this.computeReferencePoint(dc); int serviceCount = this.placeNameServiceSet.getServiceCount(); for (int i = 0; i < serviceCount; i++) { PlaceNameService placeNameService = this.placeNameServiceSet.getService(i); if (!isServiceVisible(dc, placeNameService)) continue; double minDistSquared = placeNameService.getMinDisplayDistance() * placeNameService.getMinDisplayDistance(); double maxDistSquared = placeNameService.getMaxDisplayDistance() * placeNameService.getMaxDisplayDistance(); if (isSectorVisible( dc, placeNameService.getMaskingSector(), minDistSquared, maxDistSquared)) { ArrayList<Tile> baseTiles = new ArrayList<Tile>(); NavigationTile navTile = this.navTiles.get(i); // drill down into tiles to find bottom level navTiles visible List<NavigationTile> list = navTile.navTilesVisible(dc, minDistSquared, maxDistSquared); for (NavigationTile nt : list) { baseTiles.addAll(nt.getTiles()); } for (Tile tile : baseTiles) { try { drawOrRequestTile(dc, tile, minDistSquared, maxDistSquared); } catch (Exception e) { Logging.logger() .log( Level.FINE, Logging.getMessage("layers.PlaceNameLayer.ExceptionRenderingTile"), e); } } } } this.sendRequests(); this.requestQ.clear(); }