-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mvt): TableTileSource refactor, improved typing
chore: tile recator
- Loading branch information
Showing
12 changed files
with
278 additions
and
231 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
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 was deleted.
Oops, something went wrong.
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,64 @@ | ||
// loaders.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license | ||
|
||
import {ProtoFeature} from './proto-tile'; | ||
|
||
export function createProtoFeature( | ||
id: any, | ||
type: 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon', | ||
geometry: any[], | ||
tags | ||
): ProtoFeature { | ||
const feature: ProtoFeature = { | ||
// eslint-disable-next-line | ||
id: id == null ? null : id, | ||
type, | ||
simplifiedType: undefined!, // TODO | ||
geometry, | ||
tags, | ||
minX: Infinity, | ||
minY: Infinity, | ||
maxX: -Infinity, | ||
maxY: -Infinity | ||
}; | ||
|
||
// TODO break out into separate function | ||
switch (type) { | ||
case 'Point': | ||
case 'MultiPoint': | ||
case 'LineString': | ||
calcLineBBox(feature, geometry); | ||
break; | ||
|
||
case 'MultiLineString': | ||
for (const line of geometry) { | ||
calcLineBBox(feature, line); | ||
} | ||
break; | ||
|
||
case 'Polygon': | ||
// the outer ring (ie [0]) contains all inner rings | ||
calcLineBBox(feature, geometry[0]); | ||
break; | ||
|
||
case 'MultiPolygon': | ||
for (const polygon of geometry) { | ||
// the outer ring (ie [0]) contains all inner rings | ||
calcLineBBox(feature, polygon[0]); | ||
} | ||
break; | ||
} | ||
|
||
return feature; | ||
} | ||
|
||
function calcLineBBox(feature, geometry) { | ||
for (let i = 0; i < geometry.length; i += 3) { | ||
feature.minX = Math.min(feature.minX, geometry[i]); | ||
feature.minY = Math.min(feature.minY, geometry[i + 1]); | ||
feature.maxX = Math.max(feature.maxX, geometry[i]); | ||
feature.maxY = Math.max(feature.maxY, geometry[i + 1]); | ||
} | ||
} |
Oops, something went wrong.