org.locationtech.jts.geom.Geometry.isRectangle()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(174)

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

Geometry.isRectangle介绍

暂无

代码示例

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

  1. public boolean isRectangle() {
  2. return geometry.isRectangle();
  3. }

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

  1. ReferencedEnvelope renderingEnvelope)
  2. throws FactoryException {
  3. if (validArea.isRectangle()) {
  4. this.renderingEnvelope = renderingEnvelope;
  5. this.sourceCRS = sourceCRS;

代码示例来源:origin: orbisgis/h2gis

  1. /**
  2. * Returns true if the given geometry is a rectangle.
  3. *
  4. * @param geometry Geometry
  5. * @return True if the given geometry is a rectangle
  6. */
  7. public static Boolean isRectangle(Geometry geometry) {
  8. if(geometry == null){
  9. return null;
  10. }
  11. return geometry.isRectangle();
  12. }
  13. }

代码示例来源:origin: locationtech/jts

  1. public static boolean isRectangle(Geometry g) { return g.isRectangle(); }
  2. public static boolean isClosed(Geometry g) {

代码示例来源:origin: locationtech/spatial4j

  1. /**
  2. * Reads WKT from the {@code str} via JTS's {@link org.locationtech.jts.io.WKTReader}.
  3. * @param str
  4. * @param reader <pre>new WKTReader(ctx.getGeometryFactory()))</pre>
  5. * @return Non-Null
  6. */
  7. protected Shape parseIfSupported(String str, WKTReader reader) throws ParseException {
  8. try {
  9. Geometry geom = reader.read(str);
  10. //Normalizes & verifies coordinates
  11. checkCoordinates(geom);
  12. if (geom instanceof org.locationtech.jts.geom.Point) {
  13. org.locationtech.jts.geom.Point ptGeom = (org.locationtech.jts.geom.Point) geom;
  14. if (getShapeFactory().useJtsPoint())
  15. return new JtsPoint(ptGeom, (JtsSpatialContext) ctx);
  16. else
  17. return getShapeFactory().pointXY(ptGeom.getX(), ptGeom.getY());
  18. } else if (geom.isRectangle()) {
  19. return getShapeFactory().makeRectFromRectangularPoly(geom);
  20. } else {
  21. return getShapeFactory().makeShapeFromGeometry(geom);
  22. }
  23. } catch (InvalidShapeException e) {
  24. throw e;
  25. } catch (Exception e) {
  26. throw new InvalidShapeException("error reading WKT: "+e.toString(), e);
  27. }
  28. }

代码示例来源:origin: locationtech/jts

  1. public PreparedPolygon(Polygonal poly) {
  2. super((Geometry) poly);
  3. isRectangle = getGeometry().isRectangle();
  4. }

代码示例来源:origin: locationtech/spatial4j

  1. /**
  2. * INTERNAL: Returns a Rectangle of the JTS {@link Envelope} (bounding box) of the given {@code geom}. This asserts
  3. * that {@link Geometry#isRectangle()} is true. This method reacts to the {@link DatelineRule} setting.
  4. * @param geom non-null
  5. * @return the equivalent Rectangle.
  6. */
  7. public Rectangle makeRectFromRectangularPoly(Geometry geom) {
  8. // TODO although, might want to never convert if there's a semantic difference (e.g.
  9. // geodetically)? Should have a setting for that.
  10. assert geom.isRectangle();
  11. Envelope env = geom.getEnvelopeInternal();
  12. boolean crossesDateline = false;
  13. if (ctx.isGeo() && getDatelineRule() != DatelineRule.none) {
  14. if (getDatelineRule() == DatelineRule.ccwRect) {
  15. // If JTS says it is clockwise, then it's actually a dateline crossing rectangle.
  16. crossesDateline = !CGAlgorithms.isCCW(geom.getCoordinates());
  17. } else {
  18. crossesDateline = env.getWidth() > 180;
  19. }
  20. }
  21. if (crossesDateline)
  22. return rect(env.getMaxX(), env.getMinX(), env.getMinY(), env.getMaxY());
  23. else
  24. return rect(env.getMinX(), env.getMaxX(), env.getMinY(), env.getMaxY());
  25. }

代码示例来源:origin: locationtech/jts

  1. public boolean isRectangle(String wkt)
  2. throws Exception
  3. {
  4. Geometry a = rdr.read(wkt);
  5. return a.isRectangle();
  6. }
  7. }

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

  1. && env.getHeight() > 0
  2. && !(geom instanceof GeometryCollection)
  3. && geom.isRectangle()) {

代码示例来源:origin: org.geoserver.community/gs-wps-download

  1. /**
  2. * Constructor.
  3. *
  4. * @param roi original ROI as a JTS geometry
  5. * @param roiCRS {@link CoordinateReferenceSystem} for the provided geometry. If this is null
  6. * the CRS must be provided with the USerData of the roi
  7. */
  8. public ROIManager(Geometry roi, CoordinateReferenceSystem roiCRS) {
  9. this.originalRoi = roi;
  10. DownloadUtilities.checkPolygonROI(roi);
  11. // Check ROI CRS
  12. if (roiCRS == null) {
  13. if (!(roi.getUserData() instanceof CoordinateReferenceSystem)) {
  14. throw new IllegalArgumentException("ROI without a CRS is not usable!");
  15. }
  16. this.roiCRS = (CoordinateReferenceSystem) roi.getUserData();
  17. } else {
  18. this.roiCRS = roiCRS;
  19. }
  20. roi.setUserData(this.roiCRS);
  21. // is this a bbox
  22. isROIBBOX = roi.isRectangle();
  23. }

代码示例来源:origin: it.geosolutions.jaiext.vectorbin/jt-vectorbin

  1. @Override
  2. public LinkedList getAsRectangleList(int x, int y, int width, int height) {
  3. Rectangle rect = new Rectangle(x, y, width, height);
  4. if (!intersects(rect)) {
  5. // no overlap
  6. return null;
  7. } else if (theGeom.getGeometry().isRectangle()) {
  8. // simple case, the geometry is a rectangle to start with
  9. Envelope env = theGeom.getGeometry().getEnvelopeInternal();
  10. Envelope intersection = env.intersection(new Envelope(x, x + width, y, y + width));
  11. int rx = (int) Math.round(intersection.getMinX());
  12. int ry = (int) Math.round(intersection.getMinY());
  13. int rw = (int) Math.round(intersection.getMaxX() - rx);
  14. int rh = (int) Math.round(intersection.getMaxY() - ry);
  15. LinkedList result = new LinkedList();
  16. result.add(new Rectangle(rx, ry, rw, rh));
  17. return result;
  18. } else {
  19. // we cannot force the base class to use our image, but
  20. // we can create a ROI around it
  21. ROI roiImage = new ROI(getAsImage());
  22. return roiImage.getAsRectangleList(x, y, width, height);
  23. }
  24. }

代码示例来源:origin: geosolutions-it/jai-ext

  1. @Override
  2. public LinkedList getAsRectangleList(int x, int y, int width, int height) {
  3. Rectangle rect = new Rectangle(x, y, width, height);
  4. if (!intersects(rect)) {
  5. // no overlap
  6. return null;
  7. } else if (theGeom.getGeometry().isRectangle()) {
  8. // simple case, the geometry is a rectangle to start with
  9. Envelope env = theGeom.getGeometry().getEnvelopeInternal();
  10. Envelope intersection = env.intersection(new Envelope(x, x + width, y, y + width));
  11. int rx = (int) Math.round(intersection.getMinX());
  12. int ry = (int) Math.round(intersection.getMinY());
  13. int rw = (int) Math.round(intersection.getMaxX() - rx);
  14. int rh = (int) Math.round(intersection.getMaxY() - ry);
  15. LinkedList result = new LinkedList();
  16. result.add(new Rectangle(rx, ry, rw, rh));
  17. return result;
  18. } else {
  19. // we cannot force the base class to use our image, but
  20. // we can create a ROI around it
  21. ROI roiImage = new ROI(getAsImage());
  22. return roiImage.getAsRectangleList(x, y, width, height);
  23. }
  24. }

代码示例来源:origin: it.geosolutions.jaiext.vectorbin/jt-vectorbin

  1. boolean pixelPerfectRectangle = theGeom.getGeometry().isRectangle() && x == env.getMinX()
  2. && y == env.getMinY() && (x + w) == env.getMaxX() &&
  3. (y + h) == env.getMaxY();

代码示例来源:origin: geosolutions-it/jai-ext

  1. boolean pixelPerfectRectangle = theGeom.getGeometry().isRectangle() && x == env.getMinX()
  2. && y == env.getMinY() && (x + w) == env.getMaxX() &&
  3. (y + h) == env.getMaxY();

代码示例来源:origin: locationtech/jts

  1. if (isRectangle()) {
  2. return RectangleIntersects.intersects((Polygon) this, g);
  3. if (g.isRectangle()) {
  4. return RectangleIntersects.intersects((Polygon) g, this);

代码示例来源:origin: locationtech/jts

  1. return false;
  2. if (isRectangle()) {

代码示例来源:origin: locationtech/jts

  1. return false;
  2. if (isRectangle()) {
  3. return RectangleContains.contains((Polygon) this, g);

相关文章