GithubHelp home page GithubHelp logo

jchambers / jeospatial Goto Github PK

View Code? Open in Web Editor NEW
40.0 5.0 14.0 1.07 MB

A memory-resident geospatial index library for Java

Home Page: http://jchambers.github.com/jeospatial/

License: BSD 2-Clause "Simplified" License

Java 98.07% HTML 1.93%
vp-tree geospatial nearest-neighbors

jeospatial's People

Contributors

dependabot[bot] avatar jchambers avatar kloytana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jeospatial's Issues

Add bounding "box" searching

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).

Getting a java.lang.IndexOutOfBoundsException:

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.