本文整理汇总了Java中com.github.davidmoten.rtree.geometry.Geometry类的典型用法代码示例。如果您正苦于以下问题:Java Geometry类的具体用法?Java Geometry怎么用?Java Geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Geometry类属于com.github.davidmoten.rtree.geometry包,在下文中一共展示了Geometry类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: find
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的package包/类
/**
* Finds the closest node or edges within the specified maximum radius.
*
* @param x the x position of the query point
* @param y the y position of the query point
* @param nodeAction the action that needs to be executed when a node is found
* @param edgeAction the action that needs to be executed when an edge is found
*/
@SuppressWarnings("squid:S1166") // No need to log the exception itself, a message is enough.
public void find(final double x, final double y,
final Consumer<Integer> nodeAction, final BiConsumer<Integer, Integer> edgeAction) {
try {
final Entry<Integer[], Geometry> result = tree.nearest(point(x, y), MAX_NEARNESS_DISTANCE, 1)
.toBlocking()
.first();
if (result.geometry() instanceof Rectangle) {
nodeAction.accept(result.value()[0]);
} else if (result.geometry() instanceof Line) {
edgeAction.accept(result.value()[0], result.value()[1]);
}
} catch (final NoSuchElementException e) {
// There is no need to log the exception itself.
LOGGER.debug("No node or edge found at position (" + x + ", " + y + ").");
}
}
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:27,代码来源:RTree.java
示例2: createFBSByteArray
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的package包/类
private <Object, S extends Geometry> byte[] createFBSByteArray(RTree<Object, S> tree) {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
Func1<Object, byte[]> serializer = new Func1<Object, byte[]>() {
@Override
public byte[] call(Object o) {
return new byte[0];
}
};
Func1<byte[], Object> deserializer = new Func1<byte[], Object>() {
@Override
public Object call(byte[] bytes) {
return null;
}
};
Serializer<Object, S> fbSerializer = SerializerFlatBuffers.create(serializer,
deserializer);
try {
fbSerializer.write(tree, os);
os.close();
return os.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:25,代码来源:FBSRTree.java
示例3: createFBSTree
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的package包/类
private <Object, S extends Geometry> RTree<Object, S> createFBSTree(byte [] byteArray) {
Func1<Object, byte[]> serializer = new Func1<Object, byte[]>() {
@Override
public byte[] call(Object o) {
return new byte[0];
}
};
Func1<byte[], Object> deserializer = new Func1<byte[], Object>() {
@Override
public Object call(byte[] bytes) {
return null;
}
};
Serializer<Object, S> fbSerializer = SerializerFlatBuffers.create(serializer,
deserializer);
try {
ByteArrayInputStream is = new ByteArrayInputStream(byteArray);
return fbSerializer.read(is, byteArray.length, InternalStructure.SINGLE_ARRAY);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:23,代码来源:FBSRTree.java
示例4: find
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的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
示例5: findTilesInBox
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的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
示例6: nearest
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的package包/类
public static <T, S extends Geometry> Observable<Entry<T, S>> nearest(RTree<T, S> rtree, final Rectangle r, final double maxDistance, int maxCount) {
return rtree.search(r, maxDistance).lift(
new SortedOutputQueue<Entry<T, S>>(maxCount, Comparators
.<T, S> ascendingDistance(r)));
}
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:6,代码来源:SpatialTools.java
示例7: findTilesInCircle
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的package包/类
/**
* @return all tiles that intersect the specified circle.
*/
public List<TileBounds> findTilesInCircle(final Circle circle) {
final Observable<Entry<TileBounds, Geometry>> searchResults = tree.search(circle);
return convertResultsToList(searchResults);
}
开发者ID:saalfeldlab,项目名称:render,代码行数:8,代码来源:TileBoundsRTree.java
示例8: convertResultsToList
import com.github.davidmoten.rtree.geometry.Geometry; //导入依赖的package包/类
private List<TileBounds> convertResultsToList(final Observable<Entry<TileBounds, Geometry>> searchResults) {
final List<TileBounds> matchingTiles = new ArrayList<>();
// TODO: make sure use of toBlocking() here is appropriate
final List<Entry<TileBounds, Geometry>> collectedResultList = searchResults.toList().toBlocking().single();
for (final Entry<TileBounds, Geometry> entry : collectedResultList) {
matchingTiles.add(entry.value());
}
return matchingTiles;
}
开发者ID:saalfeldlab,项目名称:render,代码行数:14,代码来源:TileBoundsRTree.java
注:本文中的com.github.davidmoten.rtree.geometry.Geometry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论