org.geotools.referencing.CRS.getEnvelope()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中org.geotools.referencing.CRS.getEnvelope()方法的一些代码示例,展示了CRS.getEnvelope()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CRS.getEnvelope()方法的具体详情如下:
包路径:org.geotools.referencing.CRS
类名称:CRS
方法名:getEnvelope

CRS.getEnvelope介绍

[英]Returns the domain of validity for the specified coordinate reference system, or nullif unknown.

This method fetchs the CoordinateReferenceSystem#getDomainOfValidity associated with the given CRS. Only GeographicExtent of kind BoundingPolygon are taken in account. If none are found, then the #getGeographicBoundingBox are used as a fallback.

The returned envelope is expressed in terms of the specified CRS.
[中]返回指定坐标参照系的有效域,如果未知,则返回null。
此方法获取与给定CRS关联的CoordinationReferenceSystem#getDomainOfValidity。只考虑边界多边形的地理范围。如果没有找到,则将#getGeographicBoundingBox用作回退。
返回的信封用指定的CRS表示。

代码示例

代码示例来源:origin: geoserver/geoserver

  1. /**
  2. * Use the CRS's defined bounds to populate the LayerGroup bounds.
  3. *
  4. * <p>If the CRS has no bounds then the layer group bounds are set to null instead
  5. *
  6. * @param crs
  7. */
  8. public void calculateBoundsFromCRS(CoordinateReferenceSystem crs) {
  9. Envelope crsEnvelope = CRS.getEnvelope(crs);
  10. if (crsEnvelope != null) {
  11. ReferencedEnvelope refEnvelope = new ReferencedEnvelope(crsEnvelope);
  12. this.group.setBounds(refEnvelope);
  13. } else {
  14. this.group.setBounds(null);
  15. }
  16. }

