mirror of https://gitee.com/antv-l7/antv-l7
fix(extrude): add geojson rewind
This commit is contained in:
parent
8e97486472
commit
12ca2c7e36
|
@ -26,7 +26,7 @@ const scene = new L7.Scene({
|
||||||
mapStyle: 'dark', // 样式URL
|
mapStyle: 'dark', // 样式URL
|
||||||
center: [121.576757,31.279873 ],
|
center: [121.576757,31.279873 ],
|
||||||
pitch: 0,
|
pitch: 0,
|
||||||
zoom: 10,
|
zoom: 12,
|
||||||
rotation:0
|
rotation:0
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -38,6 +38,73 @@ const testdata = [
|
||||||
"areaGeometry": "121.588443,31.260267;121.587893,31.260332;121.587385,31.260387;121.586751,31.26045;121.586099,31.260505;121.585549,31.260584;121.585499,31.260641;121.585475,31.260702;121.585469,31.26076;121.585473,31.260797;121.585721,31.261172;121.585957,31.261529;121.58623,31.261987;121.586426,31.26235;121.586646,31.262795;121.586791,31.263137;121.586924,31.263478;121.587054,31.263788;121.587256,31.264224;121.587319,31.264276;121.587421,31.264337;121.587503,31.264368;121.587542,31.264373;121.588431,31.264357;121.589115,31.264355;121.589253,31.264357;121.589339,31.264331;121.589409,31.264288;121.589547,31.264049;121.589752,31.263696;121.589973,31.263313;121.590156,31.262965;121.59029,31.262682;121.590285,31.262557;121.590257,31.262498;121.5902,31.262459;121.589712,31.262265;121.589543,31.262197;121.5895,31.262125;121.589484,31.262072;121.589499,31.262005;121.589638,31.261714;121.589709,31.261579;121.589911,31.261242;121.590037,31.261031;121.590413,31.261176;121.591041,31.26141;121.591095,31.261317;121.59128,31.26097;121.59132,31.260872;121.591495,31.26061;121.591573,31.260552;121.591628,31.26051;121.591846,31.260295;121.592266,31.259879;121.592656,31.259516;121.592781,31.259401;121.5928,31.259343;121.592801,31.259301;121.592789,31.259261;121.592718,31.259196;121.592689,31.259156;121.592266,31.25884;121.591889,31.258548;121.591681,31.258396;121.591423,31.258196;121.590993,31.257889;121.59091,31.257892;121.590849,31.257903;121.590782,31.257971;121.590504,31.25835;121.590177,31.258758;121.589896,31.259137;121.589722,31.259395;121.589449,31.259807;121.58932,31.260028;121.589223,31.26024;121.588443,31.260267;121.588443,31.260267"
|
"areaGeometry": "121.588443,31.260267;121.587893,31.260332;121.587385,31.260387;121.586751,31.26045;121.586099,31.260505;121.585549,31.260584;121.585499,31.260641;121.585475,31.260702;121.585469,31.26076;121.585473,31.260797;121.585721,31.261172;121.585957,31.261529;121.58623,31.261987;121.586426,31.26235;121.586646,31.262795;121.586791,31.263137;121.586924,31.263478;121.587054,31.263788;121.587256,31.264224;121.587319,31.264276;121.587421,31.264337;121.587503,31.264368;121.587542,31.264373;121.588431,31.264357;121.589115,31.264355;121.589253,31.264357;121.589339,31.264331;121.589409,31.264288;121.589547,31.264049;121.589752,31.263696;121.589973,31.263313;121.590156,31.262965;121.59029,31.262682;121.590285,31.262557;121.590257,31.262498;121.5902,31.262459;121.589712,31.262265;121.589543,31.262197;121.5895,31.262125;121.589484,31.262072;121.589499,31.262005;121.589638,31.261714;121.589709,31.261579;121.589911,31.261242;121.590037,31.261031;121.590413,31.261176;121.591041,31.26141;121.591095,31.261317;121.59128,31.26097;121.59132,31.260872;121.591495,31.26061;121.591573,31.260552;121.591628,31.26051;121.591846,31.260295;121.592266,31.259879;121.592656,31.259516;121.592781,31.259401;121.5928,31.259343;121.592801,31.259301;121.592789,31.259261;121.592718,31.259196;121.592689,31.259156;121.592266,31.25884;121.591889,31.258548;121.591681,31.258396;121.591423,31.258196;121.590993,31.257889;121.59091,31.257892;121.590849,31.257903;121.590782,31.257971;121.590504,31.25835;121.590177,31.258758;121.589896,31.259137;121.589722,31.259395;121.589449,31.259807;121.58932,31.260028;121.589223,31.26024;121.588443,31.260267;121.588443,31.260267"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
const data2 = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"properties": {},
|
||||||
|
"geometry": {
|
||||||
|
"type": "Polygon",
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
118.48068237304686,
|
||||||
|
32.120964197033615
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.49578857421874,
|
||||||
|
32.037184191435145
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.57131958007811,
|
||||||
|
32.061627957476404
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.57131958007811,
|
||||||
|
32.13492006367728
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.48068237304686,
|
||||||
|
32.120964197033615
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"properties": {},
|
||||||
|
"geometry": {
|
||||||
|
"type": "Polygon",
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
118.71414184570311,
|
||||||
|
31.966143862120095
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.67156982421875,
|
||||||
|
31.811062019751912
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.77044677734375,
|
||||||
|
31.75502854729287
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.85696411132814,
|
||||||
|
31.927689274849715
|
||||||
|
],
|
||||||
|
[
|
||||||
|
118.71414184570311,
|
||||||
|
31.966143862120095
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
scene.on('loaded', () => {
|
scene.on('loaded', () => {
|
||||||
|
|
||||||
const data = testdata.map(item=>{
|
const data = testdata.map(item=>{
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import * as turfMeta from '@turf/meta';
|
import * as turfMeta from '@turf/meta';
|
||||||
import { getCoords } from '@turf/invariant';
|
import { getCoords } from '@turf/invariant';
|
||||||
import { djb2hash } from '../../util/bkdr-hash';
|
import { djb2hash } from '../../util/bkdr-hash';
|
||||||
|
import rewind from '@mapbox/geojson-rewind';
|
||||||
export default function geoJSON(data, cfg) {
|
export default function geoJSON(data, cfg) {
|
||||||
|
rewind(data, true);
|
||||||
const resultData = [];
|
const resultData = [];
|
||||||
const featureKeys = {};
|
const featureKeys = {};
|
||||||
data.features = data.features.filter(item => {
|
data.features = data.features.filter(item => {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import rewind from '@mapbox/geojson-rewind';
|
||||||
export default function json(data, cfg) {
|
export default function json(data, cfg) {
|
||||||
const { x, y, x1, y1, coordinates } = cfg;
|
const { x, y, x1, y1, coordinates } = cfg;
|
||||||
const resultdata = [];
|
const resultdata = [];
|
||||||
|
@ -8,7 +9,12 @@ export default function json(data, cfg) {
|
||||||
coords = [[ col[x], col[y] ], [ col[x1], col[y1] ]];
|
coords = [[ col[x], col[y] ], [ col[x1], col[y1] ]];
|
||||||
}
|
}
|
||||||
if (coordinates) {
|
if (coordinates) {
|
||||||
coords = col[coordinates];
|
const geometry = {
|
||||||
|
type: 'Polygon',
|
||||||
|
coordinates: col[coordinates]
|
||||||
|
};
|
||||||
|
rewind(geometry, true);
|
||||||
|
coords = geometry.coordinates;
|
||||||
delete col[coordinates];
|
delete col[coordinates];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue