Package org.geotools.geometry

Examples of org.geotools.geometry.GeneralEnvelope


            assertEquals(3.6231999084702693,Double.valueOf(newDomainValues[0]),1E-6);
           
           
            // subsetting the envelope
            final ParameterValue<GridGeometry2D> gg = AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue();
            final GeneralEnvelope originalEnvelope = reader.getOriginalEnvelope(coverageName);
            final GeneralEnvelope reducedEnvelope = new GeneralEnvelope(new double[] {
                    originalEnvelope.getLowerCorner().getOrdinate(0),
                    originalEnvelope.getLowerCorner().getOrdinate(1) }, new double[] {
                    originalEnvelope.getMedian().getOrdinate(0),
                    originalEnvelope.getMedian().getOrdinate(1) });
            reducedEnvelope.setCoordinateReferenceSystem(reader
                    .getCoordinateReferenceSystem(coverageName));

            // Selecting bigger gridRange for a zoomed result
            final Dimension dim = new Dimension();
            GridEnvelope gridRange = reader.getOriginalGridRange(coverageName);
View Full Code Here


      protected GridCoverage2D execute() {
        return CoverageFactoryFinder.getGridCoverageFactory(null).create(
            "name",
            PlanarImage.wrapRenderedImage(RasterSymbolizerTest
                .getSynthetic(Double.NaN)),
            new GeneralEnvelope(new double[] { -90, -180 },
                new double[] { 90, 180 }),
            new GridSampleDimension[] { new GridSampleDimension(
                "sd", new Category[] { new Category("",
                    Color.BLACK, 0) }, null) }, null, null);
      }
    };
    this.testedObject2 = new BaseCoverageProcessingNode(1,
        SimpleInternationalString.wrap("fake node"),
        SimpleInternationalString.wrap("fake node")) {

      protected GridCoverage2D execute() {
        return CoverageFactoryFinder.getGridCoverageFactory(null).create(
            "name",
            PlanarImage.wrapRenderedImage(RasterSymbolizerTest
                .getSynthetic(Double.NaN)),
            new GeneralEnvelope(new double[] { -90, -180 },
                new double[] { 90, 180 }),
            new GridSampleDimension[] { new GridSampleDimension(
                "sd", new Category[] { new Category("",
                    Color.BLACK, 0) }, null) }, null, null);
      }
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
            throws Exception {
        GeneralEnvelope envelope = (GeneralEnvelope) value;

        List<Node> timePositions = (List<Node>) node.getChildren("timePosition");

        if (timePositions != null && !timePositions.isEmpty()) {
            final Map<String, Object> properties = new HashMap<String, Object>(4);
            properties.put(CoordinateReferenceSystem.NAME_KEY, "Compound");
            properties.put(CoordinateReferenceSystem.DOMAIN_OF_VALIDITY_KEY, ExtentImpl.WORLD);

            CoordinateReferenceSystem crs = new DefaultCompoundCRS(properties,
                    new CoordinateReferenceSystem[] {
                            envelope.getCoordinateReferenceSystem(),
                            DefaultTemporalCRS.TRUNCATED_JULIAN });

            double[] minCP = new double[envelope.getDimension() + 1];
            double[] maxCP = new double[envelope.getDimension() + 1];

            for (int i = 0; i < envelope.getDimension(); i++) {
                minCP[i] = envelope.getLowerCorner().getOrdinate(i);
                maxCP[i] = envelope.getUpperCorner().getOrdinate(i);
            }

            DefaultTemporalCRS TCRS = (DefaultTemporalCRS) ((CompoundCRS) crs).getCoordinateReferenceSystems().get(1);

            Node timePositionNodeBegin = timePositions.get(0);
            Node timePositionNodeEnd = timePositions.get(1);
            minCP[minCP.length - 1] = TCRS.toValue(((DefaultPosition)timePositionNodeBegin.getValue()).getDate());
            maxCP[maxCP.length - 1] = TCRS.toValue(((DefaultPosition)timePositionNodeEnd.getValue()).getDate());

            GeneralDirectPosition minDP = new GeneralDirectPosition(minCP);
                                  minDP.setCoordinateReferenceSystem(crs);
            GeneralDirectPosition maxDP = new GeneralDirectPosition(maxCP);
                                  maxDP.setCoordinateReferenceSystem(crs);

            GeneralEnvelope envelopeWithTime = new GeneralEnvelope(minDP, maxDP);

            return envelopeWithTime;
        }

        return envelope;
View Full Code Here

     * <!-- end-user-doc -->
     */
    @Override
    public Element encode(Object object, Document document, Element value)
            throws Exception {
        GeneralEnvelope envelope = (GeneralEnvelope) object;

        if (envelope == null) {
            value.appendChild(document.createElementNS(GML.NAMESPACE, org.geotools.gml3.GML.Null.getLocalPart()));
        }

View Full Code Here

        return null;
    }

    public Object getProperty(Object object, QName name) {
        GeneralEnvelope envelope = (GeneralEnvelope) object;

        if (envelope == null) {
            return null;
        }

        if (name.getLocalPart().equals("timePosition")) {
            CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();

            TemporalCRS temporalCRS = null;

            if (crs instanceof CompoundCRS) {
                List CRSs = ((DefaultCompoundCRS) crs).getCoordinateReferenceSystems();

                for (Object item : CRSs) {
                    if (item instanceof TemporalCRS) {
                        temporalCRS = (TemporalCRS) item;
                    }
                }
            }

            if (temporalCRS != null) {
                List<Position> envelopePositions = new LinkedList<Position>();

                Position beginning = new DefaultPosition(
                        ((DefaultTemporalCRS) temporalCRS).toDate(envelope.getLowerCorner().getOrdinate(envelope.getDimension() - 1)));
                Position ending = new DefaultPosition(
                        ((DefaultTemporalCRS) temporalCRS).toDate(envelope.getUpperCorner().getOrdinate(envelope.getDimension() - 1)));

                envelopePositions.add(beginning);
                envelopePositions.add(ending);

                return envelopePositions;
View Full Code Here

            double[] resolutions = mi.getResolutions();
            sbLevels.append(resolutions[0]).append(",").append(resolutions[1]).append(" ");
        }
        properties.put("LevelsDirs", sbDirNames.toString());
        properties.put("Levels", sbLevels.toString());
        GeneralEnvelope envelope = mosaics.get(0).getEnvelope();
        properties.put("Envelope2D", envelope.getMinimum(0) + "," + envelope.getMinimum(1) + " " +
                envelope.getMaximum(0) + "," + envelope.getMaximum(1));
        OutputStream os = null;
        try {
            os = new FileOutputStream(sourceFile);
            properties.store(os, "Automatically generated");
        } catch(IOException e) {
            LOGGER.log(Level.INFO, "We could not generate the pyramid propert file " +
                    sourceFile.getPath(), e);
            return null;
        } finally {
            if(os != null)
                IOUtils.closeQuietly(os);
        }
       
        // build the .prj file if possible
        if(envelope.getCoordinateReferenceSystem() != null) {
            File prjFile = new File(directory, directory.getName() + ".prj");
            PrintWriter pw = null;
            try {
                pw = new PrintWriter(new FileOutputStream(prjFile));
                pw.print(envelope.getCoordinateReferenceSystem().toString());
            } catch(IOException e) {
                LOGGER.log(Level.INFO, "We could not write out the projection file " +
                        prjFile.getPath(), e);
                return null;
            } finally {
View Full Code Here

        final AffineTransform tempTransform = new AffineTransform(
            (AffineTransform) raster2Model);
        tempTransform.translate(-0.5, -0.5);

        originalEnvelope = CRS.transform(ProjectiveTransform
            .create(tempTransform), new GeneralEnvelope(actualDim));
        originalEnvelope.setCoordinateReferenceSystem(crs);
        highestRes = new double[2];
        highestRes[0]=XAffineTransform.getScaleX0(tempTransform);
        highestRes[1]=XAffineTransform.getScaleY0(tempTransform);
      }
View Full Code Here

    // /////////////////////////////////////////////////////////////////////
    //
    // do we have parameters to use for reading from the specified source
    //
    // /////////////////////////////////////////////////////////////////////
    GeneralEnvelope requestedEnvelope = null;
    Rectangle dim = null;
    OverviewPolicy overviewPolicy=null;
    if (params != null) {
      // /////////////////////////////////////////////////////////////////////
      //
      // Checking params
      //
      // /////////////////////////////////////////////////////////////////////
      if (params != null) {
        for (int i = 0; i < params.length; i++) {
          final ParameterValue param = (ParameterValue) params[i];
          final String name = param.getDescriptor().getName().getCode();
          if (name.equals(
              AbstractGridFormat.READ_GRIDGEOMETRY2D.getName()
                  .toString())) {
            final GridGeometry2D gg = (GridGeometry2D) param
                .getValue();
            requestedEnvelope = new GeneralEnvelope((Envelope) gg
                .getEnvelope2D());
            dim = gg.getGridRange2D().getBounds();
            continue;
          }
          if (name.equals(AbstractGridFormat.OVERVIEW_POLICY
View Full Code Here

          // checking the fields
          // BBOX
          if (kvp[0].equalsIgnoreCase("BBOX")) {
            // splitting fields
            kvp = kvp[1].split(",");
            originalEnvelope = new GeneralEnvelope(new double[] {
                Double.parseDouble(kvp[0]),
                Double.parseDouble(kvp[1]) }, new double[] {
                Double.parseDouble(kvp[2]),
                Double.parseDouble(kvp[3]) });
          }
View Full Code Here

    }

    in.close();

    // building up envelope of this coverage
    originalEnvelope = new GeneralEnvelope(new double[] { xMin, yMin },
        new double[] { xMax, yMax });
    originalEnvelope.setCoordinateReferenceSystem(crs);
  }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.GeneralEnvelope

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.