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

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

本文整理了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

if (CRS.getAxisOrder(destCrs) == CRS.AxisOrder.NORTH_EAST)
  latLon = true;
else if (CRS.getAxisOrder(destCrs) == CRS.AxisOrder.EAST_NORTH)
  latLon = false;
else

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

/**
 * Determines the axis ordering of a specified crs object.
 *
 * @param crs The coordinate reference system.
 * @return One of {@link AxisOrder#EAST_NORTH}, {@link AxisOrder@NORTH_EAST}, or {@link
 *     AxisOrder#INAPPLICABLE}
 * @see AxisOrder
 * @since 2.7
 */
public static AxisOrder getAxisOrder(CoordinateReferenceSystem crs) {
  return getAxisOrder(crs, false);
}

代码示例来源: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

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

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

/**
 * Checks if axis flipping is needed comparing axis order requested for the DataStore with query
 * crs.
 *
 * @param axisOrder
 * @param coordinateSystem
 * @return
 */
public static boolean invertAxisNeeded(String axisOrder, CoordinateReferenceSystem crs) {
  CRS.AxisOrder requestedAxis = CRS.getAxisOrder(crs);
  if (requestedAxis == CRS.AxisOrder.INAPPLICABLE) {
    boolean forcedLonLat =
        Boolean.getBoolean("org.geotools.referencing.forceXY")
            || Boolean.TRUE.equals(
                Hints.getSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER));
    if (forcedLonLat) {
      requestedAxis = CRS.AxisOrder.EAST_NORTH;
    } else {
      requestedAxis = CRS.AxisOrder.NORTH_EAST;
    }
  }
  if (WFSDataStoreFactory.AXIS_ORDER_NORTH_EAST.equals(axisOrder)) {
    return requestedAxis.equals(CRS.AxisOrder.EAST_NORTH);
  } else if (WFSDataStoreFactory.AXIS_ORDER_EAST_NORTH.equals(axisOrder)) {
    return requestedAxis.equals(CRS.AxisOrder.NORTH_EAST);
  } else {
    return false; // compliant, don't do anything
  }
}

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

protected void setCentralMeridian(double centralMeridian) {
  // compute the earth radius
  try {
    CoordinateReferenceSystem targetCRS = renderingEnvelope.getCoordinateReferenceSystem();
    MathTransform mt = CRS.findMathTransform(WGS84, targetCRS, true);
    double[] src = new double[] {centralMeridian, 0, 180 + centralMeridian, 0};
    double[] dst = new double[4];
    mt.transform(src, 0, dst, 0, 2);
    if (CRS.getAxisOrder(targetCRS) == CRS.AxisOrder.NORTH_EAST) {
      radius = Math.abs(dst[3] - dst[1]);
    } else {
      radius = Math.abs(dst[2] - dst[0]);
    }
    if (radius <= 0) {
      throw new RuntimeException("Computed Earth radius is 0, what is going on?");
    }
  } catch (Exception e) {
    throw new RuntimeException(
        "Unexpected error computing the Earth radius " + "in the current projection",
        e);
  }
  computeDatelineX();
}

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

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

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

public void testSRSAxisOrder2() throws Exception {
  try {
    Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
    CoordinateReferenceSystem crsEN = CRS.decode("EPSG:4326");
    assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(crsEN));
    CoordinateReferenceSystem crsNE = CRS.decode("urn:ogc:def:crs:EPSG::4326");
    assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(crsNE));
  } finally {
    Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER);
  }
}

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

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

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

/** Encodes the given geometry with no srsName attribute and forcing 2D */
public void encode(Geometry geometry) {
  String srsName = null;
  // see if we have a EPSG CRS attached to the geometry
  if (geometry.getUserData() instanceof CoordinateReferenceSystem) {
    try {
      CoordinateReferenceSystem crs =
          (CoordinateReferenceSystem) geometry.getUserData();
      Integer code = CRS.lookupEpsgCode(crs, false);
      if (code != null) {
        if (AxisOrder.NORTH_EAST.equals(CRS.getAxisOrder(crs))) {
          srsName = "urn:ogc:def:crs:EPSG::" + code;
        } else {
          srsName = "EPSG:" + code;
        }
      }
    } catch (Exception e) {
      LOGGER.fine("Failed to encode the CoordinateReferenceSystem into a srsName");
    }
  }
  encode(geometry, srsName);
}

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

