Package org.opengis.referencing.crs

Examples of org.opengis.referencing.crs.CoordinateReferenceSystem


    public static CoveragePointInfo info2( ILayer layer, ReferencedEnvelope bbox, IProgressMonitor monitor ) throws IOException,
            InvalidGridGeometryException, TransformException {

        final Coordinate envelopeCenterOrig = bbox.centre();
        CoordinateReferenceSystem sourceCRS = bbox.getCoordinateReferenceSystem();
        final DecimalFormat formatter = new DecimalFormat("0.####");
        IGeoResource geoResource = layer.getGeoResource();

        GridCoverage2D coverage = null;
        GridGeometry2D gridGeometry = null;
        Coordinate evaluateCoord = null;
        // try to go for the reader first
        boolean isOnGrid = false;
        boolean hasProblem = false;
        Point2D p = null;
        if (geoResource.canResolve(AbstractGridCoverage2DReader.class)) {
            AbstractGridCoverage2DReader reader = geoResource.resolve(AbstractGridCoverage2DReader.class, monitor);
            GeneralEnvelope originalEnvelope = reader.getOriginalEnvelope();
            CoordinateReferenceSystem targetCrs = reader.getCrs();

            if (targetCrs != null) {
                evaluateCoord = transform(sourceCRS, targetCrs, envelopeCenterOrig);
            } else {
                evaluateCoord = envelopeCenterOrig;
                targetCrs = sourceCRS;
            }
            p = new Point2D.Double(evaluateCoord.x, evaluateCoord.y);
            if (originalEnvelope.contains(new DirectPosition2D(p))) {
                double delta = 0.0000001;
                GeneralParameterValue[] parameterValues = createGridGeometryGeneralParameter(1, 1, evaluateCoord.y + delta,
                        evaluateCoord.y - delta, evaluateCoord.x + delta, evaluateCoord.x - delta, targetCrs);
                coverage = reader.read(parameterValues);
                /*
                 * the following is done since the reader might read a singlwe pixel
                 * region and the gridcoordinate would be 0, 0 in that case. Later
                 * we want to supply the gridcoordinate of the position in the whole
                 * coverage.
                 */
                gridGeometry = new GridGeometry2D(reader.getOriginalGridRange(), reader.getOriginalEnvelope());
                isOnGrid = true;
            }
        }
        // else try with coverage
        else if (geoResource.canResolve(GridCoverage.class)) {
            coverage = (GridCoverage2D) geoResource.resolve(GridCoverage.class, monitor);
            CoordinateReferenceSystem targetCrs = coverage.getCoordinateReferenceSystem();
            gridGeometry = coverage.getGridGeometry();
            evaluateCoord = transform(sourceCRS, targetCrs, envelopeCenterOrig);
            p = new Point2D.Double(evaluateCoord.x, evaluateCoord.y);
            Envelope2D envelope2d = coverage.getEnvelope2D();
            if (envelope2d.contains(p)) {
View Full Code Here


     */
    public void op( final Display display, Object target, IProgressMonitor monitor )
            throws Exception {
       
        final Layer layer = (Layer) target;
        final CoordinateReferenceSystem layerCRS = layer.getCRS();
        final Envelope bounds = layer.getBounds(monitor, layerCRS);
       
        final List<SummaryData> data=new ArrayList<SummaryData>();
       
        data.add(new SummaryData(Messages.LayerSummary_name, layer.getName()));
        data.add(new SummaryData(Messages.LayerSummary_id,layer.getID()));
        data.add(new SummaryData(Messages.LayerSummary_zorder,layer.getZorder()));
        data.add(new SummaryData(Messages.LayerSummary_crs,layerCRS.getName()));
        data.add(new SummaryData(Messages.LayerSummary_bounds, parseBounds(bounds)));
        data.add(new SummaryData(Messages.LayerSummary_selection,layer.getFilter()));

        display.asyncExec(new Runnable(){
            public void run() {
View Full Code Here

            crsCodes.add( code );
        }
        // Second pass based on CoordinateReferenceSystem equality
        for( String code : codes ) {
            try {              
                CoordinateReferenceSystem check = CRS.decode( code );
                if( crs.equals( check )) {
                    // note we are trusting the code of the matched crs
                    // (because if the id provided by crs worked we would
                    // not get this far
                    //
                    return check.getIdentifiers().iterator().next().getCode();
                }               
            } catch (NoSuchAuthorityCodeException e) {
                // could not understand code
            } catch (FactoryException e) {
                // could not understand code               
            }
        }
        // last pass do the power set lookup based on id
        //
        for( String code : codes ) {
            try {              
                CoordinateReferenceSystem check = CRS.decode( code );
                for( Identifier checkId : check.getIdentifiers() ) {
                    String checkCode = checkId.toString();
                    if( crsCodes.contains( checkCode ) ) {
                        return code;
                    }                   
                }               
View Full Code Here

        SimpleFeatureType schema = source.getSchema();
        GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
        IViewportModel viewportModel = ApplicationGIS.getActiveMap().getViewportModel();
        ReferencedEnvelope bounds = viewportModel.getBounds();
        CoordinateReferenceSystem dataCrs = schema.getCoordinateReferenceSystem();
       
        ReferencedEnvelope newBounds = bounds.transform(dataCrs, true);
       
        String name = geometryDescriptor.getLocalName();
        Filter bboxFilter = getBboxFilter(name, newBounds);
View Full Code Here

        ViewportGraphics g = context.getGraphics();
        g.setColor(Color.RED);
        g.setStroke(ViewportGraphics.LINE_SOLID, 2);
       
        // figure out our CRS
        CoordinateReferenceSystem ourCRS = crs;
        if (ourCRS == null) {
            ourCRS = context.getLayer().getCRS();
        }
       
        // figure out how to map our coordinate to the world
        CoordinateReferenceSystem worldCRS = context.getCRS();
        MathTransform dataToWorld;
        try {
            dataToWorld = CRS.findMathTransform(ourCRS, worldCRS, false);
        } catch (FactoryException e1) {
            throw (RuntimeException) new RuntimeException( ).initCause( e1 );
View Full Code Here

    public ReferencedEnvelope getBounds() {
      ReferencedEnvelope bounds = new ReferencedEnvelope( delegate.getBounds());
      if( bounds != null ) return bounds;
     
      CoordinateReferenceSystem crs = featureType.getCoordinateReferenceSystem();   
     
        return new ReferencedEnvelope( defaultGeometry.getEnvelopeInternal(), crs );
    }
View Full Code Here

    public void op( Display display, Object target, IProgressMonitor monitor ) throws Exception {
        ILayer layer = (ILayer) target;
        IMap map = layer.getMap();
       
        final CoordinateReferenceSystem after = layer.getCRS();
       
        MapCommand changeProjection = new ChangeCRSCommand(after);
        map.sendCommandASync( changeProjection );
       
    }
View Full Code Here

        // initialize the graphics handle
        graphics.setForeground(Display.getCurrent().getSystemColor(this.color));
        graphics.setBackground(Display.getCurrent().getSystemColor(this.color));
       
        // figure out our CRS
        CoordinateReferenceSystem ourCRS = crs;
        if (ourCRS == null) {
            ourCRS = gp.getSite().getCRS();
        }

        resolution = gp.getSite().getViewportModel().getWidth() / gp.getSite().getMapDisplay().getWidth();
       
        // figure out how to map our coordinate to the world
        CoordinateReferenceSystem worldCRS =gp.getSite().getMap().getViewportModel().getCRS();
        MathTransform dataToWorld;
        try {
            dataToWorld = CRS.findMathTransform(ourCRS, worldCRS, false);
        } catch (FactoryException e1) {
            throw (RuntimeException) new RuntimeException( ).initCause( e1 );
View Full Code Here

            if (textData == null || textData.trim().length() == 0) {
                filter = Filter.INCLUDE;
            } else {
                filter = readFilter(decode(textData));
            }
            CoordinateReferenceSystem crs = readCRS(memento.getString(CRS));
            CoordinateReferenceSystem reproject = readCRS(memento.getString(REPOJECT));
            String handle = decode(memento.getString(HANDLE));
            Integer maxFeature = memento.getInteger(MAX_FEATURES);
            URI namespace;
            try {
                String uriString = decode(memento.getString(NAMESPACE));
View Full Code Here

                viewRestriction = new DefaultQuery("Feature", filter);
            } else {
                viewRestriction = (Query) value;
            }
            Filter filter;
            CoordinateReferenceSystem crs;
            CoordinateReferenceSystem reproject;
            String handle;
            int maxFeature;
            URI namespace;
            String[] propertyNames;
            String typeName;
            filter = viewRestriction.getFilter();
            crs = viewRestriction.getCoordinateSystem();
            reproject = viewRestriction.getCoordinateSystemReproject();
            handle = viewRestriction.getHandle();
            maxFeature = viewRestriction.getMaxFeatures();
            namespace = viewRestriction.getNamespace();
            propertyNames = viewRestriction.getPropertyNames();
            typeName = viewRestriction.getTypeName();

            StringBuilder propertyNamesString = new StringBuilder();
            if (propertyNames != null) {
                for( String string : propertyNames ) {
                    propertyNamesString.append(string);
                    propertyNamesString.append(',');
                }
            }

            if (filter != null) {
                FilterTransformer transformer = new FilterTransformer();

                try {
                    if (filter == Filter.EXCLUDE) {
                        memento.putTextData("all");
                    } else {
                        memento.putTextData(encode(transformer.transform(filter)));
                    }
                } catch (TransformerException e) {
                    throw new RuntimeException(
                            "Unable to convert filter to string I couldn't save the view query");
                }
            }
            if (crs != null) {
                memento.putString(CRS, encode(crs.toWKT()));
            }
            if (reproject != null) {
                memento.putString(REPOJECT, encode(reproject.toWKT()));
            }
            if (handle != null) {
                memento.putString(HANDLE, encode(handle));
            }
            if (maxFeature != Integer.MAX_VALUE) {
View Full Code Here

TOP

Related Classes of org.opengis.referencing.crs.CoordinateReferenceSystem

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.