@Override public GeoPos getGeoPos(PixelPos pixelPos, GeoPos geoPos) { Point2D point2D = affineTransform.transform(pixelPos, null); if (geoPos == null) { geoPos = new GeoPos(); } geoPos.lon = point2D.getX(); geoPos.lat = point2D.getY(); return geoPos; }
@Override public CoordinateReferenceSystem getCrs(GeoPos referencePos) throws FactoryException { if (referencePos == null) { referencePos = new GeoPos(0, 0); } String code = String.format("%s,%s,%s", super.crsCode, referencePos.lon, referencePos.lat); return super.factory.createCoordinateReferenceSystem(code); }
private static void getPixelPos(final double lat, final double lon, final GeoCoding srcGeoCoding, final PixelPos pixelPos) { srcGeoCoding.getPixelPos(new GeoPos(lat, lon), pixelPos); }
public static GeoPos[] parseCoordinates(final JSONArray node) { final List<GeoPos> geoPosList = new ArrayList<>(); for (Object o : node) { if (!(o instanceof JSONArray)) continue; final JSONArray latLonList = (JSONArray) o; for (Object latlon : latLonList) { if (!(latlon instanceof JSONArray)) continue; final JSONArray coordList = (JSONArray) latlon; GeoPos geoPos = new GeoPos((Double)coordList.get(0), (Double)coordList.get(1)); geoPosList.add(geoPos); } } return geoPosList.toArray(new GeoPos[geoPosList.size()]); }
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; }
public GeoPos getGeoPos() { return new GeoPos(getLat(), getLon()); }
private static SimpleFeature createFeature(SimpleFeatureType type, GeoCoding geoCoding, int pointIndex, float lat, float lon, double data) { PixelPos pixelPos = geoCoding.getPixelPos(new GeoPos(lat, lon), null); if (!pixelPos.isValid()) { return null; } SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type); GeometryFactory gf = new GeometryFactory(); /*0*/ fb.add(gf.createPoint(new Coordinate(pixelPos.x, pixelPos.y))); /*1*/ fb.add(gf.createPoint(new Coordinate(lon, lat))); /*2*/ fb.add(data); return fb.buildFeature(String.format("ID%08d", pointIndex)); }
private GeoPos getGeoPos(int x, int y) { final GeoPos geoPos = new GeoPos(); final GeoCoding geoCoding = sourceProduct.getSceneGeoCoding(); final PixelPos pixelPos = new PixelPos(x, y); geoCoding.getGeoPos(pixelPos, geoPos); return geoPos; }
protected void setGeoPosLon(Object lon, Placemark placemark) { double lat = placemark.getGeoPos() == null ? Double.NaN : placemark.getGeoPos().lat; placemark.setGeoPos(new GeoPos(lat, (Double) lon)); }
protected void setGeoPosLat(Object lat, Placemark placemark) { double lon = placemark.getGeoPos() == null ? Double.NaN : placemark.getGeoPos().lon; placemark.setGeoPos(new GeoPos((Double) lat, lon)); }
/** * Compute accurate target geo position. * * @param refLat The scene latitude. * @param refLon The scene longitude. * @param slrgTime The slant range time of the given pixel. * @param data The orbit data. * @return The geo position of the target. */ private static GeoPos computeLatLon(final double refLat, final double refLon, double slrgTime, Orbits.OrbitVector data) { final double[] xyz = new double[3]; final GeoPos geoPos = new GeoPos(refLat, refLon); // compute initial (x,y,z) coordinate from lat/lon GeoUtils.geo2xyz(geoPos, xyz); // compute accurate (x,y,z) coordinate using Newton's method GeoUtils.computeAccurateXYZ(data, xyz, slrgTime); // compute (lat, lon, alt) from accurate (x,y,z) coordinate GeoUtils.xyz2geo(xyz, geoPos); return geoPos; }
@Override protected void computePixel(int x, int y, Sample[] samples, WritableSample[] writableSamples) { final GeoPos geoPos = new GeoPos(); sceneGeoCoding.getGeoPos(new PixelPos(x, y), geoPos); writableSamples[0].set(aerosolTypeProvider.getAerosolType(geoPos)); }
@Override public void actionPerformed(ActionEvent e) { final Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "Coord_" + tableModel.getRowCount(), "", "", new PixelPos(), new GeoPos(0, 0), null); tableModel.addPlacemark(placemark); } }
private double getElevation(final int x, final int y) throws Exception { final GeoPos geoPos = new GeoPos(); double alt; geoPos.setLocation(latitudeTPG.getPixelDouble(x, y), longitudeTPG.getPixelDouble(x, y)); if (externalDEMFile == null) { alt = dem.getElevation(geoPos); } else { alt = fileElevationModel.getElevation(geoPos); } return alt; }
/** * 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; } }
@Test public void testWritingShapeFile_Pins() throws Exception { Placemark pin = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "name1", "label1", "", new PixelPos(0, 0), new GeoPos(52.0, 10.0), null); ArrayList<SimpleFeature> features = new ArrayList<>(); features.add(pin.getFeature()); Class<Point> geomType = Point.class; doExportImport(features, geomType); }
public static void main(String[] args) throws TransformException, FactoryException { Product product1 = new Product("A", "B", 360, 180); product1.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 360, 180, -180.0, 90.0, 1.0, 1.0, 0.0, 0.0)); PinDescriptor descriptor = PinDescriptor.getInstance(); Placemark pin1 = Placemark.createPointPlacemark(descriptor, "pin_1", "Pin 1", "Schnatter!", new PixelPos(0, 0), new GeoPos(), product1.getSceneGeoCoding()); product1.getPinGroup().add(pin1); showEditPlacemarkDialog(null, product1, pin1, descriptor); } }
@Test public void getCRS() throws Exception { CoordinateReferenceSystem crs; UTMAutomaticCrsProvider autoUtmCrsProvider = new UTMAutomaticCrsProvider(DefaultGeodeticDatum.WGS84); // The string is different to the one in the UI, because we use DefaultGeodeticDatum.WGS84, but in the UI we // use the datum from the database. crs = autoUtmCrsProvider.getCRS(new GeoPos(31.0, 33.0), null, DefaultGeodeticDatum.WGS84); assertEquals("UTM Zone 36 / WGS84", crs.getName().getCode()); crs = autoUtmCrsProvider.getCRS(new GeoPos(-31.0, 33.0), null, DefaultGeodeticDatum.WGS84); assertEquals("UTM Zone 36, South / WGS84", crs.getName().getCode()); crs = autoUtmCrsProvider.getCRS(new GeoPos(54.0, 10.0), null, DefaultGeodeticDatum.WGS84); assertEquals("UTM Zone 32 / WGS84", crs.getName().getCode()); crs = autoUtmCrsProvider.getCRS(new GeoPos(36.0, -100.0), null, DefaultGeodeticDatum.WGS84); assertEquals("UTM Zone 14 / WGS84", crs.getName().getCode()); }
private void updateForCrsChanged() { final float lon = (float) mosaicModel.getTargetEnvelope().getMedian(0); final float lat = (float) mosaicModel.getTargetEnvelope().getMedian(1); try { final CoordinateReferenceSystem crs = crsSelectionPanel.getCrs(new GeoPos(lat, lon)); if (crs != null) { updatePixelUnit(crs); mosaicModel.setTargetCRS(crs.toWKT()); } else { mosaicModel.setTargetCRS(null); } } catch (FactoryException ignored) { mosaicModel.setTargetCRS(null); } }
private void updateForCrsChanged() { final float lon = (float) mosaicModel.getTargetEnvelope().getMedian(0); final float lat = (float) mosaicModel.getTargetEnvelope().getMedian(1); try { final CoordinateReferenceSystem crs = crsSelectionPanel.getCrs(new GeoPos(lat, lon)); if (crs != null) { updatePixelUnit(crs); mosaicModel.setTargetCRS(crs.toWKT()); } else { mosaicModel.setTargetCRS(null); } } catch (FactoryException ignored) { mosaicModel.setTargetCRS(null); } }