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:

Version:
$Revision: 31641 $, $Date: 2011-08-24 21:24:55 +0200 (Wed, 24 Aug 2011) $
Author:
Andrei Ionita, Markus Schneider, Stephan Reichhelm, last edited by: $Author: mschneider $

Constructor Summary
CurveLinearizer(GeometryFactory geomFac)
          Creates a new CurveLinearizer instance.
 
Method Summary
static boolean areCollinear(Point p0, Point p1, Point p2)
          Tests if the given three points are collinear.
 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 linearizeArcString(ArcString arcString, LinearizationCriterion crit)
          Returns a linearized version (i.e. a LineStringSegment) of the given ArcString.
 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)
Creates a new CurveLinearizer instance.

Parameters:
geomFac - geometry factory to be used for creating LineStrings and LineStringSegments, must not be null
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 - curve to be linearized, must not be null
crit - linearization criterion, must not be null
Returns:
linearized version of the input curve, never null

linearize

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

Parameters:
segment - segment to be linearized, must not be null
crit - determines the interpolation quality / number of interpolation points, must not be null
Returns:
linearized version of the input segment, never null

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 - segment to be linearized, must not be null
crit - determines the interpolation quality / number of interpolation points, must not be null
Returns:
linearized version of the input segment, never null

linearizeArcString

public LineStringSegment linearizeArcString(ArcString arcString,
                                            LinearizationCriterion crit)
Returns a linearized version (i.e. a LineStringSegment) of the given ArcString.

If one of the arc elements is collinear, it will be added as a straight segment.

Parameters:
arcString - curve segment to be linearized, must not be null
crit - determines the interpolation quality / number of interpolation points, must not be null
Returns:
linearized version of the input string, never null

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, must not be null
crit - determines the interpolation quality / number of interpolation points, must not be null
Returns:
linearized version of the input segment, never null

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 - first point, must not be null
p1 - second point, must not be null
p2 - third point, must not be null
Returns:
true if the points are collinear, false otherwise


Copyright © 2011. All Rights Reserved.