Update openapi, fixing display of map basestyle with static_url
All checks were successful
/ build (push) Successful in 30s

This commit is contained in:
phil 2024-12-22 02:45:41 +01:00
parent f7629e36e0
commit 8edcf1c9f4
6 changed files with 1360 additions and 1438 deletions

View file

@ -1,5 +1,7 @@
import { Component, OnInit, OnDestroy, Input, ViewChild, NgZone,
ChangeDetectionStrategy, ChangeDetectorRef, ElementRef } from '@angular/core'
import {
Component, OnInit, OnDestroy, Input, ViewChild, NgZone,
ChangeDetectionStrategy, ChangeDetectorRef, ElementRef
} from '@angular/core'
import { ActivatedRoute, Params, Router } from '@angular/router'
import { Observable } from 'rxjs'
@ -8,9 +10,11 @@ import { WebSocketSubject } from 'rxjs/webSocket'
import { MatSnackBar } from '@angular/material/snack-bar'
import { Map, MapMouseEvent, LayerSpecification,
import {
Map, MapMouseEvent, LayerSpecification,
GeoJSONSourceSpecification, FitBoundsOptions,
ExpressionSpecification, Source, GeoJSONSource } from 'maplibre-gl'
ExpressionSpecification, Source, GeoJSONSource
} from 'maplibre-gl'
import Point from '@mapbox/point-geometry'
import * as bbox from '@turf/bbox'
@ -27,7 +31,7 @@ export class LayerWithMetaData {
public layer: LayerSpecification,
public highlightedLayer: LayerSpecification,
public layerNode: LayerNode,
) {}
) { }
}
let normalize = (s: string) => s ? s.trim().toLowerCase() : ''
@ -36,7 +40,7 @@ let normalize = (s: string) => s ? s.trim().toLowerCase() : ''
@Component({
selector: 'gisaf-mapbox',
templateUrl: 'gisaf-mapbox.component.html',
styleUrls: [ 'gisaf-mapbox.component.css' ],
styleUrls: ['gisaf-mapbox.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
GeoJsonService,
@ -107,7 +111,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
protected mapDataService: MapDataService,
public mapControlService: MapControlService,
protected infoDataService: InfoDataService,
) {}
) { }
@Input()
set baseStyleName(styleName: string) {
@ -193,7 +197,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
}
_getNewSingleOpacity(layerId: string, originalOpacity: number | object): number | object {
if (typeof(originalOpacity) === 'number') {
if (typeof (originalOpacity) === 'number') {
return originalOpacity * this._baseStyleOpacity
}
else {
@ -513,7 +517,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
selectFeaturesInBbox(point1: Point, point2: Point) {
let featureList = this.map.queryRenderedFeatures(
[point1, point2],
{layers: Object.keys(this.layers)}
{ layers: Object.keys(this.layers) }
)
// XXX: there should be a better method to build the dict of selected features, eg. map-reduce
@ -625,7 +629,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
}
else {
data['features'].forEach(
(feature:object) => {
(feature: object) => {
feature['properties']['id'] = feature['id']
}
)
@ -633,7 +637,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
// Add a property to each feature, keeping track of selection
data['features'].forEach(
(feature:object) => feature['properties']['_selected'] = false
(feature: object) => feature['properties']['_selected'] = false
)
let layer: LayerSpecification = <LayerSpecification>{
@ -895,7 +899,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
}
}
filterLayer(layerName: string, searchText: string, taggedFeatures: TaggedLayer[]=[], taggedFeatureText: string) {
filterLayer(layerName: string, searchText: string, taggedFeatures: TaggedLayer[] = [], taggedFeatureText: string) {
let layer = this.layers[layerName]
let tagsLayerName = layerName + '-tags'
let labelsLayerName = layerName + '-labels'
@ -1186,7 +1190,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
}
*/
toggleControlDrawer(value?:boolean): void {
toggleControlDrawer(value?: boolean): void {
this.mapControlService.toggleControls(value)
}
@ -1194,7 +1198,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
if (!(evt.point && this.map)) {
return
}
let features = this.map.queryRenderedFeatures(evt.point, {layers:Object.keys(this.layers)})
let features = this.map.queryRenderedFeatures(evt.point, { layers: Object.keys(this.layers) })
let feature = features[0]
if (feature) {
let layer = (<any>this.layerDefs)[(<any>feature).layer.id]
@ -1252,12 +1256,12 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
for (let layerName in this.layers) {
let filter = this.map.getFilter(layerName)
// Eventually re-fit with the filter
if (filter && filter[0]=='in' && filter[1]=='id') {
if (filter && filter[0] == 'in' && filter[1] == 'id') {
// NOTE: this.map.querySourceLayer works only for features in the viewport, so
// the source data is used
// Assuming that filter is in the form ['in', 'id', ...]
let ids = (<string[]>filter).splice(2)
features.push(...this.layers[layerName].source.data.features.filter(f=>ids.indexOf(f.id)!=-1))
features.push(...this.layers[layerName].source.data.features.filter(f => ids.indexOf(f.id) != -1))
}
else {
features.push(...this.layers[layerName].source.data.features)

View file

@ -11,7 +11,7 @@ export class BaseStyle {
constructor(
public name: string,
public style?: StyleSpecification,
) {}
) { }
}
@Injectable()
@ -61,7 +61,7 @@ export class MapDataService {
public createBaseMap(baseMapName: string, stores: string[]): Observable<BaseMapWithStores> {
console.log('TODO: Migrate Graphql createBaseMap')
return of({name: '', stores:[]})
return of({ name: '', stores: [] })
// return this.apollo.mutate({
// mutation: createBaseMapQuery,
// variables: {
@ -89,8 +89,8 @@ export class MapDataService {
// }
getBaseStyle(styleName: string): Observable<BaseStyle> {
return this.mapService.getBaseStyleApiMapBaseStyleNameGet({name: styleName}).pipe(map(
data => new BaseStyle(data.name, <any>data.style)
return this.mapService.getBaseStyleApiMapBaseStyleNameGet({ name: styleName }).pipe(map(
(data: OApiBaseStyle) => new BaseStyle(data.name, <any>data.style)
))
}

View file

@ -47,7 +47,7 @@ export const OpenAPI: OpenAPIConfig = {
PASSWORD: undefined,
TOKEN: undefined,
USERNAME: undefined,
VERSION: '0.1.dev85+g41e92fa.d20240509',
VERSION: '0.6.0a0',
WITH_CREDENTIALS: false,
interceptors: {
response: new Interceptors(),

View file

@ -259,12 +259,26 @@ export const $BaseStyle = {
title: 'Style'
},
mbtiles: {
type: 'string',
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'Mbtiles'
},
static_tiles_url: {
type: 'string',
title: 'Static Tiles Url'
static_url: {
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'Static Url'
},
enabled: {
type: 'boolean',
@ -273,7 +287,7 @@ export const $BaseStyle = {
}
},
type: 'object',
required: ['name', 'style', 'mbtiles', 'static_tiles_url'],
required: ['name'],
title: 'BaseStyle'
} as const;
@ -311,7 +325,6 @@ export const $BasketDefault = {
title: 'Store'
}
},
additionalProperties: false,
type: 'object',
title: 'BasketDefault'
} as const;
@ -514,52 +527,43 @@ export const $BootstrapData = {
version: {
type: 'string',
title: 'Version',
default: '0.1.dev85+g41e92fa.d20240509'
default: '0.6.0a0'
},
title: {
type: 'string',
title: 'Title',
default: 'Auroville Geomatics Studio (Me)'
default: 'Gisaf'
},
windowTitle: {
type: 'string',
title: 'Windowtitle',
default: 'AV Geomatics Studio (Me)'
default: 'Gisaf'
},
map: {
allOf: [
{
'$ref': '#/components/schemas/Map'
}
],
'$ref': '#/components/schemas/Map',
default: {
attribution: '© Auroville CSR Geomatics',
bearing: 0,
defaultStatus: ['E'],
lat: 12.007,
lng: 79.8098,
opacity: 0.4,
pitch: 0,
status: ['E', 'F', 'D'],
style: 'No base map',
tagKeys: ['source'],
tileServer: {
baseDir: '/home/phil/gisaf_misc/map',
openMapTilesKey: 'cS3lrAfYXoM4MDooT6aS',
spriteBaseDir: '/home/phil/gisaf_misc/map/sprite',
spriteBaseUrl: 'https://gis.auroville.org.in',
baseDir: '/home/phil/.local/share/gisaf/mbtiles_files_dir',
spriteBaseDir: '/home/phil/.local/share/gisaf/mbtiles_sprites_dir',
spriteBaseUrl: 'https://gisaf.example.org',
spriteUrl: '/tiles/sprite/sprite',
useRequestUrl: true
useRequestUrl: false
},
zoom: 14
zoom: 14,
pitch: 45,
lat: 12,
lng: 79.8106,
bearing: 0,
style: 'OpenFreeMap',
opacity: 1,
attribution: '',
status: ['E', 'F', 'D'],
defaultStatus: ['E'],
tagKeys: ['source']
}
},
geo: {
allOf: [
{
'$ref': '#/components/schemas/Geo'
}
],
'$ref': '#/components/schemas/Geo',
default: {
raw_survey: {
spatial_sys_ref: {
@ -584,19 +588,13 @@ export const $BootstrapData = {
}
},
measures: {
allOf: [
{
'$ref': '#/components/schemas/Measures'
}
],
default: {
defaultStore: 'avsm_water.well'
}
'$ref': '#/components/schemas/Measures',
default: {}
},
redirect: {
type: 'string',
title: 'Redirect',
default: 'http://gis.auroville.org.in'
default: ''
},
user: {
anyOf: [
@ -1442,11 +1440,7 @@ export const $FormFieldInput = {
export const $Geo = {
properties: {
raw_survey: {
allOf: [
{
'$ref': '#/components/schemas/RawSurvey'
}
],
'$ref': '#/components/schemas/RawSurvey',
default: {
spatial_sys_ref: {
author: 'AVSM',
@ -1485,7 +1479,6 @@ export const $Geo = {
default: 32644
}
},
additionalProperties: false,
type: 'object',
title: 'Geo'
} as const;
@ -1568,17 +1561,13 @@ export const $LegendItem = {
export const $Map = {
properties: {
tileServer: {
allOf: [
{
'$ref': '#/components/schemas/TileServer'
}
],
'$ref': '#/components/schemas/TileServer',
default: {
baseDir: '/path/to/mbtiles_files_dir',
spriteBaseDir: '/path/to/mbtiles_sprites_dir',
spriteBaseUrl: 'https://gisaf.example.org',
baseDir: '/home/phil/.local/share/gisaf/mbtiles_files_dir',
useRequestUrl: false,
spriteBaseDir: '/home/phil/.local/share/gisaf/mbtiles_sprites_dir',
spriteUrl: '/tiles/sprite/sprite',
useRequestUrl: false
spriteBaseUrl: 'https://gisaf.example.org'
}
},
zoom: {
@ -1609,7 +1598,7 @@ export const $Map = {
style: {
type: 'string',
title: 'Style',
default: 'OSM (vector)'
default: 'OpenFreeMap'
},
opacity: {
type: 'number',
@ -1646,7 +1635,6 @@ export const $Map = {
default: ['source']
}
},
additionalProperties: false,
type: 'object',
title: 'Map'
} as const;
@ -1790,7 +1778,6 @@ export const $Measures = {
title: 'Defaultstore'
}
},
additionalProperties: false,
type: 'object',
title: 'Measures'
} as const;
@ -2109,11 +2096,7 @@ export const $Project = {
export const $RawSurvey = {
properties: {
spatial_sys_ref: {
allOf: [
{
'$ref': '#/components/schemas/SpatialSysRef'
}
],
'$ref': '#/components/schemas/SpatialSysRef',
default: {
author: 'AVSM',
ellps: 'WGS84',
@ -2134,7 +2117,6 @@ export const $RawSurvey = {
default: 910001
}
},
additionalProperties: false,
type: 'object',
title: 'RawSurvey'
} as const;
@ -2237,7 +2219,6 @@ export const $SpatialSysRef = {
default: 1328608.994
}
},
additionalProperties: false,
type: 'object',
title: 'SpatialSysRef'
} as const;
@ -2386,11 +2367,12 @@ export const $Store = {
},
z_index: {
type: 'integer',
title: 'Z Index'
title: 'Z Index',
default: 500
}
},
type: 'object',
required: ['name', 'auto_import', 'custom', 'description', 'gis_type', 'group', 'in_menu', 'is_db', 'is_line_work', 'is_live', 'long_name', 'type', 'minor_group_1', 'minor_group_2', 'status', 'style', 'symbol', 'title', 'viewable_role', 'z_index'],
required: ['name', 'auto_import', 'custom', 'description', 'gis_type', 'group', 'in_menu', 'is_db', 'is_line_work', 'is_live', 'long_name', 'type', 'minor_group_1', 'minor_group_2', 'status', 'style', 'symbol', 'title'],
title: 'Store'
} as const;
@ -2648,8 +2630,9 @@ export const $TileServer = {
properties: {
baseDir: {
type: 'string',
format: 'path',
title: 'Basedir',
default: '/path/to/mbtiles_files_dir'
default: '/home/phil/.local/share/gisaf/mbtiles_files_dir'
},
useRequestUrl: {
type: 'boolean',
@ -2658,8 +2641,9 @@ export const $TileServer = {
},
spriteBaseDir: {
type: 'string',
format: 'path',
title: 'Spritebasedir',
default: '/path/to/mbtiles_sprites_dir'
default: '/home/phil/.local/share/gisaf/mbtiles_sprites_dir'
},
spriteUrl: {
type: 'string',
@ -2683,7 +2667,6 @@ export const $TileServer = {
title: 'Openmaptileskey'
}
},
additionalProperties: false,
type: 'object',
title: 'TileServer'
} as const;

View file

@ -54,11 +54,11 @@ export type BaseMapWithStores = {
export type BaseStyle = {
id?: number | null;
name: string;
style: {
style?: {
[key: string]: unknown;
} | null;
mbtiles: string;
static_tiles_url: string;
mbtiles?: string | null;
static_url?: string | null;
enabled?: boolean;
};
@ -457,8 +457,8 @@ export type Store = {
style: string | null;
symbol: string | null;
title: string;
viewable_role: string | null;
z_index: number;
viewable_role?: string | null;
z_index?: number;
};
export type StoreNameOnly = {
@ -751,9 +751,7 @@ export type $OpenApiTs = {
};
'/api/token': {
post: {
req: {
formData: Body_login_for_access_token_api_token_post;
};
req: LoginForAccessTokenApiTokenPostData;
res: {
/**
* Successful Response
@ -870,9 +868,7 @@ export type $OpenApiTs = {
};
'/api/data-provider/{store}': {
get: {
req: {
store: string;
};
req: GetModelListApiDataProviderStoreGetData;
res: {
/**
* Successful Response
@ -891,12 +887,7 @@ export type $OpenApiTs = {
};
'/api/{store_name}/values/{value}': {
get: {
req: {
resample?: string | null;
storeName: string;
value: string;
where: string;
};
req: GetModelValuesApiStoreNameValuesValueGetData;
res: {
/**
* Successful Response
@ -957,10 +948,7 @@ export type $OpenApiTs = {
};
'/api/feature-info/{store}/{id}': {
get: {
req: {
id: string;
store: string;
};
req: GetFeatureInfoApiFeatureInfoStoreIdGetData;
res: {
/**
* Successful Response
@ -979,9 +967,7 @@ export type $OpenApiTs = {
};
'/api/model-info/{store}': {
get: {
req: {
store: string;
};
req: GetModelInfoApiModelInfoStoreGetData;
res: {
/**
* Successful Response
@ -1000,11 +986,7 @@ export type $OpenApiTs = {
};
'/api/plot-params/{store}': {
get: {
req: {
id: string;
store: string;
value: string;
};
req: GetPlotParamsApiPlotParamsStoreGetData;
res: {
/**
* Successful Response
@ -1037,9 +1019,7 @@ export type $OpenApiTs = {
};
'/api/execTagActions': {
post: {
req: {
requestBody: Body_execute_tag_action_api_execTagActions_post;
};
req: ExecuteTagActionApiExecTagActionsPostData;
res: {
/**
* Successful Response
@ -1058,12 +1038,7 @@ export type $OpenApiTs = {
};
'/api/gj/{store_name}': {
get: {
req: {
ifNoneMatch?: string | null;
preserveTopology?: boolean | null;
simplify?: number | null;
storeName: unknown;
};
req: GetGeojsonApiGjStoreNameGetData;
res: {
/**
* Successful Response
@ -1096,9 +1071,7 @@ export type $OpenApiTs = {
};
'/api/admin/basket/{name}': {
get: {
req: {
name: string;
};
req: GetBasketApiAdminBasketNameGetData;
res: {
/**
* Successful Response
@ -1117,14 +1090,7 @@ export type $OpenApiTs = {
};
'/api/admin/basket/upload/{name}': {
post: {
req: {
autoImport?: boolean;
equipmentId?: number | null;
formData: Body_upload_basket_file_api_admin_basket_upload__name__post;
name: string;
projectId?: number | null;
surveyorId?: number | null;
};
req: UploadBasketFileApiAdminBasketUploadNamePostData;
res: {
/**
* Successful Response
@ -1143,11 +1109,7 @@ export type $OpenApiTs = {
};
'/api/admin/basket/download/{name}/{file_id}/{file_name}': {
get: {
req: {
fileId: number;
fileName: string;
name: string;
};
req: DownloadBasketFileApiAdminBasketDownloadNameFileIdFileNameGetData;
res: {
/**
* Successful Response
@ -1166,11 +1128,7 @@ export type $OpenApiTs = {
};
'/api/admin/basket/import/{basket}/{file_id}': {
get: {
req: {
basket: string;
dryRun?: boolean;
fileId: number;
};
req: ImportBasketFileApiAdminBasketImportBasketFileIdGetData;
res: {
/**
* Successful Response
@ -1189,10 +1147,7 @@ export type $OpenApiTs = {
};
'/api/admin/basket/delete/{basket}/{file_id}': {
get: {
req: {
basket: string;
fileId: number;
};
req: DeleteBasketFileApiAdminBasketDeleteBasketFileIdGetData;
res: {
/**
* Successful Response
@ -1239,10 +1194,7 @@ export type $OpenApiTs = {
};
'/api/dashboard/page/{group}/{name}': {
get: {
req: {
group: string;
name: string;
};
req: GetDashboardPageApiDashboardPageGroupNameGetData;
res: {
/**
* Successful Response
@ -1271,9 +1223,7 @@ export type $OpenApiTs = {
};
'/api/map/base_style/{name}': {
get: {
req: {
name: string;
};
req: GetBaseStyleApiMapBaseStyleNameGetData;
res: {
/**
* Successful Response
@ -1288,9 +1238,7 @@ export type $OpenApiTs = {
};
'/api/map/layer_style/{store}': {
get: {
req: {
store: string;
};
req: GetLayerStyleApiMapLayerStyleStoreGetData;
res: {
/**
* Successful Response
@ -1305,12 +1253,7 @@ export type $OpenApiTs = {
};
'/api/download/csv/{store}/{model_id}/{value}/{resample}': {
get: {
req: {
modelId: number;
resample: string;
store: string;
value: string;
};
req: DownloadCsvApiDownloadCsvStoreModelIdValueResampleGetData;
res: {
/**
* Successful Response
@ -1329,11 +1272,7 @@ export type $OpenApiTs = {
};
'/api/download/geodata/{stores}': {
get: {
req: {
format?: string;
reproject?: boolean;
stores: string;
};
req: DownloadGeodataApiDownloadGeodataStoresGetData;
res: {
/**
* Successful Response
@ -1352,11 +1291,7 @@ export type $OpenApiTs = {
};
'/api/download/plugin/{name}/{store}/{id}': {
get: {
req: {
id: number;
name: string;
store: string;
};
req: ExecuteActionApiDownloadPluginNameStoreIdGetData;
res: {
/**
* Successful Response