import { Feature, Geometry } from 'geojson' import { GisElement } from '../models' import { IPlatformService } from '../platform/platformResolver' export type PropertyMetadataConfig = { isImportant: boolean } export type LayerMetadataConfig = { minRenderZoom?: number properties?: { [property: string]: PropertyMetadataConfig } actions?: LayerGisActions } export interface GPSCoordinates { latitude: number longitude: number } export interface SearchResult { text: string center?: [number, number] id?: string } export interface NearbyQuery { latitude: number longitude: number radius: number } export interface GeojsonEditData { layerName?: string organization?: string isDraft?: boolean geojson?: Feature } export interface DatabaseFeature extends Feature { _id: string organization: string layerName: string isDraft?: boolean collectionProperties: { [key: string]: unknown } properties: { identifierHash: string [property: string]: unknown } element?: { elementHash: string identifierHash: string type: string } } export type HighlightMode = 'highlight' | 'selected' | 'active' | null export interface LayerGroups { [layerGroup: string]: string[] } export type IdentifierHash = string export const RELATION_FEATURES_LAYER = '$relation' export type MarkerConfig = { icon: string iconColor?: string markerColor: string outlineColor?: string outlineWidth?: number // iconSize?: [number, number] } export const DEFAULT_MARKER_CONFIG: MarkerConfig = { icon: 'circle', markerColor: '#2A6DCB', iconColor: 'white', outlineColor: 'white', outlineWidth: 1, } export interface GisAction { value_condition: string set_value: string callback?: ( element: GisElement, attribute: string, value: string, ) => Promise title: string } export interface LayerGisActions { [attribute: string]: { actions: GisAction[] } } export enum BACKUP_STATUS { PENDING = 'pending', COMPLETE = 'complete', STALE = 'stale', } export interface GisBackupStatus { status: BACKUP_STATUS exportElementHash: string updatedAt: string currentStatus: string | null syncedFiles: string[] totalFiles: number completedAt?: string } export interface OfflineProgressStatus { name: string state: number percentage: number completedResourceSize: number completedTileCount: number completedResourceCount: number requiredResourceCount: number completedTileSize: number } interface OfflineProgressError { message: string name: string } export interface OfflinePack { name: string bounds: [number[], number[]] metadata: unknown status: () => Promise resume: () => Promise pause: () => Promise } export interface OfflineCreatePackOptions { name?: string styleURL?: string bounds?: [number[], number[]] minZoom?: number maxZoom?: number metadata?: unknown } export interface OfflinePackStatus { name: string state: number percentage: number completedResourceCount: number completedResourceSize: number completedTileSize: number completedTileCount: number requiredResourceCount: number } export type MapPackListener = ( pack: OfflinePack, status: OfflineProgressStatus, ) => void export type MapPackErrorListener = ( pack: OfflinePack, status: OfflineProgressError, ) => void export interface IGisServiceImplementation extends IPlatformService { upsertFeatureToStorage: (feature: DatabaseFeature) => void syncData: () => Promise syncIncrementalData: () => Promise persistSyncStatus: ( organization: string, status: GisBackupStatus, ) => Promise getSyncStatus: (organization: string) => Promise clearSyncStatus: (organization: string) => Promise clearSyncData: () => Promise saveTilePack( pack: OfflineCreatePackOptions, progressListener: MapPackListener, errorListener: MapPackErrorListener, ): Promise getTilePacks(): Promise deleteTilePack(name: string): Promise }