Skip to content

Commit

Permalink
feat(layer): use generics for source and client config
Browse files Browse the repository at this point in the history
  • Loading branch information
ahennr committed Aug 19, 2024
1 parent 15909c1 commit 0970dd2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
40 changes: 23 additions & 17 deletions src/model/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,43 @@ export interface SearchConfig {
}

export interface DefaultLayerClientConfig {
minResolution?: number;
maxResolution?: number;
hoverable?: boolean;
searchable?: boolean;
searchConfig?: SearchConfig;
propertyConfig?: DefaultLayerPropertyConfig[];
featureInfoFormConfig?: PropertyFormTabConfig<PropertyFormItemReadConfig>[];
editFormConfig?: PropertyFormTabConfig<PropertyFormItemEditDefaultConfig |
PropertyFormItemEditReferenceTableConfig>[];
crossOrigin?: string;
opacity?: number;
downloadConfig?: DownloadConfig[];
editFormConfig?: PropertyFormTabConfig<PropertyFormItemEditDefaultConfig |
PropertyFormItemEditReferenceTableConfig>[];
editable?: boolean;
featureInfoFormConfig?: PropertyFormTabConfig<PropertyFormItemReadConfig>[];
hoverable?: boolean;
maxResolution?: number;
minResolution?: number;
opacity?: number;
propertyConfig?: DefaultLayerPropertyConfig[];
searchConfig?: SearchConfig;
searchable?: boolean;
}

export interface LayerArgs extends BaseEntityArgs {
export interface LayerArgs<
D extends DefaultLayerClientConfig,
S extends DefaultLayerSourceConfig
> extends BaseEntityArgs {
name: string;
clientConfig?: DefaultLayerClientConfig;
sourceConfig: DefaultLayerSourceConfig;
clientConfig?: D;
sourceConfig: S;
features?: FeatureCollection;
type: LayerType;
}

export default class Layer extends BaseEntity {
export default class Layer<
D extends DefaultLayerClientConfig = DefaultLayerClientConfig,
S extends DefaultLayerSourceConfig = DefaultLayerSourceConfig,
> extends BaseEntity {
name: string;
clientConfig?: DefaultLayerClientConfig;
sourceConfig: DefaultLayerSourceConfig;
clientConfig?: D;
sourceConfig: S;
features?: FeatureCollection;
type: LayerType;

constructor({id, created, modified, clientConfig, features, name, sourceConfig, type}: LayerArgs) {
constructor({id, created, modified, clientConfig, features, name, sourceConfig, type}: LayerArgs<D, S>) {
super({id, created, modified});

this.name = name;
Expand Down
5 changes: 4 additions & 1 deletion src/parser/SHOGunApplicationUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export interface SHOGunApplicationUtilOpts {
client?: SHOGunAPIClient;
}

class SHOGunApplicationUtil<T extends Application, S extends Layer> {
class SHOGunApplicationUtil<
T extends Application,
S extends Layer
> {

private readonly client: SHOGunAPIClient | undefined;

Expand Down

0 comments on commit 0970dd2

Please sign in to comment.