Tabnine Logo
CRS.getEnvelope
Code IndexAdd Tabnine to your IDE (free)

How to use
getEnvelope
method
in
org.geotools.referencing.CRS

Best Java code snippets using org.geotools.referencing.CRS.getEnvelope (Showing top 20 results out of 315)

origin: geoserver/geoserver

/**
 * Use the CRS's defined bounds to populate the LayerGroup bounds.
 *
 * <p>If the CRS has no bounds then the layer group bounds are set to null instead
 *
 * @param crs
 */
public void calculateBoundsFromCRS(CoordinateReferenceSystem crs) {
  Envelope crsEnvelope = CRS.getEnvelope(crs);
  if (crsEnvelope != null) {
    ReferencedEnvelope refEnvelope = new ReferencedEnvelope(crsEnvelope);
    this.group.setBounds(refEnvelope);
  } else {
    this.group.setBounds(null);
  }
}
origin: geoserver/geoserver

Envelope crsEnvelope = CRS.getEnvelope(crs);
if (crsEnvelope != null) {
  crsReferencedEnvelope = new ReferencedEnvelope(crsEnvelope);
origin: geoserver/geoserver

@Test
public void testUseCRSBounds() throws NoSuchAuthorityCodeException, FactoryException {
  // this test is almost trivial since the code itself is trivial
  CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
  LayerGroupHelper helper = new LayerGroupHelper(nested);
  helper.calculateBoundsFromCRS(targetCRS);
  // layer group bounds should now match target CRS bounds
  assertEquals(nested.getBounds(), new ReferencedEnvelope(CRS.getEnvelope(targetCRS)));
  // null CRS should get null bounds
  helper.calculateBoundsFromCRS(null);
  assertEquals(nested.getBounds(), null);
}
origin: geoserver/geoserver

@Test
public void testGetBoundsFromCRS() throws Exception {
  Catalog cat = getCatalog();
  CatalogBuilder cb = new CatalogBuilder(cat);
  cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix()));
  FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES));
  CoordinateReferenceSystem resourceCRS = fti.getCRS();
  assertNotNull(resourceCRS);
  // make sure the srs is as expected, otherwise the rest of the tests don't make sense
  assertEquals("EPSG:32615", fti.getSRS());
  ReferencedEnvelope crsBounds = cb.getBoundsFromCRS(fti);
  assertNotNull(crsBounds);
  CoordinateReferenceSystem exptectedCRS = CRS.decode("EPSG:32615");
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  // if we change the srs when there's no reproject policy, should still be the same bounding
  // box
  fti.setSRS("EPSG:4326");
  fti.setProjectionPolicy(ProjectionPolicy.NONE);
  crsBounds = cb.getBoundsFromCRS(fti);
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  // if we use reproject policy, bounds should now be different
  fti.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
  crsBounds = cb.getBoundsFromCRS(fti);
  assertNotEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  // should now be 4326 bounds
  CoordinateReferenceSystem crs4326 = CRS.decode("EPSG:4326");
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds);
  fti.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds);
}
origin: geotools/geotools

/**
 * Returns the bounding box for the coverage domain in {@linkplain #getCoordinateReferenceSystem
 * coordinate reference system} coordinates. May be {@code null} if this coverage has no
 * associated coordinate reference system. For grid coverages, the grid cells are centered on
 * each grid coordinate. The envelope for a 2-D grid coverage includes the following corner
 * positions.
 *
 * <blockquote>
 *
 * <pre>
 *  (Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates
 *  (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
 * </pre>
 *
 * </blockquote>
 *
 * The default implementation returns the domain of validity of the CRS, if there is one.
 *
 * @return The bounding box for the coverage domain in coordinate system coordinates.
 */
public Envelope getEnvelope() {
  return CRS.getEnvelope(crs);
}
origin: geotools/geotools

private static org.opengis.geometry.Envelope getCRSEnvelope(CoordinateReferenceSystem targetCRS)
    throws FactoryException, NoSuchAuthorityCodeException {
  if (targetCRS.getDomainOfValidity() == null) {
    Integer code = CRS.lookupEpsgCode(targetCRS, true);
    if (code != null) {
      CRS.decode("EPSG:" + code, CRS.getAxisOrder(targetCRS) != AxisOrder.NORTH_EAST);
    }
  }
  org.opengis.geometry.Envelope envelope = CRS.getEnvelope(targetCRS);
  return envelope;
}
origin: geotools/geotools

