public void createRenderables() { this.gridElements = new ArrayList<GridElement>(); double gridStep = this.size / 10; Position p1, p2; ArrayList<Position> positions = new ArrayList<Position>(); // South-North lines for (int i = 1; i <= 9; i++) { double easting = this.SWEasting + gridStep * i; positions.clear(); p1 = computePosition(this.UTMZone, this.hemisphere, easting, SWNorthing); p2 = computePosition(this.UTMZone, this.hemisphere, easting, SWNorthing + this.size); if (this.isTruncated) { computeTruncatedSegment(p1, p2, this.UTMZoneSector, positions); } else { positions.add(p1); positions.add(p2); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); Object polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); Sector lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_EASTING); ge.setValue(easting); this.gridElements.add(ge); } } // West-East lines for (int i = 1; i <= 9; i++) { double northing = this.SWNorthing + gridStep * i; positions.clear(); p1 = computePosition(this.UTMZone, this.hemisphere, SWEasting, northing); p2 = computePosition(this.UTMZone, this.hemisphere, SWEasting + this.size, northing); if (this.isTruncated) { computeTruncatedSegment(p1, p2, this.UTMZoneSector, positions); } else { positions.add(p1); positions.add(p2); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); Object polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); Sector lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_NORTHING); ge.setValue(northing); this.gridElements.add(ge); } } }
public static VirtualEarthTile[] createTiles( Sector bbox /*int wwLevel, int wwRow, int wwCol*/, VirtualEarthLayer layer) throws WWRuntimeException { if (null == bbox) { String message = Logging.getMessage("nullValue.SectorIsNull"); Logging.logger().severe(message); throw new WWRuntimeException(message); } if (null == layer) { String message = Logging.getMessage("nullValue.LayerIsNull"); Logging.logger().severe(message); throw new WWRuntimeException(message); } int level = getZoomLevelByTrueViewRange(bbox.getDeltaLatDegrees()); Point startPixel = LatLongToPixelXY(bbox.getMaxLatitude().degrees, bbox.getMinLongitude().degrees, level); Point endPixel = LatLongToPixelXY(bbox.getMinLatitude().degrees, bbox.getMaxLongitude().degrees, level); Point startTile = PixelXYToTileXY(startPixel.x, startPixel.y); Point endTile = PixelXYToTileXY(endPixel.x, endPixel.y); ArrayList<VirtualEarthTile> tileList = new ArrayList<VirtualEarthTile>(); for (int y = startTile.y; y <= endTile.y; y++) { for (int x = startTile.x; x <= endTile.x; x++) { try { int ulPixelX = x * VE_MAX_TILE_SIZE; int ulPixelY = y * VE_MAX_TILE_SIZE; LatLon ul = PixelXYToLatLong(ulPixelX, ulPixelY, level); int lrPixelX = ulPixelX + VE_MAX_TILE_SIZE; int lrPixelY = ulPixelY + VE_MAX_TILE_SIZE; LatLon lr = PixelXYToLatLong(lrPixelX, lrPixelY, level); Sector tileSector = Sector.boundingSector(ul, lr); tileList.add(new VirtualEarthTile(x, y, level, layer, tileSector)); } catch (Exception ex) { Logging.logger().log(Level.SEVERE, ex.getMessage(), ex); } } } VirtualEarthTile[] tiles = new VirtualEarthTile[tileList.size()]; return tileList.toArray(tiles); }
@Override public void render(DrawContext dc) { if (dc.isPickingMode() && this.isResizeable()) return; // This is called twice: once during normal rendering, then again during ordered surface // rendering. During // normal renering we render both the interior and border shapes. During ordered surface // rendering, both // shapes are already added to the DrawContext and both will be individually processed. // Therefore we just // call our superclass behavior if (dc.isOrderedRenderingMode()) { super.render(dc); return; } if (!this.isResizeable()) { if (this.hasSelection()) { this.doRender(dc); } return; } PickedObjectList pos = dc.getPickedObjects(); PickedObject terrainObject = pos != null ? pos.getTerrainObject() : null; if (terrainObject == null) return; if (this.getStartPosition() != null) { Position end = terrainObject.getPosition(); if (!this.getStartPosition().equals(end)) { this.setEndPosition(end); this.setSector(Sector.boundingSector(this.getStartPosition(), this.getEndPosition())); this.doRender(dc); } } else { this.setStartPosition(pos.getTerrainObject().getPosition()); } }
public SquareSector( int UTMZone, String hemisphere, Sector UTMZoneSector, double SWEasting, double SWNorthing, double size) { this.UTMZone = UTMZone; this.hemisphere = hemisphere; this.UTMZoneSector = UTMZoneSector; this.SWEasting = SWEasting; this.SWNorthing = SWNorthing; this.size = size; // Compute corners positions this.sw = computePosition(this.UTMZone, this.hemisphere, SWEasting, SWNorthing); this.se = computePosition(this.UTMZone, this.hemisphere, SWEasting + size, SWNorthing); this.nw = computePosition(this.UTMZone, this.hemisphere, SWEasting, SWNorthing + size); this.ne = computePosition(this.UTMZone, this.hemisphere, SWEasting + size, SWNorthing + size); this.squareCenter = computePosition( this.UTMZone, this.hemisphere, SWEasting + size / 2, SWNorthing + size / 2); // Compute approximate bounding sector and center point if (this.sw != null && this.se != null && this.nw != null && this.ne != null) { adjustDateLineCrossingPoints(); this.boundingSector = Sector.boundingSector(Arrays.asList(sw, se, nw, ne)); if (!isInsideGridZone()) this.boundingSector = this.UTMZoneSector.intersection(this.boundingSector); this.centroid = this.boundingSector != null ? this.boundingSector.getCentroid() : this.squareCenter; // this.squareCenter = this.boundingSector.getCentroid(); } // Check whether this square is truncated by the grid zone boundary this.isTruncated = !isInsideGridZone(); }
public void createRenderables() { this.gridElements = new ArrayList<GridElement>(); ArrayList<Position> positions = new ArrayList<Position>(); Position p1, p2; Object polyline; Sector lineSector; // left segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(sw, nw, this.UTMZoneSector, positions); } else { positions.add(sw); positions.add(nw); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_WEST); ge.setValue(this.SWEasting); this.gridElements.add(ge); } // right segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(se, ne, this.UTMZoneSector, positions); } else { positions.add(se); positions.add(ne); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_EAST); ge.setValue(this.SWEasting + this.size); this.gridElements.add(ge); } // bottom segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(sw, se, this.UTMZoneSector, positions); } else { positions.add(sw); positions.add(se); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_SOUTH); ge.setValue(this.SWNorthing); this.gridElements.add(ge); } // top segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(nw, ne, this.UTMZoneSector, positions); } else { positions.add(nw); positions.add(ne); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_NORTH); ge.setValue(this.SWNorthing + this.size); this.gridElements.add(ge); } // Label if (this.name != null) { // Only add a label to squares above some dimension if (this.boundingSector.getDeltaLon().degrees * Math.cos(this.centroid.getLatitude().radians) > .2 && this.boundingSector.getDeltaLat().degrees > .2) { LatLon labelPos = null; if (this.UTMZone != 0) // Not at poles { labelPos = this.centroid; } else if (this.isPositionInside(new Position(this.squareCenter, 0))) { labelPos = this.squareCenter; } else if (this.squareCenter.getLatitude().degrees <= this.UTMZoneSector.getMaxLatitude().degrees && this.squareCenter.getLatitude().degrees >= this.UTMZoneSector.getMinLatitude().degrees) { labelPos = this.centroid; } if (labelPos != null) { GeographicText text = new UserFacingText(this.name, new Position(labelPos, 0)); text.setPriority(this.size * 10); this.gridElements.add( new GridElement(this.boundingSector, text, GridElement.TYPE_GRIDZONE_LABEL)); } } } }