Package org.opengis.coverage.grid

Examples of org.opengis.coverage.grid.Format


            // connect and defaults
            info.setURL(url);
            info.setType(obj.str("type"));
            try {
                GridCoverageReader reader = info.getGridCoverageReader(null, null);
                Format format = reader.getFormat();
                info.setDescription( format.getDescription() );
                info.setEnabled(true);
            } catch (IOException e) {
                info.setError(e);
                info.setEnabled(false);
            }
View Full Code Here


    // getting a writer
    final WorldImageWriter wiWriter = new WorldImageWriter(tempFile);

    // writing parameters for png
    final Format writerFormat = wiWriter.getFormat();
   

    // setting write parameters
    final ParameterValueGroup params = writerFormat.getWriteParameters();
    params.parameter(WorldImageFormat.FORMAT.getName().toString())
        .setValue(format);
    final GeneralParameterValue[] gpv = { params
        .parameter(WorldImageFormat.FORMAT.getName().toString()) };
    // writing
View Full Code Here

        //
        // - calculating a new envelope which is 1/20 of the original one
        // - reading the GridCoverage subset
        //
        // /////////////////////////////////////////////////////////////////////
        Format format = csinfo.getFormat();
        final GridCoverage2D gc;

        final ParameterValueGroup readParams = format.getReadParameters();
        final Map parameters = CoverageUtils.getParametersKVP(readParams);
        final int minX = originalRange.getLow(0);
        final int minY = originalRange.getLow(1);
        final int width = originalRange.getSpan(0);
        final int height = originalRange.getSpan(1);
        final int maxX = minX + (width <= 5 ? width : 5);
        final int maxY = minY + (height <= 5 ? height : 5);

        // we have to be sure that we are working against a valid grid range.
        final GridEnvelope2D testRange = new GridEnvelope2D(minX, minY, maxX, maxY);

        // build the corresponding envelope
        final MathTransform gridToWorldCorner = reader.getOriginalGridToWorld(PixelInCell.CELL_CORNER);
        final GeneralEnvelope testEnvelope = CRS.transform(gridToWorldCorner, new GeneralEnvelope(testRange.getBounds()));
        testEnvelope.setCoordinateReferenceSystem(nativeCRS);

        if (customParameters != null) {
          parameters.putAll(customParameters);
        }
       
        parameters.put(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString(), new GridGeometry2D(testRange, testEnvelope));

        // try to read this coverage
        gc = (GridCoverage2D) reader.read(CoverageUtils.getParameters(readParams, parameters, true));
        if (gc == null) {
            throw new Exception("Unable to acquire test coverage for format:" + format.getName());
        }

        // remove read grid geometry since it is request specific
        parameters.remove(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString());

        cinfo.getDimensions().addAll(getCoverageDimensions(gc.getSampleDimensions()));
        // TODO:
        // dimentionNames = getDimensionNames(gc);
        /*
         * StringBuilder cvName =null; int count = 0; while (true) { final StringBuilder key = new
         * StringBuilder(gc.getName().toString()); if (count > 0) { key.append("_").append(count); }
         *
         * Map coverages = dataConfig.getCoverages(); Set cvKeySet = coverages.keySet(); boolean
         * key_exists = false;
         *
         * for (Iterator it = cvKeySet.iterator(); it.hasNext();) { String cvKey = ((String)
         * it.next()).toLowerCase(); if (cvKey.endsWith(key.toString().toLowerCase())) { key_exists
         * = true; } }
         *
         * if (!key_exists) { cvName = key; break; } else { count++; } }
         *
         * String name = cvName.toString();
         */
        String name = gc.getName().toString();
        cinfo.setName(name);
        cinfo.setTitle(name);
        cinfo.setDescription(new StringBuilder("Generated from ").append(format.getName()).toString());

        // keywords
        cinfo.getKeywords().add("WCS");
        cinfo.getKeywords().add(format.getName());
        cinfo.getKeywords().add(name);

        // native format name
        cinfo.setNativeFormat(format.getName());
        cinfo.getMetadata().put("dirName", new StringBuilder(store.getName()).append("_").append(name).toString());

        // request SRS's
        if ((gc.getCoordinateReferenceSystem2D().getIdentifiers() != null)
                && !gc.getCoordinateReferenceSystem2D().getIdentifiers().isEmpty()) {
            cinfo.getRequestSRS().add(((Identifier) gc.getCoordinateReferenceSystem2D().getIdentifiers().toArray()[0]).toString());
        }

        // response SRS's
        if ((gc.getCoordinateReferenceSystem2D().getIdentifiers() != null)
                && !gc.getCoordinateReferenceSystem2D().getIdentifiers().isEmpty()) {
            cinfo.getResponseSRS().add(((Identifier) gc.getCoordinateReferenceSystem2D().getIdentifiers().toArray()[0]).toString());
        }

        // supported formats
        final List formats = CoverageStoreUtils.listDataFormats();
        for (Iterator i = formats.iterator(); i.hasNext();) {
            final Format fTmp = (Format) i.next();
            final String fName = fTmp.getName();

            if (fName.equalsIgnoreCase("WorldImage")) {
                // TODO check if coverage can encode Format
                cinfo.getSupportedFormats().add("GIF");
                cinfo.getSupportedFormats().add("PNG");
View Full Code Here

    }

    public static Format acquireFormat(String type)
        throws IOException {
        Format[] formats = GridFormatFinder.getFormatArray();
        Format format = null;
        final int length = formats.length;

        for (int i = 0; i < length; i++) {
            if (formats[i].getName().equals(type)) {
                format = formats[i];
View Full Code Here

     *
     * @return
     */
    public static Format aquireFactoryByType(String type) {
        final Format[] formats = GridFormatFinder.getFormatArray();
        Format format = null;
        final int length = formats.length;

        for (int i = 0; i < length; i++) {
            format = formats[i];

            if (format.getName().equals(type)) {
                return format;
            }
        }

        return null;
View Full Code Here

     *
     * @return
     */
    public static Format aquireFactory(String description) {
        Format[] formats = GridFormatFinder.getFormatArray();
        Format format = null;
        final int length = formats.length;

        for (int i = 0; i < length; i++) {
            format = formats[i];

            if (format.getDescription().equals(description)) {
                return format;
            }
        }

        return null;
View Full Code Here

        }

        final WorldImageWriter writer = new WorldImageWriter(output);

        // writing parameters for Image
        final Format writerParams = writer.getFormat();
        final ParameterValueGroup writeParameters = writerParams.getWriteParameters();
        final ParameterValue<?> format = writeParameters.parameter("Format");
        format.setValue(this.outputFormat.toLowerCase());
       
        try{
          // writing
View Full Code Here

        final ListView coverageLinks = new ListView("rasterResources", sortedCoverageNames) {
            @Override
            protected void populateItem(ListItem item) {
                final String coverageFactoryName = item.getDefaultModelObjectAsString();
                final Map<String, Format> coverages = getAvailableCoverageStores();
                Format format = coverages.get(coverageFactoryName);
                final String description = format.getDescription();
                SubmitLink link;
                link = new SubmitLink("resourcelink") {
                    @Override
                    public void onSubmit() {
                        setResponsePage(new CoverageStoreNewPage(coverageFactoryName));
                    }
                };
                link.setEnabled(thereAreWorkspaces);
                link.add(new Label("resourcelabel", coverageFactoryName));
                item.add(link);
                item.add(new Label("resourceDescription", description));
                Image icon = new Image("storeIcon", icons.getStoreIcon(format.getClass()));
                // TODO: icons could provide a description too to be used in alt=...
                icon.add(new AttributeModifier("alt", true, new Model("")));
                item.add(icon);
            }
        };
View Full Code Here

    }

    public static Format acquireFormat(String type)
        throws IOException {
        Format[] formats = GridFormatFinder.getFormatArray();
        Format format = null;
        final int length = formats.length;

        for (int i = 0; i < length; i++) {
            if (formats[i].getName().equals(type)) {
                format = formats[i];
View Full Code Here

     *
     * @return
     */
    public static Format aquireFactoryByType(String type) {
        final Format[] formats = GridFormatFinder.getFormatArray();
        Format format = null;
        final int length = formats.length;

        for (int i = 0; i < length; i++) {
            format = formats[i];

            if (format.getName().equals(type)) {
                return format;
            }
        }

        return null;
View Full Code Here

TOP

Related Classes of org.opengis.coverage.grid.Format

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.