ilog.views.maps.datasource
Class IlvPolygonSimplifyingEngine

java.lang.Object
  extended by ilog.views.maps.datasource.IlvPolygonSimplifyingEngine

public class IlvPolygonSimplifyingEngine
extends Object

This class simplifies a set of polylines by reducing the number of points they contain.

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.

Since:
JViews 8.1

Constructor Summary
IlvPolygonSimplifyingEngine(double distance, IlvCoordinateSystem system)
          Creates a new IlvPolygonSimplifyingEngine object.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvPolygonSimplifyingEngine

public IlvPolygonSimplifyingEngine(double distance,
                                   IlvCoordinateSystem system)
Creates a new IlvPolygonSimplifyingEngine object.

Parameters:
distance - The maximum simplification distance in meters.
system - The coordinate system which the polygons coordinates are in.
Method Detail

addPolygonsFromGraphic

public boolean addPolygonsFromGraphic(IlvGraphic graphic)
Extracts the polygons which make up a graphic object.

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.

Parameters:
graphic - A projected graphic object used to represent the feature.
Returns:
If polygons could be extracted, true is returned.
See Also:
makeGraphic(int, IlvGraphic)

filterPolygon

public void filterPolygon(int ip)
Simplifies a polygon.

Parameters:
ip - The index of the polygon to be simplified.

getPolygonCount

public int getPolygonCount()
Returns the number of polygons.

Returns:
the number of polygons.

splitPolygonCommonParts

public void splitPolygonCommonParts(int i1,
                                    int i2)
Test if two polygons have common strings of points. If 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.

Parameters:
i1 - The index of the first polygon.
i2 - The index of the second polygon.

geoDistance

protected double geoDistance(IlvPoint p1,
                             IlvPoint p2)
Computes the distance between two points. This method uses the coordinate system of the engine to compute a geodetic distance.

Note: you can override this method to provide a different distance measure.

Parameters:
p1 - The first point.
p2 - The second point.
Returns:
The distance in meters between p1 and p2.

pointsEqual

protected boolean pointsEqual(IlvPoint pt1,
                              IlvPoint pt2)
Checks if two points are equal for the common point reduction phase. This default implementation uses Point2D.equals(Object).

Note: you can override this method to provide a different equality measure.

Parameters:
pt1 - The first point to test.
pt2 - The second point to test.
Returns:
If pt1 and pt2 are equal, true is returned.

getOriginGraphic

public IlvGraphic getOriginGraphic(int ip)
Returns the IlvGraphic which triggered the creation of the polygon.

Parameters:
ip - The index of the polygon
Returns:
The graphic to which the polygon has been added.

makeGraphic

public IlvGraphic makeGraphic(int ip,
                              IlvGraphic origin)
Creates an IlvGraphic object from the simplified polygon data.

Parameters:
ip - The index of the polygon.
origin - The reference graphic used to decide the output that should be produced.
Returns:
The resulting simplified graphical object.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.