private Point2D.Double modelToView(GeoPos geoPos, AffineTransform modelToView) { Point2D.Double result = new Point2D.Double(); modelToView.transform(new Point2D.Double(geoPos.getLon(), geoPos.getLat()), result); return result; }
public GeoPos[] getSelectionBox() { final GeoPos[] selectionBox = new GeoPos[5]; selectionBox[0] = selectionBoxStart; selectionBox[1] = new GeoPos(selectionBoxStart.getLat(), selectionBoxEnd.getLon()); selectionBox[2] = selectionBoxEnd; selectionBox[3] = new GeoPos(selectionBoxEnd.getLat(), selectionBoxStart.getLon()); selectionBox[4] = selectionBoxStart; return selectionBox; }
private void getGeoRegion() { geoRegion = null; geoText.setText(""); if (geoCoordRadio.isSelected()) { final GeoPos[] selectionBox = worldMapUI.getSelectionBox(); if (selectionBox != null) { final Coordinate[] coords = new Coordinate[selectionBox.length + 1]; for (int i = 0; i < selectionBox.length; ++i) { coords[i] = new Coordinate(selectionBox[i].getLon(), selectionBox[i].getLat()); } coords[selectionBox.length] = new Coordinate(selectionBox[0].getLon(), selectionBox[0].getLat()); final GeometryFactory geometryFactory = new GeometryFactory(); final LinearRing linearRing = geometryFactory.createLinearRing(coords); geoRegion = geometryFactory.createPolygon(linearRing, null); geoText.setText(geoRegion.toText()); } } }
private double computeLatitude(Product product, String level){ final GeoCoding sceneGeoCoding = product.getSceneGeoCoding(); Double[] latitudePoints = { sceneGeoCoding.getGeoPos(new PixelPos(0, 0), null).getLat(), sceneGeoCoding.getGeoPos(new PixelPos(0, product.getSceneRasterHeight()), null).getLat(), sceneGeoCoding.getGeoPos(new PixelPos(product.getSceneRasterWidth(), 0), null).getLat(), sceneGeoCoding.getGeoPos(new PixelPos(product.getSceneRasterWidth(), product.getSceneRasterHeight()), null).getLat() }; switch(level) { case PROPERTY_MIN_VALUE : return Collections.min(Arrays.asList(latitudePoints)); case PROPERTY_MAX_VALUE : return Collections.max(Arrays.asList(latitudePoints)); default : return Double.MAX_VALUE; } }
private PixelPos getProductCenter(final Product product) { final GeoCoding geoCoding = product.getSceneGeoCoding(); PixelPos centerPos = null; if (geoCoding != null) { final double pixelX = Math.floor(0.5f * product.getSceneRasterWidth()) + 0.5f; final double pixelY = Math.floor(0.5f * product.getSceneRasterHeight()) + 0.5f; final GeoPos geoPos = geoCoding.getGeoPos(new PixelPos(pixelX, pixelY), null); final AffineTransform transform = layerCanvas.getViewport().getModelToViewTransform(); final Point2D point2D = transform.transform(new Point2D.Double(geoPos.getLon(), geoPos.getLat()), null); centerPos = new PixelPos(point2D.getX(), point2D.getY()); } return centerPos; }
private PixelPos getProductCenter(final Product product) { final GeoCoding geoCoding = product.getSceneGeoCoding(); PixelPos centerPos = null; if (geoCoding != null) { final float pixelX = (float) Math.floor(0.5f * product.getSceneRasterWidth()) + 0.5f; final float pixelY = (float) Math.floor(0.5f * product.getSceneRasterHeight()) + 0.5f; final GeoPos geoPos = geoCoding.getGeoPos(new PixelPos(pixelX, pixelY), null); final AffineTransform transform = layerCanvas.getViewport().getModelToViewTransform(); final Point2D point2D = transform.transform(new Point2D.Double(geoPos.getLon(), geoPos.getLat()), null); centerPos = new PixelPos((float) point2D.getX(), (float) point2D.getY()); } return centerPos; }
double computeLatitude(Product product, String level){ Double[] latitudePoints = { product.getSceneGeoCoding().getGeoPos(new PixelPos(0, 0), null).getLat(), product.getSceneGeoCoding().getGeoPos(new PixelPos(0, product.getSceneRasterHeight()), null).getLat(), product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth(), 0), null).getLat(), product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth(), product.getSceneRasterHeight()), null).getLat() }; switch(level) { case PROPERTY_MIN_VALUE : return (double) Collections.min(Arrays.asList(latitudePoints)); case PROPERTY_MAX_VALUE : return (double) Collections.max(Arrays.asList(latitudePoints)); default : return Double.MAX_VALUE; } }
private void writeCenterLatLon(final PrintStream p) { GeoPos geoPos = srcProduct.getSceneGeoCoding().getGeoPos( new PixelPos(srcProduct.getSceneRasterWidth() / 2, srcProduct.getSceneRasterHeight() / 2), null); p.println(GammaConstants.HEADER_KEY_CENTER_LATITUDE + sep + geoPos.getLat() + tab + "degrees"); p.println(GammaConstants.HEADER_KEY_CENTER_LONGITUDE + sep + geoPos.getLon() + tab + "degrees"); GeoPos geoPos2 = srcProduct.getSceneGeoCoding().getGeoPos( new PixelPos(srcProduct.getSceneRasterWidth() / 2, (srcProduct.getSceneRasterHeight() / 2) + 100), null); GeoUtils.DistanceHeading heading = GeoUtils.vincenty_inverse(geoPos, geoPos2); p.println(GammaConstants.HEADER_KEY_HEADING + sep + heading.heading1 + tab + "degrees"); }
@Override public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters, GeodeticDatum datum) throws FactoryException { int zoneIndex = getZoneIndex(referencePos.getLon()); final boolean south = referencePos.getLat() < 0.0; ParameterValueGroup tmParameters = createTransverseMercatorParameters(zoneIndex, south, datum); final String projName = getProjectionName(zoneIndex, south); return createCrs(projName, new TransverseMercator.Provider(), tmParameters, datum); } }
/** * Returns the rotation angle of otherCell relative to the current cell. * @param otherCell The second cell to get the rotation from. * @return The angle value (radians) */ public double rotation(BandMatrixCell otherCell) { Assert.notNull(otherCell); Assert.notNull(otherCell.band); double angle = 0.0; GeoCoding otherGeoCoding = otherCell.band.getGeoCoding(); if (otherGeoCoding != null) { GeoPos brCorner = new GeoPos(); otherGeoCoding.getGeoPos(new PixelPos(otherCell.band.getRasterWidth() - 1, otherCell.band.getRasterHeight() - 1), brCorner); angle = (brCorner.getLat() - otherCell.origin.getY()) / (brCorner.getLon() - otherCell.origin.getX()); } return angle; } }
private static void updateMetadata(final Product product) { final GeoCoding geoCoding = product.getSceneGeoCoding(); if (geoCoding == null) return; final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); final int w = product.getSceneRasterWidth(); final int h = product.getSceneRasterHeight(); final GeoPos geo00 = geoCoding.getGeoPos(new PixelPos(0, 0), null); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_lat, geo00.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_long, geo00.getLon()); final GeoPos geo01 = geoCoding.getGeoPos(new PixelPos(w, 0), null); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_lat, geo01.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_long, geo01.getLon()); final GeoPos geo10 = geoCoding.getGeoPos(new PixelPos(0, h), null); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_lat, geo10.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_long, geo10.getLon()); final GeoPos geo11 = geoCoding.getGeoPos(new PixelPos(w, h), null); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_lat, geo11.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_long, geo11.getLon()); //todo causes lazy tpg to load // ReaderUtils.addMetadataIncidenceAngles(product); }
private static void setLatLonMetadata(final Product product, final MetadataElement absRoot) { final GeoCoding geoCoding = product.getSceneGeoCoding(); if (geoCoding == null) return; final GeoPos geoPosFirstNear = product.getSceneGeoCoding().getGeoPos(new PixelPos(0, 0), null); final GeoPos geoPosFirstFar = product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, 0), null); final GeoPos geoPosLastNear = product.getSceneGeoCoding().getGeoPos(new PixelPos(0, product.getSceneRasterHeight() - 1), null); final GeoPos geoPosLastFar = product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, product.getSceneRasterHeight() - 1), null); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_lat, geoPosFirstNear.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_long, geoPosFirstNear.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_lat, geoPosFirstFar.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_long, geoPosFirstFar.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_lat, geoPosLastNear.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_long, geoPosLastNear.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_lat, geoPosLastFar.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_long, geoPosLastFar.getLon()); }
private static void setLatLonMetadata(final Product product, final MetadataElement absRoot) { final GeoCoding geoCoding = product.getSceneGeoCoding(); if (geoCoding == null) return; final GeoPos geoPosFirstNear = product.getSceneGeoCoding().getGeoPos(new PixelPos(0, 0), null); final GeoPos geoPosFirstFar = product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, 0), null); final GeoPos geoPosLastNear = product.getSceneGeoCoding().getGeoPos(new PixelPos(0, product.getSceneRasterHeight() - 1), null); final GeoPos geoPosLastFar = product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, product.getSceneRasterHeight() - 1), null); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_lat, geoPosFirstNear.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_long, geoPosFirstNear.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_lat, geoPosFirstFar.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_long, geoPosFirstFar.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_lat, geoPosLastNear.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_long, geoPosLastNear.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_lat, geoPosLastFar.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_long, geoPosLastFar.getLon()); }
private static void setLatLonMetadata(final Product product, final MetadataElement absRoot) { final GeoCoding geoCoding = product.getSceneGeoCoding(); if (geoCoding == null) return; final GeoPos geoPosFirstNear = product.getSceneGeoCoding().getGeoPos(new PixelPos(0, 0), null); final GeoPos geoPosFirstFar = product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, 0), null); final GeoPos geoPosLastNear = product.getSceneGeoCoding().getGeoPos(new PixelPos(0, product.getSceneRasterHeight() - 1), null); final GeoPos geoPosLastFar = product.getSceneGeoCoding().getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, product.getSceneRasterHeight() - 1), null); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_lat, geoPosFirstNear.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_near_long, geoPosFirstNear.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_lat, geoPosFirstFar.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.first_far_long, geoPosFirstFar.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_lat, geoPosLastNear.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_near_long, geoPosLastNear.getLon()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_lat, geoPosLastFar.getLat()); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.last_far_long, geoPosLastFar.getLon()); }
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())); } }
protected void addCommonSARMetadata(final Product product) throws Exception { if(product.getSceneGeoCoding() == null) { return; } GeoPos geoPos = product.getSceneGeoCoding().getGeoPos( new PixelPos(product.getSceneRasterWidth() / 2, product.getSceneRasterHeight() / 2), null); GeoPos geoPos2 = product.getSceneGeoCoding().getGeoPos( new PixelPos(product.getSceneRasterWidth() / 2, (product.getSceneRasterHeight() / 2) + 100), null); GeoUtils.DistanceHeading heading = GeoUtils.vincenty_inverse(geoPos, geoPos2); final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); AbstractMetadata.setAttribute(absRoot, "centre_lat", geoPos.getLat()); AbstractMetadata.setAttribute(absRoot, "centre_lon", geoPos.getLon()); AbstractMetadata.setAttribute(absRoot, "centre_heading", heading.heading1); AbstractMetadata.setAttribute(absRoot, "centre_heading2", heading.heading2); }
public Coordinate[] getCoordinates() { Coordinate[] coordinates = new Coordinate[coordinateTableModel.getRowCount()]; for (int i = 0; i < coordinateTableModel.getRowCount(); i++) { final Placemark placemark = coordinateTableModel.getPlacemarkAt(i); SimpleFeature feature = placemark.getFeature(); final Date dateTime = (Date) feature.getAttribute(Placemark.PROPERTY_NAME_DATETIME); final Coordinate.OriginalValue[] originalValues = PixExOp.getOriginalValues(feature); if (placemark.getGeoPos() == null) { final Point point = (Point) feature.getDefaultGeometry(); coordinates[i] = new Coordinate(placemark.getName(), point.getY(), point.getX(), dateTime, originalValues); } else { coordinates[i] = new Coordinate(placemark.getName(), placemark.getGeoPos().getLat(), placemark.getGeoPos().getLon(), dateTime, originalValues); } } return coordinates; }
@Test public void initialState() { final double x = placemark.getPixelPos().getX(); final double y = placemark.getPixelPos().getY(); assertEquals(1.0, x, 0.0); assertEquals(1.0, y, 0.0); final Point point = (Point) placemark.getFeature().getDefaultGeometry(); assertEquals(2.0, point.getX(), 0.0); assertEquals(2.0, point.getY(), 0.0); final double lon = placemark.getGeoPos().getLon(); final double lat = placemark.getGeoPos().getLat(); assertEquals(2.0, lon, 0.0); assertEquals(2.0, lat, 0.0); }
@Test public void movePinByPixelPosition() { placemark.setPixelPos(new PixelPos(2.0f, 1.0f)); final double x = placemark.getPixelPos().getX(); final double y = placemark.getPixelPos().getY(); assertEquals(2.0, x, 0.0); assertEquals(1.0, y, 0.0); // todo: rq/?? - make asserts successful final Point point = (Point) placemark.getFeature().getDefaultGeometry(); assertEquals(4.0, point.getX(), 0.0); assertEquals(2.0, point.getY(), 0.0); // todo: rq/?? - make asserts successful final double lon = placemark.getGeoPos().getLon(); final double lat = placemark.getGeoPos().getLat(); assertEquals(4.0, lon, 0.0); assertEquals(2.0, lat, 0.0); }
@Test public void movePinByGeometry() { placemark.getFeature().setDefaultGeometry(newPoint(4.0, 2.0)); placemark.getProduct().getVectorDataGroup().get("pins").fireFeaturesChanged(placemark.getFeature()); final Point point = (Point) placemark.getFeature().getDefaultGeometry(); assertEquals(4.0, point.getX(), 0.0); assertEquals(2.0, point.getY(), 0.0); // todo: rq/?? - make asserts successful final double x = placemark.getPixelPos().getX(); final double y = placemark.getPixelPos().getY(); assertEquals(2.0, x, 0.0); assertEquals(1.0, y, 0.0); // todo: rq/?? - make asserts successful final double lon = placemark.getGeoPos().getLon(); final double lat = placemark.getGeoPos().getLat(); assertEquals(4.0, lon, 0.0); assertEquals(2.0, lat, 0.0); }