本文整理了Java中org.geotools.referencing.CRS.getEnvelope()
方法的一些代码示例,展示了CRS.getEnvelope()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CRS.getEnvelope()
方法的具体详情如下:
包路径:org.geotools.referencing.CRS
类名称: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
/**
* 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));
}
内容来源于网络,如有侵权,请联系作者删除!