schmitzm.geotools
Class JTSUtil

java.lang.Object
  extended by schmitzm.geotools.JTSUtil

public class JTSUtil
extends Object

Diese Klasse enthaelt allgemeine Funktionen fuer die Arbeit mit den in Geotools verwendeten JTS-Komponenten vereinfacht.

Version:
1.1
Author:
Martin Schmitz (University of Bonn/Germany)

Constructor Summary
JTSUtil()
           
 
Method Summary
static Envelope createEnvelope(org.opengis.geometry.Envelope envelope)
          Created an (CRS-less) JTS-Envelope from an OpenGIS-Envelope.
static ReferencedEnvelope createReferencedEnvelope(DirectPosition startCoord, DirectPosition endCoord)
          Creates an referenced envelope from two referenced coordinates.
static Envelope expandEnvelope(Envelope env, double pct)
          Expands an Envelope by percentage.
static ReferencedEnvelope expandEnvelope(ReferencedEnvelope env, double pct)
          Expands an Envelope by percentage.
static ReferencedEnvelope fixAspectRatio(Rectangle rect, ReferencedEnvelope mapArea, boolean grow)
          Returns an Envelope that has the same aspect ratio as the given rectangle
static Coordinate transformCoordinate(Coordinate sourceCoord, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem destCRS)
          Transformiert eine Koordinate von einem CRS in ein anderes.
static Envelope transformEnvelope(Envelope sourceEnv, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem destCRS)
          Transformiert einen JTS-Envelope von einem CRS in ein anderes.
static ReferencedEnvelope transformEnvelope(ReferencedEnvelope bounds, CoordinateReferenceSystem destCRS)
          Transforms a ReferencedEnvelope into another CRS and return a ReferencedEnvelope
static Geometry transformGeometry(Geometry geometry, CoordinateReferenceSystem srcCrs, CoordinateReferenceSystem destCrs)
          Transformiert eine JTS Geometry von einem CRS in ein anderes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTSUtil

public JTSUtil()
Method Detail

createEnvelope

public static Envelope createEnvelope(org.opengis.geometry.Envelope envelope)
Created an (CRS-less) JTS-Envelope from an OpenGIS-Envelope.

Parameters:
envelope - an OpenGIS-Envelope
Returns:
an JTS-Envelope

expandEnvelope

public static Envelope expandEnvelope(Envelope env,
                                      double pct)
Expands an Envelope by percentage.

Parameters:
env - the Envelope
pct - percentage (e.g. 0.1 = 10%) to expands the envelope by. Negative values are allowed.

expandEnvelope

public static ReferencedEnvelope expandEnvelope(ReferencedEnvelope env,
                                                double pct)
Expands an Envelope by percentage.

Parameters:
env - the Envelope
pct - percentage (e.g. 0.1 = 10%) to expands the envelope by. Negative values are allowed.

transformEnvelope

public static Envelope transformEnvelope(Envelope sourceEnv,
                                         CoordinateReferenceSystem sourceCRS,
                                         CoordinateReferenceSystem destCRS)
Transformiert einen JTS-Envelope von einem CRS in ein anderes. Wenn Bursa-Wolf parameter fehlen, wird abhängig von der function getLenient() lenient gerechnet.

Parameters:
sourceEnv - JTS-Envelope
sourceCRS - CRS von sourceEnv
destCRS - CRS in das umgerechnet werden soll
See Also:
CRS#findMathTransform(CoordinateReferenceSystem,CoordinateReferenceSystem), JTS#transform(Envelope,MathTransform), transformEnvelope(ReferencedEnvelope, CoordinateReferenceSystem)

transformCoordinate

public static Coordinate transformCoordinate(Coordinate sourceCoord,
                                             CoordinateReferenceSystem sourceCRS,
                                             CoordinateReferenceSystem destCRS)
Transformiert eine Koordinate von einem CRS in ein anderes.

Parameters:
sourceCoord - Koordinate
sourceCRS - CRS von sourceCoord
destCRS - CRS in das umgerechnet werden soll
See Also:
CRS#findMathTransform(CoordinateReferenceSystem,CoordinateReferenceSystem), JTS#transform(Coordinate, Coordinate, MathTransform)

transformGeometry

public static Geometry transformGeometry(Geometry geometry,
                                         CoordinateReferenceSystem srcCrs,
                                         CoordinateReferenceSystem destCrs)
Transformiert eine JTS Geometry von einem CRS in ein anderes.
Wenn beide CRS semantisch gleich sind wird das selbe Geometrieobect zurueckgeliefert.

Parameters:
geometry - Koordinate
srcCrs - CRS von sourceCoord
destCrs - CRS in das umgerechnet werden soll
See Also:
CRS#findMathTransform(CoordinateReferenceSystem,CoordinateReferenceSystem), JTS#transform(Coordinate, Coordinate, MathTransform)

fixAspectRatio

public static ReferencedEnvelope fixAspectRatio(Rectangle rect,
                                                ReferencedEnvelope mapArea,
                                                boolean grow)
Returns an Envelope that has the same aspect ratio as the given rectangle

Parameters:
rect - defines the aspect ratio the map area is fixed with (e.g. a gui components size)
mapArea - the map area to apply the aspect ratio of "r" to
grow - If true, than the area will be enlarged to match the aspect ratio. If false, it will only shrink.

transformEnvelope

public static ReferencedEnvelope transformEnvelope(ReferencedEnvelope bounds,
                                                   CoordinateReferenceSystem destCRS)
Transforms a ReferencedEnvelope into another CRS and return a ReferencedEnvelope


createReferencedEnvelope

public static ReferencedEnvelope createReferencedEnvelope(DirectPosition startCoord,
                                                          DirectPosition endCoord)
Creates an referenced envelope from two referenced coordinates.

Parameters:
startCoord -
endCoord -