deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

org.deegree.geometry.linearization
Class CurveLinearizer

java.lang.Object
  extended by org.deegree.geometry.linearization.CurveLinearizer

public class CurveLinearizer
extends Object

Provides methods for the linearization of Curves and CurveSegments.

Currently, the following CurveSegment variants are handled correctly:

Version:
$Revision: 22498 $, $Date: 2010-02-10 17:41:39 +0100 (Mi, 10 Feb 2010) $
Author:
Andrei Ionita, Markus Schneider, last edited by: $Author: mschneider $

Constructor Summary
CurveLinearizer(GeometryFactory geomFac)
           
 
Method Summary
static boolean areCollinear(Point p0, Point p1, Point p2)
          Tests if the given three points are collinear.
(package private)  Point calcCircleCenter(Point p0, Point p1, Point p2)
          Finds the center of a circle/arc that is specified by three points that lie on the circle's boundary.
(package private)  boolean isClockwise(Point p0, Point p1, Point p2)
          Returns whether the order of the given three points is clockwise or counterclockwise.
 Curve linearize(Curve curve, LinearizationCriterion crit)
          Returns a linearized version of the given Curve geometry.
 LineStringSegment linearize(CurveSegment segment, LinearizationCriterion crit)
          Returns a linearized version (i.e. a LineStringSegment) of the given CurveSegment.
 LineStringSegment linearizeArc(Arc arc, LinearizationCriterion crit)
          Returns a linearized version (i.e. a LineStringSegment) of the given Arc.
 LineStringSegment linearizeCubicSpline(CubicSpline spline, LinearizationCriterion crit)
          Returns a linearized version (i.e. a LineStringSegment) of the given CubicSpline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CurveLinearizer

public CurveLinearizer(GeometryFactory geomFac)
Parameters:
geomFac -
Method Detail

linearize

public Curve linearize(Curve curve,
                       LinearizationCriterion crit)
Returns a linearized version of the given Curve geometry.

NOTE: This method respects the semantic difference between Curve and Ring geometries: if the input is a Ring, a ring geometry will be returned.

Parameters:
curve -
crit -
Returns:
linearized version of the input curve

linearize

public LineStringSegment linearize(CurveSegment segment,
                                   LinearizationCriterion crit)
Returns a linearized version (i.e. a LineStringSegment) of the given CurveSegment.

Parameters:
segment - the segment to be linearized
crit - determines the interpolation quality / number of interpolation points
Returns:
linearized version of the input segment

linearizeArc

public LineStringSegment linearizeArc(Arc arc,
                                      LinearizationCriterion crit)
Returns a linearized version (i.e. a LineStringSegment) of the given Arc.

If the three control points p0, p1 and p2 of the arc are collinear, i.e. on a straight line, the behaviour depends on the type of Arc:

Parameters:
arc - curve segment to be linearized
crit - determines the interpolation quality / number of interpolation points
Returns:
linearized version of the input segment

linearizeCubicSpline

public LineStringSegment linearizeCubicSpline(CubicSpline spline,
                                              LinearizationCriterion crit)
Returns a linearized version (i.e. a LineStringSegment) of the given CubicSpline.

A cubic spline consists of n polynomials of degree 3: Sj(x) = aj + bj*(x-xj) + cj*(x-xj)2 + dj*(x-xj)3; that acts upon the interval [xj,xj+1], 0 <=j< n.

The algorithm for generating points on a spline defined with only control points and starting/ending tangents can be found at http://persson.berkeley.edu/128A/lec14-2x3.pdf (last visited 19/08/09)

Parameters:
spline - curve segment to be linearized
crit - determines the interpolation quality / number of interpolation points
Returns:
linearized version of the input segment

calcCircleCenter

Point calcCircleCenter(Point p0,
                       Point p1,
                       Point p2)
                 throws IllegalArgumentException
Finds the center of a circle/arc that is specified by three points that lie on the circle's boundary.

Credits go to wikipedia (visited on 13/08/09).

Parameters:
p0 - first point
p1 - second point
p2 - third point
Returns:
center of the circle
Throws:
IllegalArgumentException - if the points are collinear, i.e. on a single line

isClockwise

boolean isClockwise(Point p0,
                    Point p1,
                    Point p2)
              throws IllegalArgumentException
Returns whether the order of the given three points is clockwise or counterclockwise. Uses the (signed) area of a planar triangle to get to know about the order of the points.

Parameters:
p0 - first point
p1 - second point
p2 - third point
Returns:
true, if order is clockwise, otherwise false
Throws:
IllegalArgumentException - if no order can be determined, because the points are identical or collinear

areCollinear

public static boolean areCollinear(Point p0,
                                   Point p1,
                                   Point p2)
Tests if the given three points are collinear.

NOTE: Only this method should be used throughout the whole linearization process for testing collinearity to avoid inconsistent results (the necessary EPSILON would differ).

Parameters:
p0 -
p1 -
p2 -
Returns:
true if the points are collinear, false otherwise

deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org

]]>