private boolean isSampleValueAvailable(int pixelX, int pixelY, boolean pixelValid) { return currentProduct != null && pixelValid && pixelX >= 0 && pixelY >= 0 && pixelX < currentProduct.getSceneRasterWidth() && pixelY < currentProduct.getSceneRasterHeight(); }
public static boolean isPixelValid(Product tsProduct, PixelPos pixelPos) { return pixelPos.isValid() && pixelPos.x < tsProduct.getSceneRasterWidth() && pixelPos.x >= 0 && pixelPos.y < tsProduct.getSceneRasterHeight() && pixelPos.y >= 0; }
private RgbBand(Product product, final String bandName, final String expression) { super(bandName, ProductData.TYPE_FLOAT32, product.getSceneRasterWidth(), product.getSceneRasterHeight(), expression); setOwner(product); } }
public static Dimension getPreferredTileSize(Product product) { Dimension tileSize; final Dimension preferredTileSize = product.getPreferredTileSize(); if (preferredTileSize != null) { tileSize = preferredTileSize; } else { tileSize = JAIUtils.computePreferredTileSize(product.getSceneRasterWidth(), product.getSceneRasterHeight(), 1); } return tileSize; }
public static GeoPos getCenterGeoPos(final Product product) { final GeoCoding geoCoding = product.getGeoCoding(); if (geoCoding != null) { final PixelPos centerPixelPos = new PixelPos(0.5f * product.getSceneRasterWidth() + 0.5f, 0.5f * product.getSceneRasterHeight() + 0.5f); return geoCoding.getGeoPos(centerPixelPos, null); } return null; }
PlanarImage createValidMaskImage(Product product) { if (expression != null && product.isCompatibleBandArithmeticExpression(expression)) { return VirtualBandOpImage.create(expression, ProductData.TYPE_UINT8, 0, product, ResolutionLevel.MAXRES); } else { return ConstantDescriptor.create((float) product.getSceneRasterWidth(), (float) product.getSceneRasterHeight(), new Byte[]{-1}, null); } }
private static void setGeoCoding(Product product, String epsgCode) throws FactoryException, TransformException { final CoordinateReferenceSystem crs = CRS.decode(epsgCode, true); final Rectangle imageBounds = new Rectangle(product.getSceneRasterWidth(), product.getSceneRasterHeight()); final AffineTransform imageToMap = new AffineTransform(); imageToMap.translate(0.7, 0.8); imageToMap.scale(0.9, -0.8); imageToMap.translate(-0.5, -0.6); product.setGeoCoding(new CrsGeoCoding(crs, imageBounds, imageToMap)); }
private void fillBandDataFloat(Band band, int startValue) { final ProductData data = band.createCompatibleProductData(product.getSceneRasterWidth() * product.getSceneRasterHeight()); int value = startValue; int dataIndex = 0; for(int i = 0; i < product.getSceneRasterWidth(); i++) { for(int j = 0; j < product.getSceneRasterHeight(); j++) { data.setElemFloatAt(dataIndex++, value++); } } band.setData(data); } }
public static MultiLevelSource create(Product product, Color color, String expression, boolean inverseMask, AffineTransform i2mTransform) { Assert.notNull(product); Assert.notNull(color); Assert.notNull(expression); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); MultiLevelModel model = new DefaultMultiLevelModel(i2mTransform, width, height); return new MaskImageMultiLevelSource(model, product, color, expression, inverseMask); }
private void fillBandDataInt(Band band, int startValue) { final ProductData data = band.createCompatibleProductData(product.getSceneRasterWidth() * product.getSceneRasterHeight()); int value = startValue; int dataIndex = 0; for(int i = 0; i < product.getSceneRasterWidth(); i++) { for(int j = 0; j < product.getSceneRasterHeight(); j++) { data.setElemIntAt(dataIndex++, value++); } } band.setData(data); }
private ProductDescriptor createProductDescriptor(Product product) { return new ProductDescriptor(product.getName(), product.getProductType(), product.getSceneRasterWidth(), product.getSceneRasterHeight(), createBandDescriptors(), product.getDescription()); }
@Test public void testSpecifyingPixelSize() throws IOException { final double sizeX = 5; // degree final double sizeY = 10;// degree parameterMap.put("crs", WGS84_CODE); parameterMap.put("pixelSizeX", sizeX); parameterMap.put("pixelSizeY", sizeY); final Product targetPoduct = createReprojectedProduct(); assertNotNull(targetPoduct); assertEquals(5, targetPoduct.getSceneRasterWidth()); assertEquals(3, targetPoduct.getSceneRasterHeight()); }
protected void writeRasterDimensionElements(int indent) { final String[] rdTags = createTags(indent, DimapProductConstants.TAG_RASTER_DIMENSIONS); println(rdTags[0]); printLine(indent + 1, DimapProductConstants.TAG_NCOLS, product.getSceneRasterWidth()); printLine(indent + 1, DimapProductConstants.TAG_NROWS, product.getSceneRasterHeight()); printLine(indent + 1, DimapProductConstants.TAG_NBANDS, product.getNumBands()); println(rdTags[1]); }
private static void addTiePointGrids(Product product) { final int sceneRasterWidth = product.getSceneRasterWidth(); final int sceneRasterHeight = product.getSceneRasterHeight(); product.addTiePointGrid(createTiePointGrid("tpg1", sceneRasterWidth, sceneRasterHeight, 32, 32, 0, 0)); product.addTiePointGrid(createTiePointGrid("tpg2", sceneRasterWidth, sceneRasterHeight, 16, 32, 21, 14)); }
@Test public void testRead_QuadraticProduct() throws Exception { final Product product = readTestProduct("simple_format_4_features.txt"); assertNotNull(product); assertEquals(2, product.getSceneRasterWidth()); assertEquals(2, product.getSceneRasterHeight()); testBands(product); }
@Test public void testRead_ProductWithGivenWidth() throws Exception { final Product product = readTestProduct("simple_format_sceneRasterWidth.txt"); assertNotNull(product); assertEquals(4, product.getSceneRasterWidth()); assertEquals(2, product.getSceneRasterHeight()); testBands(product); }
@Override public void initialize() throws OperatorException { targetProduct = new Product(sourceProduct.getName() + "_MulConst", sourceProduct.getProductType(), sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight()); Band[] bands = sourceProduct.getBands(); for (Band sourceBand : bands) { targetProduct.addBand(sourceBand.getName(), sourceBand.getDataType()); } }
@Override public void initialize() throws OperatorException { targetProduct = new Product(sourceProduct1.getName() + "_Add", sourceProduct1.getProductType(), sourceProduct1.getSceneRasterWidth(), sourceProduct1.getSceneRasterHeight()); Band[] bands = sourceProduct1.getBands(); for (Band sourceBand : bands) { targetProduct.addBand(sourceBand.getName(), sourceBand.getDataType()); } }
private void addTiePointGrids(Product product) { final int sceneRasterWidth = product.getSceneRasterWidth(); final int sceneRasterHeight = product.getSceneRasterHeight(); final TiePointGrid tiePointGrid = createTiePointGrid("tpg1", sceneRasterWidth, sceneRasterHeight, 21.1f, 14.2f, 16.3f, 32.004f, false); product.addTiePointGrid(tiePointGrid); tiePointGrid.getOverlayMaskGroup().add(product.getMaskGroup().get("name2")); tiePointGrid.getOverlayMaskGroup().add(product.getMaskGroup().get("name3")); product.addTiePointGrid( createTiePointGrid("tpg2", sceneRasterWidth, sceneRasterHeight, 21.1f, 14.2f, 16.3f, 32.004f, true)); }
@Test public void testDestLatLonBandsExisting() { final ProductSubsetDef subsetDef = null; final Product destP = new Product("dest", "dest", sourceP.getSceneRasterWidth(), sourceP.getSceneRasterHeight()); copyBandTo(destP, pixelGeoCoding.getLatBand()); copyBandTo(destP, pixelGeoCoding.getLonBand()); assertEquals(true, sourceP.transferGeoCodingTo(destP, subsetDef)); assertNotNull(destP.getGeoCoding()); assertEquals(true, destP.getGeoCoding() instanceof BasicPixelGeoCoding); }