public class IlvPolygonSimplifyingEngine extends Object
The algorithm used is adapted from the Douglas and Peucker algorithm. Reference: The Canadian Cartographer 10(2): 112-22. Douglas D.H., Peucker T.K., 1973. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature.
Constructor and Description |
---|
IlvPolygonSimplifyingEngine(double distance,
IlvCoordinateSystem system)
Creates a new
IlvPolygonSimplifyingEngine object. |
Modifier and Type | Method and Description |
---|---|
boolean |
addPolygonsFromGraphic(IlvGraphic graphic)
Extracts the polygons which make up a graphic object.
|
void |
filterPolygon(int ip)
Simplifies a polygon.
|
protected double |
geoDistance(IlvPoint p1,
IlvPoint p2)
Computes the distance between two points.
|
IlvGraphic |
getOriginGraphic(int ip)
Returns the
IlvGraphic which triggered the creation of the
polygon. |
int |
getPolygonCount()
Returns the number of polygons.
|
IlvGraphic |
makeGraphic(int ip,
IlvGraphic origin)
Creates an
IlvGraphic object from the simplified polygon
data. |
protected boolean |
pointsEqual(IlvPoint pt1,
IlvPoint pt2)
Checks if two points are equal for the common point reduction phase.
|
void |
splitPolygonCommonParts(int i1,
int i2)
Test if two polygons have common strings of points.
|
public IlvPolygonSimplifyingEngine(double distance, IlvCoordinateSystem system)
IlvPolygonSimplifyingEngine
object.distance
- The maximum simplification distance in meters.system
- The coordinate system which the polygons coordinates are in.public boolean addPolygonsFromGraphic(IlvGraphic graphic)
This method stores the graphic properties for future creation
of simplified results.
The graphic
parameter is accessible by calling the
getOriginGraphic(int)
method of the resulting polygons.
Note: this method may create more than one polygon for a single graphical object. For example, this is the case for graphic sets.
graphic
- A projected graphic object used to represent the feature.true
is returned.makeGraphic(int, IlvGraphic)
public void filterPolygon(int ip)
ip
- The index of the polygon to be simplified.public int getPolygonCount()
public void splitPolygonCommonParts(int i1, int i2)
i1
and i1
have common strings of points,
this method splits the polygons internally, then
shares the common parts. This is done in order that the simplification
algorithm is used only once only in the common area.i1
- The index of the first polygon.i2
- The index of the second polygon.protected double geoDistance(IlvPoint p1, IlvPoint p2)
Note: you can override this method to provide a different distance measure.
p1
- The first point.p2
- The second point.p1
and
p2
.protected boolean pointsEqual(IlvPoint pt1, IlvPoint pt2)
Point2D.equals(Object)
.
Note: you can override this method to provide a different equality measure.
pt1
- The first point to test.pt2
- The second point to test.pt1
and pt2
are equal,
true
is returned.public IlvGraphic getOriginGraphic(int ip)
IlvGraphic
which triggered the creation of the
polygon.ip
- The index of the polygonpublic IlvGraphic makeGraphic(int ip, IlvGraphic origin)
IlvGraphic
object from the simplified polygon
data.ip
- The index of the polygon.origin
- The reference graphic used to decide the output that should
be produced.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.