/**
 * Examines the map extent and tries to determine the number of digits that will be needed in
 * the display. If a coordinate reference system with valid extent defined, it is used to
 * determine coordinate limits; otherwise the extent of the envelope is used directly. If all
 * else fails, a default number of digits is set.
 *
 * @param env the map extent (may be {@code null})
 */
private void setIntegerLen(Envelope env) {
  int len = -1;
  if (env != null) {
    // Try to get a valid extent for the CRS and use this to
    // determine num coordinate digits
    CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
    if (crs != null) {
      Envelope validExtent = CRS.getEnvelope(crs);
      if (validExtent != null) {
        len = getMaxIntegerLen(validExtent);
      }
    }
    if (len < 0) {
      // Use map extent directly
      len = getMaxIntegerLen(env);
    }
  } else {
    // Nothing to go on: use an arbitrary length
    len = DEFAULT_NUM_INTEGER_DIGITS;
  }
  intLen = len;
}
origin: geotools/geotools

/**
 * Returns a copy of current envelope. If no envelope has been {@linkplain #setEnvelope
 * explicitly defined}, then the default is inferred from the CRS (by default a geographic
 * envelope from 180°W to 180°E and 90°S to 90°N).
 */
public Envelope getEnvelope() {
  if (envelope != null) {
    return envelope.clone();
  } else {
    final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
    Envelope candidate = CRS.getEnvelope(crs);
    if (candidate == null) {
      final GeneralEnvelope copy = new GeneralEnvelope(crs);
      copy.setToNull();
      candidate = copy;
    }
    return candidate;
  }
}
origin: geotools/geotools

/**
 * Sets the coordinate reference system to the specified value. If an {@linkplain #setEnvelope
 * envelope was previously defined}, it will be reprojected to the new CRS.
 *
 * @throws IllegalArgumentException if the CRS is illegal for the {@linkplain #getEnvelope
 *     current envelope}.
 */
public void setCoordinateReferenceSystem(final CoordinateReferenceSystem crs)
    throws IllegalArgumentException {
  if (envelope == null) {
    if (crs != null) {
      envelope = wrap(CRS.getEnvelope(crs));
      if (envelope == null) {
        envelope = new GeneralEnvelope(crs);
        envelope.setToNull();
      }
    }
  } else
    try {
      envelope = wrap(CRS.transform(envelope, crs));
    } catch (TransformException exception) {
      throw new IllegalArgumentException(
          Errors.format(ErrorKeys.ILLEGAL_COORDINATE_REFERENCE_SYSTEM), exception);
    }
  coverage = null;
}
origin: geotools/geotools

