Example #1
0
 @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 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;
 }
Example #3
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);
    }
Example #4
0
 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));
 }