From 984f83346a54b46f552dd2ceb5481f86efaebdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Tue, 21 Jun 2016 11:23:20 +0200 Subject: [PATCH 1/7] openlayers: Add filter function for layers in SelectOptions --- openlayers/openlayers-tests.ts | 4 ++++ openlayers/openlayers.d.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts index a2152b11ad..39bc7284f2 100644 --- a/openlayers/openlayers-tests.ts +++ b/openlayers/openlayers-tests.ts @@ -546,3 +546,7 @@ var modify: ol.interaction.Modify = new ol.interaction.Modify({ var draw: ol.interaction.Draw = new ol.interaction.Draw({ type: "Point" }) + +const select: ol.interaction.Select = new ol.interaction.Select({ + layers: (layer: ol.layer.Layer) => true; +}); diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index d1ec613314..5ab387be4e 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -552,12 +552,12 @@ declare namespace olx { interface SelectOptions { addCondition?: ol.events.ConditionType; condition?: ol.events.ConditionType; - layers?: Array; + layers?: Array | ((layer: ol.layer.Layer) => boolean); style?: ol.style.Style | Array | ol.style.StyleFunction; removeCondition?: ol.events.ConditionType; toggleCondition?: ol.events.ConditionType; multi?: boolean; - features?: ol.Collection + features?: ol.Collection; filter?: ol.interaction.SelectFilterFunction; wrapX?: boolean; } From a0c1bd29ed97dc85521ccb1fad4492463960a1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Tue, 21 Jun 2016 11:47:10 +0200 Subject: [PATCH 2/7] openlayers: Add missing functions for ol.source.TileWMS --- openlayers/openlayers.d.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index 5ab387be4e..26753d64a5 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -4152,6 +4152,31 @@ declare namespace ol { class TileWMS { constructor(options: olx.TileWMSOptions); + + /** + * Update the user-provided (WMS request) parameters. + */ + updateParams(params: Object); + + /** + * Get the user-provided (WMS request) params, i.e. those passed to the constructor through the "params" option, and possibly updated using the updateParams method. + */ + getParams(): Object; + + /** + * Return the GetFeatureInfo URL for the passed coordinate, resolution, and + * projection. Return `undefined` if the GetFeatureInfo URL cannot be + * constructed. + * @param coordinate Coordinate. + * @param resolution Resolution. + * @param rojection Projection. + * @param params GetFeatureInfo params. `INFO_FORMAT` at least should + * be provided. If `QUERY_LAYERS` is not provided then the layers specified + * in the `LAYERS` parameter will be used. `VERSION` should not be + * specified here. + * @return GetFeatureInfo URL. + */ + getGetFeatureInfoUrl(coordinate: ol.Coordinate, resolution: number, projection: ol.proj.ProjectionLike, params: Object): string; } class Vector { From d679811f3b53886ef5bc6ab4b7f90e38c015e205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Tue, 21 Jun 2016 12:16:34 +0200 Subject: [PATCH 3/7] openlayers: Add tests for ol.source.TileWMS + Add functions and tests for ol.source.Source --- openlayers/openlayers-tests.ts | 11 +++++++++++ openlayers/openlayers.d.ts | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts index 39bc7284f2..9aeb8ffce4 100644 --- a/openlayers/openlayers-tests.ts +++ b/openlayers/openlayers-tests.ts @@ -358,6 +358,14 @@ var imageWMS: ol.source.ImageWMS = new ol.source.ImageWMS({ serverType: stringValue, url:stringValue }); + +// +// ol.source.Source +// +const source = imageWMS as ol.source.Source; +voidValue = source.refresh(); +projectionValue = source.getProjection(); + // // ol.source.TileWMS // @@ -367,6 +375,9 @@ var tileWMS: ol.source.TileWMS = new ol.source.TileWMS({ url:stringValue }); +tileWMS.updateParams(tileWMS.getParams()); +stringValue = tileWMS.getGetFeatureInfoUrl(); + // // ol.source.WMTS // diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index 26753d64a5..c03fb0cfd5 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -4121,6 +4121,16 @@ declare namespace ol { } class Source { + /** + * Get the projection of the source. + * @return Projection. + */ + getProjection(): ol.proj.Projection; + + /** + * Refreshes the source and finally dispatches a 'change' event. + */ + refresh(): void; } class Stamen { From 8c08b0f46fb442e5e83cbbd90818369bccf0c782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Tue, 21 Jun 2016 14:12:51 +0200 Subject: [PATCH 4/7] openlayers: add source inheritance --- openlayers/openlayers.d.ts | 65 ++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index c03fb0cfd5..44f921a0b5 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -4085,42 +4085,48 @@ declare namespace ol { namespace source { - class BingMaps { + class BingMaps extends TileImage { } - class Cluster { + class CartoDB extends XYZ { } - class Image { + class Cluster extends Vector { } - class ImageCanvas { + class Image extends Source { + } + + class ImageArcGISRest extends Image { + } + + class ImageCanvas extends Image { } class ImageEvent { } - class ImageMapGuide { + class ImageMapGuide extends Image { } - class ImageStatic { + class ImageStatic extends Image { } - class ImageVector { + class ImageVector extends ImageCanvas { } - class ImageWMS { + class ImageWMS extends Image { constructor(options: olx.ImageWMSOptions); } - class MapQuest { + class MapQuest extends XYZ { constructor(options: any); } - class OSM { + class OSM extends XYZ { } - class Source { + class Source extends Object { /** * Get the projection of the source. * @return Projection. @@ -4133,40 +4139,37 @@ declare namespace ol { refresh(): void; } - class Stamen { + class Stamen extends XYZ { } - class Tile { + class Tile extends Source { } - class TileArcGISRest { + class TileArcGISRest extends TileImage { } - class TileDebug { + class TileDebug extends Tile { } class TileEvent { } - class TileImage { + class TileImage extends UrlTile { } - class TileJSON { + class TileJSON extends TileImage { } - class TileUTFGrid { + class TileUTFGrid extends Tile { } - class TileVector { - } - - class TileWMS { + class TileWMS extends TileImage { constructor(options: olx.TileWMSOptions); /** * Update the user-provided (WMS request) parameters. */ - updateParams(params: Object); + updateParams(params: Object): void; /** * Get the user-provided (WMS request) params, i.e. those passed to the constructor through the "params" option, and possibly updated using the updateParams method. @@ -4186,10 +4189,13 @@ declare namespace ol { * specified here. * @return GetFeatureInfo URL. */ - getGetFeatureInfoUrl(coordinate: ol.Coordinate, resolution: number, projection: ol.proj.ProjectionLike, params: Object): string; + getGetFeatureInfoUrl(coordinate: ol.Coordinate, resolution: number, projection: ol.proj.ProjectionLike, params: {}): string; } - class Vector { + class UrlTile extends Tile { + } + + class Vector extends Source { constructor(opts?: olx.source.VectorOptions) /** * Add a single feature to the source. If you want to add a batch of features at once, @@ -4233,14 +4239,17 @@ declare namespace ol { class VectorEvent { } - class WMTS { + class VectorTile extends UrlTile { + } + + class WMTS extends TileImage { constructor(options: olx.source.WMTSOptions); } - class XYZ { + class XYZ extends TileImage { } - class Zoomify { + class Zoomify extends TileImage { } // Namespaces From 22bcfb974e1fc84b5946ab67cdd6471ef14048a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Tue, 21 Jun 2016 14:17:30 +0200 Subject: [PATCH 5/7] fix tests --- openlayers/openlayers-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts index 9aeb8ffce4..4937d52516 100644 --- a/openlayers/openlayers-tests.ts +++ b/openlayers/openlayers-tests.ts @@ -364,7 +364,7 @@ var imageWMS: ol.source.ImageWMS = new ol.source.ImageWMS({ // const source = imageWMS as ol.source.Source; voidValue = source.refresh(); -projectionValue = source.getProjection(); +projection = source.getProjection(); // // ol.source.TileWMS @@ -376,7 +376,7 @@ var tileWMS: ol.source.TileWMS = new ol.source.TileWMS({ }); tileWMS.updateParams(tileWMS.getParams()); -stringValue = tileWMS.getGetFeatureInfoUrl(); +stringValue = tileWMS.getGetFeatureInfoUrl([0, 0], 1, "EPSG:4326", {}); // // ol.source.WMTS @@ -559,5 +559,5 @@ var draw: ol.interaction.Draw = new ol.interaction.Draw({ }) const select: ol.interaction.Select = new ol.interaction.Select({ - layers: (layer: ol.layer.Layer) => true; + layers: (layer: ol.layer.Layer) => true, }); From 7678ef7519c9f177f93c12f0f01243b3cf9487d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Tue, 21 Jun 2016 14:35:54 +0200 Subject: [PATCH 6/7] replace ol.Object with {} --- 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 44f921a0b5..f08238b969 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -4169,12 +4169,12 @@ declare namespace ol { /** * Update the user-provided (WMS request) parameters. */ - updateParams(params: Object): void; + updateParams(params: {}): void; /** * Get the user-provided (WMS request) params, i.e. those passed to the constructor through the "params" option, and possibly updated using the updateParams method. */ - getParams(): Object; + getParams(): {}; /** * Return the GetFeatureInfo URL for the passed coordinate, resolution, and From 9000bf59d4c75186123f5118782c1b6c18d27178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Wed, 22 Jun 2016 10:57:35 +0200 Subject: [PATCH 7/7] change "extends Object" to "extends ol.Object" and "{}" to "any". --- openlayers/openlayers.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index f08238b969..fafaaa186b 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -4126,7 +4126,7 @@ declare namespace ol { class OSM extends XYZ { } - class Source extends Object { + class Source extends ol.Object { /** * Get the projection of the source. * @return Projection. @@ -4169,12 +4169,12 @@ declare namespace ol { /** * Update the user-provided (WMS request) parameters. */ - updateParams(params: {}): void; + updateParams(params: any): void; /** * Get the user-provided (WMS request) params, i.e. those passed to the constructor through the "params" option, and possibly updated using the updateParams method. */ - getParams(): {}; + getParams(): any; /** * Return the GetFeatureInfo URL for the passed coordinate, resolution, and