我无法将 RectF 转换为 Geometry 然后检测其中的一个点:
public static Geometry RectFtoGeometry(RectF r) {
GeometricShapeFactory gsf = new GeometricShapeFactory();
gsf.setBase(new Coordinate(r.left, r.bottom));
gsf.setNumPoints(4);
gsf.setWidth(r.width());
gsf.setHeight(r.height());
Geometry rect = gsf.createRectangle(),
point = new GeometryFactory().createPoint(new Coordinate(r.centerX(), r.centerY()));
if(!rect.contains(point))
throw new IllegalArgumentException();//This gets thrown
return gsf.createRectangle();
}
如何从“可以包含”其点的 RectF 创建几何?
提前致谢!