public class PointReducer extends Object
Constructor and Description |
---|
PointReducer() |
Modifier and Type | Method and Description |
---|---|
static double |
orthogonalDistance(GeoPoint point,
GeoPoint lineStart,
GeoPoint lineEnd)
Calculate the orthogonal distance from the line joining the
lineStart and lineEnd points to point
|
static ArrayList<GeoPoint> |
reduceWithTolerance(ArrayList<GeoPoint> shape,
double tolerance)
Reduce the number of points in a shape using the Douglas-Peucker algorithm
Suggested usage
|
public static ArrayList<GeoPoint> reduceWithTolerance(ArrayList<GeoPoint> shape, double tolerance)
//get the screen bounds
BoundingBox boundingBox = map.getBoundingBox();
final double latSpanDegrees = boundingBox.getLatitudeSpan();
//get the degree difference, divide by dpi
double tolerance = latSpanDegrees /densityDpi;
//each latitude degree on screen is represented by this many dip
points = PointReducer.reduceWithTolerance(points, tolerance);
tolerance
- The tolerance to decide whether or not
to keep a point, in the coordinate system
of the points (micro-degrees here)shape
- The shape to reducepublic static double orthogonalDistance(GeoPoint point, GeoPoint lineStart, GeoPoint lineEnd)
point
- The point the distance is being calculated forlineStart
- The point that starts the linelineEnd
- The point that ends the line