@terrestris/ol-util
Version:
A set of helper classes for working with openLayers
82 lines (81 loc) • 3.22 kB
TypeScript
import { ProjectionDefinition } from 'proj4';
export interface CrsDefinition {
crsCode: string;
definition: string | ProjectionDefinition;
}
export interface CrsMapping {
alias: string;
mappedCode: string;
}
/**
* Default proj4 CRS definitions.
*/
export declare const defaultProj4CrsDefinitions: CrsDefinition[];
/**
* Default mappings for CRS identifiers (e.g. "urn:ogc:def:crs:EPSG::25832").
*/
export declare const defaultProj4CrsMappings: CrsMapping[];
/**
* Helper class for projection handling. Makes use of
* [Proj4js](http://proj4js.org/).
*
* @class ProjectionUtil
*/
export declare class ProjectionUtil {
/**
* Registers custom CRS definitions to the application.
*
* @param { CrsDefinition | CrsDefinition[]} customCrsDefs The custom `proj4` definitions
* which should be registered additionally to default available CRS (s.
* `defaultProj4CrsDefinitions` above) as well.
* Further CRS definitions in proj4 format can be checked under
* http://epsg.io (e.g. http://epsg.io/3426.proj4).
* @param {boolean} registerDefaults Whether the default CRS should be
* registered or not. Default is true.
*/
static initProj4Definitions(customCrsDefs?: CrsDefinition | CrsDefinition[], registerDefaults?: boolean): void;
/**
* Registers custom CRS mappings to allow automatic CRS detection. Sometimes
* FeatureCollections returned by the GeoServer may be associated with
* CRS identifiers (e.g. "urn:ogc:def:crs:EPSG::25832") that aren't
* supported by `proj4` and `OpenLayers` per default. Add appropriate
* mappings to allow automatic CRS detection by `OpenLayers` here.
*
* @param {CrsMapping | CrsMapping[]} customCrsMappings The custom CRS mappings which will be
* added additionally to the by default available (s. `defaultProj4CrsMappings`
* above).
* @param {boolean} useDefaultMappings Whether the default CRS should be mapped
* as well or not. Default is true.
*/
static initProj4DefinitionMappings(customCrsMappings: CrsMapping | CrsMapping[], useDefaultMappings?: boolean): void;
/**
* Converts geographic coordinates given in DDD format like `DD.DDDD°` to
* the degree, minutes, decimal seconds (DMS) format like
* `DDD° MM' SS.SSS"`.
*
* @param {number} value Value to be converted.
*
* @return {string} Converted value.
*/
static toDms(value: number): string;
/**
* Converts geographic coordinates given in DDD format like `DD.DDDD°` to
* the degree, decimal minutes (DMM) format like `DDD° MM.MMMM`.
*
* @param {number} value Value to be converted.
*
* @return {string} Converted value.
*/
static toDmm(value: number): string;
/**
* Adds leading zero to all values less than 10 and returns this new
* zerofilled value as String. Values which are greater than 10 are not
* affected.
*
* @param {number|string} value Value to be zerofilled.
*
* @return {string} converted value with leading zero if necessary.
*/
static zerofill(value: number | string): string;
}
export default ProjectionUtil;