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); } } }
protected void makeTessellatedLocations( Globe globe, int subdivisions, List<LatLon> locations, List<LatLon> tessellatedLocations) { ArrayList<Vec4> points = new ArrayList<Vec4>(); for (LatLon ll : locations) { points.add(globe.computePointFromLocation(ll)); } //noinspection StringEquality if (WWMath.computeWindingOrderOfLocations(locations) != AVKey.COUNTER_CLOCKWISE) Collections.reverse(locations); Vec4 centerPoint = Vec4.computeAveragePoint(points); Vec4 surfaceNormal = globe.computeSurfaceNormalAtPoint(centerPoint); int numPoints = points.size(); float[] coords = new float[3 * numPoints]; for (int i = 0; i < numPoints; i++) { points.get(i).toFloatArray(coords, 3 * i, 3); } GeometryBuilder gb = new GeometryBuilder(); GeometryBuilder.IndexedTriangleArray tessellatedPoints = gb.tessellatePolygon(0, numPoints, coords, surfaceNormal); for (int i = 0; i < subdivisions; i++) { gb.subdivideIndexedTriangleArray(tessellatedPoints); } for (int i = 0; i < tessellatedPoints.getVertexCount(); i++) { Vec4 v = Vec4.fromFloatArray(tessellatedPoints.getVertices(), 3 * i, 3); tessellatedLocations.add(globe.computePositionFromPoint(v)); } }
protected static void testPositions( String name, ArrayList<Position> referencePositions, ArrayList<Position> testPositions) { int numMatches = 0; for (int i = 0; i < referencePositions.size(); i++) { if (!testPositions.get(i).equals(referencePositions.get(i))) System.out.println( "MISMATCH: reference = " + referencePositions.get(i) + ", test = " + testPositions.get(i)); else ++numMatches; } System.out.println(numMatches + " Matches for " + name); }
public void doActionOnButton2() { ArrayList<LatLon> latlons = new ArrayList<LatLon>(); latlons.add(LatLon.fromDegrees(45.50d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.51d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.52d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.53d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.54d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.55d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.56d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.57d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.58d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.59d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.60d, -123.3d)); Sector sector = Sector.fromDegrees(44d, 46d, -123d, -121d); // Sector sector = Sector.boundingSector( latlons ); double[] elevations = new double[latlons.size()]; // request resolution of DTED2 (1degree / 3600 ) double targetResolution = Angle.fromDegrees(1d).radians / 3600; double resolutionAchieved = this.wwd .getModel() .getGlobe() .getElevationModel() .getElevations(sector, latlons, targetResolution, elevations); StringBuffer sb = new StringBuffer(); for (double e : elevations) { sb.append("\n").append(e); } sb.append("\nresolutionAchieved = ").append(resolutionAchieved); sb.append(", requested resolution = ").append(targetResolution); Logging.logger().info(sb.toString()); }
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)); } } } }