1
我不能得到一個RectF轉變成一個幾何體,然後檢測在一個點:矩形幾何不包括RectF中心
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的幾何形狀「可以包含」它的要點?
提前致謝!