-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(edition): wms edition with ogc filters + wfs download widget
- Loading branch information
Showing
24 changed files
with
295 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
packages/geo/src/lib/edition/editor-selector/editor-selector.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Directive, Input, OnInit, OnDestroy } from '@angular/core'; | ||
|
||
import { Subscription } from 'rxjs'; | ||
|
||
import { | ||
Editor, | ||
EditorStore, | ||
EditorSelectorComponent | ||
} from '@igo2/common'; | ||
|
||
import { Layer, ImageLayer, VectorLayer } from '../../layer'; | ||
import { IgoMap } from '../../map'; | ||
import { WFSDataSource, WMSDataSource } from '../../datasource'; | ||
import { OgcFilterableDataSourceOptions } from '../../filter'; | ||
|
||
import { WfsEditorService } from '../shared/wfs-editor.service'; | ||
import { WmsEditorService } from '../shared/wms-editor.service'; | ||
|
||
@Directive({ | ||
selector: '[igoEditorSelector]' | ||
}) | ||
export class EditorSelectorDirective implements OnInit, OnDestroy { | ||
|
||
private layers$$: Subscription; | ||
|
||
@Input() map: IgoMap; | ||
|
||
get editorStore(): EditorStore { return this.component.store; } | ||
|
||
constructor( | ||
private component: EditorSelectorComponent, | ||
private wfsEditorService: WfsEditorService, | ||
private wmsEditorService: WmsEditorService | ||
) {} | ||
|
||
ngOnInit() { | ||
this.layers$$ = this.map.layers$ | ||
.subscribe((layers: Layer[]) => this.onLayersChange(layers)); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.layers$$.unsubscribe(); | ||
} | ||
|
||
private onLayersChange(layers: Layer[]) { | ||
const editableLayers = layers.filter((layer: Layer) => this.layerIsEditable(layer)); | ||
|
||
const editors = editableLayers.map((layer: VectorLayer) => { | ||
return this.getOrCreateEditor(layer); | ||
}); | ||
this.editorStore.updateMany(editors); | ||
} | ||
|
||
private getOrCreateEditor(layer: VectorLayer | ImageLayer): Editor { | ||
const editor = this.editorStore.get(layer.id); | ||
if (editor !== undefined) { | ||
return editor; | ||
} | ||
if (layer.dataSource instanceof WFSDataSource) { | ||
return this.wfsEditorService.createEditor( | ||
layer as VectorLayer, | ||
this.map | ||
); | ||
} else if (layer.dataSource instanceof WMSDataSource) { | ||
return this.wmsEditorService.createEditor( | ||
layer as ImageLayer, | ||
this.map | ||
); | ||
} | ||
|
||
return; | ||
} | ||
|
||
private layerIsEditable(layer: Layer): boolean { | ||
const dataSource = layer.dataSource; | ||
if (dataSource instanceof WFSDataSource) { | ||
return true; | ||
} | ||
|
||
if (dataSource instanceof WMSDataSource) { | ||
const dataSourceOptions = (dataSource.options || {}) as OgcFilterableDataSourceOptions; | ||
return dataSourceOptions.ogcFilters && dataSourceOptions.ogcFilters.enabled; | ||
} | ||
|
||
return false; | ||
|
||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
packages/geo/src/lib/edition/editor-selector/editor-selector.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { IgoOgcFilterModule } from '../ogc-filter/ogc-filter.module'; | ||
import { EditorSelectorDirective } from './editor-selector.directive'; | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
IgoOgcFilterModule | ||
], | ||
exports: [ | ||
EditorSelectorDirective | ||
], | ||
declarations: [ | ||
EditorSelectorDirective | ||
] | ||
}) | ||
export class IgoEditorSelectorModule {} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './wfs-editor.service'; | ||
export * from './wfs.widgets'; | ||
export * from './wms-editor.service'; | ||
export * from './widgets'; |
Oops, something went wrong.