本文整理汇总了Java中com.github.davidmoten.rtree.geometry.Geometries.rectangle方法的典型用法代码示例。如果您正苦于以下问题:Java Geometries.rectangle方法的具体用法?Java Geometries.rectangle怎么用?Java Geometries.rectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.davidmoten.rtree.geometry.Geometries
的用法示例。
在下文中一共展示了Geometries.rectangle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: place
import com.github.davidmoten.rtree.geometry.Geometries; //导入方法依赖的package包/类
@Override
public boolean place(final Word word) {
final Rectangle wordRectangle = Geometries.rectangle(
word.getPosition().getX(),
word.getPosition().getY(),
word.getPosition().getX() + word.getDimension().getWidth(),
word.getPosition().getY() + word.getDimension().getHeight());
final Observable<Entry<String, Rectangle>> results = placedWordRTree.search(
wordRectangle);
final int matches = results.count().toBlocking().single();
if (matches > 0) {
return false;
}
placedWordRTree = placedWordRTree.add(word.getWord(), wordRectangle);
return true;
}
示例2: geometryAwtToRtree
import com.github.davidmoten.rtree.geometry.Geometries; //导入方法依赖的package包/类
public static Rectangle geometryAwtToRtree(Rectangle2D rect) {
// this is how those coordinates are considered in the Geometries.rectangle() factory method.
//double x1 = rect.getMinX();
//double x2 = rect.getMaxX();
//double y1 = rect.getY();
//double y2 = rect.getMaxY();
double y1 = Math.min(rect.getMinY(), rect.getMaxY());
return Geometries.rectangle(rect.getMinX(), y1, rect.getMaxX(), y1 + rect.getHeight());
}
示例3: add
import com.github.davidmoten.rtree.geometry.Geometries; //导入方法依赖的package包/类
/**
*
* @param f the feature to be added
*/
public void add(T f) {
list.add(f);
Rectangle2D bbox = f.getBounds();
Rectangle r = Geometries.rectangle(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY());
tree = tree.add(f, r);
}
示例4: findTilesInBox
import com.github.davidmoten.rtree.geometry.Geometries; //导入方法依赖的package包/类
/**
* @return all tiles that intersect the specified bounding box.
*/
public List<TileBounds> findTilesInBox(final double minX,
final double minY,
final double maxX,
final double maxY) {
final Rectangle rectangle = Geometries.rectangle(minX, minY, maxX, maxY);
final Observable<Entry<TileBounds, Geometry>> searchResults = tree.search(rectangle);
return convertResultsToList(searchResults);
}
示例5: render
import com.github.davidmoten.rtree.geometry.Geometries; //导入方法依赖的package包/类
@Override
public void render(Graphics2D g, WmsRequest request) {
log.info("request=" + request);
log.info("drawing " + queue.size() + " positions");
final Projector projector = WmsUtil.getProjector(request);
Position a = projector.toPosition(0, 0);
Position b = projector.toPosition(request.getWidth(), request.getHeight());
Rectangle r = Geometries.rectangle(a.getLon(), b.getLat(), b.getLon(), a.getLat());
Optional<VesselPosition> last = Optional.absent();
Optional<Point> lastPoint = Optional.absent();
// Iterable<VesselPosition> positions = tree
// .search(r)
// .map(new Func1<Entry<VesselPosition,
// com.github.davidmoten.rtree.geometry.Point>, VesselPosition>() {
//
// @Override
// public VesselPosition call(
// Entry<VesselPosition, com.github.davidmoten.rtree.geometry.Point>
// entry) {
// return entry.value();
// }
//
// }).toBlocking().toIterable();
ConcurrentLinkedQueue<VesselPosition> positions = queue;
Point startPoint = null;
for (VesselPosition p : positions) {
// expecting positions to be in mmsi, time order
Point point = projector.toPoint(p.lat(), p.lon());
if (last.isPresent() && p.id().equals(last.get().id()) && p.data().isPresent()
&& !p.data().get().equals(p.time()) && isOkMovement(p, last.get())) {
// join the last position with this one with a line
g.setColor(Color.gray);
g.drawLine(lastPoint.get().x, lastPoint.get().y, point.x, point.y);
}
if (p.data().get().equals(p.time())
|| (last.isPresent() && !isOkMovement(p, last.get()))) {
g.setColor(Color.red);
g.drawRect(point.x, point.y, 1, 1);
startPoint = point;
} else if (startPoint != null) {
// draw intermediate point
g.setColor(Color.darkGray);
g.drawRect(point.x, point.y, 1, 1);
// redraw startPoint so that a slightly moving drift doesn't
// overdraw the startPoint with the color of an intermediate
// point
g.setColor(Color.red);
g.drawRect(startPoint.x, startPoint.y, 1, 1);
}
last = Optional.of(p);
lastPoint = Optional.of(point);
}
log.info("drawn");
}