Skip to content

Commit

Permalink
feat: update lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kip.song committed Oct 27, 2023
1 parent d95e782 commit 596aa3a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/source/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import geojson from './parser/geojson';
import geojsonVTTile from './parser/geojsonvt';
import image from './parser/image';
import json from './parser/json';
import jsonTile from './parser/jsonTile';
import mapboxVectorTile from './parser/mvt';
import raster from './parser/raster';
import rasterTile, { rasterDataTypes } from './parser/raster-tile';
import rasterRgb from './parser/rasterRgb';
import testTile from './parser/testTile';
import jsonTile from './parser/jsonTile';
import Source from './source';
import { cluster } from './transform/cluster';
import { filter } from './transform/filter';
Expand Down
81 changes: 39 additions & 42 deletions packages/source/src/parser/jsonTile.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
getData,
getURLFromTemplate,
RequestParameters,
SourceTile,
TileLoadParams,
getData,
getURLFromTemplate,
} from '@antv/l7-utils';
import {
Feature,
} from '@turf/helpers';
import { Feature } from '@turf/helpers';
import { IParserData, ITileSource } from '../interface';
import VtSource from '../source/geojsonvt';

Expand All @@ -23,39 +21,25 @@ const getVectorTile = async (
requestParameters?: Partial<RequestParameters>,
getCustomData?: ITileParserCFG['getCustomData'],
): Promise<ITileSource> => {
const tileUrl = getURLFromTemplate(url, { x: tile.x, y: tile.y, z: tile.z });
const params = { x: tile.x, y: tile.y, z: tile.z };
const tileUrl = getURLFromTemplate(url, params);
return new Promise((resolve) => {
if (getCustomData) {
getCustomData(
{
x: tile.x,
y: tile.y,
z: tile.z,
},
(err, data) => {
if (err || !data) {
const vectorTile: MapboxVectorTile = {
layers: {
defaultLayer: {
features: [],
},
},
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
} else {
const vectorTile: MapboxVectorTile = {
layers: {
defaultLayer: {
features: data.features,
},
},
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
}
},
);
getCustomData(params, (err, data) => {
if (err || !data) {
const vectorTile: MapboxVectorTile = {
layers: { defaultLayer: { features: [] } },
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
} else {
const vectorTile: MapboxVectorTile = {
layers: { defaultLayer: { features: data.features } },
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
}
});
} else {
getData(
{
Expand All @@ -71,18 +55,28 @@ const getVectorTile = async (
},
},
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
const vectorSource = new VtSource(
vectorTile,
tile.x,
tile.y,
tile.z,
);
resolve(vectorSource);
} else {
const json = JSON.parse(data)
const json = JSON.parse(data);
const vectorTile: MapboxVectorTile = {
layers: {
defaultLayer: {
features: json
features: json,
},
},
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
const vectorSource = new VtSource(
vectorTile,
tile.x,
tile.y,
tile.z,
);
resolve(vectorSource);
}
},
Expand All @@ -91,8 +85,11 @@ const getVectorTile = async (
});
};

export default function jsonTile(url: string, cfg: ITileParserCFG): IParserData {
const getTileData = (_tileParams: TileLoadParams, tile: SourceTile) => {
export default function jsonTile(
url: string,
cfg: ITileParserCFG,
): IParserData {
const getTileData = (_: TileLoadParams, tile: SourceTile) => {
return getVectorTile(url, tile, cfg?.requestParameters, cfg.getCustomData);
};

Expand Down

0 comments on commit 596aa3a

Please sign in to comment.