File tree Expand file tree Collapse file tree
main/groovy/geoscript/proj
test/groovy/geoscript/proj Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import geoscript.geom.Bounds
55import org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer
66import org.geotools.metadata.iso.citation.Citations
77import org.geotools.referencing.CRS
8+ import org.geotools.renderer.lite.RendererUtilities
89import org.opengis.referencing.crs.CoordinateReferenceSystem
910import org.opengis.referencing.operation.MathTransform
1011
@@ -128,6 +129,15 @@ class Projection {
128129 }
129130 }
130131
132+ /**
133+ * Convert a distance in the Projection's native units to meters.
134+ * @param distance A distance in the Projection's native units
135+ * @return The distance in meters
136+ */
137+ double toMeters (double distance ) {
138+ RendererUtilities . toMeters(distance, crs)
139+ }
140+
131141 /**
132142 * Transform the Geometry to another Projection
133143 * @param geom The Geometry
Original file line number Diff line number Diff line change @@ -166,5 +166,12 @@ class ProjectionTestCase {
166166 @Test void hasEpsgExtension () {
167167 assertNotNull new Projection (" EPSG:104905" )
168168 }
169+
170+ @Test void toMeters () {
171+ Projection p = new Projection (" EPSG:2927" )
172+ double meters = p. toMeters(5280 )
173+ assertEquals (1609.3472 , meters, 0.001 )
174+ }
175+
169176}
170177
You can’t perform that action at this time.
0 commit comments