Package org.locationtech.jts.jump.warp
Class Triangulator
- java.lang.Object
-
- org.locationtech.jts.jump.warp.Triangulator
-
public class Triangulator extends Object
A better name for this class would have been TriangleMapFactory. Given the coordinates of an initial and final triangulation, it will return a map of source Triangle to destination Triangle. Creates a FeatureCollection of triangles covering a given area. Thin triangles are avoided.Coordinates are not created, modified, or discarded. Thus, the triangles created will be composed of the Coordinates passed in to the Triangulator. See White, Marvin S., Jr. and Griffin, Patricia. 1985. Piecewise linear rubber-sheet map transformation. "The American Cartographer" 12:2, 123-31.
-
-
Constructor Summary
Constructors Constructor Description Triangulator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.locationtech.jts.geom.Coordinate
add(org.locationtech.jts.geom.Coordinate a, org.locationtech.jts.geom.LineString vector)
protected List
alternativeTriangles(Triangle PQS, Triangle QRS)
Collection
getIgnoredVectors()
Permits the caller to identify which vectors were ignored because they were not 2-point LineStringsprotected List
heightMaximizedTriangles(Triangle PQS, Triangle QRS)
The intent of this method is to avoid narrow triangles, which create near singularities.static Collection
nonVectors(Collection geometries)
protected Quadrilateral
tag(Quadrilateral sourceQuad, Quadrilateral destQuad)
static List
taggedVectorVertices(boolean tips, Collection vectors)
The returned Coordinates will be tagged with the tails if the tips are requested (or the tips, if the tails are requested).protected Triangle
triangleContaining(org.locationtech.jts.geom.Coordinate p, List triangles)
Map
triangleMap(org.locationtech.jts.geom.Envelope datasetEnvelope, Collection vectorLineStrings, Collection sourceHints, Collection destinationHints, TaskMonitor monitor)
Map
triangleMap(org.locationtech.jts.geom.Envelope datasetEnvelope, Collection vectorLineStrings, TaskMonitor monitor)
Splits two regions into Triangles.static boolean
vector(org.locationtech.jts.geom.Geometry g)
protected org.locationtech.jts.geom.LineString
vectorWithNearestTail(org.locationtech.jts.geom.Coordinate x, List vectors)
-
-
-
Method Detail
-
triangleMap
public Map triangleMap(org.locationtech.jts.geom.Envelope datasetEnvelope, Collection vectorLineStrings, TaskMonitor monitor)
Splits two regions into Triangles. The two regions are called the "source quadrilateral" and "destination quadrilateral", and are based on the given dataset envelope. The "source quadrilateral" is the dataset envelope expanded 5% along each margin. The "destination quadrilateral" is the source quadrilateral with each vertex shifted according to the vector with the nearest tail. The source quadrilateral is split using the vector tails; the destination quadrilateral is split using the vector tips. In this way, the vectors map the source Triangles to the destination Triangles.- Parameters:
datasetEnvelope
- the region to triangulatevectors
- vectors (2-point LineStrings) whose tails and tips split the "source quadrilateral" and "destination quadrilateral" into triangles- Returns:
- a map of source Triangles to destination Triangles
-
triangleMap
public Map triangleMap(org.locationtech.jts.geom.Envelope datasetEnvelope, Collection vectorLineStrings, Collection sourceHints, Collection destinationHints, TaskMonitor monitor)
- Parameters:
sourceHints
- "far-away" Coordinates (even outside the dataset envelope) for which we must ensure that source triangles include.destinationHints
- "far-away" Coordinates for which we must ensure that destination triangles include
-
getIgnoredVectors
public Collection getIgnoredVectors()
Permits the caller to identify which vectors were ignored because they were not 2-point LineStrings
-
nonVectors
public static Collection nonVectors(Collection geometries)
-
vector
public static boolean vector(org.locationtech.jts.geom.Geometry g)
-
heightMaximizedTriangles
protected List heightMaximizedTriangles(Triangle PQS, Triangle QRS)
The intent of this method is to avoid narrow triangles, which create near singularities.- Parameters:
PQS
- a triangle sharing an edge with QRS; vertex order is irrelevant- Returns:
- (PQS and QRS) or (PQR, PRS), whichever pair has the largest minimum height
-
triangleContaining
protected Triangle triangleContaining(org.locationtech.jts.geom.Coordinate p, List triangles)
- Returns:
- the triangle containing p, or null if no triangle contains p
-
add
protected org.locationtech.jts.geom.Coordinate add(org.locationtech.jts.geom.Coordinate a, org.locationtech.jts.geom.LineString vector)
- Returns:
- a + the displacement represented by vector
-
vectorWithNearestTail
protected org.locationtech.jts.geom.LineString vectorWithNearestTail(org.locationtech.jts.geom.Coordinate x, List vectors)
-
tag
protected Quadrilateral tag(Quadrilateral sourceQuad, Quadrilateral destQuad)
- Returns:
- sourceQuad wrapped in TaggedCoordinates pointing to the corresponding Coordinates in destQuad.
-
alternativeTriangles
protected List alternativeTriangles(Triangle PQS, Triangle QRS)
- Parameters:
PQS
- a triangle sharing an edge with QRS; vertex order is irrelevant- Returns:
- triangles PQR and PRS, or null if PQRS is not convex
-
taggedVectorVertices
public static List taggedVectorVertices(boolean tips, Collection vectors)
The returned Coordinates will be tagged with the tails if the tips are requested (or the tips, if the tails are requested).- Parameters:
tips
- true to return the vector tips; otherwise, the tails
-
-