API / geotoolkit / map / coordinatesystems / UTM / UTM
coordinatesystems.UTM.UTM
Based on Geographic/UTM (Universal Transverse Mercator) Coordinate Converter
Example
// To calculate a line n(x,y) meter away from particular latitude and longitude…..where x is distance towards east west, y is distance towards north south
import {UTM} from '@int/geotoolkit/map/coordinatesystems/UTM';
import {Polygon} from '@int/geotoolkit/scene/shapes/Polygon';
const system = new UTM(15, false); // 15 UTM zone, north hemisphere ('true' for southern)
const origin = system.transform(-95.388718, 29.716131); // your lat/lon origin, Houston coordinates here
const coordsX = [100, -200, 300]; // your coordinates in meters from the 'origin' lat/long point
const newX = coordsX.map((x) => x + origin.getX()); // shifting relative to the initial point
... // same for the Y coordinates
const polygon = new Polygon({ // Your polygon to draw
'x': newX,
'y': newY
});Example
// To find the distance between the two lat/long points only by transforming them to UTM:
import {UTM} from '@int/geotoolkit/map/coordinatesystems/UTM';
import {Point} from '@int/geotoolkit/util/Point';
const system = new UTM(18, false);
const point1 = system.transform(-77.009003, 38.889931); // Washington
const point2 = system.transform(-75.165222, 39.952583); // Philadelphia
Point.getDistance(point1, point2); // 197744 meters
// You can also use the 'system' property in map layers for automatic conversion from one coordinate system to anotherExample
// To calculate the UTM zone dynamically:
const lat = 29.761993, lon = -95.366302; // your latitude/longitude for the origin point
const zone = Math.floor((lon + 180) / 6) % 60 + 1; // formula for UTM zone
const southern = (lat < 0); // calculate hemishere
const system = new UTM(zone, southern); // create system for the point
const point1 = system.transform(lon, lat); // transform point to UTM
const point2 = new Point(point1.x + dx, point1.y + dy); // dx, dy - distance between point1 & point2 in meters
system.inverseTransform(point2.x, point2.y, point2); // transform 'point2' back to lat/long coordinate system↳
UTM
Constructors
| [new UTM(options)](/solutions/geotoolkit/apis/classes/geotoolkit.map.coordinatesystems.utm.utm.md#new utm(options)) | [new UTM(zone, southhemi)](/solutions/geotoolkit/apis/classes/geotoolkit.map.coordinatesystems.utm.utm.md#new utm(zone, southhemi)) |
|---|
Methods
Constructors
• new UTM(options?)
| Name | Type | Description |
|---|---|---|
Optional options | Options | options to specify UTM coordinate system |
AbstractSystem.constructor
• new UTM(zone?, southhemi?)
| Name | Type | Description |
|---|---|---|
Optional zone | number | UTM time zone |
Optional southhemi | boolean | true for southern hemisphere, false otherwise |
AbstractSystem.constructor
Methods
▸ getClassName(): string
string
▸ getDefaultModelLimits(): Rect
Gets the default minimal rectangular bounding region that will entirely contain this AbstractSystem (approximately). A CSR is an arbitrary complex closed region that touches the rectangular extent at least once on all four sides.
AbstractSystem.getDefaultModelLimits
▸ getEpsgCode(): number
Return epsg code of the coordinate system
number
epsg code
▸ getName(): string
Return a name of the coordinate system
string
▸ getUnits(): AbstractUnit
Return units of the coordinate system
▸ getZone(): number
number
the current zone
▸ inverseTransform(x, y, dst?): Point
Return transformed point to lat / lng from projection
| Name | Type | Description |
|---|---|---|
x | number | x coordinate |
y | number | y coordinate |
Optional dst | Point | optional destination point |
AbstractSystem.inverseTransform
▸ isSouthernHemisphere(): boolean
Return true if it is southern hemisphere
boolean
▸ isVerticalAxisUp(): boolean
Return if vertical axis goes up
boolean
AbstractSystem.isVerticalAxisUp
▸ setSouthernHemisphere(southhemi): UTM
Set southern or northern hemisphere
| Name | Type | Description |
|---|---|---|
southhemi | boolean | true if southern |
this
▸ setZone(zone): UTM
Sets the current zone
| Name | Type | Description |
|---|---|---|
zone | number | current zone |
this
▸ transform(lon, lat, dst?): Point
Transforms the specified coordinate to projection from lat / lon
| Name | Type | Description |
|---|---|---|
lon | number | long |
lat | number | lat |
Optional dst | Point | optional destination point |
▸ Static getClassName(): string
string