Examples of JGrassMapGeoResource


Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

        Layer layer = getSelectedLayer();
        IGeoResource resource = layer.getGeoResource();

        if (resource.canResolve(JGrassMapGeoResource.class)) {
            try {
                JGrassMapGeoResource grassMapGeoResource = resource.resolve(
                        JGrassMapGeoResource.class, null);
                if (grassMapGeoResource.getType().equals(JGrassConstants.GRASSBINARYRASTERMAP)) {
                    editorSupported = true;
                } else {
                    editorSupported = false;
                }
                type = grassMapGeoResource.getType();

            } catch (IOException e) {
                JGrassrasterStyleActivator.log("JGrassrasterStyleActivator problem", e); //$NON-NLS-1$
                e.printStackTrace();
            }
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

                String value = labelProvider.getText(domain);
                itemNames.add(value);
            }
            itemLayers = new ArrayList<IGeoResource>();
            for( String name : itemNames ) {
                JGrassMapGeoResource tmpLayer = itemsMap.get(name);
                if (tmpLayer != null) {
                    itemLayers.add(tmpLayer);
                }
            }
        }
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

            final IGeoResource resource = getContext().getGeoResource();
            if (resource == null || !resource.canResolve(JGrassMapGeoResource.class)) {
                return;
            }
            JGrassMapGeoResource grassMapGeoResource = resource.resolve(JGrassMapGeoResource.class, monitor);

            JGrassRegion fileWindow = new JGrassRegion(grassMapGeoResource.getFileWindow());
            JGrassMapsetGeoResource parent = (JGrassMapsetGeoResource) grassMapGeoResource.parent(new NullProgressMonitor());
            CoordinateReferenceSystem grassCrs = parent.getLocationCrs();
            JGrassRegion screenDrawWindow = new JGrassRegion(envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(),
                    envelope.getMaxY(), fileWindow.getRows(), fileWindow.getCols());

            // to intersect with the data window, we transform the screen window
            JGrassRegion reprojectedScreenDrawWindow = screenDrawWindow;
            if (!CRS.equalsIgnoreMetadata(destinationCRS, grassCrs)) {
                reprojectedScreenDrawWindow = screenDrawWindow.reproject(destinationCRS, grassCrs, true);
            }

            /*
             * if the map is not visible, do not render it
             */
            // JGrassRegion fileWindow = grassMapGeoResource.getFileWindow();
            Rectangle2D.Double fileRectDouble = fileWindow.getRectangle();
            Double reprojScreenRectangle = reprojectedScreenDrawWindow.getRectangle();
            if (!reprojScreenRectangle.intersects(fileRectDouble)) {
                getContext().setStatus(ILayer.DONE);
                getContext().setStatusMessage(THE_MAP_IS_OUTSIDE_OF_THE_VISIBLE_REGION);
                System.out.println(THE_MAP_IS_OUTSIDE_OF_THE_VISIBLE_REGION);
                return;
            }
            /*
             * we will draw only the intersection of the map in the display system = part of visible map
             */
            Rectangle2D drawMapRectangle = reprojectedScreenDrawWindow.getRectangle().createIntersection(fileRectDouble);
            // Rectangle2D drawMapRectangle = fileRectDouble.getBounds2D();
            // resolution is that of the file window
            double ewRes = fileWindow.getWEResolution();
            double nsRes = fileWindow.getNSResolution();
            if (fileRectDouble.getWidth() < ewRes || fileRectDouble.getHeight() < nsRes) {
                getContext().setStatus(ILayer.DONE);
                getContext().setStatusMessage(THE_MAP_IS_OUTSIDE_OF_THE_VISIBLE_REGION);
                System.out.println(THE_MAP_IS_OUTSIDE_OF_THE_VISIBLE_REGION);
                return;
            }
            MathTransform transform = CRS.findMathTransform(destinationCRS, grassCrs, true);
            Coordinate pixelSize = getContext().getPixelSize();

            Coordinate c1 = new Coordinate(envelope.getMinX(), envelope.getMinY());
            Coordinate c2 = new Coordinate(envelope.getMinX() + pixelSize.x, envelope.getMinY() + pixelSize.y);
            Envelope envy = new Envelope(c1, c2);
            Envelope envyTrans = JTS.transform(envy, transform);

            pixelSize = new Coordinate(envyTrans.getWidth(), envyTrans.getHeight());
            /*
             * if the resolution is higher of that of the screen, it doesn't make much sense to draw it
             * all. So for visualization we just use the screen resolution to do things faster.
             */
            if (ewRes < pixelSize.x) {
                ewRes = pixelSize.x;
            }
            if (nsRes < pixelSize.y) {
                nsRes = pixelSize.y;
            }
            fileWindow.setNSResolution(nsRes);
            fileWindow.setWEResolution(ewRes);
            nsRes = fileWindow.getNSResolution();
            ewRes = fileWindow.getWEResolution();
            /*
             * redefine the region of the map to be drawn
             */
            /*
             * snap the screen to fit into the active region grid. This is mandatory for the exactness
             * of the query of the pixels (ex. d.what.rast).
             */
            JGrassRegion activeWindow = grassMapGeoResource.getActiveWindow();
            Coordinate minXY = JGrassRegion.snapToNextHigherInRegionResolution(drawMapRectangle.getMinX(),
                    drawMapRectangle.getMinY(), activeWindow);
            Coordinate maxXY = JGrassRegion.snapToNextHigherInRegionResolution(drawMapRectangle.getMaxX(),
                    drawMapRectangle.getMaxY(), activeWindow);

            JGrassRegion drawMapRegion = new JGrassRegion(minXY.x, maxXY.x, minXY.y, maxXY.y, ewRes, nsRes);
            // JGrassRegion drawMapRegion = new JGrassRegion(drawMapRectangle.getMinX(),
            // drawMapRectangle.getMaxX(), drawMapRectangle.getMinY(), drawMapRectangle
            // .getMaxY(), ewRes, nsRes);
            JGrassMapEnvironment grassMapEnvironment = grassMapGeoResource.getjGrassMapEnvironment();
            GridCoverage2D coverage = JGrassCatalogUtilities.getGridcoverageFromGrassraster(grassMapEnvironment, drawMapRegion);
            coverage = coverage.view(ViewType.RENDERED);
            if (coverage != null) {

                // setting rendering hints
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

                                regionString.append(rows);
                                regionString.append("\ncols=");
                                regionString.append(cols);

                            } else if (object instanceof JGrassMapGeoResource) {
                                JGrassMapGeoResource mr = (JGrassMapGeoResource) object;
                                File mapFile = mr.getMapFile();
                                JGrassMapEnvironment mapEnvironment = new JGrassMapEnvironment(mapFile);
                                JGrassRegion jGrassRegion = mapEnvironment.getActiveRegion();

                                int cols = jGrassRegion.getCols();
                                int rows = jGrassRegion.getRows();
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

                                JGrassRegion currentRegion = null;
                                JGrassMapEnvironment grassMapEnvironment = null;

                                for( Object object : toList ) {
                                    if (object instanceof JGrassMapGeoResource) {
                                        JGrassMapGeoResource mr = (JGrassMapGeoResource) object;
                                        JGrassRegion fileWindow = mr.getFileWindow();
                                        if (currentRegion == null) {
                                            currentRegion = mr.getActiveWindow();
                                            grassMapEnvironment = mr.getjGrassMapEnvironment();
                                        }

                                        Envelope envelope = fileWindow.getEnvelope();
                                        if (bounds == null) {
                                            bounds = envelope;
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

            String mapName = null;
            String mapsetPath = null;
            List layers = (List) updatedObject;
            for( Object layer : layers ) {
                if (layer instanceof JGrassMapGeoResource) {
                    JGrassMapGeoResource rasterMapResource = (JGrassMapGeoResource) layer;
                    try {
                        mapName = rasterMapResource.getInfo(null).getTitle();
                        mapsetPath = ((JGrassMapsetGeoResource) rasterMapResource.parent(null)).getFile().getAbsolutePath();
                        if (mapName != null && mapsetPath != null) {
                            String colrPath = mapsetPath + File.separator + JGrassConstants.COLR + File.separator + mapName;
                            makeSomeColor(colrPath);
                        }
                    } catch (IOException e) {
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

        Layer layer = getSelectedLayer();
        IGeoResource resource = layer.getGeoResource();

        if (resource.canResolve(JGrassMapGeoResource.class)) {
            try {
                JGrassMapGeoResource grassMapGeoResource = resource.resolve(
                        JGrassMapGeoResource.class, null);
                if (grassMapGeoResource.getType().equals(JGrassConstants.GRASSBINARYRASTERMAP)) {
                    editorSupported = true;
                } else {
                    editorSupported = false;
                }
                type = grassMapGeoResource.getType();

            } catch (IOException e) {
                JGrassrasterStyleActivator.log("JGrassrasterStyleActivator problem", e); //$NON-NLS-1$
                e.printStackTrace();
            }
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

            String mapName = null;
            String mapsetPath = null;
            List layers = (List) updatedObject;
            for( Object layer : layers ) {
                if (layer instanceof JGrassMapGeoResource) {
                    JGrassMapGeoResource rasterMapResource = (JGrassMapGeoResource) layer;
                    try {
                        mapName = rasterMapResource.getInfo(null).getTitle();
                        mapsetPath = ((JGrassMapsetGeoResource) rasterMapResource.parent(null)).getFile().getAbsolutePath();
                        if (mapName != null && mapsetPath != null) {
                            String catsPath = mapsetPath + File.separator + JGrassConstants.CATS + File.separator + mapName;
                            makeSomeCategories(catsPath);
                        }
                    } catch (IOException e) {
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

                    public void run() {
                        JGRasterChooserDialog chooserDialog = new JGRasterChooserDialog(null);
                        chooserDialog.open(shell, SWT.SINGLE);
                        List<JGrassMapGeoResource> resources = chooserDialog.getSelectedResources();
                        if (resources != null && resources.size() > 0) {
                            JGrassMapGeoResource res = resources.get(0);
                            File mapFile = res.getMapFile();
                            legendStyle.mapPath = mapFile.getAbsolutePath();
                            blackboard.put(RasterLegendStyleContent.ID, legendStyle);
                            // ((StyleBlackboard) blackboard).setSelected(new
                            // String[]{RasterLegendStyleContent.ID});
                        }
View Full Code Here

Examples of org.locationtech.udig.catalog.jgrass.core.JGrassMapGeoResource

            public void widgetSelected( SelectionEvent e ) {
                JGRasterChooserDialog cDialog = new JGRasterChooserDialog(null);
                cDialog.open(mapButton.getShell(), SWT.SINGLE);

                List<JGrassMapGeoResource> selectedResource = cDialog.getSelectedResources();
                JGrassMapGeoResource jGrassMapGeoResource = selectedResource.get(0);
                File mapFile = jGrassMapGeoResource.getMapFile();
                String name = mapFile.getName();
                mapNameLabel.setText(name);
                if (style == null)
                    checkStyle();
                style.mapPath = mapFile.getAbsolutePath();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.