• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Entry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.davidmoten.rtree.Entry的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Entry类属于com.github.davidmoten.rtree包,在下文中一共展示了Entry类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: find

import com.github.davidmoten.rtree.Entry; //导入依赖的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: entries1000

import com.github.davidmoten.rtree.Entry; //导入依赖的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


示例3: place

import com.github.davidmoten.rtree.Entry; //导入依赖的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


示例4: find

import com.github.davidmoten.rtree.Entry; //导入依赖的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.Entry; //导入依赖的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: testRTree

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@Test
public void testRTree() {
    RTree<String> rtree = RTree.create();
    rtree = rtree.add("foo", closed(10, 20));
    rtree = rtree.add("bar", closedOpen(14, 28));
    rtree = rtree.add("baz", open(18, 36));

    int count = 0;
    for (Entry<String> result : rtree.search(singleton(20)).toBlocking().toIterable()) {
        count++;
    }
    assertEquals(3, count);
}
 
开发者ID:nmdp-bioinformatics,项目名称:ngs,代码行数:14,代码来源:RangeGeometriesTest.java


示例7: entriesList

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
static List<Entry<Object, Point>> entriesList() {
    List<Entry<Object, Point>> result = entries().toList().toBlocking().single();
    System.out.println("loaded greek earthquakes into list");
    return result;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:6,代码来源:GreekEarthquakes.java


示例8: insertBatchGreek

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Point> insertBatchGreek() {
    RTree<Object, Point> tree = rtreeGreek;
    for (Entry<Object, Point> entry: entriesGreek04) tree = tree.add(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java


示例9: insertBatch1k

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Rectangle> insertBatch1k() {
    RTree<Object, Rectangle> tree = rtree1k;
    for (Entry<Object, Rectangle> entry: entries1k04) tree = tree.add(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java


示例10: deleteBatchGreek

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Point> deleteBatchGreek() {
    RTree<Object, Point> tree = rtreeGreek;
    for (Entry<Object, Point> entry: entriesGreek06) tree = tree.delete(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java


示例11: deleteBatch1k

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Rectangle> deleteBatch1k() {
    RTree<Object, Rectangle> tree = rtree1k;
    for (Entry<Object, Rectangle> entry: entries1k06) tree = tree.delete(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java


示例12: joinGroupedShapes

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
protected void joinGroupedShapes() {
	
	// find groups of shapes that are visually together
	// - Must overlap
	// - Must be same type
	// - Must not contain each other
	// - Only one must have text
	
	// we can't actually make a group here, as that makes things like
	// bounding rectangles annoying. Instead, just link them together
	// with an edge 
	
	// insert naive implementation here
	for (final ShapeData shapeData: shapes) {
		
		if (shapeData.is1d())
			continue;
		
		final String symbolName = shapeData.vertex.getProperty("symbolName");
		if (symbolName.equals(""))
			continue;
		
		Observable<Entry<ShapeData, Rectangle>> entries = rtree.search(shapeData.rtreeBounds);
		
		entries.forEach(new Rx.RTreeAction() {

			@Override
			public void call(Entry<ShapeData, Rectangle> entry) {
				ShapeData other = entry.value();
				
				if (other == shapeData || other.is1d())
					return;
				
				// if the intersection is equal to the area of the smallest, then
				// we can assume one of them contains the other
				// .. don't want those to be joined
				
				if (!other.vertex.getProperty("symbolName").equals(symbolName) || 
					ShapeData.eitherEncloses(shapeData, other)) {
					return;
				}
				
				// but if it doesn't contain, then link them together
				createEdge(shapeData, other, "linked", null, null);
			}
		});
	}
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:49,代码来源:VisioPageParser.java


示例13: infer1dConnections

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
protected void infer1dConnections(final ShapeData shapeData) {
	
	// create a list of things that I'm attached to
	final Set<Vertex> attached = Sets.newHashSet(shapeData.vertex.getVertices(Direction.BOTH));
	
	// identify any shapes that it overlaps with
	// add that shape to the list of connections
	Observable<Entry<ShapeData, Rectangle>> entries = rtree.search(shapeData.rtreeBounds);
	
	entries.subscribe(new Rx.RTreeSubscriber() {
		
		@Override
		public void onNext(Entry<ShapeData, Rectangle> e) {
			
			ShapeData other = e.value();
			
			if (other == shapeData || other.removed || !other.is1d() || attached.contains(other.vertex))
				return;
			
			// don't infer connections between lines of different colors
			// or different line patterns
			if (!shapeData.lineColor.equals(other.lineColor) || shapeData.linePattern != other.linePattern) {
				return;
			}
			
			// compute if they intersect
			List<Point2D> intersections = new ArrayList<>();
			
			if (!GeomUtils.findIntersections(shapeData.path1D, other.path1D, intersections, null)) {
				return;
			}
			
			// TODO
			// if they are both dynamic connectors, don't create connections
			// unless their intersection is at the end of a line?
			// alternatively, try to check if the intersection happens at an
			// 'arcto' point. if so, discard, as that's a 'clear' visual indicator
			// that it should not be connected
			
			// ok, we've gotten here, create a connection between the two lines
			// -> connection point is first point.. not sure what to do with other points
			Point2D intersection = intersections.get(0);
			createEdge(shapeData, other, "inferred-1d", intersection.getX(), intersection.getY());
		}
	});
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:47,代码来源:VisioPageParser.java


示例14: associateTextboxWithShape

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
/**
 * this takes a shape that is a 'textbox'
 */
protected void associateTextboxWithShape(final ShapeData textBox) {
	
	// limit the search to some reasonable number/distance (TODO: what is reasonable)
	
	Observable<Entry<ShapeData, Rectangle>> entries = SpatialTools.nearest(rtree, textBox.rtreeBounds, helper.textInferenceDistance(textBox), rtree.size());
	
	final List<ShapeData> maybe = new ArrayList<>();
	
	entries.subscribe(new Rx.RTreeSubscriber() {
		
		@Override
		public void onNext(Entry<ShapeData, Rectangle> e) {
			
			ShapeData other = e.value();
			
			if (other == textBox || other.hasText || other.removed || !helper.onTextInference(textBox, other))
				return;
			
			// if it encloses it, only associate if there's nothing else closer
			if (other.encloses(textBox)) {
				if (maybe.isEmpty())
					maybe.add(other);
				
				return;
			}
			
			doAssociateTextboxWithShape(textBox, other);
			maybe.clear();
			
			// TODO: probably want to be more intelligent, and assign the text to
			//       things that are nearer in a particular direction, taking 
			//       advantage of how a human might naturally align the text..
			
			// done with this
			unsubscribe();
		}
	});
	
	// if we didn't find any alternatives, associate the first one that enclosed
	if (!maybe.isEmpty())
		doAssociateTextboxWithShape(textBox, maybe.get(0));
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:46,代码来源:VisioPageParser.java


示例15: inferDisconnectedGroupConnections

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
protected void inferDisconnectedGroupConnections(final GroupData groupData, final List<ShapeData> connections, final boolean ignore1d) {
	// identify any shapes that the group overlaps with
	// add that shape to the list of connections
	Observable<Entry<ShapeData, Rectangle>> entries = rtree.search(groupData.group.rtreeBounds);
	
	final Path2D groupPath = groupData.group.getPath();
	
	entries.subscribe(new Rx.RTreeSubscriber() {

		@Override
		public void onNext(Entry<ShapeData, Rectangle> e) {
			
			ShapeData other = e.value();
			if (other == groupData.group)
				return;
			
			if (other.is1d()) {
				
				// TODO: what we probably want is a function that checks all segments of the path 
				//       -- but only matches on the end segments matching
				
				if (ignore1d)
					return;
				
				// check to see if one of the endpoints of the 1d shape intersects
				// with the group
				if (!GeomUtils.pathIntersects(groupPath, other.path1Dstart) &&
				    !GeomUtils.pathIntersects(groupPath, other.path1Dend)) {
					return;
				}
				
			} else {
				
				if (!other.vertex.getVertices(Direction.BOTH).iterator().hasNext() ||  
					!GeomUtils.pathIntersects(groupPath, other.path2D)) {
					return;
				}
			}
			
			connections.add(other);
		}
	});
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:44,代码来源:VisioPageParser.java


示例16: removeShape

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
protected void removeShape(ShapeData shapeData) {
	shapeData.removed = true;
	graph.removeVertex(shapeData.vertex);
	rtree = rtree.delete(new Entry<ShapeData, Rectangle>(shapeData, shapeData.rtreeBounds));
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:6,代码来源:VisioPageParser.java


示例17: nearest

import com.github.davidmoten.rtree.Entry; //导入依赖的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


示例18: findTilesInCircle

import com.github.davidmoten.rtree.Entry; //导入依赖的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


示例19: convertResultsToList

import com.github.davidmoten.rtree.Entry; //导入依赖的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.Entry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContextEnvironment类代码示例发布时间:2022-05-22
下一篇:
Java VersionRequestProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap