Ongoing migration
This commit is contained in:
parent
c489a83285
commit
38ff5b8e59
23 changed files with 155 additions and 271 deletions
|
@ -1,36 +1,17 @@
|
|||
import { Injectable } from '@angular/core'
|
||||
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'
|
||||
|
||||
import { Observable, forkJoin } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
|
||||
import { Apollo, gql } from 'apollo-angular'
|
||||
|
||||
import { WebsocketService } from '../_services/websocket.service'
|
||||
|
||||
const getLayerQuery = gql`
|
||||
query mapboxStyle($store: String!) {
|
||||
mapboxStyle (store: $store) {
|
||||
paint
|
||||
layout
|
||||
attribution
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export class MapboxStyle {
|
||||
constructor(
|
||||
public paint: string,
|
||||
public layout: string,
|
||||
public attribution: string,
|
||||
) {}
|
||||
}
|
||||
import { MapService, MaplibreStyle } from '../openapi'
|
||||
|
||||
|
||||
export class MapboxDataAndStyle {
|
||||
constructor(
|
||||
public data: object,
|
||||
public style: MapboxStyle,
|
||||
public style: MaplibreStyle,
|
||||
) {}
|
||||
}
|
||||
|
||||
|
@ -39,7 +20,8 @@ export class MapboxDataAndStyle {
|
|||
export class GeoJsonService {
|
||||
constructor(
|
||||
private _http: HttpClient,
|
||||
private apollo: Apollo
|
||||
// private apollo: Apollo,
|
||||
public mapService: MapService,
|
||||
) {}
|
||||
|
||||
getLayer(url: string, params?: object): Observable<object> {
|
||||
|
@ -51,20 +33,10 @@ export class GeoJsonService {
|
|||
})
|
||||
}
|
||||
|
||||
getStyle(store: string): Observable<MapboxStyle> {
|
||||
return this.apollo.query({
|
||||
query: getLayerQuery,
|
||||
variables: {
|
||||
store: store
|
||||
},
|
||||
errorPolicy: 'all',
|
||||
}).pipe(map(
|
||||
result => new MapboxStyle(
|
||||
result['data']['mapboxStyle']['paint'],
|
||||
result['data']['mapboxStyle']['layout'],
|
||||
result['data']['mapboxStyle']['attribution'],
|
||||
)
|
||||
))
|
||||
getStyle(store: string): Observable<MaplibreStyle> {
|
||||
return this.mapService.getLayerStyleApiMapLayerStyleStoreGet(
|
||||
{store: store}
|
||||
)
|
||||
}
|
||||
|
||||
getAll(url: string, store: string, params?: object): Observable<MapboxDataAndStyle> {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<mat-toolbar fxFlex="2em" id='top-toolbar'>
|
||||
<span
|
||||
style='font-family:GisafSymbols'
|
||||
matTooltip="Gisaf v. {{ version['version'] }} ({{ version['date'] | date: 'dd/MM/yyyy' }})"
|
||||
matTooltip="Gisaf v. {{ version }}"
|
||||
matTooltipPosition="below"
|
||||
class='gisafIcon'
|
||||
>
|
||||
|
|
|
@ -52,7 +52,7 @@ export class AppComponent implements OnInit {
|
|||
this.title = res.title || this.title
|
||||
this.titleService.setTitle(res.windowTitle || this.title)
|
||||
this.configService.setConf(res)
|
||||
this.authenticationService.roles = res.user.roles || []
|
||||
this.authenticationService.roles = res.user?.roles || []
|
||||
if (res.redirect && (window != window.top)) {
|
||||
// Refusing to be embedded in an iframe
|
||||
let loc = res.redirect + window.location.pathname
|
||||
|
|
|
@ -6,6 +6,7 @@ export class Config {
|
|||
map = {}
|
||||
proj = {}
|
||||
measures = {}
|
||||
geo = {}
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
|
@ -15,7 +16,8 @@ export class ConfigService {
|
|||
defaultConf: Config = {
|
||||
'map': {},
|
||||
'proj': {},
|
||||
'measures': {}
|
||||
'measures': {},
|
||||
'geo': {}
|
||||
}
|
||||
|
||||
hasConf = new ReplaySubject<undefined>()
|
||||
|
@ -37,6 +39,7 @@ export class ConfigService {
|
|||
setConf(c: Object) {
|
||||
this.conf.value.map = c['map']
|
||||
this.conf.value.proj = c['proj']
|
||||
this.conf.value.geo = c['geo']
|
||||
this.conf.value.measures = c['measures']
|
||||
this.conf.next(this.conf.value)
|
||||
this.hasConf.next(undefined)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<mat-option *ngFor="let bm of mapDataService.mapInitData.baseMaps"
|
||||
(onSelectionChange)="selChange($event, bm)"
|
||||
[value]="bm.name"
|
||||
[title]="bm.pprint()"
|
||||
[title]="bm.stores.join(', ')"
|
||||
>
|
||||
{{ bm.name }}
|
||||
</mat-option>
|
||||
|
|
|
@ -5,8 +5,9 @@ import { combineLatest } from 'rxjs'
|
|||
import { MapControlService } from '../map-control.service'
|
||||
import { MatOptionSelectionChange } from '@angular/material/core'
|
||||
|
||||
import { BaseMap, MapDataService } from '../map-data.service'
|
||||
import { MapDataService } from '../map-data.service'
|
||||
import { UntypedFormGroup, UntypedFormControl } from '@angular/forms'
|
||||
import { BaseMapWithStores } from '../../openapi'
|
||||
|
||||
@Component({
|
||||
selector: 'gisaf-map-base-map',
|
||||
|
@ -31,7 +32,6 @@ export class BaseMapComponent implements OnInit {
|
|||
let baseMapParams = params.get('baseMap')
|
||||
if (baseMapParams) {
|
||||
let baseMapNameList = baseMapParams ? baseMapParams.split(',') : []
|
||||
|
||||
baseMapNameList.forEach(
|
||||
baseMapName => {
|
||||
let baseMap = this._getBaseMapByName(baseMapName)
|
||||
|
@ -43,7 +43,7 @@ export class BaseMapComponent implements OnInit {
|
|||
)
|
||||
|
||||
this.mapControlService.addBaseMap$.subscribe(
|
||||
(baseMap: BaseMap) => {
|
||||
(baseMap: BaseMapWithStores) => {
|
||||
let existingIndex = this.mapDataService.mapInitData.baseMaps.findIndex(bm => bm.name == baseMap.name)
|
||||
if (existingIndex > -1) {
|
||||
this.mapDataService.mapInitData.baseMaps.splice(existingIndex, 1)
|
||||
|
@ -60,11 +60,11 @@ export class BaseMapComponent implements OnInit {
|
|||
this.formGroup.addControl('baseMaps', new UntypedFormControl())
|
||||
}
|
||||
|
||||
protected _getBaseMapByName(name: string): BaseMap {
|
||||
protected _getBaseMapByName(name: string): BaseMapWithStores {
|
||||
return this.mapDataService.mapInitData.baseMaps.find(bm => bm.name == name)
|
||||
}
|
||||
|
||||
selChange(evt: MatOptionSelectionChange, baseMap: BaseMap) {
|
||||
selChange(evt: MatOptionSelectionChange, baseMap: BaseMapWithStores) {
|
||||
if (evt.isUserInput) {
|
||||
if (evt.source.selected) {
|
||||
this.mapControlService.addBaseMapLayers(baseMap.stores)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
</button>
|
||||
<mat-menu #bmMenu="matMenu">
|
||||
<button mat-menu-item
|
||||
*ngFor="let baseStyle of mapDataService.mapInitData.baseStyles"
|
||||
*ngFor="let baseStyle of mapDataService.mapInitData?.baseStyles"
|
||||
(click)="mapControlService.baseStyleName.next(baseStyle.name)">
|
||||
{{ baseStyle.name }}
|
||||
</button>
|
||||
|
@ -147,19 +147,19 @@
|
|||
<mat-menu #toolsMenu="matMenu" class='extended-width'>
|
||||
<button mat-menu-item
|
||||
(click)="downloadSelectedLayers('gpkg')">
|
||||
Download Geopackage of selected layers (EPSG {{ (configService.conf | async).proj['srid'] }})
|
||||
Download Geopackage of selected layers (EPSG {{ (configService.conf | async).geo['srid'] }})
|
||||
</button>
|
||||
<button mat-menu-item [disabled]=true
|
||||
(click)="downloadSelectedLayers('dxf')">
|
||||
Download DXF of selected layers (EPSG {{ (configService.conf | async).proj['srid'] }})
|
||||
Download DXF of selected layers (EPSG {{ (configService.conf | async).geo['srid'] }})
|
||||
</button>
|
||||
<button mat-menu-item [disabled]=true
|
||||
(click)="downloadSelectedLayers('dxf', true)">
|
||||
Download DXF of selected layers (reprojected to EPSG {{ (configService.conf | async).proj['srid_for_proj'] }})
|
||||
Download DXF of selected layers (reprojected to EPSG {{ (configService.conf | async).geo['srid_for_proj'] }})
|
||||
</button>
|
||||
<button mat-menu-item
|
||||
(click)="downloadSelectedLayers('shapefile')">
|
||||
Download Shapefiles of selected layers (EPSG {{ (configService.conf | async).proj['srid'] }}) [<i><b>Deprecated</b>: use Geopackage</i>]
|
||||
Download Shapefiles of selected layers (EPSG {{ (configService.conf | async).geo['srid'] }}) [<i><b>Deprecated</b>: use Geopackage</i>]
|
||||
</button>
|
||||
</mat-menu>
|
||||
<button mat-raised-button [disabled]="!canCreateBaseMap"
|
||||
|
|
|
@ -7,11 +7,12 @@ import { ConfigService } from '../../config.service'
|
|||
import { MapControlService } from '../map-control.service'
|
||||
import { TreeLayerItemComponent } from '../tree-layer-item/tree-layer-item.component'
|
||||
import { InfoDataService, TaggedLayer } from '../../info/info-data.service'
|
||||
import { BaseMap, MapDataService, BaseStyle } from '../map-data.service'
|
||||
import { MapDataService, BaseStyle } from '../map-data.service'
|
||||
import { LayerNode } from '../models'
|
||||
import { AuthenticationService } from '../../_services/authentication.service'
|
||||
import { CreateBaseMapDialogComponent } from './create-base-map-dialog'
|
||||
import { MatDialog } from '@angular/material/dialog'
|
||||
import { BaseMapWithStores } from '../../openapi'
|
||||
|
||||
@Component({
|
||||
selector: 'gisaf-map-controls',
|
||||
|
@ -179,7 +180,7 @@ export class MapControlsComponent implements OnInit {
|
|||
result.baseMapName,
|
||||
result.stores
|
||||
).subscribe(
|
||||
(baseMap: BaseMap) => this.mapControlService.addBaseMap.next(baseMap)
|
||||
(baseMap: BaseMapWithStores) => this.mapControlService.addBaseMap.next(baseMap)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import { WebSocketSubject } from 'rxjs/webSocket'
|
|||
import { MatSnackBar } from '@angular/material/snack-bar'
|
||||
|
||||
import { Map, MapMouseEvent, LayerSpecification,
|
||||
GeoJSONSourceSpecification, FitBoundsOptions, ExpressionSpecification } from 'maplibre-gl'
|
||||
GeoJSONSourceSpecification, FitBoundsOptions, ExpressionSpecification, Source, GeoJSONSource } from 'maplibre-gl'
|
||||
import Point from '@mapbox/point-geometry'
|
||||
|
||||
import * as bbox from '@turf/bbox'
|
||||
|
@ -607,8 +607,8 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
|
|||
console.log('Empty layer', layerDef.store)
|
||||
return
|
||||
}
|
||||
let mapboxPaint = JSON.parse(resp.style.paint)
|
||||
let mapboxLayout = JSON.parse(resp.style.layout)
|
||||
let mapboxPaint = resp.style?.paint
|
||||
let mapboxLayout = resp.style?.layout
|
||||
this.layerDefs[layerDef.store] = layerDef
|
||||
|
||||
// Make sure ids are not in properties (like postGis to_GeoJson)
|
||||
|
@ -642,7 +642,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
|
|||
type: "geojson",
|
||||
data: data
|
||||
},
|
||||
attribution: resp.style.attribution
|
||||
attribution: resp.style?.attribution
|
||||
}
|
||||
this.layers[layerDef.store] = layer
|
||||
|
||||
|
@ -731,7 +731,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
|
|||
'fill-extrusion-opacity': 0.7,
|
||||
}
|
||||
highlightedLayer['paint'] = {
|
||||
'fill-extrusion-height': (mapboxPaint && mapboxPaint['fill-extrusion-height']) || 5,
|
||||
'fill-extrusion-height': (mapboxPaint && <number>mapboxPaint['fill-extrusion-height']) || 5,
|
||||
'fill-extrusion-opacity': 0.9,
|
||||
'fill-extrusion-color': 'red',
|
||||
}
|
||||
|
@ -840,8 +840,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
|
|||
})
|
||||
ws.subscribe({
|
||||
next: (data: GeoJSON.FeatureCollection) => {
|
||||
// XXX: remove typings (maplibre 2.x)
|
||||
let source = <any>this.map.getSource(layerDef.store)
|
||||
let source: Source = this.map.getSource(layerDef.store)
|
||||
if (!source) {
|
||||
// Unsubscribe from channel on server
|
||||
console.warn('Live WS: cannot getSource for WS message: ', layerDef.store, data)
|
||||
|
@ -850,7 +849,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
|
|||
})
|
||||
return
|
||||
}
|
||||
source.setData(data)
|
||||
(<GeoJSONSource>source).setData(data)
|
||||
},
|
||||
error: err => {
|
||||
console.error('Websocket', layerDef.store, err)
|
||||
|
|
|
@ -7,9 +7,8 @@ import { MatButton } from '@angular/material/button'
|
|||
import { Position } from 'geojson'
|
||||
import distance from '@turf/distance'
|
||||
import { Units } from '@turf/helpers'
|
||||
//import { GeoJSONSource } from 'maplibre-gl'
|
||||
import { MapService } from '@maplibre/ngx-maplibre-gl'
|
||||
import { POINT_CONVERSION_HYBRID } from 'constants'
|
||||
import { GeoJSONSource, MapMouseEvent } from 'maplibre-gl'
|
||||
|
||||
|
||||
const LAYER_LINE = 'gisaf-ruler-line'
|
||||
|
@ -107,7 +106,7 @@ export class GisafRulerDirective {
|
|||
return n == 0 ? '0' : n < 1 ? `${(n * 1000).toFixed(2)} m`: `${n.toFixed(3)} km`
|
||||
}
|
||||
|
||||
onMapClick(evt) {
|
||||
onMapClick(evt: MapMouseEvent) {
|
||||
const newCoordinate = [evt.lngLat.lng, evt.lngLat.lat]
|
||||
|
||||
if (this.lineDrawn) {
|
||||
|
@ -222,10 +221,8 @@ export class GisafRulerDirective {
|
|||
},
|
||||
})
|
||||
|
||||
//this.lineSource = <GeoJSONSource>map.getSource(SOURCE_LINE)
|
||||
//this.symbolSource = <GeoJSONSource>map.getSource(SOURCE_SYMBOL)
|
||||
this.lineSource = map.getSource(SOURCE_LINE)
|
||||
this.symbolSource = map.getSource(SOURCE_SYMBOL)
|
||||
this.lineSource = <GeoJSONSource>map.getSource(SOURCE_LINE)
|
||||
this.symbolSource = <GeoJSONSource>map.getSource(SOURCE_SYMBOL)
|
||||
}
|
||||
|
||||
removeLayers() {
|
||||
|
|
|
@ -3,8 +3,9 @@ import { Subject, BehaviorSubject, forkJoin } from 'rxjs'
|
|||
|
||||
import { ConfigService } from '../config.service'
|
||||
import { LayerNode } from './models'
|
||||
import { Store, BaseMap } from './map-data.service'
|
||||
import { Store } from './map-data.service'
|
||||
import { TaggedLayer, Feature, FeatureWithField } from '../info/info-data.service'
|
||||
import { BaseMapWithStores } from '../openapi'
|
||||
|
||||
|
||||
@Injectable({
|
||||
|
@ -40,7 +41,7 @@ export class MapControlService {
|
|||
public hasTags = new BehaviorSubject<boolean>(false)
|
||||
public layerLoaded = new Subject<LayerNode>()
|
||||
public baseStyleName = new BehaviorSubject<string>(this.configService.conf.value.map['style'])
|
||||
public addBaseMap = new Subject<BaseMap>()
|
||||
public addBaseMap = new Subject<BaseMapWithStores>()
|
||||
|
||||
public mapLoaded = new BehaviorSubject<boolean>(false)
|
||||
public layerTreeLoaded = new BehaviorSubject<boolean>(false)
|
||||
|
@ -119,15 +120,15 @@ export class MapControlService {
|
|||
this.hasTags.next(flag)
|
||||
}
|
||||
|
||||
addBaseMapLayers(baseMapLayers: Store[]) {
|
||||
addBaseMapLayers(baseMapLayers: string[]) {
|
||||
for (let item of baseMapLayers) {
|
||||
this._baseMapLayerAdd.next(item)
|
||||
this._baseMapLayerAdd.next(new Store(item))
|
||||
}
|
||||
}
|
||||
|
||||
removeBaseMapLayers(baseMapLayers: Store[]) {
|
||||
removeBaseMapLayers(baseMapLayers: string[]) {
|
||||
for (let item of baseMapLayers) {
|
||||
this._baseMapLayerRemove.next(item)
|
||||
this._baseMapLayerRemove.next(new Store(item))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,142 +1,12 @@
|
|||
import { Injectable } from '@angular/core'
|
||||
import { Observable, forkJoin, BehaviorSubject } from 'rxjs'
|
||||
import { Observable, forkJoin, BehaviorSubject, of } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
|
||||
import { Apollo, gql } from 'apollo-angular'
|
||||
|
||||
import { StyleSpecification } from 'maplibre-gl'
|
||||
|
||||
import { TreeData, PrimaryGroupNode, LayerNode } from './models'
|
||||
// import { TreeData, PrimaryGroupNode, LayerNode } from './models'
|
||||
import { MapControlService } from './map-control.service'
|
||||
import { MapService, MapInitData } from '../openapi'
|
||||
|
||||
// XXX: unused
|
||||
const baseStyleListQuery = gql`
|
||||
query base_style_list {
|
||||
base_style_list {
|
||||
name
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const baseStyleQuery = gql`
|
||||
query base_style(
|
||||
$name: String!
|
||||
) {
|
||||
base_style(name: $name) {
|
||||
name
|
||||
style
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const baseMapQuery = gql`
|
||||
query baseMap {
|
||||
baseMap {
|
||||
name
|
||||
stores {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const createBaseMapQuery = gql`
|
||||
mutation createBaseMap(
|
||||
$baseMapName: String!
|
||||
$stores: [String]!
|
||||
) {
|
||||
createBaseMap(
|
||||
baseMapName: $baseMapName,
|
||||
stores: $stores,
|
||||
) {
|
||||
baseMap {
|
||||
name
|
||||
stores {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const geomGroupQuery = gql`
|
||||
query geomGroup {
|
||||
geomGroup {
|
||||
name
|
||||
title
|
||||
description
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const storeQuery = gql`
|
||||
query stores {
|
||||
stores {
|
||||
name
|
||||
store
|
||||
rawSurveyStore
|
||||
style
|
||||
zIndex
|
||||
count
|
||||
type
|
||||
gisType
|
||||
description
|
||||
custom
|
||||
group
|
||||
icon
|
||||
symbol
|
||||
live
|
||||
tagPlugins
|
||||
viewableRole
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const mapInitDataQuery = gql`
|
||||
query mapInitData {
|
||||
mapInitData {
|
||||
baseMaps {
|
||||
name
|
||||
stores {
|
||||
name
|
||||
}
|
||||
}
|
||||
baseStyles {
|
||||
name
|
||||
}
|
||||
groups {
|
||||
name
|
||||
title
|
||||
description
|
||||
}
|
||||
stores {
|
||||
name
|
||||
store
|
||||
rawSurveyStore
|
||||
style
|
||||
zIndex
|
||||
count
|
||||
type
|
||||
gisType
|
||||
description
|
||||
custom
|
||||
group
|
||||
icon
|
||||
symbol
|
||||
live
|
||||
tagPlugins
|
||||
viewableRole
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const gisTypeSymbolMap = {
|
||||
Point: '\ue32b',
|
||||
Line: '\ue32c',
|
||||
Polygon: '\ue32d',
|
||||
}
|
||||
import { MapService, MapInitData, BaseMapWithStores } from '../openapi'
|
||||
|
||||
export class BaseStyle {
|
||||
constructor(
|
||||
|
@ -151,26 +21,6 @@ export class Store {
|
|||
) {}
|
||||
}
|
||||
|
||||
export class BaseMap {
|
||||
constructor(
|
||||
public name: string,
|
||||
public stores: Store[],
|
||||
) {}
|
||||
|
||||
pprint() {
|
||||
return this.stores.map(store => store.name).join(', ')
|
||||
}
|
||||
}
|
||||
|
||||
// export class MapInitData {
|
||||
// constructor(
|
||||
// public baseStyles: BaseStyle[] = [],
|
||||
// public baseMaps: BaseMap[] = [],
|
||||
// public groups: PrimaryGroupNode[] = [],
|
||||
// public stores: LayerNode[] = [],
|
||||
// ) {}
|
||||
// }
|
||||
|
||||
@Injectable()
|
||||
export class MapDataService {
|
||||
constructor(
|
||||
|
@ -190,7 +40,7 @@ export class MapDataService {
|
|||
public mapInitDataLoaded = new BehaviorSubject<boolean>(false)
|
||||
mapInitDataLoaded$ = this.mapInitDataLoaded.asObservable()
|
||||
|
||||
mapInitData: MapInitData
|
||||
mapInitData: MapInitData = {}
|
||||
|
||||
getMapInitData(): Observable<MapInitData> {
|
||||
return this.mapService.getInitDataApiMapInitDataGet().pipe(map(
|
||||
|
@ -267,22 +117,24 @@ export class MapDataService {
|
|||
// ))
|
||||
// }
|
||||
|
||||
public createBaseMap(baseMapName: string, stores: string[]): Observable<BaseMap> {
|
||||
return this.apollo.mutate({
|
||||
mutation: createBaseMapQuery,
|
||||
variables: {
|
||||
baseMapName: baseMapName,
|
||||
stores: stores
|
||||
}
|
||||
}).pipe(map(
|
||||
res => {
|
||||
let bm: object = res['data']['createBaseMap']['baseMap']
|
||||
return new BaseMap(
|
||||
bm['name'],
|
||||
bm['stores'].map((store: object) => new Store(store['name']))
|
||||
)
|
||||
}
|
||||
))
|
||||
public createBaseMap(baseMapName: string, stores: string[]): Observable<BaseMapWithStores> {
|
||||
console.log('TODO: createBaseMap')
|
||||
return of({name: '', stores:[]})
|
||||
// return this.apollo.mutate({
|
||||
// mutation: createBaseMapQuery,
|
||||
// variables: {
|
||||
// baseMapName: baseMapName,
|
||||
// stores: stores
|
||||
// }
|
||||
// }).pipe(map(
|
||||
// res => {
|
||||
// let bm: object = res['data']['createBaseMap']['baseMap']
|
||||
// return new BaseMap(
|
||||
// bm['name'],
|
||||
// bm['stores'].map((store: object) => new Store(store['name']))
|
||||
// )
|
||||
// }
|
||||
// ))
|
||||
}
|
||||
|
||||
// XXX: unused
|
||||
|
@ -295,15 +147,17 @@ export class MapDataService {
|
|||
// }
|
||||
|
||||
getBaseStyle(styleName: string): Observable<BaseStyle> {
|
||||
return this.apollo.query({
|
||||
query: baseStyleQuery,
|
||||
variables: {
|
||||
name: styleName
|
||||
}
|
||||
}).pipe(map(
|
||||
data => new BaseStyle(data['data']['base_style']['name'],
|
||||
JSON.parse(data['data']['base_style']['style']))
|
||||
))
|
||||
console.log('TODO: getBaseStyle')
|
||||
return of({name: ''})
|
||||
// return this.apollo.query({
|
||||
// query: baseStyleQuery,
|
||||
// variables: {
|
||||
// name: styleName
|
||||
// }
|
||||
// }).pipe(map(
|
||||
// data => new BaseStyle(data['data']['base_style']['name'],
|
||||
// JSON.parse(data['data']['base_style']['style']))
|
||||
// ))
|
||||
}
|
||||
|
||||
// getStores(): Observable<LayerNode[]> {
|
||||
|
|
|
@ -44,11 +44,11 @@ export class LayerNode extends Node {
|
|||
mapSubscription: Subscription
|
||||
|
||||
constructor(
|
||||
public store: string,
|
||||
public name: string,
|
||||
public group: string,
|
||||
public icon: string,
|
||||
public symbol: string,
|
||||
public store: string,
|
||||
public rawSurveyStore: string,
|
||||
public type: string,
|
||||
public gisType: string,
|
||||
|
@ -60,12 +60,13 @@ export class LayerNode extends Node {
|
|||
public custom: boolean = false,
|
||||
public tagPlugins: string[] = [],
|
||||
public viewableRole: string,
|
||||
public category?: string,
|
||||
) {
|
||||
super(name)
|
||||
}
|
||||
|
||||
getUrl() {
|
||||
return 'gj/'+this.store
|
||||
return 'api/gj/'+this.store
|
||||
}
|
||||
|
||||
hasChildren() {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<ng-template matMenuContent let-node="node">
|
||||
<button mat-menu-item (click)="downloadGpkg(node)">
|
||||
<mat-icon>file_download</mat-icon>
|
||||
<span>Download Geopackage (EPSG {{ (configService.conf | async).proj['srid'] }})</span>
|
||||
<span>Download Geopackage (EPSG {{ (configService.conf | async).geo['srid'] }})</span>
|
||||
</button>
|
||||
</ng-template>
|
||||
</mat-menu>
|
||||
|
|
|
@ -15,6 +15,7 @@ import { Node, PrimaryGroupNode, LayerNode, TreeData } from '../models'
|
|||
import { MapControlService } from '../map-control.service'
|
||||
import { MapDataService, Store } from '../map-data.service'
|
||||
import { Feature, FeatureWithField } from '../../info/info-data.service'
|
||||
import { CategoryGroup } from '../../openapi'
|
||||
|
||||
|
||||
@Injectable()
|
||||
|
@ -145,23 +146,45 @@ export class TreeLayerComponent implements OnInit {
|
|||
// Build a mapping object for faster assignment
|
||||
// XXX: Typescript doesn't provide Object.fromEntries, otherwise it should be:
|
||||
//let pgs = Object.fromEntries(treeData.primaryGroups.map(pg=>[pg.name, pg]))
|
||||
let pgs = {}
|
||||
let pgs: Record<string, PrimaryGroupNode> = {}
|
||||
|
||||
this.mapDataService.mapInitData.groups.forEach(
|
||||
pg => pgs[pg.name] = pg
|
||||
pg => pgs[pg.name] = new PrimaryGroupNode(
|
||||
pg.name,
|
||||
pg.long_name,
|
||||
pg.long_name)
|
||||
)
|
||||
|
||||
this.mapDataService.mapInitData.stores.forEach(
|
||||
node => {
|
||||
let group: PrimaryGroupNode = pgs[node.group]
|
||||
store => {
|
||||
let group: PrimaryGroupNode = pgs[store.group]
|
||||
if (!group) {
|
||||
console.warn('No group (' + node.group + ') for layer node ' + node.store)
|
||||
console.warn('No group (' + store.group + ') for layer node ' + store.name)
|
||||
return
|
||||
}
|
||||
group.children.push(node)
|
||||
group.children.push(new LayerNode(
|
||||
store.name,
|
||||
store.long_name,
|
||||
store.group,
|
||||
store.symbol, //store.icon,
|
||||
store.symbol, //|| gisTypeSymbolMap[layer['gisType']],
|
||||
'', //store.rawSurveyStore,
|
||||
'', //store.type,
|
||||
store.gis_type,
|
||||
{}, //JSON.parse(store.style),
|
||||
store.z_index,
|
||||
store.count,
|
||||
store.description,
|
||||
store.is_live,
|
||||
store.custom,
|
||||
[], //store.tagPlugins,
|
||||
store.viewable_role,
|
||||
store.category
|
||||
))
|
||||
// console.log(this.mapDataService, group.children)
|
||||
}
|
||||
)
|
||||
this.database.setData(this.mapDataService.mapInitData.groups)
|
||||
this.database.setData(Object.values(pgs)) //this.mapDataService.mapInitData.groups)
|
||||
this.loading = false
|
||||
this.mapControlService.layerTreeLoaded.complete()
|
||||
this.cdr.markForCheck()
|
||||
|
|
|
@ -21,7 +21,7 @@ export type OpenAPIConfig = {
|
|||
|
||||
export const OpenAPI: OpenAPIConfig = {
|
||||
BASE: '',
|
||||
VERSION: '2023.4.dev34+g5dacc90.d20240212',
|
||||
VERSION: '2023.4.dev37+gb00bf1f.d20240226',
|
||||
WITH_CREDENTIALS: false,
|
||||
CREDENTIALS: 'include',
|
||||
TOKEN: undefined,
|
||||
|
|
|
@ -9,7 +9,7 @@ export type { OpenAPIConfig } from './core/OpenAPI';
|
|||
|
||||
export type { AdminBasket } from './models/AdminBasket';
|
||||
export type { Attachment } from './models/Attachment';
|
||||
export type { BaseMap } from './models/BaseMap';
|
||||
export type { BaseMapWithStores } from './models/BaseMapWithStores';
|
||||
export type { BaseStyle } from './models/BaseStyle';
|
||||
export type { BasketDefault } from './models/BasketDefault';
|
||||
export type { Body_login_for_access_token_api_token_post } from './models/Body_login_for_access_token_api_token_post';
|
||||
|
@ -30,6 +30,7 @@ export type { InfoCategory } from './models/InfoCategory';
|
|||
export type { InfoItem } from './models/InfoItem';
|
||||
export type { Map } from './models/Map';
|
||||
export type { MapInitData } from './models/MapInitData';
|
||||
export type { MaplibreStyle } from './models/MaplibreStyle';
|
||||
export type { Measures } from './models/Measures';
|
||||
export type { PlotBaseLine } from './models/PlotBaseLine';
|
||||
export type { PlotBgShape } from './models/PlotBgShape';
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type BaseMap = {
|
||||
id?: (number | null);
|
||||
export type BaseMapWithStores = {
|
||||
name: string;
|
||||
stores: Array<string>;
|
||||
};
|
||||
|
|
@ -16,8 +16,8 @@ export type CategoryRead = {
|
|||
style: (string | null);
|
||||
symbol: (string | null);
|
||||
mapbox_type_custom: (string | null);
|
||||
mapbox_paint: (Record<string, any> | null);
|
||||
mapbox_layout: (Record<string, any> | null);
|
||||
mapbox_paint: (Record<string, (Record<string, any> | number | string)> | null);
|
||||
mapbox_layout: (Record<string, (Record<string, any> | number | string)> | null);
|
||||
viewable_role: (string | null);
|
||||
extra: (Record<string, any> | null);
|
||||
/**
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { BaseMap } from './BaseMap';
|
||||
import type { BaseMapWithStores } from './BaseMapWithStores';
|
||||
import type { BaseStyle } from './BaseStyle';
|
||||
import type { CategoryGroup } from './CategoryGroup';
|
||||
import type { Store } from './Store';
|
||||
export type MapInitData = {
|
||||
baseStyles?: Array<BaseStyle>;
|
||||
baseMaps?: Array<BaseMap>;
|
||||
baseMaps?: Array<BaseMapWithStores>;
|
||||
groups?: Array<CategoryGroup>;
|
||||
stores?: Array<Store>;
|
||||
};
|
||||
|
|
10
src/app/openapi/models/MaplibreStyle.ts
Normal file
10
src/app/openapi/models/MaplibreStyle.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* generated using openapi-typescript-codegen -- do no edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type MaplibreStyle = {
|
||||
paint?: (Record<string, (Record<string, any> | number | string)> | null);
|
||||
layout?: (Record<string, (Record<string, any> | number | string)> | null);
|
||||
attribution?: (string | null);
|
||||
};
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
/* eslint-disable */
|
||||
export type Store = {
|
||||
name: string;
|
||||
category?: (string | null);
|
||||
auto_import: boolean;
|
||||
count?: (number | null);
|
||||
custom: boolean;
|
||||
|
@ -18,7 +19,6 @@ export type Store = {
|
|||
minor_group_2: (string | null);
|
||||
gis_type: string;
|
||||
status: string;
|
||||
store: string;
|
||||
style: (string | null);
|
||||
symbol: (string | null);
|
||||
title: string;
|
||||
|
|
|
@ -7,6 +7,7 @@ import { HttpClient } from '@angular/common/http';
|
|||
import type { Observable } from 'rxjs';
|
||||
import type { BaseStyle } from '../models/BaseStyle';
|
||||
import type { MapInitData } from '../models/MapInitData';
|
||||
import type { MaplibreStyle } from '../models/MaplibreStyle';
|
||||
import { OpenAPI } from '../core/OpenAPI';
|
||||
import { request as __request } from '../core/request';
|
||||
@Injectable({
|
||||
|
@ -46,4 +47,25 @@ export class MapService {
|
|||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get Layer Style
|
||||
* @returns any Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public getLayerStyleApiMapLayerStyleStoreGet({
|
||||
store,
|
||||
}: {
|
||||
store: string,
|
||||
}): Observable<(MaplibreStyle | null)> {
|
||||
return __request(OpenAPI, this.http, {
|
||||
method: 'GET',
|
||||
url: '/api/map/layer_style/{store}',
|
||||
path: {
|
||||
'store': store,
|
||||
},
|
||||
errors: {
|
||||
422: `Validation Error`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue