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

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

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

  1. @Test
  2. public void testCheckCoordinateRange() throws Exception {
  3. DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
  4. // valid
  5. JTS.checkCoordinatesRange(JTS.toGeometry(new Envelope(-10, 10, -10, 10)), crs);
  6. // invalid lat
  7. try {
  8. JTS.checkCoordinatesRange(JTS.toGeometry(new Envelope(-10, 10, -100, 10)), crs);
  9. fail("Provided invalid coordinates, yet check did not throw an exception");
  10. } catch (PointOutsideEnvelopeException e) {
  11. // fine
  12. }
  13. // invalid lon
  14. try {
  15. JTS.checkCoordinatesRange(JTS.toGeometry(new Envelope(-190, 10, -10, 10)), crs);
  16. fail("Provided invalid coordinates, yet check did not throw an exception");
  17. } catch (PointOutsideEnvelopeException e) {
  18. // fine
  19. }
  20. }

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

  1. /**
  2. * Checks that all features coordinates are within the expected coordinate range
  3. *
  4. * @param collection
  5. * @throws PointOutsideEnvelopeException
  6. */
  7. void checkFeatureCoordinatesRange(SimpleFeatureCollection collection)
  8. throws PointOutsideEnvelopeException {
  9. List types = collection.getSchema().getAttributeDescriptors();
  10. SimpleFeatureIterator fi = collection.features();
  11. try {
  12. while (fi.hasNext()) {
  13. SimpleFeature f = fi.next();
  14. for (int i = 0; i < types.size(); i++) {
  15. if (types.get(i) instanceof GeometryDescriptor) {
  16. GeometryDescriptor gat = (GeometryDescriptor) types.get(i);
  17. if (gat.getCoordinateReferenceSystem() != null) {
  18. Geometry geom = (Geometry) f.getAttribute(i);
  19. if (geom != null)
  20. JTS.checkCoordinatesRange(geom, gat.getCoordinateReferenceSystem());
  21. }
  22. }
  23. }
  24. }
  25. } finally {
  26. fi.close();
  27. }
  28. }

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

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

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

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

相关文章