if (crs != null) {
  Envelope envelope = CRS.getEnvelope(crs);
  if (envelope != null) {
    return new ReferencedEnvelope(envelope); // nice!
origin: geotools/geotools

CoordinateReferenceSystem crs = getCRS(e.getSrid());
if (crs != null) {
  org.opengis.geometry.Envelope env = CRS.getEnvelope(crs);
  if (env != null) {
    minx = env.getMinimum(0);
origin: org.geotools/gt-coverage

/**
 * Returns the bounding box for the coverage domain in
 * {@linkplain #getCoordinateReferenceSystem coordinate reference system} coordinates. May
 * be {@code null} if this coverage has no associated coordinate reference system. For grid
 * coverages, the grid cells are centered on each grid coordinate. The envelope for a 2-D
 * grid coverage includes the following corner positions.
 *
 * <blockquote><pre>
 *  (Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates
 *  (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
 * </pre></blockquote>
 *
 * The default implementation returns the domain of validity of the CRS, if there is one.
 *
 * @return The bounding box for the coverage domain in coordinate system coordinates.
 */
public Envelope getEnvelope() {
  return CRS.getEnvelope(crs);
}
origin: org.geotools/gt2-coverage

/**
 * Returns the bounding box for the coverage domain in
 * {@linkplain #getCoordinateReferenceSystem coordinate reference system} coordinates. May
 * be {@code null} if this coverage has no associated coordinate reference system. For grid
 * coverages, the grid cells are centered on each grid coordinate. The envelope for a 2-D
 * grid coverage includes the following corner positions.
 * 
 * <blockquote><pre>
 *  (Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates
 *  (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
 * </pre></blockquote>
 * 
 * The default implementation returns the domain of validity of the CRS, if there is one.
 * 
 * @return The bounding box for the coverage domain in coordinate system coordinates.
 */
public Envelope getEnvelope() {
  return CRS.getEnvelope(crs);
}
origin: geotools/geotools

final Envelope domain = CRS.getEnvelope(crs);
if (domain != null) {
  final CoordinateReferenceSystem domainCRS =
origin: org.geotools/gt-swing

Envelope validExtent = CRS.getEnvelope(crs);
if (validExtent != null) {
  len = getMaxIntegerLen(validExtent);
origin: org.geotools/gt-coverage

/**
 * Returns a copy of current envelope. If no envelope has been {@linkplain #setEnvelope
 * explicitly defined}, then the default is inferred from the CRS (by default a geographic
 * envelope from 180°W to 180°E and 90°S to 90°N).
 */
public Envelope getEnvelope() {
  if (envelope != null) {
    return envelope.clone();
  } else {
    final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
    Envelope candidate = CRS.getEnvelope(crs);
    if (candidate == null) {
      final GeneralEnvelope copy = new GeneralEnvelope(crs);
      copy.setToNull();
      candidate = copy;
    }
    return candidate;
  }
}
origin: org.geoserver.community/gs-qos

@Override
protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) {
  super.onAfterSubmit(target, form);
  try {
    CoordinateReferenceSystem crs =
        envelopePanel.getCoordinateReferenceSystem();
    if (crs == null) return;
    ReferencedEnvelope refEnv =
        new ReferencedEnvelope(CRS.getEnvelope(crs));
    envelopePanel.setModelObject(refEnv);
    envelopePanel.modelChanged();
    target.add(envelopePanel);
  } catch (Exception e) {
    throw new WicketRuntimeException(e);
  }
}
origin: org.geotools/gt-coverage

/**
 * Sets the coordinate reference system to the specified value. If an
 * {@linkplain #setEnvelope envelope was previously defined}, it will
 * be reprojected to the new CRS.
 *
 * @throws IllegalArgumentException if the CRS is illegal for the
 *         {@linkplain #getEnvelope current envelope}.
 */
public void setCoordinateReferenceSystem(final CoordinateReferenceSystem crs)
    throws IllegalArgumentException
{
  if (envelope == null) {
    if (crs != null) {
      envelope = wrap(CRS.getEnvelope(crs));
      if (envelope == null) {
        envelope = new GeneralEnvelope(crs);
        envelope.setToNull();
      }
    }
  } else try {
    envelope = wrap(CRS.transform(envelope, crs));
  } catch (TransformException exception) {
    throw new IllegalArgumentException(Errors.format(
        ErrorKeys.ILLEGAL_COORDINATE_REFERENCE_SYSTEM), exception);
  }
  coverage = null;
}
origin: org.geotools/gt2-widgets-swing

/**
 * Creates an initially empty table model using the specified coordinate reference system.
 */
public CoordinateTableModel(final CoordinateReferenceSystem crs) {
  this.crs = crs;
  final CoordinateSystem cs = crs.getCoordinateSystem();
  columnNames = new String[cs.getDimension()];
  for (int i=0; i<columnNames.length; i++){
    columnNames[i] = crs.getCoordinateSystem().getAxis(i).getName().getCode();
  }
  validArea = new GeneralEnvelope(CRS.getEnvelope(crs));
}
origin: org.geoserver/gs-wms

StaticRasterReader(Object source) {
  coverageFactory = new GridCoverageFactory();
  crs = DefaultGeographicCRS.WGS84;
  // instantiate the bounds based on the default CRS
  originalEnvelope = new GeneralEnvelope(CRS.getEnvelope(crs));
  originalEnvelope.setCoordinateReferenceSystem(crs);
  originalGridRange = new GeneralGridEnvelope(originalEnvelope, PixelInCell.CELL_CENTER);
  // create a default layout based on the static image
  setlayout(new ImageLayout(STATIC_IMAGE));
}
org.geotools.referencingCRSgetEnvelope

Javadoc

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.

Popular methods of CRS

  • decode
  • findMathTransform
  • equalsIgnoreMetadata
  • parseWKT
  • lookupEpsgCode
  • transform
  • getAxisOrder
  • lookupIdentifier
  • toSRS
  • getHorizontalCRS
  • getCoordinateOperationFactory
  • getAuthorityFactory
  • getCoordinateOperationFactory,
  • getAuthorityFactory,
  • getMapProjection,
  • getSupportedCodes,
  • getGeographicBoundingBox,
  • reset,
  • getEllipsoid,
  • getProjectedCRS,
  • getTemporalCRS

Popular in Java

  • Start an intent from android
  • compareTo (BigDecimal)
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now