public GeoPos getGeoPos(final PixelPos pixelPos, GeoPos geoPos) { for (int i = 0; i < _codingWrappers.length; i++) { final CodingWrapper codingWrapper = _codingWrappers[i]; if (codingWrapper.contains(pixelPos)) { return codingWrapper.getGeoPos(pixelPos, geoPos); } } if (geoPos == null) { geoPos = new GeoPos(0, 0); } return geoPos; }
private static GeoPos toGeoPos(Coordinate coordinate) { if (coordinate != null) { return new GeoPos((float) coordinate.y, (float) coordinate.x); } return null; }
/** * Inverse project map co-ordinates into geographical co-ordinates. */ public GeoPos inverse(Point2D mapPoint, GeoPos geoPoint) { if (geoPoint == null) { geoPoint = new GeoPos(); } _inverse.transform(mapPoint, _temp); geoPoint.lon = _temp.x; geoPoint.lat = _temp.y; return geoPoint; }
@Override public GeoPos getGeoPos(PixelPos pixelPos, GeoPos geoPos) { if (geoPos == null) { geoPos = new GeoPos(); } geoPos.lon = pixelPos.x; geoPos.lat = pixelPos.y; return geoPos; }
protected GeoPos getGeoPos(PixelPos pixelPos) { final GeoPos geoPos = new GeoPos(); gc.getGeoPos(pixelPos, geoPos); return geoPos; }
/** * Inverse project map co-ordinates into geographical co-ordinates. */ public GeoPos inverse(Point2D mapPoint, GeoPos geoPoint) { if (geoPoint != null) { geoPoint.setLocation((float) mapPoint.getY(), (float) mapPoint.getX()); } else { geoPoint = new GeoPos((float) mapPoint.getY(), (float) mapPoint.getX()); } return geoPoint; }
@Override public GeoPos getGeoPos(PixelPos pixelPos, GeoPos geoPos) { if (geoPos == null) { geoPos = new GeoPos(); } geoPos.lon = pixelPos.x; geoPos.lat = pixelPos.y; return geoPos; }
@Override protected GeoPos inverse_impl(float x, float y, GeoPos geoPoint) { final float cm = _centralMeridian; final double phi = y; final double lam = cm + x / Math.cos(phi); if (geoPoint == null) { geoPoint = new GeoPos(); } geoPoint.setLocation((float) Math.toDegrees(phi), (float) Math.toDegrees(lam)); return geoPoint; }
private static GeoPos[] createPositiveRotationGeoPolygon(int lonOffset) { return new GeoPos[]{ new GeoPos(-60, -40 + lonOffset), new GeoPos(-80, +20 + lonOffset), new GeoPos(-40, +60 + lonOffset), new GeoPos(+20, +120 + lonOffset), new GeoPos(+60, +40 + lonOffset), new GeoPos(+80, -20 + lonOffset), new GeoPos(+40, -60 + lonOffset), new GeoPos(-20, -120 + lonOffset) }; }
private static GeoPos[] createNegativeRotationGeoPolygon(int lonOffset) { return new GeoPos[]{ new GeoPos(-60, -40 + lonOffset), new GeoPos(-20, -120 + lonOffset), new GeoPos(+40, -60 + lonOffset), new GeoPos(+80, -20 + lonOffset), new GeoPos(+60, +40 + lonOffset), new GeoPos(+20, +120 + lonOffset), new GeoPos(-40, +60 + lonOffset), new GeoPos(-80, +20 + lonOffset) }; }
@Override public void filter(Coordinate coordinate) { final GeoPos geoPos = new GeoPos((float) coordinate.y, (float) coordinate.x); final PixelPos pixelPos = geoCoding.getPixelPos(geoPos, null); if (pixelPos.isValid()) { x1 = min(x1, (int) floor(pixelPos.x)); x2 = max(x2, (int) ceil(pixelPos.x)); y1 = min(y1, (int) floor(pixelPos.y)); y2 = max(y2, (int) ceil(pixelPos.y)); } }
@Override public void filter(CoordinateSequence seq, int i) { Coordinate coord = seq.getCoordinate(i); PixelPos pixelPos = geoCoding.getPixelPos(new GeoPos((float) coord.y, (float) coord.x), null); // rounding needed because closed geometries yield errors if their first and last coordinate // do not exactly match double x = Math.round(pixelPos.x * 10000) / 10000; double y = Math.round(pixelPos.y * 10000) / 10000; coord.setCoordinate(new Coordinate(x, y)); count++; }
public GeoPos getPSReferencePoint() throws IOException, IllegalCeosFormatException { final float referenceLat = (float) _ancillary1Record.getPSReferenceLat(); final float referenceLon = (float) _ancillary1Record.getPSReferenceLon(); return new GeoPos(referenceLat, referenceLon); }
public static GeoPos getGeoPos(SimpleFeature feature) throws IOException { final Geometry defaultGeometry = (Geometry) feature.getDefaultGeometry(); if (defaultGeometry == null) { throw new IOException("Could not read geometry of feature '" + feature.getID() + "'."); } final Point centroid = defaultGeometry.getCentroid(); return new GeoPos((float) centroid.getY(), (float) centroid.getX()); }
@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); } }
public static void main(String[] args) throws TransformException, FactoryException { Product product1 = new Product("A", "B", 360, 180); product1.setGeoCoding(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.getGeoCoding()); product1.getPinGroup().add(pin1); showEditPlacemarkDialog(null, product1, pin1, descriptor); } }
@Test public void testMaskIsNotAddedWhenPinIsAddedForTheSecondTime() throws Exception { final Product p = new Product("P", "T", 1, 1); p.getPinGroup().add(Placemark.createPointPlacemark(PinDescriptor.getInstance(), "a", "a", "a", new PixelPos(), new GeoPos(), null)); p.getPinGroup().add(Placemark.createPointPlacemark(PinDescriptor.getInstance(), "b", "b", "b", new PixelPos(), new GeoPos(), null)); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("pins")); }
public void testWriteXML_XmlWriterIsNull() { Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "pinName", "pinLabel", "", null, new GeoPos(), product.getGeoCoding()); try { PlacemarkIO.writeXML(placemark, null, 1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected IllegalArgumentException } catch (Exception e) { fail("IllegalArgumentException expected"); } }
@Test public void testMaskIsAddedWhenGcpIsAddedForTheFirstTime() throws Exception { final Product p = new Product("P", "T", 1, 1); p.getGcpGroup().add(Placemark.createPointPlacemark(GcpDescriptor.getInstance(), "a", "a", "a", new PixelPos(), new GeoPos(), null)); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("ground_control_points")); }