Skip to content

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

Description

@emilburzo

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions