Package org.geotools.geometry.jts

Examples of org.geotools.geometry.jts.ReferencedEnvelope


        if (null != ogEnvelope) {
          Envelope envelope = new Envelope(ogEnvelope.getLowerCorner().getCoordinate()[0], ogEnvelope
              .getUpperCorner().getCoordinate()[0], ogEnvelope.getLowerCorner().getCoordinate()[1],
              ogEnvelope.getUpperCorner().getCoordinate()[1]);
          log.info("CRS " + targetCrs.getId() + " envelope " + envelope);
          ReferencedEnvelope refEnvelope = new ReferencedEnvelope(envelope, targetCrs);
          transformableArea = refEnvelope.transform(sourceCrs, true);
          log.info("transformable area for " + key + " is " + transformableArea);
        }
      } catch (MismatchedDimensionException mde) {
        log.warn("Cannot build transformableArea for CRS transformation between " + sourceCrs.getId() + " and "
            + targetCrs.getId() + ", " + mde.getMessage());
View Full Code Here


          envelope = envelope.intersection(transformableArea);
        }
        if (envelope.isNull()) {
          return new Bbox();
        } else {
          ReferencedEnvelope refEnvelope = new ReferencedEnvelope(envelope, crsTransform.getSource());
          envelope = refEnvelope.transform(crsTransform.getTarget(), true);
          return new Bbox(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight());
        }
      } else {
        return source;
      }
View Full Code Here

          source = source.intersection(transformableArea);
        }
        if (source.isNull()) {
          return source;
        } else {
          ReferencedEnvelope refEnvelope = new ReferencedEnvelope(source, crsTransform.getSource());
          return refEnvelope.transform(crsTransform.getTarget(), true);
        }
      } else {
        return source;
      }
    } catch (Exception e) { // typically TopologyException, TransformException or FactoryException, but be safe
View Full Code Here

    @Override
    public ReferencedEnvelope getExtent() {
        Geometry geometry = getGeometry();
        if (geometry != null){
            CoordinateReferenceSystem crs = getCrs();
            return new ReferencedEnvelope(geometry.getEnvelopeInternal(), crs);
        }
        return null;
    }
View Full Code Here

                @SuppressWarnings("unchecked")
                public void run(IProgressMonitor monitor) throws InvocationTargetException,
                        InterruptedException {
                    monitor.beginTask(Messages.ArrowSelection_0, 5);
                    ReferencedEnvelope bbox = getContext().getBoundingBox(new Point(x, y), 5);
                    SimpleFeatureCollection collection = null;
                    FeatureIterator<SimpleFeature> iter = null;
                    try {
                        ILayer selectedLayer = getContext().getSelectedLayer();
                        SimpleFeatureSource source = selectedLayer.getResource(
View Full Code Here

        ILayer layer = getContext().getSelectedLayer();
        if (layer.hasResource(SimpleFeatureSource.class)) {
            try {
                SimpleFeatureSource resource = featureSource(layer);
                Query query = layer.getQuery(true);
                ReferencedEnvelope bounds = resource.getBounds(query);
                if (bounds == null) {
                  FeatureCollection<SimpleFeatureType, SimpleFeature> featureResult = resource.getFeatures(query);
                  if (featureResult != null && !featureResult.isEmpty()) {
                    ReferencedEnvelope envelope = featureResult.getBounds();
                    if (envelope != null) {
                      bounds = new ReferencedEnvelope(envelope, layer.getCRS());
                    }
                  }
                }
               
                if (bounds != null) {
View Full Code Here

      try {
        @SuppressWarnings("unchecked")
        FeatureSource<SimpleFeatureType, SimpleFeature> source = owner
            .resolve(FeatureSource.class, new NullProgressMonitor());
        ReferencedEnvelope temp = source.getBounds();

        bounds = temp;
        if (bounds == null) {
          CoordinateReferenceSystem crs = getCRS();
          // try getting an envelope out of the crs
          org.opengis.geometry.Envelope envelope = CRS
              .getEnvelope(crs);

          if (envelope != null) {
            bounds = new ReferencedEnvelope(new Envelope(envelope
                .getLowerCorner().getOrdinate(0), envelope
                .getUpperCorner().getOrdinate(0), envelope
                .getLowerCorner().getOrdinate(1), envelope
                .getUpperCorner().getOrdinate(1)), crs);
          } else {
            // TODO: perhaps access a preference which indicates
            // whether to do a full table scan
            // bounds = new ReferencedEnvelope(new Envelope(),crs);
            // as a last resort do the full scan
            bounds = new ReferencedEnvelope(new Envelope(), crs);
            FeatureIterator<SimpleFeature> iter = source
                .getFeatures().features();
            try {
              while (iter.hasNext()) {
                SimpleFeature element = iter.next();
                if (bounds.isNull())
                  bounds.init(element.getBounds());
                else
                  bounds.include(element.getBounds());
              }
            } finally {
              iter.close();
            }
          }
        }
      } catch (DataSourceException e) {
        Activator.log(
            "Exception while generating TeradataGeoResource.", e); //$NON-NLS-1$
      } catch (Exception e) {
        CatalogPlugin
            .getDefault()
            .getLog()
            .log(new org.eclipse.core.runtime.Status(
                IStatus.WARNING,
                "org.locationtech.udig.catalog", 0, Messages.TeradataGeoResource_error_layer_bounds, e)); //$NON-NLS-1$
        bounds = new ReferencedEnvelope(new Envelope(), null);
      }

    }
    return bounds;
  }
View Full Code Here

                    // try getting an envelope out of the crs
                    org.opengis.geometry.Envelope envelope = CRS.getEnvelope(crs);

                    if (envelope != null) {
                        bounds = new ReferencedEnvelope(new Envelope(envelope.getLowerCorner()
                                .getOrdinate(0), envelope.getLowerCorner().getOrdinate(1), envelope
                                .getUpperCorner().getOrdinate(0), envelope.getUpperCorner()
                                .getOrdinate(1)), crs);
                    } else {
                        // TODO: perhaps access a preference which indicates
                        // wether to do a full table scan
                        // bounds = new ReferencedEnvelope(new Envelope(),crs);
                        // as a last resort do the full scan
                      FeatureIterator<SimpleFeature> r = fs.getFeatures().features();
                        try{
                        SimpleFeature f = r.next();

                        bounds = new ReferencedEnvelope(new Envelope(), crs);
                        bounds.init(f.getBounds());
                        for( ; r.hasNext(); ) {
                            f = r.next();
                            bounds.include(f.getBounds());
                        }
View Full Code Here

        Rectangle size = screen[0];
        final BufferedImage buffered = AWTSWTImageUtils.createBufferedImage( size.width, size.height );
        buffered.getGraphics().draw3DRect(1,1,size.width-3,size.height-3,false);
       
        if (map2 != null) {
            ReferencedEnvelope world = map2.getBounds(new NullProgressMonitor());
            DrawMapParameter toDraw = new DrawMapParameter(buffered.createGraphics(),
                    new Dimension(size.width, size.height), map2, new BoundsStrategy(world),
                    dpi[0], SelectionStyle.IGNORE, monitor, true, false);
            ApplicationGIS.drawMap(toDraw);
        }
View Full Code Here

                IEditorPart editor = getSite().getPage().getActiveEditor();
                Object obj = editor.getEditorInput();
                Class mapType = obj.getClass();
                Method get = mapType.getMethod("getExtent" ); //$NON-NLS-1$
                Object value = get.invoke( obj );
                ReferencedEnvelope world = (ReferencedEnvelope) value;               
                filter.bbox = world.transform( DefaultGeographicCRS.WGS84, true);
            }
            catch( Throwable t ) {
                LocationUIPlugin.log( "ha ha", t ); //$NON-NLS-1$
            }           
        }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.jts.ReferencedEnvelope

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.