@Test public void getInfo() throws Exception { DirectPosition2D pos = new DirectPosition2D(WORLD.getCoordinateReferenceSystem()); for (int i = 0; i < NUM_TEST_POINTS; i++) { pos.x = WORLD.getMinX() + WORLD.getWidth() * rand.nextDouble(); pos.y = WORLD.getMinY() + WORLD.getHeight() * rand.nextDouble(); InfoToolResult info = helper.getInfo(pos); int[] values = getValues(pos); Map<String, Object> featureData = info.getFeatureData(0); for (int band = 0; band < values.length; band++) { Object o = featureData.get("Band " + band); assertNotNull(o); assertEquals(values[band], ((Number) o).intValue()); } } }
@Override public InfoToolResult getInfo(DirectPosition2D pos) throws Exception { InfoToolResult result = new InfoToolResult(); if (isValid()) { DirectPosition trPos = InfoToolHelperUtils.getTransformed(pos, getContentToLayerTransform()); if (cachedCoverage == null || !cachedCoverage.getEnvelope2D().contains(trPos)) { if (!renewCachedCoverage(trPos)) { return result; } } try { Object objArray = cachedCoverage.evaluate(trPos); Number[] bandValues = InfoToolHelperUtils.asNumberArray(objArray); if (bandValues != null) { result.newFeature("Raw values"); for (int i = 0; i < bandValues.length; i++) { result.setFeatureValue("Band " + i, bandValues[i]); } } } catch (PointOutsideCoverageException e) { } } return result; }
GridReaderLayerHelper extends InfoToolHelper { @Override public InfoToolResult getInfo(DirectPosition2D pos) throws Exception { InfoToolResult result = new InfoToolResult(); if (isValid()) { DirectPosition trPos = InfoToolHelperUtils.getTransformed(pos, getContentToLayerTransform()); if (cachedCoverage == null || !cachedCoverage.getEnvelope2D().contains(trPos)) { if (!renewCachedCoverage(trPos)) { return result; } } try { Object objArray = cachedCoverage.evaluate(trPos); Number[] bandValues = InfoToolHelperUtils.asNumberArray(objArray); if (bandValues != null) { result.newFeature("Raw values"); for (int i = 0; i < bandValues.length; i++) { result.setFeatureValue("Band " + i, bandValues[i]); } } } catch (PointOutsideCoverageException e) { } } return result; } }
GridReaderLayerHelper extends InfoToolHelper { @Override public InfoToolResult getInfo(DirectPosition2D pos) throws Exception { InfoToolResult result = new InfoToolResult(); if (isValid()) { DirectPosition trPos = InfoToolHelperUtils.getTransformed(pos, getContentToLayerTransform()); if (cachedCoverage == null || !cachedCoverage.getEnvelope2D().contains(trPos)) { if (!renewCachedCoverage(trPos)) { return result; } } try { Object objArray = cachedCoverage.evaluate(trPos); Number[] bandValues = InfoToolHelperUtils.asNumberArray(objArray); if (bandValues != null) { result.newFeature("Raw values"); for (int i = 0; i < bandValues.length; i++) { result.setFeatureValue("Band " + i, bandValues[i]); } } } catch (PointOutsideCoverageException e) { } } return result; } GridReaderLayerHelper(); }
GridReaderLayerHelper extends InfoToolHelper { @Override public InfoToolResult getInfo(DirectPosition2D pos) throws Exception { InfoToolResult result = new InfoToolResult(); if (isValid()) { DirectPosition trPos = InfoToolHelperUtils.getTransformed(pos, getContentToLayerTransform()); if (cachedCoverage == null || !cachedCoverage.getEnvelope2D().contains(trPos)) { if (!renewCachedCoverage(trPos)) { return result; } } try { Object objArray = cachedCoverage.evaluate(trPos); Number[] bandValues = InfoToolHelperUtils.asNumberArray(objArray); if (bandValues != null) { result.newFeature("Raw values"); for (int i = 0; i < bandValues.length; i++) { result.setFeatureValue("Band " + i, bandValues[i]); } } } catch (PointOutsideCoverageException e) { } } return result; } GridReaderLayerHelper(); @Override boolean isSupportedLayer(Layer layer); @Override void setLayer(Layer layer); @Override boolean isValid(); @Override InfoToolResult getInfo(DirectPosition2D pos); }
GridReaderLayerHelper extends InfoToolHelper { @Override public InfoToolResult getInfo(DirectPosition2D pos) throws Exception { InfoToolResult result = new InfoToolResult(); if (isValid()) { DirectPosition trPos = InfoToolHelperUtils.getTransformed(pos, getContentToLayerTransform()); if (cachedCoverage == null || !cachedCoverage.getEnvelope2D().contains(trPos)) { if (!renewCachedCoverage(trPos)) { return result; } } try { Object objArray = cachedCoverage.evaluate(trPos); Number[] bandValues = InfoToolHelperUtils.asNumberArray(objArray); if (bandValues != null) { result.newFeature("Raw values"); for (int i = 0; i < bandValues.length; i++) { result.setFeatureValue("Band " + i, bandValues[i]); } } } catch (PointOutsideCoverageException e) { } } return result; } GridReaderLayerHelper(); @Override boolean isSupportedLayer(Layer layer); @Override void setLayer(Layer layer); @Override boolean isValid(); @Override InfoToolResult getInfo(DirectPosition2D pos);  }