org.geotools.geometry.jts.JTS.checkCoordinatesRange()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(164)

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

JTS.checkCoordinatesRange介绍

[英]Checks a Geometry coordinates are within the area of validity of the specified reference system. If a coordinate falls outside the area of validity a PointOutsideEnvelopeException is thrown
[中]检查几何坐标是否在指定参考系的有效区域内。如果坐标落在有效区域之外,则抛出PointOutsideEnvelopeException

代码示例

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

@Test
public void testCheckCoordinateRange() throws Exception {
  DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
  // valid
  JTS.checkCoordinatesRange(JTS.toGeometry(new Envelope(-10, 10, -10, 10)), crs);
  // invalid lat
  try {
    JTS.checkCoordinatesRange(JTS.toGeometry(new Envelope(-10, 10, -100, 10)), crs);
    fail("Provided invalid coordinates, yet check did not throw an exception");
  } catch (PointOutsideEnvelopeException e) {
    // fine
  }
  // invalid lon
  try {
    JTS.checkCoordinatesRange(JTS.toGeometry(new Envelope(-190, 10, -10, 10)), crs);
    fail("Provided invalid coordinates, yet check did not throw an exception");
  } catch (PointOutsideEnvelopeException e) {
    // fine
  }
}

代码示例来源:origin: org.geoserver/gs-wfs

/**
 * Checks that all features coordinates are within the expected coordinate range
 *
 * @param collection
 * @throws PointOutsideEnvelopeException
 */
void checkFeatureCoordinatesRange(SimpleFeatureCollection collection)
    throws PointOutsideEnvelopeException {
  List types = collection.getSchema().getAttributeDescriptors();
  SimpleFeatureIterator fi = collection.features();
  try {
    while (fi.hasNext()) {
      SimpleFeature f = fi.next();
      for (int i = 0; i < types.size(); i++) {
        if (types.get(i) instanceof GeometryDescriptor) {
          GeometryDescriptor gat = (GeometryDescriptor) types.get(i);
          if (gat.getCoordinateReferenceSystem() != null) {
            Geometry geom = (Geometry) f.getAttribute(i);
            if (geom != null)
              JTS.checkCoordinatesRange(geom, gat.getCoordinateReferenceSystem());
          }
        }
      }
    }
  } finally {
    fi.close();
  }
}

代码示例来源:origin: org.geoserver/gs-wfs

if (crs != null)
  try {
    JTS.checkCoordinatesRange(geometry, crs);
  } catch (PointOutsideEnvelopeException e) {
    throw new WFSException(e, "InvalidParameterValue");

代码示例来源:origin: org.geoserver/gs-wfs

JTS.checkCoordinatesRange(geometry, source != null ? source : target);

相关文章