Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

position prediction fails for close-to-the-dateline #87

Open
emilburzo opened this issue Apr 2, 2019 · 2 comments
Open

position prediction fails for close-to-the-dateline #87

emilburzo opened this issue Apr 2, 2019 · 2 comments
Labels

Comments

@emilburzo
Copy link

It appears that the position predictor has difficulties near the dateline meridian.

You can see in the output below that it's a positive value instead of a negative one.

Testcase:

public void test180Meridian() {
	int distanceKm = 10;
	Position from = Position.create(-16.796686666666666, -179.99983333333333);
	Position north = from.predict(distanceKm, 0);
	Position south = from.predict(distanceKm, 180);
	Position east = from.predict(distanceKm, 90);
	Position west = from.predict(distanceKm, 270);

	System.out.println(north);
	System.out.println(south);
	System.out.println(east);
	System.out.println(west);

	Geometries.rectangle(west.getLon(), south.getLat(), east.getLon(), north.getLat());
}

Output:

[-16.706754647233197,-179.99983333333333]
[-16.886618686100135,-179.99983333333333]
[-16.79666536204166,-179.90589349094225]
[-16.79666536204166,179.9062268242756]

Stacktrace:

java.lang.IllegalArgumentException
	at com.github.davidmoten.guavamini.Preconditions.checkArgument(Preconditions.java:25)
	at com.github.davidmoten.rtree.geometry.internal.RectangleDouble.<init>(RectangleDouble.java:14)
	at com.github.davidmoten.rtree.geometry.internal.RectangleDouble.create(RectangleDouble.java:23)
	at com.github.davidmoten.rtree.geometry.Geometries.rectangleDouble(Geometries.java:58)
	at com.github.davidmoten.rtree.geometry.Geometries.rectangle(Geometries.java:36)
@davidmoten
Copy link
Owner

I think there are some normalization offerings with other methods like Geometries.rectangleGeographic. You may still have to break your desired search region into two rectangles (one left of the 180 longitude line and the other right of it).

@emilburzo
Copy link
Author

Ok, I just thought it might make sense for the position predictor to be capped at the dateline, but I admit I am not sure of the implications.

Thanks for the Geometries.rectangleGeographic tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants