Skip to content

Complete Source refactor #2528

@HoloTheDrunk

Description

@HoloTheDrunk

⚠️ WIP ⚠️

This is a tracking issue for the refactor of iTowns' Source-derived classes and adjacent logic.

Context

The current source architecture and specific implementations leave much to be desired in terms of code quality, readability and extensibility due to the bastardized OO structure and API. As discussed and presented during the Spring 2025 Hackathon and following weekly meetings, we aim to completely redo sources, retaining only the business logic from their current state.
A complete rewrite directly in TypeScript provides significantly stronger soundness guarantees.

Tasks

  • General structure and interfaces
  • Working examples of each source variant
  • Full implementation of all preexisting sources

Proposed structure

---
title: Proposed Source architecture
---

classDiagram

class Source~Key, Data~ {
    <<Interface>>
    +isSource: true
    +load(key: Key) Data
}
note for Source "Blackbox interface that all sources must implement."

class Loader~Data~ {
    <<Interface>>
    +isLoader: true
    +getData(uri: string) Data
}
note for Loader "Performs the fetching and parsing of data."

class RemoteSourceOptions~Key, Data~ {
    <<Interface>>
    +isRemoteSourceOptions: true
    +loader: Loader~Data~
    +crs: ProjectionLike
    +url: string
    +format: string
    +networkOptions: RequestInit
}
Loader *-- RemoteSourceOptions

class RemoteSource~Key, Data~ {
    <<Abstract>>
    +isRemoteSource: true
    +constructor(options: RemoteSourceOptions~Key, Data~)
    +load(key: Key)* Promise~Data~
}
Source <|.. RemoteSource
RemoteSourceOptions <.. RemoteSource

class TmsSource~Data~ {
    +isTmsSource: true
    +zoom: Zoom
    +isInverted: boolean
    +tileMatrixSetLimits: Record~number, TmsLimit~
    +extentSetLimits: Record~string, ExtentSetLimit~
    +tileMatrixCallback: (level: number) string
    -fetcher: Fetcher

    +get url() string
    +load(tile: Tile) Promise~Data~
}
RemoteSource <|-- TmsSource

class ProceduralSource~Key, Data~ {
    <<Abstract>>
    +isProceduralSource: true
    +load(key: Key)* Data
}
Source <|.. ProceduralSource
Loading

Metadata

Metadata

Type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions