本文整理了Java中org.geotools.referencing.CRS.equalsIgnoreMetadata()
方法的一些代码示例,展示了CRS.equalsIgnoreMetadata()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CRS.equalsIgnoreMetadata()
方法的具体详情如下:
包路径:org.geotools.referencing.CRS
类名称:CRS
方法名:equalsIgnoreMetadata
[英]Compares the specified objects for equality. If both objects are Geotools implementations of class AbstractIdentifiedObject, then this method will ignore the metadata during the comparaison.
[中]比较指定的对象是否相等。如果两个对象都是类AbstractIdentifiedObject的Geotools实现,那么该方法将在比较过程中忽略元数据。
代码示例来源:origin: geoserver/geoserver
/** Helper method for transforming an envelope. */
private static ReferencedEnvelope transform(ReferencedEnvelope e, CoordinateReferenceSystem crs)
throws TransformException, FactoryException {
if (!CRS.equalsIgnoreMetadata(crs, e.getCoordinateReferenceSystem())) {
return e.transform(crs, true);
}
return e;
}
代码示例来源:origin: geoserver/geoserver
/**
* Computes the geographic bounds of a {@link ResourceInfo} by reprojecting the available native
* bounds
*
* @param rinfo
* @return the geographic bounds, or null if the native bounds are not available
* @throws IOException
*/
public ReferencedEnvelope getLatLonBounds(
ReferencedEnvelope nativeBounds, CoordinateReferenceSystem declaredCRS)
throws IOException {
if (nativeBounds != null && declaredCRS != null) {
// make sure we use the declared CRS, not the native one, the may differ
if (!CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, declaredCRS)) {
// transform
try {
ReferencedEnvelope bounds =
new ReferencedEnvelope(nativeBounds, CRS.getHorizontalCRS(declaredCRS));
return bounds.transform(DefaultGeographicCRS.WGS84, true);
} catch (Exception e) {
throw (IOException) new IOException("transform error").initCause(e);
}
} else {
return new ReferencedEnvelope(nativeBounds, DefaultGeographicCRS.WGS84);
}
}
return null;
}
代码示例来源:origin: geoserver/geoserver
CoordinateReferenceSystem crs1 = e1.getCoordinateReferenceSystem();
CoordinateReferenceSystem crs2 = e2.getCoordinateReferenceSystem();
if (crs1 != crs2 && !CRS.equalsIgnoreMetadata(crs1, crs2)) {
throw new RuntimeException(
"Two collections are returning different CRSs, cannot perform this "
代码示例来源:origin: geoserver/geoserver
if (CRS.equalsIgnoreMetadata(sourceCRS, DefaultGeographicCRS.WGS84)) {
return new GeneralEnvelope(envelope);
if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
targetEnvelope = CRS.transform(envelope, targetCRS);
} else {
代码示例来源:origin: geoserver/geoserver
if (!CRS.equalsIgnoreMetadata(sourceCRS, destCRS)) {
try {
envelope = CRS.transform(envelope, destCRS);
代码示例来源:origin: geoserver/geoserver
if (!CRS.equalsIgnoreMetadata(crs, this.crs)) {
try {
destinationToSourceTransform = CRS.findMathTransform(crs, this.crs, true);
代码示例来源:origin: geoserver/geoserver
public ReferencedEnvelope boundingBox() throws Exception {
CoordinateReferenceSystem declaredCRS = getCRS();
CoordinateReferenceSystem nativeCRS = getNativeCRS();
ProjectionPolicy php = getProjectionPolicy();
ReferencedEnvelope nativeBox = this.nativeBoundingBox;
if (nativeBox == null) {
// back project from lat lon
try {
nativeBox = getLatLonBoundingBox().transform(declaredCRS, true);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to derive native bbox from declared one", e);
return null;
}
}
ReferencedEnvelope result;
if (!CRS.equalsIgnoreMetadata(declaredCRS, nativeCRS)
&& php == ProjectionPolicy.REPROJECT_TO_DECLARED) {
result = nativeBox.transform(declaredCRS, true);
} else if (php == ProjectionPolicy.FORCE_DECLARED) {
result = ReferencedEnvelope.create((Envelope) nativeBox, declaredCRS);
} else {
result = nativeBox;
}
// make sure that in no case the actual field value is returned to the client, this
// is not a getter, it's a derivative, thus ModificationProxy won't do a copy on its own
return ReferencedEnvelope.create(result);
}
代码示例来源:origin: geoserver/geoserver
} else {
if (!CRS.equalsIgnoreMetadata(nativeCRS, targetCRS)) {
fc = new ReprojectFeatureResults(fc, targetCRS);
代码示例来源:origin: geoserver/geoserver
@Test
public void testCRSConverter() throws Exception {
CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
CRSConverter c = new CRSConverter();
assertEquals(crs.toWKT(), c.toString(crs));
assertEquals(DefaultGeographicCRS.WGS84.toWKT(), c.toString(DefaultGeographicCRS.WGS84));
CoordinateReferenceSystem crs2 = (CoordinateReferenceSystem) c.fromString(crs.toWKT());
assertTrue(CRS.equalsIgnoreMetadata(crs, crs2));
crs2 = (CoordinateReferenceSystem) c.fromString("EPSG:4326");
assertTrue(CRS.equalsIgnoreMetadata(crs, crs2));
}
代码示例来源:origin: geoserver/geoserver
public SimpleFeatureCollection subCollection(Filter filter) {
// reproject the filter to the delegate native crs
CoordinateReferenceSystem crs = getSchema().getCoordinateReferenceSystem();
CoordinateReferenceSystem crsDelegate = delegate.getSchema().getCoordinateReferenceSystem();
if (crs != null) {
DefaultCRSFilterVisitor defaulter = new DefaultCRSFilterVisitor(FF, crs);
filter = (Filter) filter.accept(defaulter, null);
if (crsDelegate != null && !CRS.equalsIgnoreMetadata(crs, crsDelegate)) {
ReprojectingFilterVisitor reprojector =
new ReprojectingFilterVisitor(FF, delegate.getSchema());
filter = (Filter) filter.accept(reprojector, null);
}
}
SimpleFeatureCollection sub = delegate.subCollection(filter);
if (sub != null) {
try {
ReprojectingFeatureCollection wrapper =
new ReprojectingFeatureCollection(sub, target);
wrapper.setDefaultSource(defaultSource);
return wrapper;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return null;
}
代码示例来源:origin: geoserver/geoserver
if (nativeCRS == null) {
if (other.getNativeCRS() != null) return false;
} else if (!CRS.equalsIgnoreMetadata(nativeCRS, other.getNativeCRS())) return false;
if (nativeName == null) {
if (other.getNativeName() != null) return false;
代码示例来源:origin: geoserver/geoserver
@Test
public void testWgs84BoundsFromCompoundCRS() throws Exception {
try {
MapProjection.SKIP_SANITY_CHECKS = true;
CatalogBuilder cb = new CatalogBuilder(getCatalog());
ReferencedEnvelope3D bounds =
new ReferencedEnvelope3D(
142892, 470783, 16, 142900, 470790, 20, CRS.decode("EPSG:7415"));
// used to throw an exception here
ReferencedEnvelope latLonBounds =
cb.getLatLonBounds(bounds, bounds.getCoordinateReferenceSystem());
assertTrue(
CRS.equalsIgnoreMetadata(
CRS.decode("EPSG:4326"), latLonBounds.getCoordinateReferenceSystem()));
// System.out.println(latLonBounds);
} finally {
MapProjection.SKIP_SANITY_CHECKS = false;
}
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testCRSConverterInvalidWKT() throws Exception {
CoordinateReferenceSystem crs = CRS.decode("EPSG:3575");
try {
((Formattable) crs).toWKT(2, true);
fail("expected exception");
} catch (UnformattableObjectException e) {
}
String wkt = null;
try {
wkt = new CRSConverter().toString(crs);
} catch (UnformattableObjectException e) {
fail("Should have thrown exception");
}
CoordinateReferenceSystem crs2 =
(CoordinateReferenceSystem) new CRSConverter().fromString(wkt);
assertTrue(CRS.equalsIgnoreMetadata(crs, crs2));
}
代码示例来源:origin: geoserver/geoserver
r = (GridCoverage2DReader) ci.getGridCoverageReader(null, GeoTools.getDefaultHints());
assertTrue(
CRS.equalsIgnoreMetadata(
CRS.decode("EPSG:3857"), r.getCoordinateReferenceSystem()));
CRS.equalsIgnoreMetadata(
CRS.decode("EPSG:3857"), r.getCoordinateReferenceSystem()));
r = (GridCoverage2DReader) rpool.getGridCoverageReader(store, GeoTools.getDefaultHints());
assertTrue(
CRS.equalsIgnoreMetadata(
CRS.decode("EPSG:4326"), r.getCoordinateReferenceSystem()));
代码示例来源:origin: geoserver/geoserver
requestedEnvelope.getCoordinateReferenceSystem();
final CoordinateReferenceSystem nativeCRS = reader.getCoordinateReferenceSystem();
if (!CRS.equalsIgnoreMetadata(requestCRS, nativeCRS)) {
requestedEnvelope = CRS.transform(requestedEnvelope, nativeCRS);
代码示例来源:origin: geoserver/geoserver
if (!CRS.equalsIgnoreMetadata(resultCRS, schema.getCoordinateReferenceSystem()))
schema = FeatureTypes.transform(schema, resultCRS);
} catch (Exception e) {
代码示例来源:origin: geoserver/geoserver
assertTrue(cv.getParameters().containsKey("foo"));
assertNull(cv.getParameters().get("foo"));
assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), cv.getNativeCRS()));
代码示例来源:origin: geoserver/geoserver
assertEquals(ns, wl.getNamespace());
assertEquals("EPSG:4326", wl.getSRS());
assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), wl.getNativeCRS()));
代码示例来源:origin: geoserver/geoserver
assertEquals(ns, wl.getNamespace());
assertEquals("EPSG:4326", wl.getSRS());
assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), wl.getNativeCRS()));
代码示例来源:origin: geoserver/geoserver
assertEquals("EPSG:4326", ft.getSRS());
assertEquals(new Measure(10, SI.METRE), ft.getLinearizationTolerance());
assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), ft.getNativeCRS()));
内容来源于网络,如有侵权,请联系作者删除!