private static boolean isPole(DirectPosition point, CoordinateReferenceSystem crs) {
  DirectPosition result = new DirectPosition2D();
  GeographicCRS geographic;
  try {
    ProjectedCRS projectedCRS = getProjectedCRS(crs);
    if (projectedCRS != null) {
      geographic = projectedCRS.getBaseCRS();
      MathTransform mt = CRS.findMathTransform(projectedCRS, geographic);
      mt.transform(point, result);
    } else if (crs instanceof GeographicCRS) {
      result = point;
      geographic = (GeographicCRS) crs;
    } else {
      return false;
    }
  } catch (MismatchedDimensionException | TransformException | FactoryException e) {
    return false;
  }
  final double EPS = 1e-6;
  if (getAxisOrder(geographic) == AxisOrder.NORTH_EAST) {
    return Math.abs(result.getOrdinate(0) - 90) < EPS
        || Math.abs(result.getOrdinate(0) + 90) < EPS;
  } else {
    return Math.abs(result.getOrdinate(1) - 90) < EPS
        || Math.abs(result.getOrdinate(1) + 90) < EPS;
  }
}

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

|| CRS.getAxisOrder(crs).equals(AxisOrder.NORTH_EAST);
swapAxes &= !retainAxesOrder;

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

/**
 * @param lon
 * @param lat
 */
public void setTopLeft(double lon, double lat) {
  boolean isLongitudeFirstAxisOrderForced =
      Boolean.getBoolean(GeoTools.FORCE_LONGITUDE_FIRST_AXIS_ORDER)
          || GeoTools.getDefaultHints().get(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER)
              == Boolean.TRUE;
  CoordinateReferenceSystem crs = getCrs();
  if (isLongitudeFirstAxisOrderForced
      || (crs != null && CRS.getAxisOrder(crs).equals(CRS.AxisOrder.EAST_NORTH))) {
    topLeft = gf.createPoint(new Coordinate(lon, lat));
    return;
  } else {
    // guess lat/lon?
    topLeft = gf.createPoint(new Coordinate(lat, lon));
  }
}

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

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

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

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

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

CRS.reset("all");
  Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
  assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", false)));
  assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", true)));
  assertEquals(
      AxisOrder.NORTH_EAST,
      CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", false)));
  assertEquals(
      AxisOrder.NORTH_EAST,
      CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", true)));
} finally {
  Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER);
  assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.decode("EPSG:4326", false)));
  assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", true)));
  assertEquals(
      AxisOrder.NORTH_EAST,
      CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", false)));
  assertEquals(
      AxisOrder.NORTH_EAST,
      CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", true)));
} finally {
  CRS.reset("all");
  System.setProperty("org.geotools.referencing.forceXY", "true");
  assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", false)));
  assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", true)));
  assertEquals(
      AxisOrder.NORTH_EAST,

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

+ "AXIS[\"Geodetic longitude\", EAST],"
        + "AXIS[\"Geodetic latitude\", NORTH]]";
assertEquals(AxisOrder.LON_LAT, CRS.getAxisOrder(CRS.parseWKT(wkt)));
assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.parseWKT(wkt)));
        + "AXIS[\"Geodetic latitude\", NORTH],"
        + "AXIS[\"Geodetic longitude\", EAST]]";
assertEquals(AxisOrder.LAT_LON, CRS.getAxisOrder(CRS.parseWKT(wkt)));
assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.parseWKT(wkt)));
    CRS.getAxisOrder(CRS.getHorizontalCRS(DefaultEngineeringCRS.GENERIC_2D)));
        + "  AXIS[\"Northing\", NORTH], "
        + "  AUTHORITY[\"EPSG\",\"23031\"]]";
assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.parseWKT(wkt)));
assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.parseWKT(wkt), true));

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

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

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

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

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

@Test
public void testGDA94Points() throws Exception {
  Style style = RendererBaseTest.loadStyle(this, "markCircle.sld");
  BufferedImage reference = toImage(point_test_2d, style);
  BufferedImage actual = null;
  if (CRS.getAxisOrder(point_test_strict.getSchema().getCoordinateReferenceSystem())
      == AxisOrder.NORTH_EAST) {
    actual = toImage(point_test_strict, style);
  }
  if (CRS.getAxisOrder(point_test.getSchema().getCoordinateReferenceSystem())
      == AxisOrder.EAST_NORTH) {
    actual = toImage(point_test, style);
  }
  ImageAssert.assertEquals(reference, actual, 10);
}

相关文章