jchambers / jeospatial Goto Github PK
View Code? Open in Web Editor NEWA memory-resident geospatial index library for Java
Home Page: http://jchambers.github.com/jeospatial/
License: BSD 2-Clause "Simplified" License
A memory-resident geospatial index library for Java
Home Page: http://jchambers.github.com/jeospatial/
License: BSD 2-Clause "Simplified" License
Add a set of search methods for finding points within a latitude/longitude bounding "box." Bounding box searches could be useful for finding points in a subsection of map that has a cylindrical projection (e.g. a viewport of a Google/Bing map).
I am getting below error when trying to handle an index of size 100000000.
Sample program
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.eatthepath.jeospatial.VPTreeGeospatialIndex;
import com.eatthepath.jeospatial.GeospatialPoint;
public class GeoIndexTest {
public static void main(String[] args) {
List<GeospatialPoint> points = new ArrayList<>();
final Random r = new Random();
long t1 = System.currentTimeMillis();
for (int i = 0; i < 100000000; i++) {
points.add(new GeospatialPoint() {
@Override
public double getLatitude() {
return (r.nextDouble() * -180.0) + 90.0;
}
@Override
public double getLongitude() {
return (r.nextDouble() * -360.0) + 180.0;
}
});
}
long t2 = System.currentTimeMillis();
System.out.println("Inserted in " + (t2 - t1));
points.add(new GeospatialPoint(){
@Override
public double getLatitude() {
// TODO Auto-generated method stub
return 39.165325d;
}
@Override
public double getLongitude() {
// TODO Auto-generated method stub
return -86.5263857d;
}
});
VPTreeGeospatialIndex vpti = new VPTreeGeospatialIndex(points);
// indiana
List allPointsInBoundingBox = vpti.getAllPointsInBoundingBox(37.96, -87.54d, 41.76, -84.81d);
System.out.println("Results : " + allPointsInBoundingBox.size());
long t3 = System.currentTimeMillis();
System.out.println("Searched in " + (t3 - t2));
}
}
Output
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index -65467727 out of bounds for length 100000001
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:373)
at java.base/java.util.ArrayList.get(ArrayList.java:426)
at com.eatthepath.jvptree.util.SamplingMedianDistanceThresholdSelectionStrategy.getSampledPoints(SamplingMedianDistanceThresholdSelectionStrategy.java:61)
at com.eatthepath.jvptree.util.SamplingMedianDistanceThresholdSelectionStrategy.selectThreshold(SamplingMedianDistanceThresholdSelectionStrategy.java:43)
at com.eatthepath.jvptree.VPTreeNode.anneal(VPTreeNode.java:88)
at com.eatthepath.jvptree.VPTreeNode.<init>(VPTreeNode.java:62)
at com.eatthepath.jvptree.VPTree.<init>(VPTree.java:129)
at com.eatthepath.jvptree.VPTree.<init>(VPTree.java:70)
at com.eatthepath.jeospatial.VPTreeGeospatialIndex.<init>(VPTreeGeospatialIndex.java:24)
at edu.iu.iuni.moe.GeoIndexTest.main(GeoIndexTest.java:53)
Consider using the Haversine formula for distance calculations instead of the spherical law of cosines. The spherical law of cosines gets a bit shaky at small angles.
If possible please deploy jar to https://repo1.maven.org/maven2/com/eatthepath/.
jeospatial contains a ReverseComparator
class that duplicates the functionality of java.util.Collections#reverseOrder(Comparator<T>)
. Oops.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.