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

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

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

CRS.getProjectedCRS介绍

[英]Returns the first projected coordinate reference system found in a the given CRS, or null if there is none.
[中]返回在给定CRS中找到的第一个投影坐标系,如果没有,则返回null。

代码示例

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

  1. /**
  2. * Returns the first projected coordinate reference system found in a the given CRS, or {@code
  3. * null} if there is none.
  4. *
  5. * @param crs The coordinate reference system, or {@code null}.
  6. * @return The projected CRS, or {@code null} if none.
  7. * @since 2.4
  8. */
  9. public static ProjectedCRS getProjectedCRS(final CoordinateReferenceSystem crs) {
  10. if (crs instanceof ProjectedCRS) {
  11. return (ProjectedCRS) crs;
  12. }
  13. if (crs instanceof CompoundCRS) {
  14. final CompoundCRS cp = (CompoundCRS) crs;
  15. for (final CoordinateReferenceSystem c : cp.getCoordinateReferenceSystems()) {
  16. final ProjectedCRS candidate = getProjectedCRS(c);
  17. if (candidate != null) {
  18. return candidate;
  19. }
  20. }
  21. }
  22. return null;
  23. }

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

  1. /**
  2. * Returns the {@link MapProjection} driving the specified crs, or {@code null} if none could be
  3. * found.
  4. *
  5. * @param crs The coordinate reference system, or {@code null}.
  6. * @return The {@link MapProjection}, or {@code null} if none.
  7. */
  8. public static MapProjection getMapProjection(final CoordinateReferenceSystem crs) {
  9. ProjectedCRS projectedCRS = CRS.getProjectedCRS(crs);
  10. if (projectedCRS == null) return null;
  11. Projection conversion = projectedCRS.getConversionFromBase();
  12. MathTransform mt = conversion.getMathTransform();
  13. return unrollProjection(mt);
  14. }

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

  1. private static boolean isPole(DirectPosition point, CoordinateReferenceSystem crs) {
  2. DirectPosition result = new DirectPosition2D();
  3. GeographicCRS geographic;
  4. try {
  5. ProjectedCRS projectedCRS = getProjectedCRS(crs);
  6. if (projectedCRS != null) {
  7. geographic = projectedCRS.getBaseCRS();
  8. MathTransform mt = CRS.findMathTransform(projectedCRS, geographic);
  9. mt.transform(point, result);
  10. } else if (crs instanceof GeographicCRS) {
  11. result = point;
  12. geographic = (GeographicCRS) crs;
  13. } else {
  14. return false;
  15. }
  16. } catch (MismatchedDimensionException | TransformException | FactoryException e) {
  17. return false;
  18. }
  19. final double EPS = 1e-6;
  20. if (getAxisOrder(geographic) == AxisOrder.NORTH_EAST) {
  21. return Math.abs(result.getOrdinate(0) - 90) < EPS
  22. || Math.abs(result.getOrdinate(0) + 90) < EPS;
  23. } else {
  24. return Math.abs(result.getOrdinate(1) - 90) < EPS
  25. || Math.abs(result.getOrdinate(1) + 90) < EPS;
  26. }
  27. }

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

  1. if (CRS.getProjectedCRS(geometryCRS) != null) {
  2. precision = 1e-3;
  3. } else {

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

  1. @BeforeClass
  2. public static void setupClass() throws FactoryException, TransformException {
  3. sphericalGeosCRS = CRS.parseWKT(sphericalGeosWKT);
  4. sphericalGeosToGeog =
  5. CRS.findMathTransform(
  6. sphericalGeosCRS, CRS.getProjectedCRS(sphericalGeosCRS).getBaseCRS(), true);
  7. geogToSphericalGeos = sphericalGeosToGeog.inverse();
  8. ellipsoidalGeosCRS = CRS.parseWKT(ellipsoidalGeosWKT);
  9. ellipsoidalGeosToGeog =
  10. CRS.findMathTransform(
  11. ellipsoidalGeosCRS,
  12. CRS.getProjectedCRS(ellipsoidalGeosCRS).getBaseCRS(),
  13. true);
  14. geogToEllipsoidalGeos = ellipsoidalGeosToGeog.inverse();
  15. }

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

  1. /** Circumscribed rectangle (smallest) for full disk earth image */
  2. public static Envelope2D circumscribeFullDisk(CoordinateReferenceSystem geosCRS)
  3. throws TransformException, FactoryException {
  4. if (!isGeostationaryCRS(geosCRS)) {
  5. return null;
  6. }
  7. MathTransform mt =
  8. CRS.findMathTransform(geosCRS, CRS.getProjectedCRS(geosCRS).getBaseCRS(), true);
  9. MathTransform imt = mt.inverse();
  10. ParameterValueGroup parameters = CRS.getMapProjection(geosCRS).getParameterValues();
  11. double semiMajorAxis = parameters.parameter("semi_major").doubleValue();
  12. double satelliteHeight = parameters.parameter("satellite_height").doubleValue();
  13. double centralMeridian = parameters.parameter("central_meridian").doubleValue();
  14. DirectPosition2D dp2d = new DirectPosition2D();
  15. double halfFoVRadians = Math.acos(semiMajorAxis / (satelliteHeight + semiMajorAxis));
  16. double halfFoVDegrees = Math.toDegrees(halfFoVRadians);
  17. dp2d.setLocation(centralMeridian - halfFoVDegrees, 0.);
  18. imt.transform(dp2d, dp2d);
  19. double xMin = dp2d.getX();
  20. dp2d.setLocation(centralMeridian + halfFoVDegrees, 0.);
  21. imt.transform(dp2d, dp2d);
  22. double xMax = dp2d.getX();
  23. dp2d.setLocation(centralMeridian, -halfFoVDegrees);
  24. imt.transform(dp2d, dp2d);
  25. double yMin = dp2d.getY();
  26. dp2d.setLocation(centralMeridian, halfFoVDegrees);
  27. imt.transform(dp2d, dp2d);
  28. double yMax = dp2d.getY();
  29. return new Envelope2D(geosCRS, xMin, yMin, xMax - xMin, yMax - yMin);
  30. }

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

  1. public Object getValue(final GridCoverage coverage) {
  2. final ProjectedCRS crs;
  3. crs = CRS.getProjectedCRS(coverage.getCoordinateReferenceSystem());
  4. return (crs!=null) ? crs.getConversionFromBase() : null;
  5. }
  6. };

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

  1. /**
  2. * Returns the value for this key from the specified grid coverage.
  3. */
  4. public Object getValue(final GridCoverage coverage) {
  5. final ProjectedCRS crs = CRS.getProjectedCRS(coverage.getCoordinateReferenceSystem());
  6. if (crs != null) {
  7. final ParameterValueGroup parameters = crs.getConversionFromBase().getParameterValues();
  8. try {
  9. return parameters.parameter(toString()).getValue();
  10. } catch (ParameterNotFoundException exception) {
  11. // No value set for the specified parameter.
  12. // This is not an error. Just ignore...
  13. }
  14. }
  15. return null;
  16. }
  17. }

相关文章