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

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

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

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

  1. /** Helper method for transforming an envelope. */
  2. private static ReferencedEnvelope transform(ReferencedEnvelope e, CoordinateReferenceSystem crs)
  3. throws TransformException, FactoryException {
  4. if (!CRS.equalsIgnoreMetadata(crs, e.getCoordinateReferenceSystem())) {
  5. return e.transform(crs, true);
  6. }
  7. return e;
  8. }

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

  1. /**
  2. * Computes the geographic bounds of a {@link ResourceInfo} by reprojecting the available native
  3. * bounds
  4. *
  5. * @param rinfo
  6. * @return the geographic bounds, or null if the native bounds are not available
  7. * @throws IOException
  8. */
  9. public ReferencedEnvelope getLatLonBounds(
  10. ReferencedEnvelope nativeBounds, CoordinateReferenceSystem declaredCRS)
  11. throws IOException {
  12. if (nativeBounds != null && declaredCRS != null) {
  13. // make sure we use the declared CRS, not the native one, the may differ
  14. if (!CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, declaredCRS)) {
  15. // transform
  16. try {
  17. ReferencedEnvelope bounds =
  18. new ReferencedEnvelope(nativeBounds, CRS.getHorizontalCRS(declaredCRS));
  19. return bounds.transform(DefaultGeographicCRS.WGS84, true);
  20. } catch (Exception e) {
  21. throw (IOException) new IOException("transform error").initCause(e);
  22. }
  23. } else {
  24. return new ReferencedEnvelope(nativeBounds, DefaultGeographicCRS.WGS84);
  25. }
  26. }
  27. return null;
  28. }

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

  1. CoordinateReferenceSystem crs1 = e1.getCoordinateReferenceSystem();
  2. CoordinateReferenceSystem crs2 = e2.getCoordinateReferenceSystem();
  3. if (crs1 != crs2 && !CRS.equalsIgnoreMetadata(crs1, crs2)) {
  4. throw new RuntimeException(
  5. "Two collections are returning different CRSs, cannot perform this "

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

  1. if (CRS.equalsIgnoreMetadata(sourceCRS, DefaultGeographicCRS.WGS84)) {
  2. return new GeneralEnvelope(envelope);
  3. if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
  4. targetEnvelope = CRS.transform(envelope, targetCRS);
  5. } else {

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

  1. if (!CRS.equalsIgnoreMetadata(sourceCRS, destCRS)) {
  2. try {
  3. envelope = CRS.transform(envelope, destCRS);

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

  1. if (!CRS.equalsIgnoreMetadata(crs, this.crs)) {
  2. try {
  3. destinationToSourceTransform = CRS.findMathTransform(crs, this.crs, true);

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

  1. public ReferencedEnvelope boundingBox() throws Exception {
  2. CoordinateReferenceSystem declaredCRS = getCRS();
  3. CoordinateReferenceSystem nativeCRS = getNativeCRS();
  4. ProjectionPolicy php = getProjectionPolicy();
  5. ReferencedEnvelope nativeBox = this.nativeBoundingBox;
  6. if (nativeBox == null) {
  7. // back project from lat lon
  8. try {
  9. nativeBox = getLatLonBoundingBox().transform(declaredCRS, true);
  10. } catch (Exception e) {
  11. LOGGER.log(Level.WARNING, "Failed to derive native bbox from declared one", e);
  12. return null;
  13. }
  14. }
  15. ReferencedEnvelope result;
  16. if (!CRS.equalsIgnoreMetadata(declaredCRS, nativeCRS)
  17. && php == ProjectionPolicy.REPROJECT_TO_DECLARED) {
  18. result = nativeBox.transform(declaredCRS, true);
  19. } else if (php == ProjectionPolicy.FORCE_DECLARED) {
  20. result = ReferencedEnvelope.create((Envelope) nativeBox, declaredCRS);
  21. } else {
  22. result = nativeBox;
  23. }
  24. // make sure that in no case the actual field value is returned to the client, this
  25. // is not a getter, it's a derivative, thus ModificationProxy won't do a copy on its own
  26. return ReferencedEnvelope.create(result);
  27. }

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

  1. } else {
  2. if (!CRS.equalsIgnoreMetadata(nativeCRS, targetCRS)) {
  3. fc = new ReprojectFeatureResults(fc, targetCRS);

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

  1. @Test
  2. public void testCRSConverter() throws Exception {
  3. CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
  4. CRSConverter c = new CRSConverter();
  5. assertEquals(crs.toWKT(), c.toString(crs));
  6. assertEquals(DefaultGeographicCRS.WGS84.toWKT(), c.toString(DefaultGeographicCRS.WGS84));
  7. CoordinateReferenceSystem crs2 = (CoordinateReferenceSystem) c.fromString(crs.toWKT());
  8. assertTrue(CRS.equalsIgnoreMetadata(crs, crs2));
  9. crs2 = (CoordinateReferenceSystem) c.fromString("EPSG:4326");
  10. assertTrue(CRS.equalsIgnoreMetadata(crs, crs2));
  11. }

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

  1. public SimpleFeatureCollection subCollection(Filter filter) {
  2. // reproject the filter to the delegate native crs
  3. CoordinateReferenceSystem crs = getSchema().getCoordinateReferenceSystem();
  4. CoordinateReferenceSystem crsDelegate = delegate.getSchema().getCoordinateReferenceSystem();
  5. if (crs != null) {
  6. DefaultCRSFilterVisitor defaulter = new DefaultCRSFilterVisitor(FF, crs);
  7. filter = (Filter) filter.accept(defaulter, null);
  8. if (crsDelegate != null && !CRS.equalsIgnoreMetadata(crs, crsDelegate)) {
  9. ReprojectingFilterVisitor reprojector =
  10. new ReprojectingFilterVisitor(FF, delegate.getSchema());
  11. filter = (Filter) filter.accept(reprojector, null);
  12. }
  13. }
  14. SimpleFeatureCollection sub = delegate.subCollection(filter);
  15. if (sub != null) {
  16. try {
  17. ReprojectingFeatureCollection wrapper =
  18. new ReprojectingFeatureCollection(sub, target);
  19. wrapper.setDefaultSource(defaultSource);
  20. return wrapper;
  21. } catch (Exception e) {
  22. throw new RuntimeException(e);
  23. }
  24. }
  25. return null;
  26. }

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

  1. if (nativeCRS == null) {
  2. if (other.getNativeCRS() != null) return false;
  3. } else if (!CRS.equalsIgnoreMetadata(nativeCRS, other.getNativeCRS())) return false;
  4. if (nativeName == null) {
  5. if (other.getNativeName() != null) return false;

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

  1. @Test
  2. public void testWgs84BoundsFromCompoundCRS() throws Exception {
  3. try {
  4. MapProjection.SKIP_SANITY_CHECKS = true;
  5. CatalogBuilder cb = new CatalogBuilder(getCatalog());
  6. ReferencedEnvelope3D bounds =
  7. new ReferencedEnvelope3D(
  8. 142892, 470783, 16, 142900, 470790, 20, CRS.decode("EPSG:7415"));
  9. // used to throw an exception here
  10. ReferencedEnvelope latLonBounds =
  11. cb.getLatLonBounds(bounds, bounds.getCoordinateReferenceSystem());
  12. assertTrue(
  13. CRS.equalsIgnoreMetadata(
  14. CRS.decode("EPSG:4326"), latLonBounds.getCoordinateReferenceSystem()));
  15. // System.out.println(latLonBounds);
  16. } finally {
  17. MapProjection.SKIP_SANITY_CHECKS = false;
  18. }
  19. }

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

  1. @Test
  2. public void testCRSConverterInvalidWKT() throws Exception {
  3. CoordinateReferenceSystem crs = CRS.decode("EPSG:3575");
  4. try {
  5. ((Formattable) crs).toWKT(2, true);
  6. fail("expected exception");
  7. } catch (UnformattableObjectException e) {
  8. }
  9. String wkt = null;
  10. try {
  11. wkt = new CRSConverter().toString(crs);
  12. } catch (UnformattableObjectException e) {
  13. fail("Should have thrown exception");
  14. }
  15. CoordinateReferenceSystem crs2 =
  16. (CoordinateReferenceSystem) new CRSConverter().fromString(wkt);
  17. assertTrue(CRS.equalsIgnoreMetadata(crs, crs2));
  18. }

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

  1. r = (GridCoverage2DReader) ci.getGridCoverageReader(null, GeoTools.getDefaultHints());
  2. assertTrue(
  3. CRS.equalsIgnoreMetadata(
  4. CRS.decode("EPSG:3857"), r.getCoordinateReferenceSystem()));
  5. CRS.equalsIgnoreMetadata(
  6. CRS.decode("EPSG:3857"), r.getCoordinateReferenceSystem()));
  7. r = (GridCoverage2DReader) rpool.getGridCoverageReader(store, GeoTools.getDefaultHints());
  8. assertTrue(
  9. CRS.equalsIgnoreMetadata(
  10. CRS.decode("EPSG:4326"), r.getCoordinateReferenceSystem()));

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

  1. requestedEnvelope.getCoordinateReferenceSystem();
  2. final CoordinateReferenceSystem nativeCRS = reader.getCoordinateReferenceSystem();
  3. if (!CRS.equalsIgnoreMetadata(requestCRS, nativeCRS)) {
  4. requestedEnvelope = CRS.transform(requestedEnvelope, nativeCRS);

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

  1. if (!CRS.equalsIgnoreMetadata(resultCRS, schema.getCoordinateReferenceSystem()))
  2. schema = FeatureTypes.transform(schema, resultCRS);
  3. } catch (Exception e) {

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

  1. assertTrue(cv.getParameters().containsKey("foo"));
  2. assertNull(cv.getParameters().get("foo"));
  3. assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), cv.getNativeCRS()));

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

  1. assertEquals(ns, wl.getNamespace());
  2. assertEquals("EPSG:4326", wl.getSRS());
  3. assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), wl.getNativeCRS()));

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

  1. assertEquals(ns, wl.getNamespace());
  2. assertEquals("EPSG:4326", wl.getSRS());
  3. assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), wl.getNativeCRS()));

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

  1. assertEquals("EPSG:4326", ft.getSRS());
  2. assertEquals(new Measure(10, SI.METRE), ft.getLinearizationTolerance());
  3. assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), ft.getNativeCRS()));

相关文章