From 8019e772000ee923462ae3d95829310a674e6f9c Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Thu, 7 Nov 2019 07:48:51 +0000 Subject: [PATCH] Organise imports in tileserver --- app/src/tiles/dataDefinition.ts | 1 + app/src/tiles/rendererDefinition.ts | 14 +++++++------- app/src/tiles/renderers/getTileWithCaching.ts | 2 +- app/src/tiles/renderers/renderDataSourceTile.ts | 9 ++++----- app/src/tiles/renderers/stitchTile.ts | 2 +- app/src/tiles/tileCache.ts | 6 +++--- app/src/tiles/tileserver.ts | 7 ++++--- app/src/tiles/util.ts | 2 +- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/src/tiles/dataDefinition.ts b/app/src/tiles/dataDefinition.ts index 92eb2c0e..3f029d2b 100644 --- a/app/src/tiles/dataDefinition.ts +++ b/app/src/tiles/dataDefinition.ts @@ -1,4 +1,5 @@ import { strictParseInt } from "../parse"; + import { DataConfig } from "./types"; const BUILDING_LAYER_DEFINITIONS = { diff --git a/app/src/tiles/rendererDefinition.ts b/app/src/tiles/rendererDefinition.ts index e4187cb3..2ae4d086 100644 --- a/app/src/tiles/rendererDefinition.ts +++ b/app/src/tiles/rendererDefinition.ts @@ -1,11 +1,11 @@ -import { TileCache } from "./tileCache"; -import { BoundingBox, TileParams, Tile } from "./types"; -import { getBuildingsDataConfig, getHighlightDataConfig, getAllLayerNames, getBuildingLayerNames } from "./dataDefinition"; -import { isOutsideExtent } from "./util"; -import { renderDataSourceTile } from "./renderers/renderDataSourceTile"; -import { getTileWithCaching } from "./renderers/getTileWithCaching"; -import { stitchTile } from "./renderers/stitchTile"; +import { getAllLayerNames, getBuildingLayerNames, getBuildingsDataConfig, getHighlightDataConfig } from "./dataDefinition"; import { createBlankTile } from "./renderers/createBlankTile"; +import { getTileWithCaching } from "./renderers/getTileWithCaching"; +import { renderDataSourceTile } from "./renderers/renderDataSourceTile"; +import { stitchTile } from "./renderers/stitchTile"; +import { TileCache } from "./tileCache"; +import { BoundingBox, Tile, TileParams } from "./types"; +import { isOutsideExtent } from "./util"; /** * A list of all tilesets handled by the tile server diff --git a/app/src/tiles/renderers/getTileWithCaching.ts b/app/src/tiles/renderers/getTileWithCaching.ts index 6595d82d..451574d0 100644 --- a/app/src/tiles/renderers/getTileWithCaching.ts +++ b/app/src/tiles/renderers/getTileWithCaching.ts @@ -1,5 +1,5 @@ -import { TileParams, RendererFunction, Tile } from "../types"; import { TileCache } from "../tileCache"; +import { RendererFunction, Tile, TileParams } from "../types"; async function getTileWithCaching(tileParams: TileParams, dataParams: any, tileCache: TileCache, renderTile: RendererFunction): Promise { diff --git a/app/src/tiles/renderers/renderDataSourceTile.ts b/app/src/tiles/renderers/renderDataSourceTile.ts index 9cb7d5e5..2c2655b3 100644 --- a/app/src/tiles/renderers/renderDataSourceTile.ts +++ b/app/src/tiles/renderers/renderDataSourceTile.ts @@ -1,11 +1,10 @@ -import path from 'path'; - import mapnik from "mapnik"; - -import { TileParams, Tile, TableDefinitionFunction } from "../types"; -import { getBbox, TILE_SIZE } from "../util"; +import path from 'path'; import { promisify } from "util"; +import { TableDefinitionFunction, Tile, TileParams } from "../types"; +import { getBbox, TILE_SIZE } from "../util"; + const TILE_BUFFER_SIZE = 64; const PROJ4_STRING = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over'; diff --git a/app/src/tiles/renderers/stitchTile.ts b/app/src/tiles/renderers/stitchTile.ts index eb7acb84..b0c2c840 100644 --- a/app/src/tiles/renderers/stitchTile.ts +++ b/app/src/tiles/renderers/stitchTile.ts @@ -1,6 +1,6 @@ import sharp from 'sharp'; -import { TileParams, RendererFunction, Tile } from "../types"; +import { RendererFunction, Tile, TileParams } from "../types"; import { getBbox, getXYZ, TILE_SIZE } from "../util"; diff --git a/app/src/tiles/tileCache.ts b/app/src/tiles/tileCache.ts index 1176986c..6be7ce41 100644 --- a/app/src/tiles/tileCache.ts +++ b/app/src/tiles/tileCache.ts @@ -16,12 +16,12 @@ // Using node-fs package to patch fs // for node >10 we could drop this in favour of fs.mkdir (which has recursive option) // and then use stdlib `import fs from 'fs';` +import { Image } from 'mapnik'; import fs from 'node-fs'; import { promisify } from 'util' -import { Image } from 'mapnik'; -import { TileParams, BoundingBox } from './types'; -import { getXYZ, formatParams } from './util'; +import { BoundingBox, TileParams } from './types'; +import { formatParams, getXYZ } from './util'; // TODO: switch to modern node and use built-in fs with promise-based API const readFile = promisify(fs.readFile), diff --git a/app/src/tiles/tileserver.ts b/app/src/tiles/tileserver.ts index 9ebf101a..5463297b 100644 --- a/app/src/tiles/tileserver.ts +++ b/app/src/tiles/tileserver.ts @@ -5,10 +5,11 @@ */ import express from 'express'; -import { strictParseInt } from '../parse'; -import { TileParams } from './types'; -import { renderTile, allTilesets } from './rendererDefinition'; import asyncController from '../api/routes/asyncController'; +import { strictParseInt } from '../parse'; + +import { allTilesets, renderTile } from './rendererDefinition'; +import { TileParams } from './types'; const handleTileRequest = asyncController(async function (req: express.Request, res: express.Response) { try { diff --git a/app/src/tiles/util.ts b/app/src/tiles/util.ts index 42f4dab9..1612bb42 100644 --- a/app/src/tiles/util.ts +++ b/app/src/tiles/util.ts @@ -1,6 +1,6 @@ import SphericalMercator from '@mapbox/sphericalmercator'; -import { TileParams, BoundingBox } from './types'; +import { BoundingBox, TileParams } from './types'; const TILE_SIZE = 256;