-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup lanczos; toTiles makes some progress
- Loading branch information
Mr Martian
committed
Nov 3, 2024
1 parent
a15a0bb
commit 379271e
Showing
24 changed files
with
799 additions
and
30 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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
declare let self: Worker; | ||
|
||
// TWO WAYS TO BUILD TILES: | ||
// * Vector Tiles | ||
// * Raster Tiles | ||
|
||
/** | ||
* A worker that sorts a chunk of a file and sends it to an output directory | ||
* @param event - the sort chunk message | ||
* @param _event | ||
*/ | ||
self.onmessage = (_event: Bun.MessageEvent<unknown>): void => { | ||
// void sortChunk(event.data as SortChunk).then((outFile): void => { | ||
// postMessage(outFile); | ||
// }); | ||
}; |
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,14 @@ | ||
declare let self: Worker; | ||
|
||
import { FileMultiMap } from '../../../dataStore/multimap/file'; | ||
import VectorTileWorker from './vectorTileWorker'; | ||
|
||
import type { VectorFeature } from '../../../geometry'; | ||
|
||
/** Convert a vector feature to a collection of tiles and store each tile feature */ | ||
class FileVectorTileWorker extends VectorTileWorker { | ||
writer = new FileMultiMap<VectorFeature>(); | ||
} | ||
|
||
const vecWorker = new FileVectorTileWorker(); | ||
self.onmessage = vecWorker.onmessage.bind(vecWorker); |
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,6 @@ | ||
declare let self: Worker; | ||
|
||
import VectorTileWorker from './vectorTileWorker'; | ||
|
||
const vecWorker = new VectorTileWorker(); | ||
self.onmessage = vecWorker.onmessage.bind(vecWorker); |
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,71 @@ | ||
import { MultiMap } from '../../../dataStore'; | ||
|
||
import type { MultiMapStore } from '../../../dataStore'; | ||
import type { VectorFeature } from '../../../geometry'; | ||
import type { OnFeature, ParsedSourceGuide, SourceGuide } from '../..'; | ||
|
||
/** Take in options that will be used to create a tiled data correctly */ | ||
export interface InitMessage { | ||
/** Message type */ | ||
type: 'init'; | ||
/** The sources that will be used to create the tile */ | ||
sources: SourceGuide; | ||
} | ||
|
||
/** Take in a feature that will be added to the tile */ | ||
export interface FeatureMessage { | ||
/** Message type */ | ||
type: 'feature'; | ||
/** The feature to add to the tile */ | ||
feature: VectorFeature; | ||
} | ||
|
||
/** Convert a vector feature to a collection of tiles and store each tile feature */ | ||
export default class VectorTileWorker { | ||
sources: ParsedSourceGuide = {}; | ||
writer: MultiMapStore<VectorFeature> = new MultiMap<VectorFeature>(); | ||
/** | ||
* Tile-ize input vector features and store them | ||
* @param event - the init message or a feature message | ||
*/ | ||
onmessage(event: Bun.MessageEvent<InitMessage | FeatureMessage>): void { | ||
this.handleMessage(event.data); | ||
self.postMessage({ type: 'ready' }); | ||
} | ||
|
||
/** | ||
* Tile-ize input vector features and store them | ||
* @param message - the init message or a feature message | ||
*/ | ||
handleMessage(message: InitMessage | FeatureMessage): void { | ||
const { type } = message; | ||
if (type === 'init') { | ||
this.sources = parseSourceGuide(message.sources); | ||
} else { | ||
// TODO: | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Convert a source guide to a parsed source guide (where onFeature is parsed back into a function) | ||
* @param sourceGuide - the source guide to parse | ||
* @returns the parsed source guide | ||
*/ | ||
function parseSourceGuide(sourceGuide: SourceGuide): ParsedSourceGuide { | ||
const res: ParsedSourceGuide = {}; | ||
|
||
for (const [sourceName, source] of Object.entries(sourceGuide)) { | ||
for (const [layerName, layer] of Object.entries(source)) { | ||
res[sourceName][layerName] = { | ||
...layer, | ||
onFeature: | ||
layer.onFeature !== undefined | ||
? (new Function(layer.onFeature)() as OnFeature) | ||
: undefined, | ||
}; | ||
} | ||
} | ||
|
||
return res; | ||
} |
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
Oops, something went wrong.