本文整理汇总了Java中com.github.davidmoten.rtree.geometry.Geometries类的典型用法代码示例。如果您正苦于以下问题:Java Geometries类的具体用法?Java Geometries怎么用?Java Geometries使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Geometries类属于com.github.davidmoten.rtree.geometry包,在下文中一共展示了Geometries类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: entries1000
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
static List<Entry<Object, Rectangle>> entries1000() {
List<Entry<Object, Rectangle>> list = new ArrayList<Entry<Object, Rectangle>>();
BufferedReader br = new BufferedReader(
new InputStreamReader(RTreeBenchmark.class.getResourceAsStream("/1000.txt")));
String line;
try {
while ((line = br.readLine()) != null) {
String[] items = line.split(" ");
double x = Double.parseDouble(items[0]);
double y = Double.parseDouble(items[1]);
list.add(Entries.entry(new Object(), Geometries.rectangle(x, y, x + 1, y + 1)));
}
br.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
return list;
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:19,代码来源:RTreeBenchmark.java
示例2: 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;
}
开发者ID:kennycason,项目名称:kumo,代码行数:19,代码来源:RTreeWordPlacer.java
示例3: find
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
/**
* Find.
*
* @param longitude the longitude
* @param latitude the latitude
* @return the city
*/
public City find(Double longitude, Double latitude){
if(longitude == null || latitude == null){
return null;
}
Observable<Entry<City, Geometry>> result = this.rtree.nearest(Geometries.pointGeographic(longitude, latitude), 10000, 1);
if(result==null){
return null;
}
try{
return result.toBlocking().single().value();
}catch(NoSuchElementException e){
return null;
}
}
开发者ID:mmarmol,项目名称:geolite2,代码行数:22,代码来源:CityFinder.java
示例4: 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());
}
开发者ID:chhh,项目名称:batmass,代码行数:10,代码来源:FeatureUtils.java
示例5: 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);
}
开发者ID:chhh,项目名称:batmass,代码行数:11,代码来源:Features.java
示例6: addTile
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
/**
* Add a tile to this tree.
*
* @param tileBounds bounds for the tile.
*/
public void addTile(final TileBounds tileBounds) {
tileBoundsList.add(tileBounds);
tree = tree.add(tileBounds,
Geometries.rectangle(tileBounds.getMinX(),
tileBounds.getMinY(),
tileBounds.getMaxX(),
tileBounds.getMaxY()));
}
开发者ID:saalfeldlab,项目名称:render,代码行数:14,代码来源:TileBoundsRTree.java
示例7: 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);
}
开发者ID:saalfeldlab,项目名称:render,代码行数:13,代码来源:TileBoundsRTree.java
示例8: addToQueue
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
private Action1<VesselPosition> addToQueue() {
return new Action1<VesselPosition>() {
@Override
public void call(VesselPosition p) {
// System.out.println(p.lat() + "\t" + p.lon() + "\t"
// + p.id().uniqueId());
if (queue.size() % 10000 == 0)
System.out.println("queue.size=" + queue.size());
queue.add(p);
tree = tree.add(p, Geometries.point(p.lon(), p.lat()));
}
};
}
开发者ID:amsa-code,项目名称:risky,代码行数:15,代码来源:DriftingLayer.java
示例9: testRange
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@Test
public void testRange() {
assertEquals(Geometries.rectangle(42.0d, 0.0d, 42.0d, 1.0d), range(Range.singleton(42L)));
assertEquals(Geometries.rectangle(24.0d, 0.0d, 42.0d, 1.0d), range(Range.closed(24L, 42L)));
assertEquals(Geometries.rectangle(24.0d, 0.0d, 41.0d, 1.0d), range(Range.closedOpen(24L, 42L)));
assertEquals(Geometries.rectangle(25.0d, 0.0d, 42.0d, 1.0d), range(Range.openClosed(24L, 42L)));
assertEquals(Geometries.rectangle(25.0d, 0.0d, 41.0d, 1.0d), range(Range.open(24L, 42L)));
}
开发者ID:nmdp-bioinformatics,项目名称:ngs,代码行数:9,代码来源:RangeGeometriesTest.java
示例10: searchOneGreek
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@GenerateMicroBenchmark
public void searchOneGreek() {
rtreeGreek.search(Geometries.rectangle(40, 27.0, 40.5, 27.5)).subscribe();
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:5,代码来源:RTreeBenchmark.java
示例11: searchOne1k
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@GenerateMicroBenchmark
public void searchOne1k() {
rtree1k.search(Geometries.rectangle(500, 500, 630, 630)).subscribe();
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:5,代码来源:RTreeBenchmark.java
示例12: searchOneBackpressureGreek
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@GenerateMicroBenchmark
public void searchOneBackpressureGreek() {
rtreeGreek.search(Geometries.rectangle(40, 27.0, 40.5, 27.5)).take(1000).subscribe();
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:5,代码来源:RTreeBenchmark.java
示例13: searchOneBackpressure1k
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@GenerateMicroBenchmark
public void searchOneBackpressure1k() {
rtree1k.search(Geometries.rectangle(500, 500, 630, 630)).take(600).subscribe();
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:5,代码来源:RTreeBenchmark.java
示例14: searchNearestGreek
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@GenerateMicroBenchmark
public void searchNearestGreek() {
rtreeGreek.nearest(Geometries.point(40.0, 27.0), 1, 300).subscribe();
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:5,代码来源:RTreeBenchmark.java
示例15: searchNearest1k
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@GenerateMicroBenchmark
public void searchNearest1k() {
rtree1k.nearest(Geometries.point(500.0, 500.0), 10, 30).subscribe();
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:5,代码来源:RTreeBenchmark.java
示例16: findTilesInCircle
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
/**
* @return all tiles that intersect the specified circle.
*/
public List<TileBounds> findTilesInCircle(final double centerX,
final double centerY,
final double radius) {
return findTilesInCircle(Geometries.circle(centerX, centerY, radius));
}
开发者ID:saalfeldlab,项目名称:render,代码行数:9,代码来源:TileBoundsRTree.java
示例17: getCircleNeighbors
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
/**
* @param neighborTrees list of trees for all neighboring sections to include in the pairing process.
*
* @param neighborRadiusFactor If explicitRadius is null, this factor is applied to max(width, height) of
* each tile to determine radius for locating neighbor tiles.
*
* @param explicitRadius explicit radius in full scale pixels for locating neighbor tiles.
* If set, will override neighborRadiusFactor.
* Specify as null to use neighborRadiusFactor.
*
* @param excludeCornerNeighbors if true, exclude neighbor tiles whose center x and y is outside the
* source tile's x and y range respectively.
*
* @param excludeSameLayerNeighbors if true, exclude neighbor tiles in the same layer (z) as the source tile.
*
* @param excludeSameSectionNeighbors if true, exclude neighbor tiles with the same sectionId as the source tile.
*
* @return set of distinct neighbor pairs between this tree's tiles and the specified neighbor trees' tiles.
*/
public Set<OrderedCanvasIdPair> getCircleNeighbors(final List<TileBoundsRTree> neighborTrees,
final double neighborRadiusFactor,
final Double explicitRadius,
final boolean excludeCornerNeighbors,
final boolean excludeSameLayerNeighbors,
final boolean excludeSameSectionNeighbors) {
String firstTileId = null;
if (tileBoundsList.size() > 0) {
firstTileId = tileBoundsList.get(0).getTileId();
}
LOG.debug("getCircleNeighbors: entry, {} tiles with z {}, {} neighborTrees, firstTileId is {}",
tileBoundsList.size(), z, neighborTrees.size(), firstTileId);
final Set<OrderedCanvasIdPair> neighborTileIdPairs = new HashSet<>(50000);
double tileWidth;
double tileHeight;
double centerX;
double centerY;
double radius;
Circle circle;
List<TileBounds> searchResults;
for (final TileBounds tileBounds : tileBoundsList) {
tileWidth = tileBounds.getDeltaX();
tileHeight = tileBounds.getDeltaY();
centerX = tileBounds.getMinX() + (tileWidth / 2);
centerY = tileBounds.getMinY() + (tileHeight / 2);
if (explicitRadius == null) {
radius = Math.max(tileWidth, tileHeight) * neighborRadiusFactor;
} else {
radius = explicitRadius;
}
circle = Geometries.circle(centerX, centerY, radius);
if (! excludeSameLayerNeighbors) {
searchResults = findTilesInCircle(circle);
neighborTileIdPairs.addAll(
getDistinctPairs(tileBounds, searchResults,
excludeCornerNeighbors, excludeSameSectionNeighbors, true));
}
for (final TileBoundsRTree neighborTree : neighborTrees) {
searchResults = neighborTree.findTilesInCircle(circle);
neighborTileIdPairs.addAll(
getDistinctPairs(tileBounds, searchResults,
excludeCornerNeighbors, excludeSameSectionNeighbors, false));
}
}
LOG.debug("getCircleNeighbors: exit, returning {} pairs", neighborTileIdPairs.size());
return neighborTileIdPairs;
}
开发者ID:saalfeldlab,项目名称:render,代码行数:79,代码来源:TileBoundsRTree.java
示例18: 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");
}
开发者ID:amsa-code,项目名称:risky,代码行数:58,代码来源:DriftingLayer.java
示例19: geometry
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
private static Point geometry(VesselPosition p) {
return Geometries.point(p.lon(), p.lat());
}
开发者ID:amsa-code,项目名称:risky,代码行数:4,代码来源:State.java
示例20: testSingleton
import com.github.davidmoten.rtree.geometry.Geometries; //导入依赖的package包/类
@Test
public void testSingleton() {
assertEquals(Geometries.point(42.0d, 0.5d), singleton(42L));
}
开发者ID:nmdp-bioinformatics,项目名称:ngs,代码行数:5,代码来源:RangeGeometriesTest.java
注:本文中的com.github.davidmoten.rtree.geometry.Geometries类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论