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

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

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

CRS.getAxisOrder介绍

[英]Determines the axis ordering of a specified crs object.
[中]确定指定crs对象的轴顺序。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

  1. if (CRS.getAxisOrder(destCrs) == CRS.AxisOrder.NORTH_EAST)
  2. latLon = true;
  3. else if (CRS.getAxisOrder(destCrs) == CRS.AxisOrder.EAST_NORTH)
  4. latLon = false;
  5. else

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

  1. /**
  2. * Determines the axis ordering of a specified crs object.
  3. *
  4. * @param crs The coordinate reference system.
  5. * @return One of {@link AxisOrder#EAST_NORTH}, {@link AxisOrder@NORTH_EAST}, or {@link
  6. * AxisOrder#INAPPLICABLE}
  7. * @see AxisOrder
  8. * @since 2.7
  9. */
  10. public static AxisOrder getAxisOrder(CoordinateReferenceSystem crs) {
  11. return getAxisOrder(crs, false);
  12. }

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

  1. private static org.opengis.geometry.Envelope getCRSEnvelope(CoordinateReferenceSystem targetCRS)
  2. throws FactoryException, NoSuchAuthorityCodeException {
  3. if (targetCRS.getDomainOfValidity() == null) {
  4. Integer code = CRS.lookupEpsgCode(targetCRS, true);
  5. if (code != null) {
  6. CRS.decode("EPSG:" + code, CRS.getAxisOrder(targetCRS) != AxisOrder.NORTH_EAST);
  7. }
  8. }
  9. org.opengis.geometry.Envelope envelope = CRS.getEnvelope(targetCRS);
  10. return envelope;
  11. }

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

  1. CoordinateReferenceSystem crs = CRS.decode(srsName, true);
  2. if (CRS.getAxisOrder(crs) == AxisOrder.NORTH_EAST) {
  3. Integer epsgCode = CRS.lookupEpsgCode(crs, false);
  4. if (epsgCode == null) {

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

  1. /**
  2. * Checks if axis flipping is needed comparing axis order requested for the DataStore with query
  3. * crs.
  4. *
  5. * @param axisOrder
  6. * @param coordinateSystem
  7. * @return
  8. */
  9. public static boolean invertAxisNeeded(String axisOrder, CoordinateReferenceSystem crs) {
  10. CRS.AxisOrder requestedAxis = CRS.getAxisOrder(crs);
  11. if (requestedAxis == CRS.AxisOrder.INAPPLICABLE) {
  12. boolean forcedLonLat =
  13. Boolean.getBoolean("org.geotools.referencing.forceXY")
  14. || Boolean.TRUE.equals(
  15. Hints.getSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER));
  16. if (forcedLonLat) {
  17. requestedAxis = CRS.AxisOrder.EAST_NORTH;
  18. } else {
  19. requestedAxis = CRS.AxisOrder.NORTH_EAST;
  20. }
  21. }
  22. if (WFSDataStoreFactory.AXIS_ORDER_NORTH_EAST.equals(axisOrder)) {
  23. return requestedAxis.equals(CRS.AxisOrder.EAST_NORTH);
  24. } else if (WFSDataStoreFactory.AXIS_ORDER_EAST_NORTH.equals(axisOrder)) {
  25. return requestedAxis.equals(CRS.AxisOrder.NORTH_EAST);
  26. } else {
  27. return false; // compliant, don't do anything
  28. }
  29. }

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

  1. protected void setCentralMeridian(double centralMeridian) {
  2. // compute the earth radius
  3. try {
  4. CoordinateReferenceSystem targetCRS = renderingEnvelope.getCoordinateReferenceSystem();
  5. MathTransform mt = CRS.findMathTransform(WGS84, targetCRS, true);
  6. double[] src = new double[] {centralMeridian, 0, 180 + centralMeridian, 0};
  7. double[] dst = new double[4];
  8. mt.transform(src, 0, dst, 0, 2);
  9. if (CRS.getAxisOrder(targetCRS) == CRS.AxisOrder.NORTH_EAST) {
  10. radius = Math.abs(dst[3] - dst[1]);
  11. } else {
  12. radius = Math.abs(dst[2] - dst[0]);
  13. }
  14. if (radius <= 0) {
  15. throw new RuntimeException("Computed Earth radius is 0, what is going on?");
  16. }
  17. } catch (Exception e) {
  18. throw new RuntimeException(
  19. "Unexpected error computing the Earth radius " + "in the current projection",
  20. e);
  21. }
  22. computeDatelineX();
  23. }

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

  1. return null;
  2. if (isForcedLonLat() && CRS.getAxisOrder(crs, false) == AxisOrder.NORTH_EAST) {
  3. try {

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

  1. public void testSRSAxisOrder2() throws Exception {
  2. try {
  3. Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
  4. CoordinateReferenceSystem crsEN = CRS.decode("EPSG:4326");
  5. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(crsEN));
  6. CoordinateReferenceSystem crsNE = CRS.decode("urn:ogc:def:crs:EPSG::4326");
  7. assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(crsNE));
  8. } finally {
  9. Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER);
  10. }
  11. }

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

  1. if (CRS.getAxisOrder(this.crs) == CRS.AxisOrder.NORTH_EAST) {

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

  1. /** Encodes the given geometry with no srsName attribute and forcing 2D */
  2. public void encode(Geometry geometry) {
  3. String srsName = null;
  4. // see if we have a EPSG CRS attached to the geometry
  5. if (geometry.getUserData() instanceof CoordinateReferenceSystem) {
  6. try {
  7. CoordinateReferenceSystem crs =
  8. (CoordinateReferenceSystem) geometry.getUserData();
  9. Integer code = CRS.lookupEpsgCode(crs, false);
  10. if (code != null) {
  11. if (AxisOrder.NORTH_EAST.equals(CRS.getAxisOrder(crs))) {
  12. srsName = "urn:ogc:def:crs:EPSG::" + code;
  13. } else {
  14. srsName = "EPSG:" + code;
  15. }
  16. }
  17. } catch (Exception e) {
  18. LOGGER.fine("Failed to encode the CoordinateReferenceSystem into a srsName");
  19. }
  20. }
  21. encode(geometry, srsName);
  22. }

代码示例来源: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. || CRS.getAxisOrder(crs).equals(AxisOrder.NORTH_EAST);
  2. swapAxes &= !retainAxesOrder;

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

  1. /**
  2. * @param lon
  3. * @param lat
  4. */
  5. public void setTopLeft(double lon, double lat) {
  6. boolean isLongitudeFirstAxisOrderForced =
  7. Boolean.getBoolean(GeoTools.FORCE_LONGITUDE_FIRST_AXIS_ORDER)
  8. || GeoTools.getDefaultHints().get(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER)
  9. == Boolean.TRUE;
  10. CoordinateReferenceSystem crs = getCrs();
  11. if (isLongitudeFirstAxisOrderForced
  12. || (crs != null && CRS.getAxisOrder(crs).equals(CRS.AxisOrder.EAST_NORTH))) {
  13. topLeft = gf.createPoint(new Coordinate(lon, lat));
  14. return;
  15. } else {
  16. // guess lat/lon?
  17. topLeft = gf.createPoint(new Coordinate(lat, lon));
  18. }
  19. }

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

  1. @BeforeClass
  2. public static void setupCRS() throws FactoryException {
  3. CRS.reset("all");
  4. Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
  5. // the following is only to make the test work in Eclipse, where the test
  6. // classpath is tainted by the test classpath of dependent modules (whilst in Maven it's
  7. // not)
  8. Set<CRSAuthorityFactory> factories =
  9. ReferencingFactoryFinder.getCRSAuthorityFactories(null);
  10. for (CRSAuthorityFactory factory : factories) {
  11. if (factory.getClass().getSimpleName().equals("EPSGCRSAuthorityFactory")) {
  12. ReferencingFactoryFinder.removeAuthorityFactory(factory);
  13. }
  14. }
  15. assertEquals(
  16. AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.decode("urn:ogc:def:crs:EPSG::4326")));
  17. }

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

  1. ReferencedEnvelope readerEnvelope =
  2. ReferencedEnvelope.reference(reader.getOriginalEnvelope());
  3. boolean northEast = CRS.getAxisOrder(readerCRS) == AxisOrder.NORTH_EAST;
  4. int lonAxis = northEast ? 1 : 0;
  5. if (readerEnvelope.getMaximum(lonAxis) > 180) {

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

  1. CRS.reset("all");
  2. Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
  3. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", false)));
  4. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", true)));
  5. assertEquals(
  6. AxisOrder.NORTH_EAST,
  7. CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", false)));
  8. assertEquals(
  9. AxisOrder.NORTH_EAST,
  10. CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", true)));
  11. } finally {
  12. Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER);
  13. assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.decode("EPSG:4326", false)));
  14. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", true)));
  15. assertEquals(
  16. AxisOrder.NORTH_EAST,
  17. CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", false)));
  18. assertEquals(
  19. AxisOrder.NORTH_EAST,
  20. CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", true)));
  21. } finally {
  22. CRS.reset("all");
  23. System.setProperty("org.geotools.referencing.forceXY", "true");
  24. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", false)));
  25. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", true)));
  26. assertEquals(
  27. AxisOrder.NORTH_EAST,

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

  1. + "AXIS[\"Geodetic longitude\", EAST],"
  2. + "AXIS[\"Geodetic latitude\", NORTH]]";
  3. assertEquals(AxisOrder.LON_LAT, CRS.getAxisOrder(CRS.parseWKT(wkt)));
  4. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.parseWKT(wkt)));
  5. + "AXIS[\"Geodetic latitude\", NORTH],"
  6. + "AXIS[\"Geodetic longitude\", EAST]]";
  7. assertEquals(AxisOrder.LAT_LON, CRS.getAxisOrder(CRS.parseWKT(wkt)));
  8. assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.parseWKT(wkt)));
  9. CRS.getAxisOrder(CRS.getHorizontalCRS(DefaultEngineeringCRS.GENERIC_2D)));
  10. + " AXIS[\"Northing\", NORTH], "
  11. + " AUTHORITY[\"EPSG\",\"23031\"]]";
  12. assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.parseWKT(wkt)));
  13. assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.parseWKT(wkt), true));

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

  1. AxisOrder axisOrder = CRS.getAxisOrder(crs, true);

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

  1. if (CRS.getAxisOrder(sourceCrs) == AxisOrder.NORTH_EAST) {
  2. validArea =
  3. new ReferencedEnvelope(

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

  1. @Test
  2. public void testGDA94Points() throws Exception {
  3. Style style = RendererBaseTest.loadStyle(this, "markCircle.sld");
  4. BufferedImage reference = toImage(point_test_2d, style);
  5. BufferedImage actual = null;
  6. if (CRS.getAxisOrder(point_test_strict.getSchema().getCoordinateReferenceSystem())
  7. == AxisOrder.NORTH_EAST) {
  8. actual = toImage(point_test_strict, style);
  9. }
  10. if (CRS.getAxisOrder(point_test.getSchema().getCoordinateReferenceSystem())
  11. == AxisOrder.EAST_NORTH) {
  12. actual = toImage(point_test, style);
  13. }
  14. ImageAssert.assertEquals(reference, actual, 10);
  15. }

相关文章