0
我有許多點對象(n)與各種座標。 我有一個座標代理。在java中構建特定大小的包絡對象?
我想查找點a的某個距離內的所有點並將它們放入列表中。
public class Agent {
private Context<Object> context;
private Geography<Object> geography;
...
public Agent(Context<Object> context, Geography<Object> geography) {
this.context = context;
this.geography = geography;
}
...
public void step() {
//gets the coordinates of the agent, calls them coord
Context context = ContextUtils.getContext(this);
Geography<Agent> geography = (Geography)context.getProjection("Geography");
Geometry geom = geography.getGeometry(this);
Coordinate coord = geom.getCoordinates()[0];
//creates a list of called points
List<Object> points = new ArrayList<Object>();
//creates an envelope object and creates envelope dimensions
Envelope envelope = new Envelope((coord.x + 0.0001, coord.y + 0.0001, coord.x - 0.001, coord.y - 0.001);
//for all objects within the envelope, if they are of the specific class type, add them to the list
for(Object obj: geography.getObjectsWithin(envelope, Specific.class)) {
trees.add(tree);
}
System.out.println("The number of objects in the envelope is : " + trees.size());
我的問題是:當我使用這些尺寸(在上面的代碼中)時,我在信封中得到了1342個對象。這大概是一個非常小的信封,應該包含最多200-300個信封。爲什麼這麼大?
這可能是我沒有正確創建信封。有誰知道更多關於如何指定這些信封尺寸的細節?