Package org.geotools.gce.grassraster

Examples of org.geotools.gce.grassraster.JGrassRegion


        if (adaptee.isAssignableFrom(CoordinateReferenceSystem.class)) {
            return adaptee.cast(locationCrs);
        }
        if (adaptee.isAssignableFrom(GridGeometry2D.class)) {
            try {
                JGrassRegion r = jGrassMapEnvironment.getFileRegion();
                Envelope2D envelope = new Envelope2D(locationCrs, r.getWest(), r.getSouth(), r.getEast() - r.getWest(),
                        r.getNorth() - r.getSouth());
                GridEnvelope2D gridRange = new GridEnvelope2D(0, 0, r.getCols(), r.getRows());
                GridGeometry2D gridGeometry2D = new GridGeometry2D(gridRange, (org.opengis.geometry.Envelope) envelope);
                return adaptee.cast(gridGeometry2D);
            } catch (Exception e) {
                msg = e;
            }
        }
        if (adaptee.isAssignableFrom(GridCoverage.class)) {
            try {
                JGrassRegion jGrassRegion = jGrassMapEnvironment.getFileRegion();
                GridCoverage2D mapCoverage = JGrassCatalogUtilities.getGridcoverageFromGrassraster(jGrassMapEnvironment,
                        jGrassRegion);
                return adaptee.cast(mapCoverage);
            } catch (Exception e) {
                msg = e;
View Full Code Here


                }
                jGrassMapsetGeoResource = selectedLayers.get(0);
                String windPath = jGrassMapsetGeoResource.getActiveRegionWindowPath();
                windPathText.setText(windPath);

                JGrassRegion jgR = jGrassMapsetGeoResource.getActiveRegionWindow();
                CoordinateReferenceSystem crs = jGrassMapsetGeoResource.getLocationCrs();

                commitToBlackboards(jgR, crs, windPath);
            }

        });

        // the group for the region
        Group regionGroup = new Group(c, SWT.BORDER);
        GridLayout layout2 = new GridLayout(2, true);
        regionGroup.setLayout(layout2);
        regionGroup.setText("Region settings");
        regionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

        northLabel = new Label(regionGroup, SWT.NONE);
        northLabel.setText("north");
        northLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        northText = new Text(regionGroup, SWT.BORDER);
        northText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        southLabel = new Label(regionGroup, SWT.NONE);
        southLabel.setText("south");
        southLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        southText = new Text(regionGroup, SWT.BORDER);
        southText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        westLabel = new Label(regionGroup, SWT.NONE);
        westLabel.setText("west");
        westLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        westText = new Text(regionGroup, SWT.BORDER);
        westText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        eastLabel = new Label(regionGroup, SWT.NONE);
        eastLabel.setText("east");
        eastLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        eastText = new Text(regionGroup, SWT.BORDER);
        eastText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        rowsLabel = new Label(regionGroup, SWT.NONE);
        rowsLabel.setText("rows");
        rowsLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        rowsText = new Text(regionGroup, SWT.BORDER);
        rowsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        colsLabel = new Label(regionGroup, SWT.NONE);
        colsLabel.setText("cols");
        colsLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        colsText = new Text(regionGroup, SWT.BORDER);
        colsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        xresLabel = new Label(regionGroup, SWT.NONE);
        xresLabel.setText("xres");
        xresLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        xresText = new Text(regionGroup, SWT.BORDER);
        xresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        yresLabel = new Label(regionGroup, SWT.NONE);
        yresLabel.setText("yres");
        yresLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        yresText = new Text(regionGroup, SWT.BORDER);
        yresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

        // the group for the style
        Group styleGroup = new Group(c, SWT.BORDER);
        GridLayout layout3 = new GridLayout(2, true);
        styleGroup.setLayout(layout3);
        styleGroup.setText("Style properties");
        styleGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

        gridButton = new Button(styleGroup, SWT.BORDER | SWT.CHECK);
        gridButton.setText("visualize active region grid");
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
        gridData.horizontalSpan = 2;
        gridButton.setLayoutData(gridData);

        Label backgroundColourLabel = new Label(styleGroup, SWT.NONE);
        backgroundColourLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        backgroundColourLabel.setText("background color");
        backgroundColour = new ColorEditor(styleGroup);
        backgroundColour.getButton().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        Label backgroundAlphaLabel = new Label(styleGroup, SWT.NONE);
        backgroundAlphaLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        backgroundAlphaLabel.setText("background alpha (0-1)");
        backgroundAlphaText = new Text(styleGroup, SWT.BORDER);
        backgroundAlphaText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        Label foregroundColourLabel = new Label(styleGroup, SWT.NONE);
        foregroundColourLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        foregroundColourLabel.setText("foreground color");
        foregroundColor = new ColorEditor(styleGroup);
        foregroundColor.getButton().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        Label forgroundAlphaLabel = new Label(styleGroup, SWT.NONE);
        forgroundAlphaLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        forgroundAlphaLabel.setText("foreground alpha (0-1)");
        forgroundAlphaText = new Text(styleGroup, SWT.BORDER);
        forgroundAlphaText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

        // the group for the set region to map
        final Group settoGroup = new Group(c, SWT.BORDER);
        GridLayout layout4 = new GridLayout(1, true);
        settoGroup.setLayout(layout4);
        settoGroup.setText("Set region to...");
        settoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

        rasterMapSetButton = new Button(settoGroup, SWT.NONE);
        rasterMapSetButton.setText("set region to raster map");
        rasterMapSetButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        rasterMapSetButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
            public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
                JGRasterChooserDialog tree = new JGRasterChooserDialog(null);
                tree.open(settoGroup.getShell(), SWT.SINGLE);

                update(tree.getSelectedResources());
            }
        });
        featuresMapSetButton = new Button(settoGroup, SWT.NONE);
        featuresMapSetButton.setText("set region to vector map");
        featuresMapSetButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        featuresMapSetButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
            public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
                FeatureChooserDialog tree = new FeatureChooserDialog();
                tree.open(settoGroup.getShell(), SWT.SINGLE);

                update(tree.getSelectedResources());
            }
        });
        resetToActiveButton = new Button(settoGroup, SWT.NONE);
        resetToActiveButton.setText("reset back to actual region");
        resetToActiveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
        resetToActiveButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
            public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
                String windPath = windPathText.getText();
                try {
                    JGrassRegion jgR = new JGrassRegion(windPath);
                    setWidgetsToWindow(jgR);
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
View Full Code Here

            if (style.windPath == null) {
                CatalogJGrassMapsetTreeViewerDialog mapsetDialog = new CatalogJGrassMapsetTreeViewerDialog();
                mapsetDialog.open(parent.getShell());
                jGrassMapsetGeoResource = mapsetDialog.getSelectedLayers().get(0);

                JGrassRegion activeRegionWindow = jGrassMapsetGeoResource.getActiveRegionWindow();
                style.windPath = jGrassMapsetGeoResource.getActiveRegionWindowPath();
                style.north = (float) activeRegionWindow.getNorth();
                style.south = (float) activeRegionWindow.getSouth();
                style.west = (float) activeRegionWindow.getWest();
                style.east = (float) activeRegionWindow.getEast();
                style.rows = activeRegionWindow.getRows();
                style.cols = activeRegionWindow.getCols();

                CoordinateReferenceSystem jGrassCrs = jGrassMapsetGeoResource.getLocationCrs();
                try {
                    Integer epsg = CRS.lookupEpsgCode(jGrassCrs, true);
                    style.crsString = "EPSG:" + epsg;
                } catch (Exception e) {
                    // try non epsg
                    style.crsString = CRS.lookupIdentifier(jGrassCrs, true);
                }
            }
            windPathText.setText(style.windPath);

            JGrassRegion tmp = new JGrassRegion(style.west, style.east, style.south, style.north, style.rows, style.cols);
            // set initial values
            isWorking = true;
            northText.setText(String.valueOf(style.north));
            southText.setText(String.valueOf(style.south));
            westText.setText(String.valueOf(style.west));
            eastText.setText(String.valueOf(style.east));
            xresText.setText(String.valueOf(tmp.getWEResolution()));
            yresText.setText(String.valueOf(tmp.getNSResolution()));
            colsText.setText(String.valueOf(style.cols));
            rowsText.setText(String.valueOf(style.rows));
            isWorking = false;

            forgroundAlphaText.setText(Float.toString(style.fAlpha));
View Full Code Here

     * mapset.
     * @throws IOException
     */
    public JGrassRegion getActiveWindow() throws IOException {
        if (JGrassMapGeoResource.this.type.equals(JGrassConstants.GRASSBINARYRASTERMAP)) {
            JGrassRegion activeRegion = jGrassMapEnvironment.getActiveRegion();
            return activeRegion;
        }

        return null;
    }
View Full Code Here

                if (layer instanceof JGrassMapGeoResource) {
                    JGrassMapGeoResource rasterMapResource = (JGrassMapGeoResource) layer;
                    try {
                        text = rasterMapResource.getInfo(null).getName();

                        JGrassRegion fileWindow = rasterMapResource.getFileWindow();
                        if (fileWindow != null) {
                            setWidgetsToWindow(fileWindow);
                        }
                    } catch (IOException e1) {
                        return;
                    }
                } else if (layer instanceof DataStore || layer instanceof UDIGFeatureStore) {
                    try {
                        DataStore store = ((DataStore) layer);
                        FeatureSource featureStore = store.getFeatureSource(store.getTypeNames()[0]);
                        Envelope envelope = featureStore.getBounds();

                        ActiveRegionStyle style = getActiveRegionStyle();
                        JGrassRegion activeWindow = new JGrassRegion(style.west, style.east, style.south, style.north,
                                style.rows, style.cols);
                        JGrassRegion newWindow = JGrassRegion.adaptActiveRegionToEnvelope(envelope, activeWindow);
                        northText.setText(String.valueOf(newWindow.getNorth()));
                        southText.setText(String.valueOf(newWindow.getSouth()));
                        eastText.setText(String.valueOf(newWindow.getEast()));
                        westText.setText(String.valueOf(newWindow.getWest()));
                        textModified(bound_type);
                    } catch (IOException e1) {
                        e1.printStackTrace();
                        return;
                    }
View Full Code Here

            this.description = JGrassMapGeoResource.this.type;

            try {
                if (JGrassMapGeoResource.this.type.equals(JGrassConstants.GRASSBINARYRASTERMAP)) {
                    File cellhd = jGrassMapEnvironment.getCELLHD();
                    fileWindow = new JGrassRegion(cellhd.getAbsolutePath());
                    bounds = new ReferencedEnvelope(fileWindow.getEnvelope(), locationCrs);
                    super.icon = gridIconID;
                } else {
                    super.icon = gridMissingIconID;
                }
View Full Code Here

        double e = Double.parseDouble(eastText.getText());
        double xr = Double.parseDouble(xresText.getText());
        double yr = Double.parseDouble(yresText.getText());

        // write the region to file
        JGrassRegion newRegion = new JGrassRegion(w, e, s, n, xr, yr);
        try {
            File mapsetFile = new File(style.windPath).getParentFile();
            File locationFile = mapsetFile.getParentFile();
            JGrassRegion.writeWINDToMapset(mapsetFile.getAbsolutePath(), newRegion);
            CoordinateReferenceSystem locationCrs = JGrassCatalogUtilities.getLocationCrs(locationFile.getAbsolutePath());
View Full Code Here

                    List<JGrassMapsetGeoResource> selectedLayers = mapsetDialog.getSelectedLayers();
                    if (selectedLayers==null || selectedLayers.size() == 0) {
                        return;
                    }
                    JGrassMapsetGeoResource jGrassMapsetGeoResource = selectedLayers.get(0);
                    JGrassRegion activeRegionWindow = jGrassMapsetGeoResource.getActiveRegionWindow();
                    ActiveRegionStyle style = (ActiveRegionStyle) styleBlackboard.get(ActiveregionStyleContent.ID);
                    style.windPath = jGrassMapsetGeoResource.getActiveRegionWindowPath();
                    style.north = (float) activeRegionWindow.getNorth();
                    style.south = (float) activeRegionWindow.getSouth();
                    style.east = (float) activeRegionWindow.getEast();
                    style.west = (float) activeRegionWindow.getWest();
                    style.rows = activeRegionWindow.getRows();
                    style.cols = activeRegionWindow.getCols();

                    CoordinateReferenceSystem jGrassCrs = jGrassMapsetGeoResource.getLocationCrs();
                    String code = null;
                    try {
                        Integer epsg = CRS.lookupEpsgCode(jGrassCrs, true);
View Full Code Here

                            for( Object object : toList ) {
                                if (object instanceof JGrassMapGeoResource) {
                                    JGrassMapGeoResource mr = (JGrassMapGeoResource) object;
                                    File mapFile = mr.getMapFile();
                                    JGrassMapEnvironment mapEnvironment = new JGrassMapEnvironment(mapFile);
                                    JGrassRegion jGrassRegion = mapEnvironment.getActiveRegion();

                                    GeneralParameterValue[] readParams = createGridGeometryGeneralParameter(
                                            jGrassRegion.getCols(), jGrassRegion.getRows(), jGrassRegion.getNorth(),
                                            jGrassRegion.getSouth(), jGrassRegion.getEast(), jGrassRegion.getWest(),
                                            mapEnvironment.getCoordinateReferenceSystem());

                                    AbstractGridFormat format = (AbstractGridFormat) new GrassCoverageFormatFactory()
                                            .createFormat();
                                    GridCoverageReader reader = format.getReader(mapEnvironment.getCELL());
View Full Code Here

                IMap activeMap = ApplicationGIS.getActiveMap();
                IBlackboard blackboard = activeMap.getBlackboard();
                ActiveRegionStyle style = (ActiveRegionStyle) blackboard.get(ActiveregionStyleContent.ID);
                if (style != null) {
                    try {
                        JGrassRegion activeRegion = new JGrassRegion(style.windPath);
                        JGrassRegion newActiveRegion = JGrassRegion.adaptActiveRegionToEnvelope(bounds, activeRegion);
                        JGrassRegion.writeWINDToMapset(new File(style.windPath).getParent(), newActiveRegion);
                        style.north = (float) newActiveRegion.getNorth();
                        style.south = (float) newActiveRegion.getSouth();
                        style.east = (float) newActiveRegion.getEast();
                        style.west = (float) newActiveRegion.getWest();
                        style.rows = newActiveRegion.getRows();
                        style.cols = newActiveRegion.getCols();

                        blackboard.put(ActiveregionStyleContent.ID, style);

                        activeRegionLayer.refresh(null);
                    } catch (IOException e1) {
View Full Code Here

TOP

Related Classes of org.geotools.gce.grassraster.JGrassRegion

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.