コード例 #1
0
 @Override
 public boolean accept(Product sourceProduct) {
   final ProductData.UTC productStartTime = sourceProduct.getStartTime();
   final ProductData.UTC productEndTime = sourceProduct.getEndTime();
   final boolean hasStartTime = productStartTime != null;
   final boolean hasEndTime = productEndTime != null;
   final GeoCoding geoCoding = sourceProduct.getGeoCoding();
   if (geoCoding == null || !geoCoding.canGetGeoPos()) {
     return false;
   } else if (startTime != null
       && hasStartTime
       && productStartTime.getAsDate().after(startTime.getAsDate())
       && endTime != null
       && hasEndTime
       && productEndTime.getAsDate().before(endTime.getAsDate())) {
     return true;
   } else if (!hasStartTime && !hasEndTime) {
     return true;
   } else if (startTime != null
       && hasStartTime
       && productStartTime.getAsDate().after(startTime.getAsDate())
       && !hasEndTime) {
     return true;
   } else if (!hasStartTime
       && endTime != null
       && productEndTime.getAsDate().before(endTime.getAsDate())) {
     return true;
   } else {
     return false;
   }
 }
コード例 #2
0
 @Override
 public boolean getPixelLocation(double lon, double lat, Point2D p) {
   if (geoCoding.canGetPixelPos()) {
     gp.setLocation((float) lat, (float) lon);
     geoCoding.getPixelPos(gp, pp);
     if (pp.isValid()) {
       p.setLocation(pp);
       return true;
     }
   }
   return false;
 }
コード例 #3
0
 @Override
 public boolean getGeoLocation(double x, double y, Point2D g) {
   if (geoCoding.canGetGeoPos()) {
     pp.setLocation(x, y);
     geoCoding.getGeoPos(pp, gp);
     if (gp.isValid()) {
       g.setLocation(gp.getLon(), gp.getLat());
       return true;
     }
   }
   return false;
 }
コード例 #4
0
    private void syncLatLonWithXYParams() {
      final PixelPos pixelPos1 =
          new PixelPos(
              ((Number) paramX1.getValue()).intValue(), ((Number) paramY1.getValue()).intValue());
      final PixelPos pixelPos2 =
          new PixelPos(
              ((Number) paramX2.getValue()).intValue(), ((Number) paramY2.getValue()).intValue());

      final GeoCoding geoCoding = product.getGeoCoding();
      final GeoPos geoPos1 = geoCoding.getGeoPos(pixelPos1, null);
      final GeoPos geoPos2 = geoCoding.getGeoPos(pixelPos2, null);
      paramNorthLat1.setValue(geoPos1.getLat(), null);
      paramWestLon1.setValue(geoPos1.getLon(), null);
      paramSouthLat2.setValue(geoPos2.getLat(), null);
      paramEastLon2.setValue(geoPos2.getLon(), null);
    }
コード例 #5
0
ファイル: SubsetOp.java プロジェクト: syedimam/beam
 @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));
   }
 }
コード例 #6
0
    private void updateXYParams(GeoPos geoPos1, GeoPos geoPos2) {
      final GeoCoding geoCoding = product.getGeoCoding();
      final PixelPos pixelPos1 = geoCoding.getPixelPos(geoPos1, null);
      if (!pixelPos1.isValid()) {
        pixelPos1.setLocation(0, 0);
      }
      final PixelPos pixelPos2 = geoCoding.getPixelPos(geoPos2, null);
      if (!pixelPos2.isValid()) {
        pixelPos2.setLocation(product.getSceneRasterWidth(), product.getSceneRasterHeight());
      }
      final Rectangle.Float region = new Rectangle.Float();
      region.setFrameFromDiagonal(pixelPos1.x, pixelPos1.y, pixelPos2.x, pixelPos2.y);
      final Rectangle.Float productBounds =
          new Rectangle.Float(0, 0, product.getSceneRasterWidth(), product.getSceneRasterHeight());
      Rectangle2D finalRegion = productBounds.createIntersection(region);

      paramX1.setValue((int) finalRegion.getMinX(), null);
      paramY1.setValue((int) finalRegion.getMinY(), null);
      paramX2.setValue((int) finalRegion.getMaxX() - 1, null);
      paramY2.setValue((int) finalRegion.getMaxY() - 1, null);
    }
コード例 #7
0
ファイル: ImportTrackAction.java プロジェクト: TonioF/beam
 private static SimpleFeatureType createTrackFeatureType(GeoCoding geoCoding) {
   SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder();
   ftb.setName("org.esa.beam.TrackPoint");
   /*0*/
   ftb.add("pixelPos", Point.class, geoCoding.getImageCRS());
   /*1*/
   ftb.add("geoPos", Point.class, DefaultGeographicCRS.WGS84);
   /*2*/
   ftb.add("data", Double.class);
   ftb.setDefaultGeometry(geoCoding instanceof CrsGeoCoding ? "geoPos" : "pixelPos");
   // GeoTools Bug: this doesn't work
   // ftb.userData("trackPoints", "true");
   final SimpleFeatureType ft = ftb.buildFeatureType();
   ft.getUserData().put("trackPoints", "true");
   return ft;
 }
コード例 #8
0
ファイル: ImportTrackAction.java プロジェクト: TonioF/beam
 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));
 }
コード例 #9
0
 private boolean canUseGeoCoordinates(Product product) {
   final GeoCoding geoCoding = product.getGeoCoding();
   return geoCoding != null && geoCoding.canGetPixelPos() && geoCoding.canGetGeoPos();
 }