Package org.geotools.coverage.grid.io.imageio

Examples of org.geotools.coverage.grid.io.imageio.GeoToolsWriteParams


    public void write(final GridCoverage gc,
                        final GeneralParameterValue[] params)
                        throws IllegalArgumentException, IOException,
                        IndexOutOfBoundsException {

                GeoToolsWriteParams gtParams = null;
                boolean writeTfw=GeoTiffFormat.WRITE_TFW.getDefaultValue();
                ProgressListener listener=null;
                boolean retainAxesOrder = false;
                if (params != null) {
                        // /////////////////////////////////////////////////////////////////////
                        //
                        // Checking params
                        //
                        // /////////////////////////////////////////////////////////////////////
                        if (params != null) {
                                Parameter<?> param;
                                final int length = params.length;
                                for (int i = 0; i < length; i++) {
                                        param = (Parameter) params[i];
                                        final ReferenceIdentifier name=param.getDescriptor().getName();
                                        if (name.equals(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName())) {
                                            gtParams = (GeoToolsWriteParams) param.getValue();
                                            continue;
                                        }
                                        if (name.equals(GeoTiffFormat.WRITE_TFW.getName())){
                                            writeTfw = (Boolean) param.getValue();
                                            continue;
                                        }
                                        if (name.equals(GeoTiffFormat.PROGRESS_LISTENER.getName())) {
                                            listener = (ProgressListener) param.getValue();
                                            continue;
                                        }
                                        if (name.equals(GeoTiffFormat.RETAIN_AXES_ORDER.getName())) {
                                            retainAxesOrder = (Boolean) param.getValue();
                                            continue;
                                        }                                       
                                }
                        }
                }
                if (gtParams == null)
                        gtParams = new GeoTiffWriteParams();

                //
                // getting the coordinate reference system
                //
                final GridGeometry2D gg = (GridGeometry2D) gc.getGridGeometry();
                GridEnvelope2D range = gg.getGridRange2D();
                final Rectangle sourceRegion = gtParams.getSourceRegion();
                if (sourceRegion != null){
                    range = new GridEnvelope2D(sourceRegion);
                }
                final AffineTransform tr = (AffineTransform) gg.getGridToCRS2D();
                final CoordinateReferenceSystem crs = gg.getCoordinateReferenceSystem2D();
View Full Code Here


      // /////////////////////////////////////////////////////////////////////
      //
      // Checking writing params
      //
      // /////////////////////////////////////////////////////////////////////
      GeoToolsWriteParams gtParams = null;
      boolean grass = false;
      boolean forceCellSize = false;
      final String grassParam = ArcGridFormat.GRASS.getName().getCode().toString();
      final String cellSizeParam = ArcGridFormat.FORCE_CELLSIZE
          .getName().getCode().toString();
      if (parameters != null) {
        for (int i = 0; i < parameters.length; i++) {
          Parameter param = (Parameter) parameters[i];
          String name = param.getDescriptor().getName().toString();
          if (param.getDescriptor().getName().getCode().equals(
              AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName()
                  .toString())) {
            gtParams = (GeoToolsWriteParams) param.getValue();
          }
          if (name.equalsIgnoreCase(grassParam))
            grass = param.booleanValue();
          if (name.equalsIgnoreCase(cellSizeParam))
            forceCellSize = param.booleanValue();
        }
      }
      if (gtParams == null)
        gtParams = new ArcGridWriteParams();
      // write band
      int[] writeBands = gtParams.getSourceBands();
      writeBand = CoverageUtilities.getVisibleBand(gc.getRenderedImage());
      if ((writeBands == null || writeBands.length == 0 || writeBands.length > 1)
          && (writeBand < 0 || writeBand > gc
              .getNumSampleDimensions()))
        throw new IllegalArgumentException(
View Full Code Here

    // /////////////////////////////////////////////////////////////////////
    //
    // Checking writing params
    //
    // /////////////////////////////////////////////////////////////////////
    GeoToolsWriteParams gtParams = null;
    if (params != null) {

      if (params != null) {
        Parameter<?> param;
        final int length = params.length;
        for (int i = 0; i < length; i++) {
          param = (Parameter<?>) params[i];
          if (param.getDescriptor().getName().getCode().equals(
              AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName()
                  .toString())) {
            gtParams = (GeoToolsWriteParams) param.getValue();
          }
        }
      }
    }
    if (gtParams == null)
      gtParams = new GTopo30WriteParams();
    // compression
    final boolean compressed = gtParams.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT;
    // write band
    int[] writeBands = gtParams.getSourceBands();
    int writeBand = CoverageUtilities.getVisibleBand(gc2D
        .getRenderedImage());
    if ((writeBands == null || writeBands.length == 0 || writeBands.length > 1)
        && (writeBand < 0 || writeBand > gc2D.getNumSampleDimensions()))
      throw new IllegalArgumentException(
View Full Code Here

    public void write(final GridCoverage gc,
            final GeneralParameterValue[] params)
            throws IllegalArgumentException, IOException,
            IndexOutOfBoundsException {

        GeoToolsWriteParams gtParams = null;
        if (params != null) {
            // /////////////////////////////////////////////////////////////////////
            //
            // Checking params
            //
            // /////////////////////////////////////////////////////////////////////
            if (params != null) {
                Parameter param;
                final int length = params.length;
                for (int i = 0; i < length; i++) {
                    param = (Parameter) params[i];
                    if (param.getDescriptor().getName().getCode().equals(
                            AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName()
                                    .toString())) {
                        gtParams = (GeoToolsWriteParams) param.getValue();
                    }
                }
            }
        }
        if (gtParams == null)
            gtParams = new GeoTiffWriteParams();

        // /////////////////////////////////////////////////////////////////////
        //
        // getting the coordinate reference system
        //
        // /////////////////////////////////////////////////////////////////////
        final GridGeometry2D gg = (GridGeometry2D) gc.getGridGeometry();
        GridEnvelope2D range = gg.getGridRange2D();
        final Rectangle sourceRegion = gtParams.getSourceRegion();
        if (sourceRegion != null)
            range = new GridEnvelope2D(sourceRegion);
        final AffineTransform tr = (AffineTransform) gg.getGridToCRS2D();
        final CoordinateReferenceSystem crs = gg
                .getCoordinateReferenceSystem2D();
View Full Code Here

     *      org.opengis.parameter.GeneralParameterValue[])
     */
    public void write(final GridCoverage gc, final GeneralParameterValue[] params)
            throws IllegalArgumentException, IOException, IndexOutOfBoundsException {

        GeoToolsWriteParams gtParams = null;
        boolean writeTfw = GeoTiffFormat.WRITE_TFW.getDefaultValue();
        if (params != null) {
            // /////////////////////////////////////////////////////////////////////
            //
            // Checking params
            //
            // /////////////////////////////////////////////////////////////////////
            if (params != null) {
                Parameter param;
                final int length = params.length;
                for (int i = 0; i < length; i++) {
                    param = (Parameter) params[i];
                    final ReferenceIdentifier name = param.getDescriptor().getName();
                    if (name.equals(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName())) {
                        gtParams = (GeoToolsWriteParams) param.getValue();
                    }
                    if (name.equals(GeoTiffFormat.WRITE_TFW.getName())) {
                        writeTfw = (Boolean) param.getValue();
                    }
                }
            }
        }
        if (gtParams == null)
            gtParams = new GeoTiffWriteParams();

        // /////////////////////////////////////////////////////////////////////
        //
        // getting the coordinate reference system
        //
        // /////////////////////////////////////////////////////////////////////
        final GridGeometry2D gg = (GridGeometry2D) gc.getGridGeometry();
        GridEnvelope2D range = gg.getGridRange2D();
        final Rectangle sourceRegion = gtParams.getSourceRegion();
        if (sourceRegion != null)
            range = new GridEnvelope2D(sourceRegion);
        final AffineTransform tr = (AffineTransform) gg.getGridToCRS2D();
        final CoordinateReferenceSystem crs = gg.getCoordinateReferenceSystem2D();
        final double inNoData = getCandidateNoData(gc);
View Full Code Here

            / totalNumberOfFile);

        try {

          final GeoTiffWriter writerWI = new GeoTiffWriter(fileOut);
          final GeoToolsWriteParams wp = ((AbstractGridFormat) writerWI
              .getFormat()).getDefaultImageIOWriteParameters();
          if (this.compressionScheme != null) {
            wp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
            wp.setCompressionType(this.compressionScheme);
            wp.setCompressionQuality((float) this.compressionRatio);
          }
          wp.setTilingMode(ImageWriteParam.MODE_EXPLICIT);
          wp.setTiling(internalTileWidth, internalTileHeight, 0, 0);
          writerWI.write(gc, null);
          writerWI.dispose();

        } catch (IOException e) {
          LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
View Full Code Here

TOP

Related Classes of org.geotools.coverage.grid.io.imageio.GeoToolsWriteParams

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.