Skip to content

Commit

Permalink
Update to ol ext 4.0.18 and ol 9.1 (#153)
Browse files Browse the repository at this point in the history
add set source method for cluster and adjust types

Signed-off-by: Siedlerchr <[email protected]>
  • Loading branch information
Siedlerchr authored May 30, 2024
1 parent 0989dfb commit 273c363
Show file tree
Hide file tree
Showing 26 changed files with 602 additions and 465 deletions.
2 changes: 1 addition & 1 deletion @types/ol-ext/control/Imageline.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ImageLineOnSignature<Return> = OnSignature<EventTypes, Event, Return> &
export interface Options extends ControlOptions {
className?: string;
source?: VectorSource;
layers?: VectorLayer<VectorSource<Geometry>>[];
layers?: VectorLayer<VectorSource<Feature<Geometry>>>[];
getImage?: (f: Feature) => string;
getTitle?: (f: Feature) => string;
collapsed?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/control/PrintDialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class PrintDialog extends ol_control_Control {
* @param {function} [options.saveAs] a function to save the image as blob
* @param {*} [options.jsPDF] jsPDF object to save map as pdf
*/
constructor(options: any);
constructor(options?: Options);

/** Check if the dialog is oprn
* @return {boolean}
Expand Down
48 changes: 48 additions & 0 deletions @types/ol-ext/control/PrintDialog2x.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Map as _ol_Map_ } from 'ol'
import type { Options as PrintOptions } from './PrintDialog'
import PrintDialog from './PrintDialog'

/** Print control to get an image of the map
* @constructor
* @fire show
* @fire print
* @fire error
* @fire printing
* @extends {ol_control_PrintDialog}
*/
export default class PrintDialog2x extends PrintDialog {
/** Add a new language
* @param {string} lang lang id
* @param labels
*/
static addLang(lang: string, labels: any): void;

/**
* @param {Object=} options Control options.
* @param {string} options.className class of the control
* @param {string} [options.lang=en] control language, default en
* @param {string} options.imageType A string indicating the image format, default image/jpeg
* @param {number} options.quality Number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp
* @param {string} options.orientation Page orientation (landscape/portrait), default guest the best one
* @param {boolean} options.immediate force print even if render is not complete, default false
* @param {boolean} [options.openWindow=false] open the file in a new window on print
* @param {boolean} [options.copy=true] add a copy select option
* @param {boolean} [options.print=true] add a print select option
* @param {boolean} [options.pdf=true] add a pdf select option
* @param {function} [options.saveAs] a function to save the image as blob
* @param {*} [options.jsPDF] jsPDF object to save map as pdf
*/
constructor(options: PrintOptions)

/** Set the second map to print
* @param {ol.Map} map
* @API
*/
setMap2(map: _ol_Map_): void

/** Set the second map to print
* @returns {ol.Map}
* @API
*/
getMap2(): _ol_Map_
}
4 changes: 2 additions & 2 deletions @types/ol-ext/control/Profile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface Options extends ControlOptions {
}

/**
* @classdesc OpenLayers 3 Profil Control.
* @classdesc OpenLayers 3 Profile Control.
* Draw a profile of a feature (with a 3D geometry)
*
* @constructor
Expand All @@ -33,7 +33,7 @@ export interface Options extends ControlOptions {
* @fires dragend
* @fires dragcancel
*/
export default class Profil extends ol_control_Control {
export default class Profile extends ol_control_Control {
/**
* @param {Object=} options
* @param {string} options.className
Expand Down
5 changes: 3 additions & 2 deletions @types/ol-ext/interaction/DrawHole.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Map as _ol_Map_ } from 'ol'
import type Feature from 'ol/Feature'
import type { Layer, Vector } from 'ol/layer'
import type { Layer } from 'ol/layer'
import type { StyleLike } from 'ol/style/Style'
import type { Options as DrawOptions } from 'ol/interaction/Draw'
import Draw from 'ol/interaction/Draw'
Expand All @@ -10,6 +10,7 @@ import type { ModifyEvent } from 'ol/interaction/Modify'
import type { ObjectEvent } from 'ol/Object'
import type { CombinedOnSignature, EventTypes, OnSignature } from 'ol/Observable'
import type { Types } from 'ol/ObjectEventType'
import type VectorLayer from 'ol/layer/Vector'
import type VectorSource from 'ol/source/Vector'
import type { Geometry } from 'ol/geom'
import type { DrawEvent } from './DrawRegular'
Expand All @@ -21,7 +22,7 @@ type DrawHoleOnSignature<Return> = OnSignature<EventTypes, Event, Return> &
CombinedOnSignature<Types | EventTypes | 'change' | 'change:active' | 'error' | 'propertychange' | 'drawabort' | 'drawend' | 'drawstart' | 'modifyend' | 'modifystart', Return>;

export interface Options extends DrawOptions {
layers?: Vector<VectorSource<Geometry>>[] | ((l: Layer) => boolean);
layers?: VectorLayer<VectorSource<Feature<Geometry>>>[] | ((l: Layer) => boolean);
featureFilter?: Feature[] | Collection<Feature> | ((feature: Feature, layer: Layer) => boolean);
style?: StyleLike;
}
Expand Down
21 changes: 11 additions & 10 deletions @types/ol-ext/interaction/Offset.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Map as _ol_Map_ } from 'ol'
import type Collection from 'ol/Collection'
import type Feature from 'ol/Feature'
import type { Layer, Vector } from 'ol/layer'
import type { Layer } from 'ol/layer'
import type VectorLayer from 'ol/layer/Vector'
import type { Vector as VectorSource } from 'ol/source'
import { Pointer } from 'ol/interaction'
import type { StyleLike } from 'ol/style/Style'
Expand All @@ -22,7 +23,7 @@ type OffsetOnSignature<Return> = OnSignature<EventTypes, Event, Return> &

export interface Options {
filter?: (f: Feature, l: Layer) => boolean;
layers?: Vector<VectorSource<Geometry>> | Vector<VectorSource<Geometry>>[];
layers?: VectorLayer<VectorSource<Feature<Geometry>>> | VectorLayer<VectorSource<Feature<Geometry>>>[];
features?: Collection<Feature>;
source?: VectorSource;
duplicate?: boolean;
Expand Down Expand Up @@ -63,8 +64,8 @@ export default class Offset extends Pointer {

export class OffsetStartEvent extends BaseEvent {
constructor(type: 'offsetstart',
feature: Feature,
offset: number
feature: Feature,
offset: number
);

feature: Feature
Expand All @@ -74,10 +75,10 @@ export class OffsetStartEvent extends BaseEvent {

export class OffsettingEvent extends BaseEvent {
constructor(type: 'offsetting',
feature: Feature,
offset: number,
segment: number[],
coordinate: Coordinate
feature: Feature,
offset: number,
segment: number[],
coordinate: Coordinate
);

feature: Feature
Expand All @@ -91,8 +92,8 @@ export class OffsettingEvent extends BaseEvent {

export class OffsetEndEvent extends BaseEvent {
constructor(type: 'offsetend',
feature: Feature,
coordinate: Coordinate
feature: Feature,
coordinate: Coordinate
);

feature: Feature
Expand Down
5 changes: 2 additions & 3 deletions @types/ol-ext/interaction/SelectCluster.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Map as _ol_Map_ } from 'ol'
import type Feature from 'ol/Feature'
import { FeatureLike } from 'ol/Feature'
import type { Vector } from 'ol/layer'
import type VectorLayer from 'ol/layer/Vector'
import type { StyleLike } from 'ol/style/Style'
import { Select } from 'ol/interaction'
import type { Coordinate } from 'ol/coordinate'
Expand Down Expand Up @@ -69,7 +68,7 @@ export default class SelectCluster extends Select {
* Get the layer for the revealed features
* @api stable
*/
getLayer(): Vector<VectorSource<Geometry>>;
getLayer(): VectorLayer<VectorSource<Feature<Geometry>>>;

/**
* Select a cluster
Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/interaction/SnapGuides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Options {
pixelTolerance?: number;
enableInitialGuides?: boolean;
style?: Style | Style[];
vectorClass?: VectorLayer<VectorSource<Geometry>> | VectorImageLayer<VectorSource<Geometry>>;
vectorClass?: VectorLayer<VectorSource<Feature<Geometry>>> | VectorImageLayer<VectorSource<Feature<Geometry>>>;
}

/** Interaction to snap to guidelines
Expand Down
8 changes: 7 additions & 1 deletion @types/ol-ext/layer/AnimatedCluster.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import VectorLayer from 'ol/layer/Vector'
import type { Options } from 'ol/layer/BaseVector'
import type VectorSource from 'ol/source/Vector'
import type { Geometry } from 'ol/geom'
import type Feature from 'ol/Feature'

interface ClusterOptions extends Options<VectorSource> {
animationDuration?: number;
Expand All @@ -14,11 +15,16 @@ interface ClusterOptions extends Options<VectorSource> {
* @extends {ol.layer.Vector}
*/
export default class AnimatedCluster extends VectorLayer<VectorSource<Geometry>> {
export default class AnimatedCluster extends VectorLayer<VectorSource<Feature<Geometry>>> {
/**
* @param {olx.layer.AnimatedClusterOptions=} options extend olx.layer.Options
* @param {Number} options.animationDuration animation duration in ms, default is 700ms
* @param {ol.easingFunction} animationMethod easing method to use, default ol.easing.easeOut
*/
constructor(options?: ClusterOptions);

/** Set the cluster source
* @param {ol_source_Vector} source
*/
setSource(source: VectorSource): void
}
2 changes: 1 addition & 1 deletion @types/ol-ext/layer/Render3D.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class Render3D {
* @param {function|string|Number} param.height a height function (returns height giving a feature) or a popertie name for the height or a fixed value
*/
constructor(param: {
layer: Vector<VectorSource<Geometry>>;
layer: Vector<VectorSource<Feature<Geometry>>>;
style?: Style
active?: (() => boolean)
maxResolution?: number;
Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/layer/SketchOverlay.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface Options {
* @fires drawabort
*/
export default class SketchOverlay extends VectorLayer<VectorSource<Geometry>> {
export default class SketchOverlay extends VectorLayer<VectorSource<Feature<Geometry>>> {
/**
* @param {*} options
* @param {string} options.type Geometry type, default LineString
Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/source/BinBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Polygon, Point } from 'ol/geom'
import type { Options as VectorOptions } from 'ol/source/Vector'
import VectorSource from 'ol/source/Vector'

export interface Options extends VectorOptions {
export interface Options extends VectorOptions<Feature> {
source?: VectorSource;
listenChange?: boolean;
geometryFunction?: (f: Feature) => Point;
Expand Down
3 changes: 2 additions & 1 deletion @types/ol-ext/source/DFCI.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type Feature from 'ol/Feature'
import type { Options as VectorSourceOptions } from 'ol/source/Vector'
import VectorSource from 'ol/source/Vector'

export interface Options extends VectorSourceOptions {
export interface Options extends VectorSourceOptions<Feature> {
resolutions?: number[];
}

Expand Down
3 changes: 2 additions & 1 deletion @types/ol-ext/source/DayNight.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Options as VectorSourceOptions } from 'ol/source/Vector'
import VectorSource from 'ol/source/Vector'
import type { Point } from 'ol/geom'
import type Feature from 'ol/Feature'

export interface Options extends VectorSourceOptions {
export interface Options extends VectorSourceOptions<Feature> {
time?: string | Date;
step?: number;
}
Expand Down
4 changes: 2 additions & 2 deletions @types/ol-ext/source/Delaunay.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Options as VectorSourceOptions } from 'ol/source/Vector'
import VectorSource from 'ol/source/Vector'
import type { Coordinate } from 'ol/coordinate'
import type { Feature } from 'ol'
import type Feature from 'ol/Feature'
import type Polygon from 'ol/geom/Polygon'

export interface Options extends VectorSourceOptions {
export interface Options extends VectorSourceOptions<Feature> {
source?: VectorSource;
}

Expand Down
3 changes: 2 additions & 1 deletion @types/ol-ext/source/GeoRSS.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type Feature from 'ol/Feature'
import type { Options as VectorSourceOptions } from 'ol/source/Vector'
import VectorSource from 'ol/source/Vector'

export interface Options extends VectorSourceOptions {
export interface Options extends VectorSourceOptions<Feature> {
url?: string;
}

Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/source/GridBin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Options as VectorSourceOptions } from 'ol/source/Vector'
import type VectorSource from 'ol/source/Vector'
import { BinBase } from './BinBase'

export interface Options extends VectorSourceOptions {
export interface Options extends VectorSourceOptions<Feature> {
source?: VectorSource;
size?: number;
geometryFunction?: (f: Feature) => Point;
Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/source/HexBin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type VectorSource from 'ol/source/Vector'
import type HexagonLayout from '../render/HexGrid'
import { BinBase } from './BinBase'

export interface Options extends VectorSourceOptions {
export interface Options extends VectorSourceOptions<Feature> {
source?: VectorSource;
size?: number;
origin?: Coordinate;
Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/source/Mapillary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class Mapillary extends VectorSource {
/**
* @param {olx.source.Mapillary=} options
*/
constructor(options?: VectorSourceOptions);
constructor(options?: VectorSourceOptions<Feature>);

/** Decode wiki attributes and choose to add feature to the layer
* @param {feature} the feature
Expand Down
9 changes: 5 additions & 4 deletions @types/ol-ext/source/TileWFS.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import type { EventsKey } from 'ol/events'
import BaseEvent from 'ol/events/Event'
import type Feature from 'ol/Feature'
import type { Geometry } from 'ol/geom'
import type { ObjectEvent } from 'ol/Object'
import type { Types } from 'ol/ObjectEventType'
import type { CombinedOnSignature, EventTypes, OnSignature } from 'ol/Observable'
import type { TileSourceEvent } from 'ol/source/Tile'
import type { VectorSourceEvent } from 'ol/source/Vector'
import VectorSource, { Options as VectorSourceOptions } from 'ol/source/Vector'
import VectorSource from 'ol/source/Vector'

type TileWFSOnSignature<Return> =
OnSignature<EventTypes, Event, Return>
&
OnSignature<Types | 'change' | 'error' | 'propertychange', ObjectEvent, Return>
&
OnSignature<Types | 'addfeature' | 'changefeature' | 'clear' | 'featuresloadend' | 'featuresloaderror' | 'featuresloadstart' | 'removefeature', VectorSourceEvent<Geometry>, Return>
OnSignature<Types | 'addfeature' | 'changefeature' | 'clear' | 'featuresloadend' | 'featuresloaderror' | 'featuresloadstart' | 'removefeature', VectorSourceEvent<Feature<Geometry>>, Return>
&
OnSignature<Types | 'tileloadend' | 'tileloaderror' | 'tileloadstart', TileSourceEvent, Return>
&
Expand Down Expand Up @@ -65,8 +66,8 @@ export default class TileWFS extends VectorSource {

export class OverloadEvent extends BaseEvent {
constructor(type: TileWFSEventType,
total: number,
returned: number
total: number,
returned: number
);

total: number
Expand Down
2 changes: 1 addition & 1 deletion @types/ol-ext/source/WikiCommons.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class WikiCommons extends VectorSource {
/**
* @param {olx.source.WikiCommons=} options
*/
constructor(options?: VectorSourceOptions);
constructor(options?: VectorSourceOptions<Feature>);

/** Decode wiki attributes and choose to add feature to the layer
* @param {feature} the feature
Expand Down
1 change: 0 additions & 1 deletion examples/storymap/map.control.imageline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function style(select?: boolean) {
image: new Photo({
src: f.get('img'),
radius: select ? 20 : 15,
shadow: true,
stroke: new Stroke({
width: 4,
color: select ? '#fff' : '#fafafa',
Expand Down
4 changes: 2 additions & 2 deletions examples/style/map.style.font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const vectorSource = new VectorSource({
featureProjection: 'EPSG:3857',
}),
attributions: ['&copy; <a href=\'https://data.culture.gouv.fr/explore/dataset/fonds-de-la-guerre-14-18-extrait-de-la-base-memoire\'>'
+ '<img src=\'https://data.culture.gouv.fr/assets/logo\' height=\'12px\'>data.culture.gouv.fr</a>'],
+ '<img src=\'https://data.culture.gouv.fr/assets/logo\' height=\'12px\'>data.culture.gouv.fr</a>'],
})

const vector = new Vector({
Expand Down Expand Up @@ -198,7 +198,7 @@ declare global {
vector: Vector<VectorSource>,

setOptions(glyph: string, form: string, color: string, scolor: string, fcolor: string, border: number,
radius: number, fsize: number, offset: boolean, gradient: boolean, shadow: boolean): void,
radius: number, fsize: number, offset: boolean, gradient: boolean, shadow: boolean): void,

setFont(g: string | HTMLElement): void,

Expand Down
Loading

0 comments on commit 273c363

Please sign in to comment.