本文整理了Java中org.matsim.core.utils.collections.QuadTree.getRectangle
方法的一些代码示例,展示了QuadTree.getRectangle
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QuadTree.getRectangle
方法的具体详情如下:
包路径:org.matsim.core.utils.collections.QuadTree
类名称:QuadTree
方法名:getRectangle
[英]Gets all objects inside the specified area. Objects on the border of the area are not included.
[中]获取指定区域内的所有对象。区域边界上的对象不包括在内。
代码示例来源:origin: matsim-org/matsim
/**
* Gets all objects inside the specified area. Objects on the border of
* the area are not included.
*
* @param minX The minimum left-right location, longitude
* @param minY The minimum up-down location, latitude
* @param maxX The maximum left-right location, longitude
* @param maxY The maximum up-down location, latitude
* @param values1 A collection to store the found objects in.
* @return The objects found within the area.
*/
public Collection<T> getRectangle(final double minX, final double minY, final double maxX, final double maxY, final Collection<T> values1) {
return getRectangle(new Rect(minX, minY, maxX, maxY), values1);
}
代码示例来源:origin: matsim-org/matsim
/**
* retrieve cells within bounds
*
* @param bounds bounds
* @return all cells which have their centroid withing the given bounds
*/
public Collection<Cell<T>> getCells(Geometry bounds) {
return quadTree.getRectangle(
bounds.getEnvelopeInternal().getMinX(), bounds.getEnvelopeInternal().getMinY(),
bounds.getEnvelopeInternal().getMaxX(), bounds.getEnvelopeInternal().getMaxY(),
new ArrayList<>()
);
}
代码示例来源:origin: matsim-org/matsim
@Test
public void testGetRect_flatNetwork() {
QuadTree<String> qt = new QuadTree<>(0, 0, 1000, 0);
qt.put(0, 0, "node1");
qt.put(100, 0, "node2");
qt.put(500, 0, "node3");
qt.put(900, 0, "node4");
Collection<String> values = new ArrayList<>();
qt.getRectangle(new Rect(90, -10, 600, +10), values);
Assert.assertEquals(2, values.size());
Assert.assertTrue(values.contains("node2"));
Assert.assertTrue(values.contains("node3"));
Collection<String> values2 = new ArrayList<>();
qt.getRectangle(new Rect(90, 0, 600, 0), values2);
Assert.assertEquals(2, values2.size());
Assert.assertTrue(values2.contains("node2"));
Assert.assertTrue(values2.contains("node3"));
}
代码示例来源:origin: matsim-org/matsim
@Test
public void testGetRect() {
QuadTree<String> qt = new QuadTree<>(0, 0, 1000, 1000);
qt.put(100, 200, "node1");
qt.put(400, 900, "node2");
qt.put(700, 300, "node3");
qt.put(900, 400, "node4");
Collection<String> values = new ArrayList<>();
qt.getRectangle(new Rect(400, 300, 700, 900), values);
Assert.assertEquals(2, values.size());
Assert.assertTrue(values.contains("node2"));
Assert.assertTrue(values.contains("node3"));
}
代码示例来源:origin: matsim-org/matsim
qt.getRectangle(0.0, 0.0, 20.1, 20.1, values); // test with no object on the boundary
assertEquals(4, values.size());
qt.getRectangle(0.0, 0.0, 20.0, 20.0, values); // test with an object exactly on the boundary
assertEquals(4, values.size());
qt.getRectangle(0.0, 0.0, 19.9, 19.9, values); // test with no object on the boundary
assertEquals(3, values.size());
内容来源于网络,如有侵权,请联系作者删除!