From cf72a199fbe39230f548cda5b3de70bdead4d0dd Mon Sep 17 00:00:00 2001 From: matjos Date: Fri, 28 Aug 2015 11:36:44 +0200 Subject: [PATCH 1/5] Added ImageWMS constructor options. --- openlayers/openlayers.d.ts | 39 +++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index 39091a849..96b544cdc 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -88,6 +88,42 @@ declare module olx { targetSize?: number; } + interface ImageWMSOptions { + + /** Attributions. */ + attributions?: Array; + + /** The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you are using the WebGL renderer or if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail. */ + crossOrigin?: string; + + /** experimental Use the ol.Map#pixelRatio value when requesting the image from the remote server. Default is true. */ + hidpi?: boolean; + + /** experimental The type of the remote WMS server: mapserver, geoserver or qgis. Only needed if hidpi is true. Default is undefined. */ + serverType?: any; + + /** experimental Optional function to load an image given a URL. */ + imageLoadFunction?: any; + + /** Logo. */ + logo?: any; + + /** WMS request parameters. At least a LAYERS param is required. STYLES is '' by default. VERSION is 1.3.0 by default. WIDTH, HEIGHT, BBOX and CRS (SRS for WMS version < 1.3.0) will be set dynamically. */ + params?: any; + + /** experimental Projection. */ + projection?: ol.proj.ProjectionLike; + /** Ratio. 1 means image requests are the size of the map viewport, 2 means twice the width and height of the map viewport, and so on. Must be 1 or higher. Default is 1.5. */ + ratio?: number; + + /** Resolutions. If specified, requests will be made for these resolutions only. */ + resolutions?: Array; + + /** WMS service URL. */ + url?: string; + } + + interface MapOptions { /** Controls initially added to the map. If not specified, ol.control.defaults() is used. */ @@ -2150,7 +2186,7 @@ declare module ol { * @param number Input between 0 and 1 * @returns Output between 0 and 1 */ - function inAndOut (t: number): number; + function inAndOut(t: number): number; /** * Maintain a constant speed over time. @@ -3112,6 +3148,7 @@ declare module ol { } class ImageWMS { + constructor(options: olx.ImageWMSOptions); } class MapQuest { From 9390bb6fe4251784708c7c301625846d396b30f0 Mon Sep 17 00:00:00 2001 From: matjos Date: Fri, 28 Aug 2015 16:18:15 +0200 Subject: [PATCH 2/5] Added TileWMS, Projection and refactored --- openlayers/openlayers.d.ts | 87 +++++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 11 deletions(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index 96b544cdc..842ebfd5a 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -88,11 +88,14 @@ declare module olx { targetSize?: number; } - interface ImageWMSOptions { - + interface BaseWMSOptions { + /** Attributions. */ attributions?: Array; + /** WMS request parameters. At least a LAYERS param is required. STYLES is '' by default. VERSION is 1.3.0 by default. WIDTH, HEIGHT, BBOX and CRS (SRS for WMS version < 1.3.0) will be set dynamically. */ + params?: any; + /** The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you are using the WebGL renderer or if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail. */ crossOrigin?: string; @@ -102,27 +105,48 @@ declare module olx { /** experimental The type of the remote WMS server: mapserver, geoserver or qgis. Only needed if hidpi is true. Default is undefined. */ serverType?: any; - /** experimental Optional function to load an image given a URL. */ - imageLoadFunction?: any; + /** WMS service URL. */ + url?: string; /** Logo. */ logo?: any; - /** WMS request parameters. At least a LAYERS param is required. STYLES is '' by default. VERSION is 1.3.0 by default. WIDTH, HEIGHT, BBOX and CRS (SRS for WMS version < 1.3.0) will be set dynamically. */ - params?: any; - /** experimental Projection. */ projection?: ol.proj.ProjectionLike; + } + + interface ImageWMSOptions extends BaseWMSOptions { + + /** experimental Optional function to load an image given a URL. */ + imageLoadFunction?: any; + /** Ratio. 1 means image requests are the size of the map viewport, 2 means twice the width and height of the map viewport, and so on. Must be 1 or higher. Default is 1.5. */ ratio?: number; /** Resolutions. If specified, requests will be made for these resolutions only. */ resolutions?: Array; - - /** WMS service URL. */ - url?: string; } + interface TileWMSOptions { + + /** The size in pixels of the gutter around image tiles to ignore. By setting this property to a non-zero value, images will be requested that are wider and taller than the tile size by a value of 2 x gutter. Defaults to zero. Using a non-zero value allows artifacts of rendering at tile edges to be ignored. If you control the WMS service it is recommended to address "artifacts at tile edges" issues by properly configuring the WMS service. For example, MapServer has a tile_map_edge_buffer configuration parameter for this. See http://mapserver.org/output/tile_mode.html. */ + gutter?: number; + + /** Tile grid. Base this on the resolutions, tilesize and extent supported by the server. If this is not defined, a default grid will be used: if there is a projection extent, the grid will be based on that; if not, a grid based on a global extent with origin at 0,0 will be used. */ + tileGrid?: ol.tilegrid.TileGrid; + + /** experimental Maximum zoom. */ + maxZoom?: number; + + /** experimental Optional function to load a tile given a URL. */ + tileLoadFunction?: any; //todo + + /** WMS service urls. Use this instead of url when the WMS supports multiple urls for GetMap requests. */ + urls?: Array; + + /** experimental Whether to wrap the world horizontally. When set to false, only one world will be rendered. When true, tiles will be requested for one world only, but they will be wrapped horizontally to render multiple worlds. The default is true. */ + wrapX?: boolean; + } interface MapOptions { @@ -279,6 +303,45 @@ declare module olx { rotation: number; } + interface Projection { + /** + * The SRS identifier code, e.g. EPSG:4326. + */ + code: string; + + /** + * Units. Required unless a proj4 projection is defined for code. + */ + units?: ol.proj.Units; + + /** + * The validity extent for the SRS. + */ + extent?: Array; + + /** + * The axis orientation as specified in Proj4. The default is enu. + */ + axisOrientation?: string; + + /** + * Whether the projection is valid for the whole globe. Default is false. + */ + global?: boolean; + + /** + * experimental The world extent for the SRS. + */ + worldExtent?: ol.Extent; + + /** + * experimental Function to determine resolution at a point. The function is called with + * a {number} view resolution and an {ol.Coordinate} as arguments, and returns the {number} + * resolution at the passed coordinate. + */ + getPointResolution?: any; + } + module animation { interface BounceOptions { @@ -3103,7 +3166,8 @@ declare module ol { */ function transformExtent(extent: Extent, source: ProjectionLike, destination: ProjectionLike): Extent; - interface Projection { + class Projection { + constructor(options: olx.Projection) } } @@ -3189,6 +3253,7 @@ declare module ol { } class TileWMS { + constructor(options: olx.TileWMSOptions); } class Vector { From 9f0231e58e9e1b7b8d2102630c7d688fd1a473bf Mon Sep 17 00:00:00 2001 From: matjos Date: Wed, 2 Sep 2015 21:05:30 +0200 Subject: [PATCH 3/5] added tests to openlayers input --- openlayers/openlayers-tests.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts index 3effa928a..009273746 100644 --- a/openlayers/openlayers-tests.ts +++ b/openlayers/openlayers-tests.ts @@ -34,6 +34,7 @@ var geometry: ol.geom.Geometry; var loadingstrategy: ol.LoadingStrategy; var tilegrid: ol.tilegrid.TileGrid; var vector: ol.source.Vector; +var projection: ol.proj.Projection; // // ol.Attribution @@ -161,7 +162,9 @@ var tileLayer: ol.layer.Tile = new ol.layer.Tile({ // // ol.proj // -var projection: ol.proj.Projection; +projection = new ol.proj.Projection({ + code:stringValue, +}); // // ol.Map @@ -174,6 +177,21 @@ var map: ol.Map = new ol.Map({ }); map.beforeRender(preRenderFunction); +// +// ol.source.ImageWMS +// +var imageWMS: ol.source.ImageWMS = new ol.source.ImageWMS({ + serverType: stringValue, + url:stringValue +}); +// +// ol.source.TileWMS +// +var tileWMS: ol.source.TileWMS = new ol.source.TileWMS({ + serverType: stringValue, + url:stringValue +}); + // // ol.animation // From c1592cc0ad3e8cc64cb222fa4ad76ad80a42d0a8 Mon Sep 17 00:00:00 2001 From: matjos Date: Wed, 2 Sep 2015 22:07:57 +0200 Subject: [PATCH 4/5] Removed unnecesery any definitions. --- openlayers/openlayers.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index eb51c27a1..d7099c85f 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -103,13 +103,13 @@ declare module olx { hidpi?: boolean; /** experimental The type of the remote WMS server: mapserver, geoserver or qgis. Only needed if hidpi is true. Default is undefined. */ - serverType?: any; + serverType?: ol.source.wms.ServerType; /** WMS service URL. */ url?: string; /** Logo. */ - logo?: any; + logo?: olx.LogoOptions; /** experimental Projection. */ projection?: ol.proj.ProjectionLike; From 133698acc7df8b22c43a22a433ab1ea02c0d4fee Mon Sep 17 00:00:00 2001 From: matjos Date: Wed, 2 Sep 2015 23:10:18 +0200 Subject: [PATCH 5/5] Replaced any with correct methods --- openlayers/openlayers.d.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index d7099c85f..782ecaea0 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -118,7 +118,7 @@ declare module olx { interface ImageWMSOptions extends BaseWMSOptions { /** experimental Optional function to load an image given a URL. */ - imageLoadFunction?: any; + imageLoadFunction?: ol.ImageLoadFunctionType; /** Ratio. 1 means image requests are the size of the map viewport, 2 means twice the width and height of the map viewport, and so on. Must be 1 or higher. Default is 1.5. */ ratio?: number; @@ -139,7 +139,7 @@ declare module olx { maxZoom?: number; /** experimental Optional function to load a tile given a URL. */ - tileLoadFunction?: any; //todo + tileLoadFunction?: ol.TileLoadFunctionType; /** WMS service urls. Use this instead of url when the WMS supports multiple urls for GetMap requests. */ urls?: Array; @@ -354,7 +354,7 @@ declare module olx { * a {number} view resolution and an {ol.Coordinate} as arguments, and returns the {number} * resolution at the passed coordinate. */ - getPointResolution?: any; + getPointResolution?: (resolution: number, coordinate: ol.Coordinate) => number; } module animation { @@ -951,6 +951,10 @@ declare module olx { */ declare module ol { + interface TileLoadFunctionType{ (image: ol.Image, url: string): void } + + interface ImageLoadFunctionType{ (image: ol.Image, url: string): void } + /** * An attribution for a layer source. */