/** @deprecated Use {@link #getSpan}. */ public double getLength(final int dimension) { return getSpan(dimension); }
public MBTilesReader(Object source, Hints hints) throws IOException { sourceFile = MBTilesFormat.getFileFromSource(source); MBTilesFile file = new MBTilesFile(sourceFile); metadata = file.loadMetaData(); try { bounds = ReferencedEnvelope.create(metadata.getBounds(), WGS_84) .transform(SPHERICAL_MERCATOR, true); } catch (Exception e) { bounds = null; } originalEnvelope = new GeneralEnvelope(bounds == null ? WORLD_ENVELOPE : bounds); long maxZoom; try { maxZoom = file.maxZoom(); } catch (SQLException e) { throw new IOException(e); } long size = Math.round(Math.pow(ZOOM_LEVEL_BASE, maxZoom)) * DEFAULT_TILE_SIZE; highestRes = new double[] {WORLD_ENVELOPE.getSpan(0) / size, WORLD_ENVELOPE.getSpan(1) / size}; originalGridRange = new GridEnvelope2D(new Rectangle((int) size, (int) size)); coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(this.hints); crs = SPHERICAL_MERCATOR; }
requestedEnvelope.getSpan(0) / WORLD_ENVELOPE.getSpan( 0); // proportion of total width that is being requested double propWidth = ZOOM_LEVEL_BASE, double resX = WORLD_ENVELOPE.getSpan(0) / numberOfTiles; // points per tile double resY = WORLD_ENVELOPE.getSpan(1) / numberOfTiles; // points per tile double offsetX = WORLD_ENVELOPE.getMinimum(0); double offsetY = WORLD_ENVELOPE.getMinimum(1);
requestedEnvelope.getSpan(0)
public MBTilesReader(Object source, Hints hints) throws IOException { sourceFile = MBTilesFormat.getFileFromSource(source); MBTilesFile file = new MBTilesFile(sourceFile); metadata = file.loadMetaData(); try { bounds = ReferencedEnvelope.create(metadata.getBounds(), WGS_84) .transform(SPHERICAL_MERCATOR, true); } catch (Exception e) { bounds = null; } originalEnvelope = new GeneralEnvelope(bounds == null ? WORLD_ENVELOPE : bounds); long maxZoom; try { maxZoom = file.maxZoom(); } catch (SQLException e) { throw new IOException(e); } long size = Math.round(Math.pow(ZOOM_LEVEL_BASE, maxZoom)) * DEFAULT_TILE_SIZE; highestRes = new double[] {WORLD_ENVELOPE.getSpan(0) / size, WORLD_ENVELOPE.getSpan(1) / size}; originalGridRange = new GridEnvelope2D(new Rectangle((int) size, (int) size)); coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(this.hints); crs = SPHERICAL_MERCATOR; }
private Product createOutputProduct() { try { CoordinateReferenceSystem targetCRS; try { targetCRS = CRS.parseWKT(crs); } catch (FactoryException e) { targetCRS = CRS.decode(crs, true); } final Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(westBound, northBound, eastBound, southBound); final ReferencedEnvelope boundsEnvelope = new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84); final ReferencedEnvelope targetEnvelope = boundsEnvelope.transform(targetCRS, true); final int width = MathUtils.floorInt(targetEnvelope.getSpan(0) / pixelSizeX); final int height = MathUtils.floorInt(targetEnvelope.getSpan(1) / pixelSizeY); final CrsGeoCoding geoCoding = new CrsGeoCoding(targetCRS, width, height, targetEnvelope.getMinimum(0), targetEnvelope.getMaximum(1), pixelSizeX, pixelSizeY); final Product product = new Product("Percentile", "TemporalPercentile", width, height); product.setGeoCoding(geoCoding); final Dimension tileSize = JAIUtils.computePreferredTileSize(width, height, 1); product.setPreferredTileSize(tileSize); return product; } catch (Exception e) { throw new OperatorException(e); } }
private Product createTargetProduct() { try { CoordinateReferenceSystem targetCRS; try { targetCRS = CRS.parseWKT(crs); } catch (FactoryException e) { targetCRS = CRS.decode(crs, true); } final Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(westBound, northBound, eastBound, southBound); final ReferencedEnvelope boundsEnvelope = new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84); final ReferencedEnvelope targetEnvelope = boundsEnvelope.transform(targetCRS, true); final int width = MathUtils.floorInt(targetEnvelope.getSpan(0) / pixelSizeX); final int height = MathUtils.floorInt(targetEnvelope.getSpan(1) / pixelSizeY); final CrsGeoCoding geoCoding = new CrsGeoCoding(targetCRS, width, height, targetEnvelope.getMinimum(0), targetEnvelope.getMaximum(1), pixelSizeX, pixelSizeY); final Product product = new Product("mosaic", "BEAM_MOSAIC", width, height); product.setGeoCoding(geoCoding); final Dimension tileSize = JAIUtils.computePreferredTileSize(width, height, 1); product.setPreferredTileSize(tileSize); addTargetBands(product); return product; } catch (Exception e) { throw new OperatorException(e); } }
ReferencedEnvelope bbox = new ReferencedEnvelope(new GeneralEnvelope(latLonBBox)); Polygon geometry = JTS.toGeometry(bbox); double distanceTolerance = Math.max(bbox.getSpan(0), bbox.getSpan(1)) / 2E5; Geometry densifiedGeom = Densifier.densify(geometry, distanceTolerance); MathTransform mathTransform;
ReferencedEnvelope bbox = new ReferencedEnvelope(new GeneralEnvelope(latLonBBox)); Polygon geometry = JTS.toGeometry(bbox); double distanceTolerance = Math.max(bbox.getSpan(0), bbox.getSpan(1)) / 2E5; Geometry densifiedGeom = Densifier.densify(geometry, distanceTolerance); MathTransform mathTransform;
this.pixelSizeY = maximumPixelSizeSourceProduct[1]; final int width = MathUtils.floorInt(this.targetEnvelope.getSpan(0) / this.pixelSizeX); final int height = MathUtils.floorInt(this.targetEnvelope.getSpan(1) / this.pixelSizeY); final CrsGeoCoding geoCoding = new CrsGeoCoding(targetCRS, width, height,
double stepX = Math.abs(affineTransformSourceBand.getScaleX()); double stepY = Math.abs(affineTransformSourceBand.getScaleY()); int bandWidth = MathUtils.floorInt(this.targetEnvelope.getSpan(0) / Math.abs(stepX)); int bandHeight = MathUtils.floorInt(this.targetEnvelope.getSpan(1) / Math.abs(stepY)); Band targetBand = new Band(outputVariable.getName(), targetDataType, bandWidth, bandHeight); targetBand.setDescription(outputVariable.getExpression());