Try harder to get the projection from GeoTIFF headers
This commit is contained in:
@@ -8,6 +8,11 @@
|
||||
* @enum {string}
|
||||
*/
|
||||
const Units = {
|
||||
/**
|
||||
* Radians
|
||||
* @api
|
||||
*/
|
||||
RADIANS: 'radians',
|
||||
/**
|
||||
* Degrees
|
||||
* @api
|
||||
@@ -40,6 +45,26 @@ const Units = {
|
||||
USFEET: 'us-ft',
|
||||
};
|
||||
|
||||
/**
|
||||
* See http://duff.ess.washington.edu/data/raster/drg/docs/geotiff.txt
|
||||
* @type {Object<number, Units>}
|
||||
*/
|
||||
const unitByCode = {
|
||||
'9001': Units.METERS,
|
||||
'9002': Units.FEET,
|
||||
'9003': Units.USFEET,
|
||||
'9101': Units.RADIANS,
|
||||
'9102': Units.DEGREES,
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} code Unit code.
|
||||
* @return {Units} Units.
|
||||
*/
|
||||
export function fromCode(code) {
|
||||
return unitByCode[code];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meters per unit lookup table.
|
||||
* @const
|
||||
@@ -48,6 +73,7 @@ const Units = {
|
||||
*/
|
||||
export const METERS_PER_UNIT = {};
|
||||
// use the radius of the Normal sphere
|
||||
METERS_PER_UNIT[Units.RADIANS] = 6370997 / (2 * Math.PI);
|
||||
METERS_PER_UNIT[Units.DEGREES] = (2 * Math.PI * 6370997) / 360;
|
||||
METERS_PER_UNIT[Units.FEET] = 0.3048;
|
||||
METERS_PER_UNIT[Units.METERS] = 1;
|
||||
|
||||
Reference in New Issue
Block a user