Comments (11)
Once you've created an RTree
loading one by one from your txt file you then use the Serializers.write
example to write the tree to a binary (flatbuffers) file. You can then load an RTree
from that file later in the blink of an eye using Serializers.read
.
from rtree.
Just use the method RTree.nearest. you're right I should put an example in
the README, thanks.
On Wed, 18 May 2016 21:15 starryskyWW [email protected] wrote:
Thanks for your sharing.
I have many points which records latitude and longitude. I want to know
whether this code support K-nn query for each point?
I don't read relevant message exceptAs of 0.7.5 this library does not depend on guava (>2M) but rather depends
on guava-mini (11K). The nearest search used to depend on
MinMaxPriorityQueue from guava but now uses a backport of Java 8
PriorityQueue inside a custom BoundedPriorityQueue class that gives about
1.7x the throughput as the guava class.But there is no specific example for k-nn query.
Thanks so much.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#48
from rtree.
Thanks for your prompt reply. By the way, I want to ask something which concerns about loading data. I'm not quite clear about the use of class serializer.
I have a .txt file which records lots of location coordinates, the first column records latitude and the second column records corresponding longitude. I want to load these data at one time to build a r-tree, because it's quite time-consuming to add these points one by one. Some issues asked by others and the README.md indicated that serializer can achieve this .
But I don't know how to use this.
For the .txt file, I creat an inputstream like the following
But I thought I might be wrong to the processing of the data.
Thanks so much. This code is powerful.
from rtree.
Thanks for your kind explanation. There is another problem,
when I add rtree-0.7.5 version dependency in my pom.xml, there is no mistake for the code
List<Entry<String, Point>> list = new ArrayList<Entry<String, Point>>();
list.add(new Entry<String,Point>(String.valueOf(i),Point.create(Float.parseFloat(s[0]),Float.parseFloat(s[1]))));
But once I change to rtree-0.8-RC1
There is error hints that The method create(double, double) from the type Point is not visible
And when I type Point. in the second situation, there is not any hint for the method in the Point class.
I don't know why. Because the content of the Point class doesn't change in two versions.
from rtree.
Use Geometries.point
instead.
from rtree.
Thanks. And if I want to search the points inside a specific circle which is defined by a specific point and radius, what can I do?
It seems like the search(point,Distance)
will return all points inside a rectangle whose minimum bounding rectangles are within Distance from the given point. And I think maybe this will miss some points.
And I don't know whether it's right to write as
Point location = p1; (p1 is the heart of the circle)
String result = tree.search(location)
// filter on the exact distance from the centre of the GeoCircle
.filter(new Func1<Entry<String,Point>, Boolean>() {
Position from = Position.create(location.y(), location.x());
@Override
public Boolean call(Entry<String,Point> entry) {
Position centre = Position.create(entry.value().lat, entry.value().lon);
return from.getDistanceToKm(centre) < from.value().radiusKm;' }
I just made some small changes in the LatLongExampleTest.testSearchLatLongCircles().
I think if this can be realized,it would be very good. Thanks so much .
Thanks so much.
from rtree.
After I used Geometries.point
there is another problem for the code new Entry<String,Point>(String.valueOf(i),Geometries.point(Float.parseFloat(s[0]),Float.parseFloat(s[1])))
It said that Cannot instantiate the type Entry<String,Point>
And I tried Entry.entry(String.valueOf(i),Geometries.point(Float.parseFloat(s[0]),Float.parseFloat(s[1])))
It still doesn't work. It said that The method entry(String, Point) is undefined for the type Entry
I am sorry to occupy your time.
from rtree.
Entries.entry
(examples are on the README).
from rtree.
For the circle search you need to make sure the initial search is big enough not to miss any then filter on exact distance. Boils down to some simple geometry. Watch out though because when you do search(point, distance)
the distance unit will be degrees so you pick a large enough degrees value to cover the radius that you know in km, then filter in km as you were.
from rtree.
See worked example mentioned in README:
https://github.com/davidmoten/rtree#another-lat-long-example-searching-geo-circles-
from rtree.
Also remember the geographic distortion with latitude, a circle of radius 1 degree on the Earth's surface some distance from the equator will be "taller" in terms of km north-south than east-west. If accurate distance tests are needed they should be performed (as suggested) on the subset of results returned by the tree.
from rtree.
Related Issues (20)
- 0.8.7 version method add in RTree HOT 1
- RTree search function not invoking callback function number of expected times HOT 9
- How can I use R-tree and R*-tree to store roads information and use circle to search point nearest roads?
- How to serialize all geometry? HOT 1
- How to add the count of data points and their linear sum for each MBR HOT 1
- Rtree can't insert anything HOT 2
- The unit of Circle radius is in meter? HOT 2
- Question: how to find overlapping circles? HOT 4
- How to do an incremental knn search? HOT 5
- Pre conditions failing in Rectangle Implementation HOT 2
- Honour minChildren with delete operation HOT 1
- Is the unit of the parameter radius in CircleDouble. create (x, y, radius) in meters? What other unit is it? HOT 2
- Difference between LineDouble and LineFloat
- Is there a way to have sampled results over a geographical search ? HOT 3
- Incorrect result for horizontal line search HOT 4
- Rxjava2 version available? HOT 2
- Would you plan to provide a method that deletes entries according to a value? HOT 2
- rtree2 HOT 2
- [Question] A R-Tree search performance question HOT 7
- Propose to store the geographic rectangles in Integer rather than in Float
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rtree.