gov.nasa.worldwind.geom.Position Java Examples
The following examples show how to use
gov.nasa.worldwind.geom.Position.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WWJPanel.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.leo.traceroute.core.sniffer.IPacketListener#startCapture(boolean) */ @Override public void startCapture() { _mode = Mode.SNIFFER; reinit(); _packetDestCoordToPath.clear(); final GeoPoint localGeo = _services.getGeo().getLocalIpGeoLocation(); _sourcePos = new Position(Position.fromDegrees(localGeo.getLat(), localGeo.getLon()), 1e4); localGeo.setTown(youAreHere); localGeo.setCountry(youAreHere); pointAdded(localGeo, false); _sourcePoint = _toAvoidDuplicatedLabels.get(localGeo.getCoordKey()); final AnnotationAttributes attrs = _sourcePoint.getRight().getAttributes(); final Color color = SOURCE_COLOR; attrs.setTextColor(color); attrs.setBackgroundColor(new Color(1f, 1f, 1f, 1f)); attrs.setBorderColor(color); }
Example #2
Source File: FeatureCollectionPointsLayer.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private void addPoint( SimpleFeature pointFeature ) { Geometry geometry = (Geometry) pointFeature.getDefaultGeometry(); if (geometry == null) { return; } int numGeometries = geometry.getNumGeometries(); for( int i = 0; i < numGeometries; i++ ) { Geometry geometryN = geometry.getGeometryN(i); if (geometryN instanceof Point) { Point point = (Point) geometryN; FeaturePoint marker = new FeaturePoint(Position.fromDegrees(point.getY(), point.getX(), 0), featureStoreInfo); marker.setFeature(pointFeature); marker.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); marker.setAttributes(basicMarkerAttributes); addRenderable(marker); } } }
Example #3
Source File: ViewControlsSelectListener.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
protected Angle computePanAmount(Globe globe, OrbitView view, ScreenAnnotation control, double panStep) { // Compute last pick point distance relative to pan control center double size = control.getAttributes().getSize().width * control.getAttributes().getScale(); Vec4 center = new Vec4(control.getScreenPoint().x, control.getScreenPoint().y + size / 2, 0); double px = lastPickPoint.x - center.x; double py = view.getViewport().getHeight() - lastPickPoint.y - center.y; double pickDistance = Math.sqrt(px * px + py * py); double pickDistanceFactor = Math.min(pickDistance / 10, 5); // Compute globe angular distance depending on eye altitude Position eyePos = view.getEyePosition(); double radius = globe.getRadiusAt(eyePos); double minValue = 0.5 * (180.0 / (Math.PI * radius)); // Minimum change ~0.5 meters double maxValue = 1.0; // Maximum change ~1 degree // Compute an interpolated value between minValue and maxValue, using (eye altitude)/(globe radius) as // the interpolant. Interpolation is performed on an exponential curve, to keep the value from // increasing too quickly as eye altitude increases. double a = eyePos.getElevation() / radius; a = (a < 0 ? 0 : (a > 1 ? 1 : a)); double expBase = 2.0; // Exponential curve parameter. double value = minValue + (maxValue - minValue) * ((Math.pow(expBase, a) - 1.0) / (expBase - 1.0)); return Angle.fromDegrees(value * pickDistanceFactor * panStep); }
Example #4
Source File: ViewControlsSelectListener.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Setup the view to a first person mode (zoom = 0) * * @param view the orbit view to set into a first person view. */ protected void setupFirstPersonView(OrbitView view) { if (view.getZoom() == 0) // already in first person mode return; Vec4 eyePoint = view.getEyePoint(); // Center pos at eye pos Position centerPosition = wwd.getModel().getGlobe().computePositionFromPoint(eyePoint); // Compute pitch and heading relative to center position Vec4 normal = wwd.getModel().getGlobe().computeSurfaceNormalAtLocation(centerPosition.getLatitude(), centerPosition.getLongitude()); Vec4 north = wwd.getModel().getGlobe().computeNorthPointingTangentAtLocation(centerPosition.getLatitude(), centerPosition.getLongitude()); // Pitch view.setPitch(Angle.POS180.subtract(view.getForwardVector().angleBetween3(normal))); // Heading Vec4 perpendicular = view.getForwardVector().perpendicularTo3(normal); Angle heading = perpendicular.angleBetween3(north); double direction = Math.signum(-normal.cross3(north).dot3(perpendicular)); view.setHeading(heading.multiply(direction)); // Zoom view.setZoom(0); // Center pos view.setCenterPosition(centerPosition); }
Example #5
Source File: StatusBar.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
protected void handleCursorPositionChange( PositionEvent event ) { Position newPos = event.getPosition(); if (newPos != null) { String las = makeAngleDescription("Lat", newPos.getLatitude()); String los = makeAngleDescription("Lon", newPos.getLongitude()); String els = makeCursorElevationDescription( eventSource.getModel().getGlobe().getElevation(newPos.getLatitude(), newPos.getLongitude())); latDisplay.setText(las); lonDisplay.setText(los); eleDisplay.setText(els); } else { latDisplay.setText(""); lonDisplay.setText(Logging.getMessage("term.OffGlobe")); eleDisplay.setText(""); } }
Example #6
Source File: NwwUtilities.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Get the lat/long world geometry from two screen corner coordinates. * * @param wwd * the {@link WorldWindow} instance. * @param x1 * the first point screen x. * @param y1 * the first point screen y. * @param x2 * the second point screen x. * @param y2 * the second point screen y. * @return the world geomnetry. */ public static Geometry getScreenPointsPolygon( WorldWindow wwd, int x1, int y1, int x2, int y2 ) { View view = wwd.getView(); Position p1 = view.computePositionFromScreenPoint(x1, y1); Position p2 = view.computePositionFromScreenPoint(x1, y2); Position p3 = view.computePositionFromScreenPoint(x2, y2); Position p4 = view.computePositionFromScreenPoint(x2, y1); Coordinate[] coords = { // new Coordinate(p1.longitude.degrees, p1.latitude.degrees), // new Coordinate(p2.longitude.degrees, p2.latitude.degrees), // new Coordinate(p3.longitude.degrees, p3.latitude.degrees), // new Coordinate(p4.longitude.degrees, p4.latitude.degrees)// }; Geometry convexHull = GeometryUtilities.gf().createMultiPoint(coords).convexHull(); return convexHull; }
Example #7
Source File: NwwPanel.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public ReferencedEnvelope getViewportBounds() { View view = wwd.getView(); Position posUL = view.computePositionFromScreenPoint(0, 0); Position posLR = view.computePositionFromScreenPoint(getWidth(), getHeight()); if (posLR != null && posUL != null) { double west = posUL.longitude.degrees; double north = posUL.latitude.degrees; double east = posLR.longitude.degrees; double south = posLR.latitude.degrees; ReferencedEnvelope env = new ReferencedEnvelope(west, east, south, north, DefaultGeographicCRS.WGS84); return env; } else { return null;// new ReferencedEnvelope(-180, 180, -90, 90, // DefaultGeographicCRS.WGS84); } }
Example #8
Source File: WorldMapPanelWrapper.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public void setEyePosition(Path2D.Double polygonPath) { if (this.currentWorldMap != null) { if (this.currentWorldMap == this.worldMap3DPanel) { Rectangle2D rectangleBounds = polygonPath.getBounds2D(); if (rectangleBounds == null) { throw new NullPointerException("The rectangle bounds is null."); } Position eyePosition = this.worldMap3DPanel.getView().getEyePosition(); if (eyePosition == null) { throw new NullPointerException("The eye position is null."); } Position position = Position.fromDegrees(rectangleBounds.getCenterY(), rectangleBounds.getCenterX(), eyePosition.getElevation()); this.worldMap3DPanel.getView().setEyePosition(position); this.worldMap3DPanel.redrawNow(); } else if (this.currentWorldMap == this.worldMap2DPanel) { // do nothing } else { throw new IllegalStateException("The world map type '"+this.currentWorldMap + "' is unknown."); } } }
Example #9
Source File: CustomPolyline.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public CustomPolyline(Path2D.Double path) { this.path = path; List<Position> positions = new ArrayList<>(); double[] coordinates = new double[2]; PathIterator pathIterator = this.path.getPathIterator(null); pathIterator.currentSegment(coordinates); Position firstPosition = new Position(Angle.fromDegreesLatitude(coordinates[1]), Angle.fromDegreesLongitude(coordinates[0]), 0.0d); positions.add(firstPosition); pathIterator.next(); while (!pathIterator.isDone()) { pathIterator.currentSegment(coordinates); Position position = new Position(Angle.fromDegreesLatitude(coordinates[1]), Angle.fromDegreesLongitude(coordinates[0]), 0.0d); positions.add(position); pathIterator.next(); } setPositions(positions); }
Example #10
Source File: WWJPanel.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.leo.traceroute.ui.AbstractRoutePanel#afterShow() */ @Override public void afterShow(final Mode mode) { super.afterShow(mode); SwingUtilities.invokeLater(() -> { _container.invalidate(); _container.revalidate(); final GeoPoint localGeo = _services.getGeo().getLocalIpGeoLocation(); final Position p = new Position(Angle.fromDegrees(localGeo.getLat()), Angle.fromDegrees(localGeo.getLon()), 2000); ((OrbitView) _controller.getWWd().getView()).setCenterPosition(p); if (mode == Mode.TRACE_ROUTE) { _route.renotifyRoute(); } else if (mode == Mode.SNIFFER) { _sniffer.renotifyPackets(); } else { _whois.renotifyWhoIs(); } }); }
Example #11
Source File: WorldMap3DPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public Point.Double convertPointToDegrees(Point point) { SceneController sceneController = getSceneController(); Point pickPoint = sceneController.getPickPoint(); if (pickPoint != null && pickPoint.getX() == point.getX() && pickPoint.getY() == point.getY()) { PickedObjectList pickedObjectList = sceneController.getPickedObjectList(); if (pickedObjectList != null && pickedObjectList.size() > 0) { Position position = (Position) pickedObjectList.get(0).getObject(); return new Point.Double(position.getLongitude().getDegrees(), position.getLatitude().getDegrees()); } } return null; }
Example #12
Source File: NwwPanel.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Move to see a given sector. * * @param sector * the sector to go to. * @param animate * if <code>true</code>, it animates to the position. */ public void goTo( Sector sector, boolean animate ) { View view = getWwd().getView(); view.stopAnimations(); view.stopMovement(); if (sector == null) { return; } // Create a bounding box for the specified sector in order to estimate // its size in model coordinates. Box extent = Sector.computeBoundingBox(getWwd().getModel().getGlobe(), getWwd().getSceneController().getVerticalExaggeration(), sector); // Estimate the distance between the center position and the eye // position that is necessary to cause the sector to // fill a viewport with the specified field of view. Note that we change // the distance between the center and eye // position here, and leave the field of view constant. Angle fov = view.getFieldOfView(); double zoom = extent.getRadius() / fov.cosHalfAngle() / fov.tanHalfAngle(); // Configure OrbitView to look at the center of the sector from our // estimated distance. This causes OrbitView to // animate to the specified position over several seconds. To affect // this change immediately use the following: if (animate) { view.goTo(new Position(sector.getCentroid(), 0d), zoom); } else { ((OrbitView) wwd.getView()).setCenterPosition(new Position(sector.getCentroid(), 0d)); ((OrbitView) wwd.getView()).setZoom(zoom); } }
Example #13
Source File: WWBaseToolView.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void gotoProduct(final Product product) { if (product == null) return; final View theView = getWwd().getView(); final Position origPos = theView.getEyePosition(); final GeoCoding geoCoding = product.getSceneGeoCoding(); if (geoCoding != null && origPos != null) { final GeoPos centre = product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth() / 2, product.getSceneRasterHeight() / 2), null); centre.normalize(); theView.setEyePosition(Position.fromDegrees(centre.getLat(), centre.getLon(), origPos.getElevation())); } }
Example #14
Source File: ViewControlsSelectListener.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Reset the view to an orbit view state if in first person mode (zoom = 0) * * @param view the orbit view to reset */ protected void resetOrbitView(OrbitView view) { if (view.getZoom() > 0) // already in orbit view mode return; // Find out where on the terrain the eye is looking at in the viewport center // TODO: if no terrain is found in the viewport center, iterate toward viewport bottom until it is found Vec4 centerPoint = computeSurfacePoint(view, view.getHeading(), view.getPitch()); // Reset the orbit view center point heading, pitch and zoom if (centerPoint != null) { Vec4 eyePoint = view.getEyePoint(); // Center pos on terrain surface Position centerPosition = wwd.getModel().getGlobe().computePositionFromPoint(centerPoint); // Compute pitch and heading relative to center position Vec4 normal = wwd.getModel().getGlobe().computeSurfaceNormalAtLocation(centerPosition.getLatitude(), centerPosition.getLongitude()); Vec4 north = wwd.getModel().getGlobe().computeNorthPointingTangentAtLocation(centerPosition.getLatitude(), centerPosition.getLongitude()); // Pitch view.setPitch(Angle.POS180.subtract(view.getForwardVector().angleBetween3(normal))); // Heading Vec4 perpendicular = view.getForwardVector().perpendicularTo3(normal); Angle heading = perpendicular.angleBetween3(north); double direction = Math.signum(-normal.cross3(north).dot3(perpendicular)); view.setHeading(heading.multiply(direction)); // Zoom view.setZoom(eyePoint.distanceTo3(centerPoint)); // Center pos view.setCenterPosition(centerPosition); } }
Example #15
Source File: GeopackageVectorLayer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
private void addLine( Geometry geometry, BasicShapeAttributes shapeAttributes, boolean convert ) { if (geometry == null) { return; } Coordinate[] coordinates = geometry.getCoordinates(); if (coordinates.length < 2) return; int numGeometries = geometry.getNumGeometries(); for( int i = 0; i < numGeometries; i++ ) { Geometry geometryN = geometry.getGeometryN(i); if (geometryN instanceof LineString) { LineString line = (LineString) geometryN; Coordinate[] lineCoords = line.getCoordinates(); int numVertices = lineCoords.length; List<Position> verticesList = new ArrayList<>(numVertices); for( int j = 0; j < numVertices; j++ ) { Coordinate c = lineCoords[j]; if (convert) { c = MercatorUtils.convert3857To4326(c); } bounds.expandToInclude(c); verticesList.add(Position.fromDegrees(c.y, c.x)); } FeatureLine path = new FeatureLine(verticesList, null); // path.setFeature(lineFeature); path.setAltitudeMode(mElevationMode); path.setAttributes(shapeAttributes); path.setHighlightAttributes(highlightAttrs); addRenderable(path); } } }
Example #16
Source File: ShapefilesFolderLayer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
private void addLine( SimpleFeature lineFeature, BasicShapeAttributes shapeAttributes ) { Geometry geometry = (Geometry) lineFeature.getDefaultGeometry(); if (geometry == null) { return; } Coordinate[] coordinates = geometry.getCoordinates(); if (coordinates.length < 2) return; int numGeometries = geometry.getNumGeometries(); for( int i = 0; i < numGeometries; i++ ) { Geometry geometryN = geometry.getGeometryN(i); if (geometryN instanceof LineString) { LineString line = (LineString) geometryN; Coordinate[] lineCoords = line.getCoordinates(); int numVertices = lineCoords.length; List<Position> verticesList = new ArrayList<>(numVertices); for( int j = 0; j < numVertices; j++ ) { Coordinate c = lineCoords[j]; verticesList.add(Position.fromDegrees(c.y, c.x)); } FeatureLine path = new FeatureLine(verticesList, null); path.setFeature(lineFeature); path.setAltitudeMode(mElevationMode); path.setAttributes(shapeAttributes); path.setHighlightAttributes(highlightAttrs); addRenderable(path); } } }
Example #17
Source File: DefaultProductLayer.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private PointPlacemark getLabelPlacemark(Position pos, String label) { PointPlacemarkAttributes ppmAtttrs = new PointPlacemarkAttributes(); ppmAtttrs.setLabelOffset(new Offset(0.0, 0.0, AVKey.PIXELS, AVKey.PIXELS)); ppmAtttrs.setScale(0.0); PointPlacemark ppm = new PointPlacemark(pos); ppm.setAttributes(ppmAtttrs); ppm.setLabelText(label); return ppm; }
Example #18
Source File: CurrentGpsPointLayer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public void updatePosition( double lat, double lon ) { if (gpsMarker == null) { gpsMarker = new BasicMarker(Position.fromDegrees(lat, lon, 0), basicMarkerAttributes); addMarker(gpsMarker); } else { if (doHeading) { double azimuth = GeometryUtilities.azimuth(new Coordinate(previousLon, previousLat), new Coordinate(lon, lat)); Angle heading = Angle.fromDegrees(azimuth); gpsMarker.setHeading(heading); } gpsMarker.setPosition(Position.fromDegrees(lat, lon, 10)); } previousLat = lat; previousLon = lon; }
Example #19
Source File: BasicMarkerWithInfo.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public BasicMarkerWithInfo(Position position, MarkerAttributes attrs, Angle heading, String info) { this.info = info; if (attrs == null) { String message = Logging.getMessage("nullValue.AttributesIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.position = position; this.heading = heading; this.attributes = attrs; }
Example #20
Source File: BasicMarkerWithInfo.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public BasicMarkerWithInfo(Position position, MarkerAttributes attrs, String info) { this.info = info; if (attrs == null) { String message = Logging.getMessage("nullValue.AttributesIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.position = position; this.attributes = attrs; }
Example #21
Source File: WWJPanel.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void focusPoint(final GeoPoint point, final boolean isRunning, final boolean animation) { final long elevation = 5000 * 1000; if (_controller == null || _controller.getWWd() == null) { return; } // center the map on the given point final LabeledPath label = point == null ? null : _pointToLabel.get(point); if (label != null) { highlightAnnotation(label, point); final View view = _controller.getWWd().getView(); final OrbitViewInputHandler ovih = (OrbitViewInputHandler) view.getViewInputHandler(); if (animation && Env.INSTANCE.getAnimationSpeed() > 0) { final Position pos = new Position(label.getLocations().iterator().next(), 10); ovih.addPanToAnimator(pos, view.getHeading(), view.getPitch(), elevation, Env.INSTANCE.getAnimationSpeed(), true); // if (_mode == Mode.TRACE_ROUTE && isRunning) { // // if tracing, move at the speed of the timeout // final Position pos = new Position(label.getLocations().iterator().next(), 10); // ovih.addPanToAnimator(pos, view.getHeading(), view.getPitch(), elevation, // Env.INSTANCE.getAnimationSpeed(), true); // } else if (_mode == Mode.TRACE_ROUTE || !isRunning) { // _controller.getWWd().getView() // .goTo(new Position(label.getLocations().iterator().next(), 10), elevation); // } } else { final Position p = new Position(Angle.fromDegrees(point.getLat()), Angle.fromDegrees(point.getLon()), 2000); ((OrbitView) view).setCenterPosition(p); } } }
Example #22
Source File: SectorSelector.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
protected int determineAdjustmentSide(Movable dragObject, double factor) { if (dragObject instanceof SurfaceSector) { SurfaceSector quad = (SurfaceSector) dragObject; Sector s = quad.getSector(); // TODO: go over all sectors Position p = this.getWwd().getCurrentPosition(); if (p == null) { return NONE; } double dN = abs(s.getMaxLatitude().subtract(p.getLatitude()).degrees); double dS = abs(s.getMinLatitude().subtract(p.getLatitude()).degrees); double dW = abs(s.getMinLongitude().subtract(p.getLongitude()).degrees); double dE = abs(s.getMaxLongitude().subtract(p.getLongitude()).degrees); double sLat = factor * s.getDeltaLatDegrees(); double sLon = factor * s.getDeltaLonDegrees(); if (dN < sLat && dW < sLon) return NORTHWEST; if (dN < sLat && dE < sLon) return NORTHEAST; if (dS < sLat && dW < sLon) return SOUTHWEST; if (dS < sLat && dE < sLon) return SOUTHEAST; if (dN < sLat) return NORTH; if (dS < sLat) return SOUTH; if (dW < sLon) return WEST; if (dE < sLon) return EAST; } return NONE; }
Example #23
Source File: SectorSelector.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
@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()); } }
Example #24
Source File: SectorSelector.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
protected Position getPreviousPosition() { return previousPosition; }
Example #25
Source File: DefaultProductLayer.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void addWaveProduct(final Product product) { final MetadataElement root = AbstractMetadata.getOriginalProductMetadata(product); final MetadataElement ggADS = root.getElement("GEOLOCATION_GRID_ADS"); if (ggADS == null) return; final MetadataElement[] geoElemList = ggADS.getElements(); final Polyline[] lineList = new Polyline[geoElemList.length]; int cnt = 0; int numPoints = 0; float centreLat = 0; float centreLon = 0; for (MetadataElement geoElem : geoElemList) { final double lat = geoElem.getAttributeDouble("center_lat", 0.0) / Constants.oneMillion; final double lon = geoElem.getAttributeDouble("center_long", 0.0) / Constants.oneMillion; final double heading = geoElem.getAttributeDouble("heading", 0.0); final GeoUtils.LatLonHeading r1 = GeoUtils.vincenty_direct(new GeoPos(lat, lon), 5000, heading); final GeoUtils.LatLonHeading corner1 = GeoUtils.vincenty_direct(new GeoPos(r1.lat, r1.lon), 2500, heading - 90.0); final GeoUtils.LatLonHeading corner2 = GeoUtils.vincenty_direct(new GeoPos(r1.lat, r1.lon), 2500, heading + 90.0); final GeoUtils.LatLonHeading r2 = GeoUtils.vincenty_direct(new GeoPos(lat, lon), 5000, heading + 180.0); final GeoUtils.LatLonHeading corner3 = GeoUtils.vincenty_direct(new GeoPos(r2.lat, r2.lon), 2500, heading - 90.0); final GeoUtils.LatLonHeading corner4 = GeoUtils.vincenty_direct(new GeoPos(r2.lat, r2.lon), 2500, heading + 90.0); final List<Position> positions = new ArrayList<>(4); positions.add(new Position(Angle.fromDegreesLatitude(corner1.lat), Angle.fromDegreesLongitude(corner1.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner2.lat), Angle.fromDegreesLongitude(corner2.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner4.lat), Angle.fromDegreesLongitude(corner4.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner3.lat), Angle.fromDegreesLongitude(corner3.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner1.lat), Angle.fromDegreesLongitude(corner1.lon), 0.0)); centreLat += corner1.lat; centreLon += corner1.lon; centreLat += corner2.lat; centreLon += corner2.lon; centreLat += corner3.lat; centreLon += corner3.lon; centreLat += corner4.lat; centreLon += corner4.lon; numPoints += 4; final Polyline line = new Polyline(); line.setFollowTerrain(true); line.setPositions(positions); addRenderable(line); lineList[cnt++] = line; } centreLat = centreLat / numPoints; centreLon = centreLon / numPoints; Position centrePos = new Position(Angle.fromDegreesLatitude(centreLat), Angle.fromDegreesLongitude(centreLon), 0.0); PointPlacemark ppm = getLabelPlacemark(centrePos, String.valueOf(product.getRefNo())); ppm.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); ppm.setEnableDecluttering(true); addRenderable(ppm); outlineTable.put(getUniqueName(product), lineList); labelTable.put(getUniqueName(product), ppm); }
Example #26
Source File: DefaultProductLayer.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void addOutline(final Product product) { final int step = Math.max(16, (product.getSceneRasterWidth() + product.getSceneRasterHeight()) / 250); final GeneralPath[] boundaryPaths = ProductUtils.createGeoBoundaryPaths(product, null, step); final Polyline[] polyLineList = new Polyline[boundaryPaths.length]; int i = 0; int numPoints = 0; float centreLat = 0; float centreLon = 0; for (GeneralPath boundaryPath : boundaryPaths) { final PathIterator it = boundaryPath.getPathIterator(null); final float[] floats = new float[2]; final List<Position> positions = new ArrayList<>(4); it.currentSegment(floats); final Position firstPosition = new Position(Angle.fromDegreesLatitude(floats[1]), Angle.fromDegreesLongitude(floats[0]), 0.0); positions.add(firstPosition); centreLat += floats[1]; centreLon += floats[0]; it.next(); numPoints++; while (!it.isDone()) { it.currentSegment(floats); positions.add(new Position(Angle.fromDegreesLatitude(floats[1]), Angle.fromDegreesLongitude(floats[0]), 0.0)); centreLat += floats[1]; centreLon += floats[0]; it.next(); numPoints++; } // close the loop positions.add(firstPosition); centreLat = centreLat / numPoints; centreLon = centreLon / numPoints; polyLineList[i] = new Polyline(); polyLineList[i].setFollowTerrain(true); polyLineList[i].setPositions(positions); // ADDED //polyLineList[i].setColor(new Color(1f, 0f, 0f, 0.99f)); //polyLineList[i].setLineWidth(10); addRenderable(polyLineList[i]); ++i; } Position centrePos = new Position(Angle.fromDegreesLatitude(centreLat), Angle.fromDegreesLongitude(centreLon), 0.0); PointPlacemark ppm = getLabelPlacemark(centrePos, String.valueOf(product.getRefNo())); ppm.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); ppm.setEnableDecluttering(true); addRenderable(ppm); outlineTable.put(getUniqueName(product), polyLineList); labelTable.put(getUniqueName(product), ppm); }
Example #27
Source File: FeaturePoint.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public FeaturePoint( Position position, FeatureStoreInfo featureStoreInfo ) { super(position); this.featureStoreInfo = featureStoreInfo; }
Example #28
Source File: InfoPoint.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public InfoPoint( Position position, MarkerAttributes attrs ) { super(position, attrs); }
Example #29
Source File: FeatureLine.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public FeatureLine(List<Position> verticesList, FeatureStoreInfo featureStoreInfo) { super(verticesList); this.featureStoreInfo = featureStoreInfo; }
Example #30
Source File: InfoLine.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public InfoLine( List<Position> verticesList ) { super(verticesList); }