/** * Calculates the resolution (world units / pixel) for the given scale denominator (1 / map scale) and unit system. * * @param scaleDenominator * scale denominator (1 / map scale) * @param units * units, must not be <code>null</code> * @return resolution in world units per pixel */ public static double calcResolution( double scaleDenominator, IUnit units ) { if ( units.equals( METRE ) ) { return calcMetricResFromScale( scaleDenominator ); } else if ( units.equals( DEGREE ) ) { return calcDegreeResFromScale( scaleDenominator ); } String msg = "Unhandled unit type: " + units + ". Conversion from scale denominator to resolution not implemented"; throw new IllegalArgumentException( msg ); }
double maxy = bbox.getMin().get1() + dy * ( mapHeight / 2d - 1 ); double distance = MapUtils.calcDistance( minx, miny, maxx, maxy );
@Override public TileMatrixSet build() { try { ICRS crs = CRSManager.getCRSRef( cfg.getCRS() ); List<TileMatrix> matrices = new ArrayList<TileMatrix>(); for ( TileMatrixSetConfig.TileMatrix tm : cfg.getTileMatrix() ) { double res; if ( crs.getUnits()[0].equals( Unit.DEGREE ) ) { res = MapUtils.calcDegreeResFromScale( tm.getScaleDenominator() ); } else { res = tm.getScaleDenominator() * DEFAULT_PIXEL_SIZE; } double minx = tm.getTopLeftCorner().get( 0 ); double maxy = tm.getTopLeftCorner().get( 1 ); double maxx = tm.getTileWidth().longValue() * tm.getMatrixWidth().longValue() * res + minx; double miny = maxy - tm.getTileHeight().longValue() * tm.getMatrixHeight().longValue() * res; Envelope env = new GeometryFactory().createEnvelope( minx, miny, maxx, maxy, crs ); SpatialMetadata smd = new SpatialMetadata( env, Collections.singletonList( crs ) ); TileMatrix md = new TileMatrix( tm.getIdentifier(), smd, tm.getTileWidth(), tm.getTileHeight(), res, tm.getMatrixWidth(), tm.getMatrixHeight() ); matrices.add( md ); } String identifier = metadata.getIdentifier().getId(); String wknScaleSet = cfg.getWellKnownScaleSet(); return new TileMatrixSet( identifier, wknScaleSet, matrices, matrices.get( 0 ).getSpatialMetadata(), metadata ); } catch ( Exception e ) { throw new ResourceInitException( "Could not create tile matrix set. Reason: " + e.getLocalizedMessage(), e ); } }
private void exportTileMatrixSet( TileMatrixSet tms ) throws XMLStreamException { writer.writeStartElement( WMTSNS, "TileMatrixSet" ); exportMetadata( null, true, tms.getIdentifier(), null ); ICRS cs = tms.getSpatialMetadata().getCoordinateSystems().get( 0 ); writeElement( writer, OWS110_NS, "SupportedCRS", cs.getAlias() ); String wknScaleSet = tms.getWellKnownScaleSet(); if ( wknScaleSet != null ) { writeElement( writer, WMTSNS, "WellKnownScaleSet", wknScaleSet ); } for ( TileMatrix tm : tms.getTileMatrices() ) { writer.writeStartElement( WMTSNS, "TileMatrix" ); double scale; if ( cs.getUnits()[0].equals( Unit.DEGREE ) && wknScaleSet == null ) { scale = MapUtils.calcScaleFromDegrees( tm.getResolution() ); } else { scale = tm.getResolution() / DEFAULT_PIXEL_SIZE; } writeElement( writer, OWS110_NS, "Identifier", tm.getIdentifier() ); writeElement( writer, WMTSNS, "ScaleDenominator", scale + "" ); Envelope env = tm.getSpatialMetadata().getEnvelope(); writeElement( writer, WMTSNS, "TopLeftCorner", env.getMin().get0() + " " + env.getMax().get1() ); writeElement( writer, WMTSNS, "TileWidth", "" + tm.getTilePixelsX() ); writeElement( writer, WMTSNS, "TileHeight", "" + tm.getTilePixelsY() ); writeElement( writer, WMTSNS, "MatrixWidth", "" + tm.getNumTilesX() ); writeElement( writer, WMTSNS, "MatrixHeight", "" + tm.getNumTilesY() ); writer.writeEndElement(); } writer.writeEndElement(); }
double maxy = bbox.getMin().get1() + dy * ( mapHeight / 2d ); double distance = MapUtils.calcDistance( minx, miny, maxx, maxy );
double maxy = bbox.getMin().get1() + dy * ( mapHeight / 2d ); double distance = MapUtils.calcDistance( minx, miny, maxx, maxy );
double maxy = bbox.getMin().get1() + dy * ( mapHeight / 2d - 1 ); double distance = MapUtils.calcDistance( minx, miny, maxx, maxy );