代码示例来源:origin: geoserver/geoserver

  1. Envelope crsEnvelope = CRS.getEnvelope(crs);
  2. if (crsEnvelope != null) {
  3. crsReferencedEnvelope = new ReferencedEnvelope(crsEnvelope);

代码示例来源:origin: geoserver/geoserver

  1. @Test
  2. public void testUseCRSBounds() throws NoSuchAuthorityCodeException, FactoryException {
  3. // this test is almost trivial since the code itself is trivial
  4. CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
  5. LayerGroupHelper helper = new LayerGroupHelper(nested);
  6. helper.calculateBoundsFromCRS(targetCRS);
  7. // layer group bounds should now match target CRS bounds
  8. assertEquals(nested.getBounds(), new ReferencedEnvelope(CRS.getEnvelope(targetCRS)));
  9. // null CRS should get null bounds
  10. helper.calculateBoundsFromCRS(null);
  11. assertEquals(nested.getBounds(), null);
  12. }

代码示例来源:origin: geoserver/geoserver

  1. @Test
  2. public void testGetBoundsFromCRS() throws Exception {
  3. Catalog cat = getCatalog();
  4. CatalogBuilder cb = new CatalogBuilder(cat);
  5. cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix()));
  6. FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES));
  7. CoordinateReferenceSystem resourceCRS = fti.getCRS();
  8. assertNotNull(resourceCRS);
  9. // make sure the srs is as expected, otherwise the rest of the tests don't make sense
  10. assertEquals("EPSG:32615", fti.getSRS());
  11. ReferencedEnvelope crsBounds = cb.getBoundsFromCRS(fti);
  12. assertNotNull(crsBounds);
  13. CoordinateReferenceSystem exptectedCRS = CRS.decode("EPSG:32615");
  14. assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  15. // if we change the srs when there's no reproject policy, should still be the same bounding
  16. // box
  17. fti.setSRS("EPSG:4326");
  18. fti.setProjectionPolicy(ProjectionPolicy.NONE);
  19. crsBounds = cb.getBoundsFromCRS(fti);
  20. assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  21. // if we use reproject policy, bounds should now be different
  22. fti.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
  23. crsBounds = cb.getBoundsFromCRS(fti);
  24. assertNotEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  25. // should now be 4326 bounds
  26. CoordinateReferenceSystem crs4326 = CRS.decode("EPSG:4326");
  27. assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds);
  28. fti.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
  29. assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds);
  30. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Returns the bounding box for the coverage domain in {@linkplain #getCoordinateReferenceSystem
  3. * coordinate reference system} coordinates. May be {@code null} if this coverage has no
  4. * associated coordinate reference system. For grid coverages, the grid cells are centered on
  5. * each grid coordinate. The envelope for a 2-D grid coverage includes the following corner
  6. * positions.
  7. *
  8. * <blockquote>
  9. *
  10. * <pre>
  11. * (Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates
  12. * (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
  13. * </pre>
  14. *
  15. * </blockquote>
  16. *
  17. * The default implementation returns the domain of validity of the CRS, if there is one.
  18. *
  19. * @return The bounding box for the coverage domain in coordinate system coordinates.
  20. */
  21. public Envelope getEnvelope() {
  22. return CRS.getEnvelope(crs);
  23. }

代码示例来源:origin: geotools/geotools

  1. private static org.opengis.geometry.Envelope getCRSEnvelope(CoordinateReferenceSystem targetCRS)
  2. throws FactoryException, NoSuchAuthorityCodeException {
  3. if (targetCRS.getDomainOfValidity() == null) {
  4. Integer code = CRS.lookupEpsgCode(targetCRS, true);
  5. if (code != null) {
  6. CRS.decode("EPSG:" + code, CRS.getAxisOrder(targetCRS) != AxisOrder.NORTH_EAST);
  7. }
  8. }
  9. org.opengis.geometry.Envelope envelope = CRS.getEnvelope(targetCRS);
  10. return envelope;
  11. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Examines the map extent and tries to determine the number of digits that will be needed in
  3. * the display. If a coordinate reference system with valid extent defined, it is used to
  4. * determine coordinate limits; otherwise the extent of the envelope is used directly. If all
  5. * else fails, a default number of digits is set.
  6. *
  7. * @param env the map extent (may be {@code null})
  8. */
  9. private void setIntegerLen(Envelope env) {
  10. int len = -1;
  11. if (env != null) {
  12. // Try to get a valid extent for the CRS and use this to
  13. // determine num coordinate digits
  14. CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
  15. if (crs != null) {
  16. Envelope validExtent = CRS.getEnvelope(crs);
  17. if (validExtent != null) {
  18. len = getMaxIntegerLen(validExtent);
  19. }
  20. }
  21. if (len < 0) {
  22. // Use map extent directly
  23. len = getMaxIntegerLen(env);
  24. }
  25. } else {
  26. // Nothing to go on: use an arbitrary length
  27. len = DEFAULT_NUM_INTEGER_DIGITS;
  28. }
  29. intLen = len;
  30. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Returns a copy of current envelope. If no envelope has been {@linkplain #setEnvelope
  3. * explicitly defined}, then the default is inferred from the CRS (by default a geographic
  4. * envelope from 180°W to 180°E and 90°S to 90°N).
  5. */
  6. public Envelope getEnvelope() {
  7. if (envelope != null) {
  8. return envelope.clone();
  9. } else {
  10. final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
  11. Envelope candidate = CRS.getEnvelope(crs);
  12. if (candidate == null) {
  13. final GeneralEnvelope copy = new GeneralEnvelope(crs);
  14. copy.setToNull();
  15. candidate = copy;
  16. }
  17. return candidate;
  18. }
  19. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Sets the coordinate reference system to the specified value. If an {@linkplain #setEnvelope
  3. * envelope was previously defined}, it will be reprojected to the new CRS.
  4. *
  5. * @throws IllegalArgumentException if the CRS is illegal for the {@linkplain #getEnvelope
  6. * current envelope}.
  7. */
  8. public void setCoordinateReferenceSystem(final CoordinateReferenceSystem crs)
  9. throws IllegalArgumentException {
  10. if (envelope == null) {
  11. if (crs != null) {
  12. envelope = wrap(CRS.getEnvelope(crs));
  13. if (envelope == null) {
  14. envelope = new GeneralEnvelope(crs);
  15. envelope.setToNull();
  16. }
  17. }
  18. } else
  19. try {
  20. envelope = wrap(CRS.transform(envelope, crs));
  21. } catch (TransformException exception) {
  22. throw new IllegalArgumentException(
  23. Errors.format(ErrorKeys.ILLEGAL_COORDINATE_REFERENCE_SYSTEM), exception);
  24. }
  25. coverage = null;
  26. }

代码示例来源:origin: geotools/geotools

  1. if (crs != null) {
  2. Envelope envelope = CRS.getEnvelope(crs);
  3. if (envelope != null) {
  4. return new ReferencedEnvelope(envelope); // nice!

代码示例来源:origin: geotools/geotools

  1. CoordinateReferenceSystem crs = getCRS(e.getSrid());
  2. if (crs != null) {
  3. org.opengis.geometry.Envelope env = CRS.getEnvelope(crs);
  4. if (env != null) {
  5. minx = env.getMinimum(0);

代码示例来源:origin: org.geotools/gt-coverage

  1. /**
  2. * Returns the bounding box for the coverage domain in
  3. * {@linkplain #getCoordinateReferenceSystem coordinate reference system} coordinates. May
  4. * be {@code null} if this coverage has no associated coordinate reference system. For grid
  5. * coverages, the grid cells are centered on each grid coordinate. The envelope for a 2-D
  6. * grid coverage includes the following corner positions.
  7. *
  8. * <blockquote><pre>
  9. * (Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates
  10. * (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
  11. * </pre></blockquote>
  12. *
  13. * The default implementation returns the domain of validity of the CRS, if there is one.
  14. *
  15. * @return The bounding box for the coverage domain in coordinate system coordinates.
  16. */
  17. public Envelope getEnvelope() {
  18. return CRS.getEnvelope(crs);
  19. }

代码示例来源:origin: org.geotools/gt2-coverage

  1. /**
  2. * Returns the bounding box for the coverage domain in
  3. * {@linkplain #getCoordinateReferenceSystem coordinate reference system} coordinates. May
  4. * be {@code null} if this coverage has no associated coordinate reference system. For grid
  5. * coverages, the grid cells are centered on each grid coordinate. The envelope for a 2-D
  6. * grid coverage includes the following corner positions.
  7. *
  8. * <blockquote><pre>
  9. * (Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates
  10. * (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
  11. * </pre></blockquote>
  12. *
  13. * The default implementation returns the domain of validity of the CRS, if there is one.
  14. *
  15. * @return The bounding box for the coverage domain in coordinate system coordinates.
  16. */
  17. public Envelope getEnvelope() {
  18. return CRS.getEnvelope(crs);
  19. }

代码示例来源:origin: geotools/geotools

  1. final Envelope domain = CRS.getEnvelope(crs);
  2. if (domain != null) {
  3. final CoordinateReferenceSystem domainCRS =

代码示例来源:origin: org.geotools/gt-swing

  1. Envelope validExtent = CRS.getEnvelope(crs);
  2. if (validExtent != null) {
  3. len = getMaxIntegerLen(validExtent);

代码示例来源:origin: org.geotools/gt-coverage

  1. /**
  2. * Returns a copy of current envelope. If no envelope has been {@linkplain #setEnvelope
  3. * explicitly defined}, then the default is inferred from the CRS (by default a geographic
  4. * envelope from 180°W to 180°E and 90°S to 90°N).
  5. */
  6. public Envelope getEnvelope() {
  7. if (envelope != null) {
  8. return envelope.clone();
  9. } else {
  10. final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
  11. Envelope candidate = CRS.getEnvelope(crs);
  12. if (candidate == null) {
  13. final GeneralEnvelope copy = new GeneralEnvelope(crs);
  14. copy.setToNull();
  15. candidate = copy;
  16. }
  17. return candidate;
  18. }
  19. }

代码示例来源:origin: org.geoserver.community/gs-qos

  1. @Override
  2. protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) {
  3. super.onAfterSubmit(target, form);
  4. try {
  5. CoordinateReferenceSystem crs =
  6. envelopePanel.getCoordinateReferenceSystem();
  7. if (crs == null) return;
  8. ReferencedEnvelope refEnv =
  9. new ReferencedEnvelope(CRS.getEnvelope(crs));
  10. envelopePanel.setModelObject(refEnv);
  11. envelopePanel.modelChanged();
  12. target.add(envelopePanel);
  13. } catch (Exception e) {
  14. throw new WicketRuntimeException(e);
  15. }
  16. }

代码示例来源:origin: org.geotools/gt-coverage

  1. /**
  2. * Sets the coordinate reference system to the specified value. If an
  3. * {@linkplain #setEnvelope envelope was previously defined}, it will
  4. * be reprojected to the new CRS.
  5. *
  6. * @throws IllegalArgumentException if the CRS is illegal for the
  7. * {@linkplain #getEnvelope current envelope}.
  8. */
  9. public void setCoordinateReferenceSystem(final CoordinateReferenceSystem crs)
  10. throws IllegalArgumentException
  11. {
  12. if (envelope == null) {
  13. if (crs != null) {
  14. envelope = wrap(CRS.getEnvelope(crs));
  15. if (envelope == null) {
  16. envelope = new GeneralEnvelope(crs);
  17. envelope.setToNull();
  18. }
  19. }
  20. } else try {
  21. envelope = wrap(CRS.transform(envelope, crs));
  22. } catch (TransformException exception) {
  23. throw new IllegalArgumentException(Errors.format(
  24. ErrorKeys.ILLEGAL_COORDINATE_REFERENCE_SYSTEM), exception);
  25. }
  26. coverage = null;
  27. }

代码示例来源:origin: org.geotools/gt2-widgets-swing

  1. /**
  2. * Creates an initially empty table model using the specified coordinate reference system.
  3. */
  4. public CoordinateTableModel(final CoordinateReferenceSystem crs) {
  5. this.crs = crs;
  6. final CoordinateSystem cs = crs.getCoordinateSystem();
  7. columnNames = new String[cs.getDimension()];
  8. for (int i=0; i<columnNames.length; i++){
  9. columnNames[i] = crs.getCoordinateSystem().getAxis(i).getName().getCode();
  10. }
  11. validArea = new GeneralEnvelope(CRS.getEnvelope(crs));
  12. }

代码示例来源:origin: org.geoserver/gs-wms

  1. StaticRasterReader(Object source) {
  2. coverageFactory = new GridCoverageFactory();
  3. crs = DefaultGeographicCRS.WGS84;
  4. // instantiate the bounds based on the default CRS
  5. originalEnvelope = new GeneralEnvelope(CRS.getEnvelope(crs));
  6. originalEnvelope.setCoordinateReferenceSystem(crs);
  7. originalGridRange = new GeneralGridEnvelope(originalEnvelope, PixelInCell.CELL_CENTER);
  8. // create a default layout based on the static image
  9. setlayout(new ImageLayout(STATIC_IMAGE));
  10. }

相关文章