Package org.geotools.geometry

Examples of org.geotools.geometry.GeneralEnvelope


            coverageCRS2D = CRS.getHorizontalCRS(coverageCRS);
            assert coverageCRS2D.getCoordinateSystem().getDimension() == 2;
            if (coverageCRS.getCoordinateSystem().getDimension() != 2) {
                final MathTransform transform = CRS.findMathTransform(coverageCRS,
                        (CoordinateReferenceSystem) coverageCRS2D);
                final GeneralEnvelope bbox = CRS.transform(transform, coverageEnvelope);
                bbox.setCoordinateReferenceSystem(coverageCRS2D);
                coverageBBox = new ReferencedEnvelope(bbox);
            } else {
                // it is already a bbox
                coverageBBox = new ReferencedEnvelope(coverageEnvelope);
            }
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("srsName")) {
            try {
                return CRS.lookupIdentifier(envelope.getCoordinateReferenceSystem(), true);
            } catch (FactoryException e) {
                return null;
            }
        }
       
        if (name.getLocalPart().equals("pos")) {
            CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();

            GeographicCRS spatialCRS = null;

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

                for (Object item : CRSs) {
                    if (item instanceof GeographicCRS) {
                        spatialCRS = (GeographicCRS) item;
                    }
                }
            } else {
                spatialCRS = (GeographicCRS) envelope.getCoordinateReferenceSystem();
            }

            if (spatialCRS != null) {
                List<DirectPosition> envelopePositions = new LinkedList<DirectPosition>();

                GeneralDirectPosition lowerCorner = new GeneralDirectPosition(envelope.getCoordinateReferenceSystem());
                GeneralDirectPosition upperCorner = new GeneralDirectPosition(envelope.getCoordinateReferenceSystem());

                for (int i = 0; i < spatialCRS.getCoordinateSystem().getDimension(); i++) {
                    lowerCorner.setOrdinate(i, envelope.getLowerCorner().getOrdinate(i));
                    upperCorner.setOrdinate(i, envelope.getUpperCorner().getOrdinate(i));
                }

                envelopePositions.add(lowerCorner);
                envelopePositions.add(upperCorner);
View Full Code Here

        return null;
    }

    public Element encode(Object object, Document document, Element value)
            throws Exception {
        GeneralEnvelope envelope = (GeneralEnvelope) object;

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

        return null;
    }
View Full Code Here

            Node n1 = (Node) positions.get(0);
            Node n2 = (Node) positions.get(1);
            GeneralDirectPosition p1 = (GeneralDirectPosition) n1.getValue();
            GeneralDirectPosition p2 = (GeneralDirectPosition) n2.getValue();

            GeneralEnvelope envelope = new GeneralEnvelope(p1, p2);
           
            if (p1.getDimension() == 2 && p1.getDimension() == 2) {
                envelope.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);

                return envelope;
            } else if (p1.getDimension() > 2 && p2.getDimension() > 2) {
                envelope.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84_3D);

                return envelope;
            }
        }
View Full Code Here

  private void doFullExtent(String name) {
    JDBCAccess access = getJDBCAccess();
    ImageLevelInfo li = access.getLevelInfo(access.getNumOverviews());

    double scale = li.getEnvelope().getWidth() / 400;
    GeneralEnvelope env = new GeneralEnvelope(new double[] {
        li.getExtentMinX(), li.getExtentMinY() }, new double[] {
        li.getExtentMaxX(), li.getExtentMaxY() });

    try {
      env.setCoordinateReferenceSystem(CRS.decode(CRSNAME));
      imageMosaic(name, getConfigUrl(), env, 400, (int) (li.getEnvelope()
          .getHeight() / scale));
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
View Full Code Here

  private void doNoData(String name) {
    JDBCAccess access = getJDBCAccess();
    ImageLevelInfo li = access.getLevelInfo(access.getNumOverviews());

    GeneralEnvelope env = new GeneralEnvelope(new double[] {
        li.getExtentMaxX() + DELTA, li.getExtentMaxY() + DELTA },
        new double[] { li.getExtentMaxX() + (DELTA * 2),
            li.getExtentMaxY() + (DELTA * 2) });

    try {
      env.setCoordinateReferenceSystem(CRS.decode(CRSNAME));
      imageMosaic(name, getConfigUrl(), env, 400, 400);
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
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, 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("srsName")) {
            return "WGS84(DD)";
        }

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

            GeographicCRS spatialCRS = null;

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

                for (Object item : CRSs) {
                    if (item instanceof GeographicCRS) {
                        spatialCRS = (GeographicCRS) item;
                    }
                }
            } else {
                spatialCRS = (GeographicCRS) envelope.getCoordinateReferenceSystem();
            }

            if (spatialCRS != null) {
                List<DirectPosition> envelopePositions = new LinkedList<DirectPosition>();
               
                GeneralDirectPosition lowerCorner = new GeneralDirectPosition(envelope.getCoordinateReferenceSystem());
                GeneralDirectPosition upperCorner = new GeneralDirectPosition(envelope.getCoordinateReferenceSystem());

                for (int i = 0; i < spatialCRS.getCoordinateSystem().getDimension(); i++) {
                    lowerCorner.setOrdinate(i, envelope.getLowerCorner().getOrdinate(i));
                    upperCorner.setOrdinate(i, envelope.getUpperCorner().getOrdinate(i));
                }

                envelopePositions.add(lowerCorner);
                envelopePositions.add(upperCorner);
View Full Code Here

  private void doPartial(String name) {
    JDBCAccess access = getJDBCAccess();
    ImageLevelInfo li = access.getLevelInfo(access.getNumOverviews());

    GeneralEnvelope env = new GeneralEnvelope(new double[] {
        li.getExtentMaxX() - DELTA, li.getExtentMaxY() - DELTA },
        new double[] { li.getExtentMaxX() + DELTA,
            li.getExtentMaxY() + DELTA });

    try {
      env.setCoordinateReferenceSystem(CRS.decode(CRSNAME));
      imageMosaic(name, getConfigUrl(), env, 400, 400,Color.green,null,null);
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

         public void testOutputTransparentColor() {
                  JDBCAccess access = getJDBCAccess();
                  ImageLevelInfo li = access.getLevelInfo(access.getNumOverviews());

                  GeneralEnvelope env = new GeneralEnvelope(new double[] {
                                  li.getExtentMaxX() - DELTA, li.getExtentMaxY() - DELTA },
                                  new double[] { li.getExtentMaxX() + DELTA,
                                                  li.getExtentMaxY() + DELTA });

                  try {
                          env.setCoordinateReferenceSystem(CRS.decode(CRSNAME));
                          imageMosaic("transparent", getConfigUrl(), env, 400, 400,
                                          null,Color.black, null);
                  } catch (Exception e) {
                          Assert.fail(e.getMessage());
                  }
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.