@dartcom/ui-kit 3.7.1 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/layers/leaflet/layers/index.d.ts +1 -0
- package/dist/components/layers/leaflet/layers/index.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/landuse-area/utils.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/nature-field/utils.d.ts +2 -2
- package/dist/components/layers/leaflet/layers/nature-field/utils.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/nature-forest/index.d.ts +2 -0
- package/dist/components/layers/leaflet/layers/nature-forest/index.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/nature-forest/utils.d.ts +3 -0
- package/dist/components/layers/leaflet/layers/nature-forest/utils.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/ocean-area/utils.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/water-link/utils.d.ts.map +1 -1
- package/dist/components/layers/leaflet/leaflet.d.ts.map +1 -1
- package/dist/components/layers/leaflet/utils.d.ts +5 -1
- package/dist/components/layers/leaflet/utils.d.ts.map +1 -1
- package/dist/index.cjs +1225 -1156
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43870,586 +43870,191 @@ const getParkingLineLayers = (source) => {
|
|
|
43870
43870
|
return layers;
|
|
43871
43871
|
};
|
|
43872
43872
|
|
|
43873
|
-
const
|
|
43874
|
-
const
|
|
43875
|
-
|
|
43873
|
+
const getBuiltupAreaLayers = (source) => {
|
|
43874
|
+
const layers = [];
|
|
43875
|
+
const data = {
|
|
43876
|
+
source,
|
|
43877
|
+
layer: '"MapAdminBuiltupArea"',
|
|
43878
|
+
};
|
|
43879
|
+
const layer = {
|
|
43880
|
+
id: uuid(),
|
|
43881
|
+
data,
|
|
43882
|
+
draw: {
|
|
43883
|
+
polygons: {
|
|
43884
|
+
color: '#CFC8C8',
|
|
43885
|
+
},
|
|
43886
|
+
},
|
|
43887
|
+
};
|
|
43888
|
+
layers.push(layer);
|
|
43889
|
+
return layers;
|
|
43876
43890
|
};
|
|
43877
|
-
|
|
43878
|
-
|
|
43879
|
-
const
|
|
43880
|
-
|
|
43881
|
-
|
|
43882
|
-
|
|
43883
|
-
|
|
43884
|
-
|
|
43885
|
-
|
|
43891
|
+
|
|
43892
|
+
const getPointAddressLayers = (source) => {
|
|
43893
|
+
const layer = {
|
|
43894
|
+
id: uuid(),
|
|
43895
|
+
data: {
|
|
43896
|
+
source,
|
|
43897
|
+
layer: '"PointAddress"',
|
|
43898
|
+
minzoom: 15,
|
|
43899
|
+
},
|
|
43900
|
+
draw: {
|
|
43901
|
+
text: {
|
|
43902
|
+
interactive: true,
|
|
43903
|
+
text_source: 'address',
|
|
43904
|
+
font: {
|
|
43905
|
+
fill: 'black',
|
|
43906
|
+
size: '12px',
|
|
43907
|
+
},
|
|
43908
|
+
},
|
|
43909
|
+
},
|
|
43910
|
+
};
|
|
43911
|
+
return [layer];
|
|
43912
|
+
};
|
|
43913
|
+
|
|
43914
|
+
const text_source = `function() {
|
|
43915
|
+
const { poi_name, cat_id } = feature;
|
|
43916
|
+
|
|
43917
|
+
switch (+cat_id) {
|
|
43918
|
+
case 4100: {
|
|
43919
|
+
const text = poi_name.replaceAll(/(Метро-|Станция-|МЦД-)/g, "");
|
|
43920
|
+
|
|
43921
|
+
return text;
|
|
43922
|
+
}
|
|
43923
|
+
|
|
43924
|
+
default: {
|
|
43925
|
+
return poi_name;
|
|
43926
|
+
}
|
|
43927
|
+
}
|
|
43928
|
+
}`;
|
|
43929
|
+
const catIds = [
|
|
43930
|
+
3578, 4013, 4100, 5400, 5511, 5512, 5540, 5541, 5800, 5813, 5999, 6000, 7011,
|
|
43931
|
+
7389, 7832, 7929, 7990, 8060, 8410, 9517, 9530, 9565, 9583, 9718, 9992,
|
|
43932
|
+
];
|
|
43933
|
+
|
|
43934
|
+
const getDefaultPOI = (cat_id) => {
|
|
43935
|
+
const defaultPOI = {};
|
|
43936
|
+
switch (cat_id) {
|
|
43937
|
+
case 4100: {
|
|
43938
|
+
defaultPOI[`_${cat_id}-metro`] = {
|
|
43939
|
+
filter: `function() {
|
|
43940
|
+
const { poi_name, cat_id } = feature;
|
|
43941
|
+
|
|
43942
|
+
const isMetro = poi_name.startsWith('Метро-');
|
|
43943
|
+
const isStation = poi_name.startsWith('Станция-');
|
|
43944
|
+
|
|
43945
|
+
const isCatId = +cat_id === ${cat_id};
|
|
43946
|
+
|
|
43947
|
+
const isFilter = isCatId && (isMetro || isStation);
|
|
43948
|
+
|
|
43949
|
+
return isFilter;
|
|
43950
|
+
}`,
|
|
43951
|
+
draw: {
|
|
43952
|
+
points: getPOITypeLayer(`POI_${cat_id}(metro)`),
|
|
43953
|
+
},
|
|
43886
43954
|
};
|
|
43887
|
-
|
|
43888
|
-
|
|
43889
|
-
|
|
43890
|
-
|
|
43891
|
-
|
|
43955
|
+
defaultPOI[`_${cat_id}-diameter`] = {
|
|
43956
|
+
filter: `function() {
|
|
43957
|
+
const { cat_id, poi_name } = feature;
|
|
43958
|
+
|
|
43959
|
+
const isDiameter = poi_name.startsWith('МЦД-');
|
|
43960
|
+
|
|
43961
|
+
const isCatId = +cat_id === ${cat_id};
|
|
43962
|
+
|
|
43963
|
+
const isFilter = isCatId && isDiameter;
|
|
43964
|
+
|
|
43965
|
+
return isFilter;
|
|
43966
|
+
}`,
|
|
43967
|
+
draw: {
|
|
43968
|
+
points: getPOITypeLayer(`POI_${cat_id}(diameter)`),
|
|
43969
|
+
},
|
|
43892
43970
|
};
|
|
43971
|
+
break;
|
|
43893
43972
|
}
|
|
43894
|
-
|
|
43895
|
-
|
|
43896
|
-
|
|
43897
|
-
|
|
43973
|
+
case 9530: {
|
|
43974
|
+
defaultPOI[`_${cat_id}-mail`] = {
|
|
43975
|
+
filter: `function() {
|
|
43976
|
+
const { cat_id, poi_name = '' } = feature;
|
|
43977
|
+
|
|
43978
|
+
const isCatId = +cat_id === ${cat_id};
|
|
43979
|
+
|
|
43980
|
+
const isMail = poi_name.startsWith('Почта');
|
|
43981
|
+
|
|
43982
|
+
const isFilter = isCatId && isMail;
|
|
43983
|
+
|
|
43984
|
+
return isFilter;
|
|
43985
|
+
}`,
|
|
43986
|
+
draw: {
|
|
43987
|
+
points: getPOITypeLayer(`POI_${cat_id}(Mail)`),
|
|
43988
|
+
},
|
|
43989
|
+
};
|
|
43990
|
+
defaultPOI[`_${cat_id}-delivery`] = {
|
|
43991
|
+
filter: `function() {
|
|
43992
|
+
const { cat_id, poi_name = '' } = feature;
|
|
43993
|
+
|
|
43994
|
+
const isCatId = +cat_id === ${cat_id};
|
|
43995
|
+
|
|
43996
|
+
const isMail = poi_name.startsWith('Почта');
|
|
43997
|
+
|
|
43998
|
+
const isFilter = isCatId && !isMail;
|
|
43999
|
+
|
|
44000
|
+
return isFilter;
|
|
44001
|
+
}`,
|
|
44002
|
+
draw: {
|
|
44003
|
+
points: getPOITypeLayer(`POI_${cat_id}(Delivery)`),
|
|
44004
|
+
},
|
|
43898
44005
|
};
|
|
44006
|
+
break;
|
|
43899
44007
|
}
|
|
43900
|
-
|
|
43901
|
-
|
|
43902
|
-
|
|
43903
|
-
|
|
44008
|
+
case 9992: {
|
|
44009
|
+
const subcat = {
|
|
44010
|
+
mosque: 1,
|
|
44011
|
+
church: 2,
|
|
44012
|
+
temple: 3,
|
|
44013
|
+
davidStar: 4,
|
|
44014
|
+
mortar: 6,
|
|
43904
44015
|
};
|
|
44016
|
+
Object.entries(subcat).forEach(([subcat_name, subcat_id]) => {
|
|
44017
|
+
defaultPOI[`_${cat_id}-${subcat_name}`] = {
|
|
44018
|
+
filter: `function() {
|
|
44019
|
+
const { cat_id, subcat_id } = feature;
|
|
44020
|
+
|
|
44021
|
+
const isCatId = +cat_id === ${cat_id};
|
|
44022
|
+
const isSubcatId = +subcat_id === ${subcat_id};
|
|
44023
|
+
|
|
44024
|
+
const isFilter = isCatId && isSubcatId;
|
|
44025
|
+
|
|
44026
|
+
return isFilter;
|
|
44027
|
+
}`,
|
|
44028
|
+
draw: {
|
|
44029
|
+
points: getPOITypeLayer(`POI_${cat_id}(${subcat_name})`),
|
|
44030
|
+
},
|
|
44031
|
+
};
|
|
44032
|
+
});
|
|
44033
|
+
break;
|
|
43905
44034
|
}
|
|
43906
|
-
|
|
43907
|
-
|
|
43908
|
-
|
|
43909
|
-
|
|
43910
|
-
|
|
43911
|
-
|
|
44035
|
+
default: {
|
|
44036
|
+
defaultPOI[`_${cat_id}`] = {
|
|
44037
|
+
filter: `function {
|
|
44038
|
+
const { cat_id } = feature;
|
|
44039
|
+
|
|
44040
|
+
const isFilter = +cat_id === ${cat_id};
|
|
44041
|
+
|
|
44042
|
+
return isFilter;
|
|
44043
|
+
}`,
|
|
44044
|
+
draw: {
|
|
44045
|
+
points: getPOITypeLayer(`POI_${cat_id}`),
|
|
43912
44046
|
},
|
|
43913
|
-
}
|
|
44047
|
+
};
|
|
43914
44048
|
}
|
|
43915
|
-
cloneLayer.draw = structuredClone(draw);
|
|
43916
|
-
}
|
|
43917
|
-
if (sublayers) {
|
|
43918
|
-
Object.entries(sublayers).forEach(([name, sublayer]) => {
|
|
43919
|
-
if (sublayer) {
|
|
43920
|
-
const { draw } = sublayer;
|
|
43921
|
-
if (draw) {
|
|
43922
|
-
const { points, lines, polygons } = draw;
|
|
43923
|
-
if (points) {
|
|
43924
|
-
points.order = order;
|
|
43925
|
-
draw.points = points;
|
|
43926
|
-
}
|
|
43927
|
-
if (lines) {
|
|
43928
|
-
lines.order = order;
|
|
43929
|
-
draw.lines = lines;
|
|
43930
|
-
}
|
|
43931
|
-
if (polygons) {
|
|
43932
|
-
polygons.order = order;
|
|
43933
|
-
draw.polygons = polygons;
|
|
43934
|
-
}
|
|
43935
|
-
sublayer.draw = structuredClone(draw);
|
|
43936
|
-
}
|
|
43937
|
-
sublayers[name] = structuredClone(sublayer);
|
|
43938
|
-
}
|
|
43939
|
-
});
|
|
43940
|
-
cloneLayer.sublayers = structuredClone(sublayers);
|
|
43941
44049
|
}
|
|
43942
|
-
return
|
|
44050
|
+
return defaultPOI;
|
|
43943
44051
|
};
|
|
43944
|
-
|
|
43945
|
-
const
|
|
43946
|
-
|
|
43947
|
-
|
|
43948
|
-
|
|
43949
|
-
|
|
43950
|
-
const getLeafletLayer = () => {
|
|
43951
|
-
Promise.resolve().then(function () { return tangram_min; }).then(() => {
|
|
43952
|
-
if (window.Tangram) {
|
|
43953
|
-
const leafletLayer = window.Tangram.leafletLayer({
|
|
43954
|
-
scene: sceneTiles,
|
|
43955
|
-
});
|
|
43956
|
-
const { scene } = leafletLayer;
|
|
43957
|
-
setLayer(leafletLayer);
|
|
43958
|
-
setScene(scene);
|
|
43959
|
-
}
|
|
43960
|
-
});
|
|
43961
|
-
};
|
|
43962
|
-
const addSource = React__namespace.useCallback((sourceConfig) => {
|
|
43963
|
-
if (!scene) {
|
|
43964
|
-
console.warn('Scene не инициализирована');
|
|
43965
|
-
return;
|
|
43966
|
-
}
|
|
43967
|
-
if (!config) {
|
|
43968
|
-
console.warn('Config не инициализирована');
|
|
43969
|
-
return;
|
|
43970
|
-
}
|
|
43971
|
-
const { name } = sourceConfig;
|
|
43972
|
-
config.sources[name] = structuredClone(sourceConfig);
|
|
43973
|
-
scene.updateConfig({ rebuild: true });
|
|
43974
|
-
return getSources();
|
|
43975
|
-
}, [scene, config]);
|
|
43976
|
-
const getSource = React__namespace.useCallback((sourceName) => {
|
|
43977
|
-
if (!config) {
|
|
43978
|
-
console.warn('Config не инициализирована');
|
|
43979
|
-
return;
|
|
43980
|
-
}
|
|
43981
|
-
return structuredClone(config.sources[sourceName]);
|
|
43982
|
-
}, [config]);
|
|
43983
|
-
const updateSource = React__namespace.useCallback((sourceName, newUrl) => {
|
|
43984
|
-
if (!scene) {
|
|
43985
|
-
console.warn('Scene не инициализирована');
|
|
43986
|
-
return;
|
|
43987
|
-
}
|
|
43988
|
-
if (!config) {
|
|
43989
|
-
console.warn('Config не инициализирована');
|
|
43990
|
-
return;
|
|
43991
|
-
}
|
|
43992
|
-
config.sources[sourceName].url = newUrl;
|
|
43993
|
-
scene.updateConfig({ rebuild: true });
|
|
43994
|
-
return getSources();
|
|
43995
|
-
}, [config, scene]);
|
|
43996
|
-
const addLayer = React__namespace.useCallback((layer) => {
|
|
43997
|
-
if (!scene) {
|
|
43998
|
-
console.warn('Scene не инициализирован');
|
|
43999
|
-
return;
|
|
44000
|
-
}
|
|
44001
|
-
if (!config) {
|
|
44002
|
-
console.warn('Config не инициализирован');
|
|
44003
|
-
return;
|
|
44004
|
-
}
|
|
44005
|
-
const order = getLayers().length + 1;
|
|
44006
|
-
const layerWithOrder = setLayerOrder({
|
|
44007
|
-
layer,
|
|
44008
|
-
order,
|
|
44009
|
-
});
|
|
44010
|
-
const layerName = getLayerName(layerWithOrder);
|
|
44011
|
-
const { sublayers = {}, draw } = layerWithOrder;
|
|
44012
|
-
if (draw) {
|
|
44013
|
-
const { styles = {} } = draw;
|
|
44014
|
-
if (styles) {
|
|
44015
|
-
layerWithOrder.draw = {
|
|
44016
|
-
...structuredClone(draw),
|
|
44017
|
-
...structuredClone(styles),
|
|
44018
|
-
};
|
|
44019
|
-
}
|
|
44020
|
-
}
|
|
44021
|
-
config.layers[layerName] = {
|
|
44022
|
-
...structuredClone(layerWithOrder),
|
|
44023
|
-
...structuredClone(sublayers),
|
|
44024
|
-
};
|
|
44025
|
-
scene.updateConfig({ rebuild: true });
|
|
44026
|
-
return getLayers();
|
|
44027
|
-
}, [config, scene]);
|
|
44028
|
-
const removeLayer = React__namespace.useCallback((layer) => {
|
|
44029
|
-
if (!scene) {
|
|
44030
|
-
console.warn('Scene не инициализирован');
|
|
44031
|
-
return;
|
|
44032
|
-
}
|
|
44033
|
-
if (!config) {
|
|
44034
|
-
console.warn('Config не инициализирован');
|
|
44035
|
-
return;
|
|
44036
|
-
}
|
|
44037
|
-
const layerName = getLayerName(layer);
|
|
44038
|
-
if (config.layers[layerName]) {
|
|
44039
|
-
delete config.layers[layerName];
|
|
44040
|
-
}
|
|
44041
|
-
scene.updateConfig({ rebuild: true });
|
|
44042
|
-
return getLayers();
|
|
44043
|
-
}, [config, scene]);
|
|
44044
|
-
const addStyle = React__namespace.useCallback(({ name, style }) => {
|
|
44045
|
-
if (!scene) {
|
|
44046
|
-
console.warn('Scene не инициализирована');
|
|
44047
|
-
return;
|
|
44048
|
-
}
|
|
44049
|
-
if (!config) {
|
|
44050
|
-
console.warn('Config не инициализирована');
|
|
44051
|
-
return;
|
|
44052
|
-
}
|
|
44053
|
-
config.styles[name] = structuredClone(style);
|
|
44054
|
-
scene.updateConfig({ rebuild: true });
|
|
44055
|
-
}, [config, scene]);
|
|
44056
|
-
const getLayerVisibility = React__namespace.useCallback((layer) => {
|
|
44057
|
-
if (!config) {
|
|
44058
|
-
console.warn('Config не инициализирована');
|
|
44059
|
-
return;
|
|
44060
|
-
}
|
|
44061
|
-
const layerName = getLayerName(layer);
|
|
44062
|
-
const { visible: layerVisibility } = config.layers[layerName];
|
|
44063
|
-
return layerVisibility;
|
|
44064
|
-
}, [config]);
|
|
44065
|
-
const toggleLayerVisibility = React__namespace.useCallback(({ layer, visible }) => {
|
|
44066
|
-
if (!scene) {
|
|
44067
|
-
console.warn('Scene не инициализирована');
|
|
44068
|
-
return;
|
|
44069
|
-
}
|
|
44070
|
-
if (!config) {
|
|
44071
|
-
console.warn('Config не инициализирована');
|
|
44072
|
-
return;
|
|
44073
|
-
}
|
|
44074
|
-
const layerName = getLayerName(layer);
|
|
44075
|
-
config.layers[layerName].visible = visible;
|
|
44076
|
-
scene.updateConfig();
|
|
44077
|
-
return getLayerVisibility(layer);
|
|
44078
|
-
}, [config, scene]);
|
|
44079
|
-
const getLayers = React__namespace.useCallback(() => {
|
|
44080
|
-
if (!config)
|
|
44081
|
-
return [];
|
|
44082
|
-
const { layers } = config;
|
|
44083
|
-
return Object.keys(layers);
|
|
44084
|
-
}, [config]);
|
|
44085
|
-
const removeLayers = React__namespace.useCallback(() => {
|
|
44086
|
-
if (!config)
|
|
44087
|
-
return [];
|
|
44088
|
-
const { layers } = config;
|
|
44089
|
-
Object.values(layers).forEach(removeLayer);
|
|
44090
|
-
}, [config]);
|
|
44091
|
-
const getSources = React__namespace.useCallback(() => {
|
|
44092
|
-
if (!config)
|
|
44093
|
-
return [];
|
|
44094
|
-
const { sources } = config;
|
|
44095
|
-
return Object.keys(sources);
|
|
44096
|
-
}, [config]);
|
|
44097
|
-
React__namespace.useEffect(() => {
|
|
44098
|
-
if (isValidApiKey) {
|
|
44099
|
-
getLeafletLayer();
|
|
44100
|
-
}
|
|
44101
|
-
return () => {
|
|
44102
|
-
setLayer(null);
|
|
44103
|
-
setScene(null);
|
|
44104
|
-
setConfig(null);
|
|
44105
|
-
};
|
|
44106
|
-
}, [isValidApiKey]);
|
|
44107
|
-
React__namespace.useEffect(() => {
|
|
44108
|
-
if (scene) {
|
|
44109
|
-
scene.subscribe({
|
|
44110
|
-
load: ({ config }) => {
|
|
44111
|
-
setConfig(config);
|
|
44112
|
-
},
|
|
44113
|
-
});
|
|
44114
|
-
}
|
|
44115
|
-
}, [scene]);
|
|
44116
|
-
React__namespace.useEffect(() => {
|
|
44117
|
-
addStyle({
|
|
44118
|
-
name: 'space-tile',
|
|
44119
|
-
style: {
|
|
44120
|
-
shaders: {
|
|
44121
|
-
defines: {
|
|
44122
|
-
TILE_SCALE: 0.0002445,
|
|
44123
|
-
'NORMALIZED_SHORT(x)': '(x * 32767.)',
|
|
44124
|
-
},
|
|
44125
|
-
blocks: {
|
|
44126
|
-
global: `
|
|
44127
|
-
varying vec3 v_pos;
|
|
44128
|
-
vec2 getTileCoords() {
|
|
44129
|
-
return fract(v_pos.xy);
|
|
44130
|
-
}
|
|
44131
|
-
`,
|
|
44132
|
-
position: `
|
|
44133
|
-
v_pos = modelPosition().xyz;
|
|
44134
|
-
`,
|
|
44135
|
-
},
|
|
44136
|
-
},
|
|
44137
|
-
},
|
|
44138
|
-
});
|
|
44139
|
-
addStyle({
|
|
44140
|
-
name: 'tools-aastep',
|
|
44141
|
-
style: {
|
|
44142
|
-
shaders: {
|
|
44143
|
-
extensions: 'OES_standard_derivatives',
|
|
44144
|
-
blocks: {
|
|
44145
|
-
global: `
|
|
44146
|
-
float aastep(float threshold, float value) {
|
|
44147
|
-
#ifdef TANGRAM_FRAGMENT_SHADER
|
|
44148
|
-
#ifdef TANGRAM_EXTENSION_OES_standard_derivatives
|
|
44149
|
-
float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
|
|
44150
|
-
return smoothstep(threshold-afwidth, threshold+afwidth, value);
|
|
44151
|
-
#else
|
|
44152
|
-
return step(threshold, value);
|
|
44153
|
-
#endif
|
|
44154
|
-
#else
|
|
44155
|
-
return step(threshold, value);
|
|
44156
|
-
#endif
|
|
44157
|
-
}
|
|
44158
|
-
`,
|
|
44159
|
-
},
|
|
44160
|
-
},
|
|
44161
|
-
},
|
|
44162
|
-
});
|
|
44163
|
-
addStyle({
|
|
44164
|
-
name: 'pattern-diagonal-grid',
|
|
44165
|
-
style: {
|
|
44166
|
-
mix: ['space-tile', 'tools-aastep'],
|
|
44167
|
-
shaders: {
|
|
44168
|
-
blocks: {
|
|
44169
|
-
global: `
|
|
44170
|
-
float DiagonalGrid(float scale, float lineWidth) {
|
|
44171
|
-
vec2 st = getTileCoords() * scale;
|
|
44172
|
-
|
|
44173
|
-
float d1 = mod(st.x + st.y, 1.0);
|
|
44174
|
-
float line1 = aastep(lineWidth, d1) * aastep(1.0 - lineWidth, d1);
|
|
44175
|
-
|
|
44176
|
-
float d2 = mod(st.x - st.y, 1.0);
|
|
44177
|
-
float line2 = aastep(lineWidth, d2) * aastep(1.0 - lineWidth, d2);
|
|
44178
|
-
|
|
44179
|
-
return max(line1, line2);
|
|
44180
|
-
}
|
|
44181
|
-
`,
|
|
44182
|
-
},
|
|
44183
|
-
},
|
|
44184
|
-
},
|
|
44185
|
-
});
|
|
44186
|
-
addStyle({
|
|
44187
|
-
name: 'diagonal-grid',
|
|
44188
|
-
style: {
|
|
44189
|
-
mix: 'pattern-diagonal-grid',
|
|
44190
|
-
blend: 'overlay',
|
|
44191
|
-
base: 'polygons',
|
|
44192
|
-
shaders: {
|
|
44193
|
-
blocks: {
|
|
44194
|
-
color: `
|
|
44195
|
-
float grid = DiagonalGrid(12.0, 0.08);
|
|
44196
|
-
|
|
44197
|
-
color.a = grid;
|
|
44198
|
-
`,
|
|
44199
|
-
},
|
|
44200
|
-
},
|
|
44201
|
-
},
|
|
44202
|
-
});
|
|
44203
|
-
addStyle({
|
|
44204
|
-
name: 'zebra_crossing',
|
|
44205
|
-
style: {
|
|
44206
|
-
base: 'polygons',
|
|
44207
|
-
lighting: false,
|
|
44208
|
-
shaders: {
|
|
44209
|
-
attributes: {
|
|
44210
|
-
a_angle: {
|
|
44211
|
-
type: 'float',
|
|
44212
|
-
default: 0.0,
|
|
44213
|
-
},
|
|
44214
|
-
},
|
|
44215
|
-
uniforms: {
|
|
44216
|
-
u_stripe_width: 1,
|
|
44217
|
-
},
|
|
44218
|
-
blocks: {
|
|
44219
|
-
filter: `
|
|
44220
|
-
vec3 pos = worldPosition().xyz;
|
|
44221
|
-
|
|
44222
|
-
float ang = radians(a_angle);
|
|
44223
|
-
|
|
44224
|
-
vec2 dir = vec2(sin(ang), cos(ang));
|
|
44225
|
-
|
|
44226
|
-
float positionAlongLine = dot(pos.xy, dir);
|
|
44227
|
-
|
|
44228
|
-
float stripe = step(1.0, mod(positionAlongLine / u_stripe_width, 2.0));
|
|
44229
|
-
|
|
44230
|
-
color.rgb = mix(vec3(1.0, 1.0, 1.0), vec3(1.0, 0.8, 0.0), stripe);
|
|
44231
|
-
|
|
44232
|
-
color.a = 1.0;
|
|
44233
|
-
`,
|
|
44234
|
-
},
|
|
44235
|
-
},
|
|
44236
|
-
},
|
|
44237
|
-
});
|
|
44238
|
-
}, [addStyle]);
|
|
44239
|
-
React__namespace.useEffect(() => {
|
|
44240
|
-
Object.values(exports.TangramSourceNames).forEach((name) => {
|
|
44241
|
-
const url = sourceUrl[name];
|
|
44242
|
-
addSource({
|
|
44243
|
-
tile_size,
|
|
44244
|
-
name,
|
|
44245
|
-
url,
|
|
44246
|
-
type: 'MVT',
|
|
44247
|
-
});
|
|
44248
|
-
});
|
|
44249
|
-
}, [addSource]);
|
|
44250
|
-
return {
|
|
44251
|
-
layer,
|
|
44252
|
-
scene,
|
|
44253
|
-
config,
|
|
44254
|
-
addSource,
|
|
44255
|
-
getSource,
|
|
44256
|
-
updateSource,
|
|
44257
|
-
addLayer,
|
|
44258
|
-
removeLayer,
|
|
44259
|
-
addStyle,
|
|
44260
|
-
getLayerVisibility,
|
|
44261
|
-
toggleLayerVisibility,
|
|
44262
|
-
getSources,
|
|
44263
|
-
getLayers,
|
|
44264
|
-
removeLayers,
|
|
44265
|
-
};
|
|
44266
|
-
};
|
|
44267
|
-
|
|
44268
|
-
const getBuiltupAreaLayers = (source) => {
|
|
44269
|
-
const layers = [];
|
|
44270
|
-
const data = {
|
|
44271
|
-
source,
|
|
44272
|
-
layer: '"MapAdminBuiltupArea"',
|
|
44273
|
-
};
|
|
44274
|
-
const layer = {
|
|
44275
|
-
id: uuid(),
|
|
44276
|
-
data,
|
|
44277
|
-
draw: {
|
|
44278
|
-
polygons: {
|
|
44279
|
-
color: '#CFC8C8',
|
|
44280
|
-
},
|
|
44281
|
-
},
|
|
44282
|
-
};
|
|
44283
|
-
layers.push(layer);
|
|
44284
|
-
return layers;
|
|
44285
|
-
};
|
|
44286
|
-
|
|
44287
|
-
const getPointAddressLayers = (source) => {
|
|
44288
|
-
const layer = {
|
|
44289
|
-
id: uuid(),
|
|
44290
|
-
data: {
|
|
44291
|
-
source,
|
|
44292
|
-
layer: '"PointAddress"',
|
|
44293
|
-
minzoom: 15,
|
|
44294
|
-
},
|
|
44295
|
-
draw: {
|
|
44296
|
-
text: {
|
|
44297
|
-
interactive: true,
|
|
44298
|
-
text_source: 'address',
|
|
44299
|
-
font: {
|
|
44300
|
-
fill: 'black',
|
|
44301
|
-
size: '12px',
|
|
44302
|
-
},
|
|
44303
|
-
},
|
|
44304
|
-
},
|
|
44305
|
-
};
|
|
44306
|
-
return [layer];
|
|
44307
|
-
};
|
|
44308
|
-
|
|
44309
|
-
const text_source = `function() {
|
|
44310
|
-
const { poi_name, cat_id } = feature;
|
|
44311
|
-
|
|
44312
|
-
switch (+cat_id) {
|
|
44313
|
-
case 4100: {
|
|
44314
|
-
const text = poi_name.replaceAll(/(Метро-|Станция-|МЦД-)/g, "");
|
|
44315
|
-
|
|
44316
|
-
return text;
|
|
44317
|
-
}
|
|
44318
|
-
|
|
44319
|
-
default: {
|
|
44320
|
-
return poi_name;
|
|
44321
|
-
}
|
|
44322
|
-
}
|
|
44323
|
-
}`;
|
|
44324
|
-
const catIds = [
|
|
44325
|
-
3578, 4013, 4100, 5400, 5511, 5512, 5540, 5541, 5800, 5813, 5999, 6000, 7011,
|
|
44326
|
-
7389, 7832, 7929, 7990, 8060, 8410, 9517, 9530, 9565, 9583, 9718, 9992,
|
|
44327
|
-
];
|
|
44328
|
-
|
|
44329
|
-
const getDefaultPOI = (cat_id) => {
|
|
44330
|
-
const defaultPOI = {};
|
|
44331
|
-
switch (cat_id) {
|
|
44332
|
-
case 4100: {
|
|
44333
|
-
defaultPOI[`_${cat_id}-metro`] = {
|
|
44334
|
-
filter: `function() {
|
|
44335
|
-
const { poi_name, cat_id } = feature;
|
|
44336
|
-
|
|
44337
|
-
const isMetro = poi_name.startsWith('Метро-');
|
|
44338
|
-
const isStation = poi_name.startsWith('Станция-');
|
|
44339
|
-
|
|
44340
|
-
const isCatId = +cat_id === ${cat_id};
|
|
44341
|
-
|
|
44342
|
-
const isFilter = isCatId && (isMetro || isStation);
|
|
44343
|
-
|
|
44344
|
-
return isFilter;
|
|
44345
|
-
}`,
|
|
44346
|
-
draw: {
|
|
44347
|
-
points: getPOITypeLayer(`POI_${cat_id}(metro)`),
|
|
44348
|
-
},
|
|
44349
|
-
};
|
|
44350
|
-
defaultPOI[`_${cat_id}-diameter`] = {
|
|
44351
|
-
filter: `function() {
|
|
44352
|
-
const { cat_id, poi_name } = feature;
|
|
44353
|
-
|
|
44354
|
-
const isDiameter = poi_name.startsWith('МЦД-');
|
|
44355
|
-
|
|
44356
|
-
const isCatId = +cat_id === ${cat_id};
|
|
44357
|
-
|
|
44358
|
-
const isFilter = isCatId && isDiameter;
|
|
44359
|
-
|
|
44360
|
-
return isFilter;
|
|
44361
|
-
}`,
|
|
44362
|
-
draw: {
|
|
44363
|
-
points: getPOITypeLayer(`POI_${cat_id}(diameter)`),
|
|
44364
|
-
},
|
|
44365
|
-
};
|
|
44366
|
-
break;
|
|
44367
|
-
}
|
|
44368
|
-
case 9530: {
|
|
44369
|
-
defaultPOI[`_${cat_id}-mail`] = {
|
|
44370
|
-
filter: `function() {
|
|
44371
|
-
const { cat_id, poi_name = '' } = feature;
|
|
44372
|
-
|
|
44373
|
-
const isCatId = +cat_id === ${cat_id};
|
|
44374
|
-
|
|
44375
|
-
const isMail = poi_name.startsWith('Почта');
|
|
44376
|
-
|
|
44377
|
-
const isFilter = isCatId && isMail;
|
|
44378
|
-
|
|
44379
|
-
return isFilter;
|
|
44380
|
-
}`,
|
|
44381
|
-
draw: {
|
|
44382
|
-
points: getPOITypeLayer(`POI_${cat_id}(Mail)`),
|
|
44383
|
-
},
|
|
44384
|
-
};
|
|
44385
|
-
defaultPOI[`_${cat_id}-delivery`] = {
|
|
44386
|
-
filter: `function() {
|
|
44387
|
-
const { cat_id, poi_name = '' } = feature;
|
|
44388
|
-
|
|
44389
|
-
const isCatId = +cat_id === ${cat_id};
|
|
44390
|
-
|
|
44391
|
-
const isMail = poi_name.startsWith('Почта');
|
|
44392
|
-
|
|
44393
|
-
const isFilter = isCatId && !isMail;
|
|
44394
|
-
|
|
44395
|
-
return isFilter;
|
|
44396
|
-
}`,
|
|
44397
|
-
draw: {
|
|
44398
|
-
points: getPOITypeLayer(`POI_${cat_id}(Delivery)`),
|
|
44399
|
-
},
|
|
44400
|
-
};
|
|
44401
|
-
break;
|
|
44402
|
-
}
|
|
44403
|
-
case 9992: {
|
|
44404
|
-
const subcat = {
|
|
44405
|
-
mosque: 1,
|
|
44406
|
-
church: 2,
|
|
44407
|
-
temple: 3,
|
|
44408
|
-
davidStar: 4,
|
|
44409
|
-
mortar: 6,
|
|
44410
|
-
};
|
|
44411
|
-
Object.entries(subcat).forEach(([subcat_name, subcat_id]) => {
|
|
44412
|
-
defaultPOI[`_${cat_id}-${subcat_name}`] = {
|
|
44413
|
-
filter: `function() {
|
|
44414
|
-
const { cat_id, subcat_id } = feature;
|
|
44415
|
-
|
|
44416
|
-
const isCatId = +cat_id === ${cat_id};
|
|
44417
|
-
const isSubcatId = +subcat_id === ${subcat_id};
|
|
44418
|
-
|
|
44419
|
-
const isFilter = isCatId && isSubcatId;
|
|
44420
|
-
|
|
44421
|
-
return isFilter;
|
|
44422
|
-
}`,
|
|
44423
|
-
draw: {
|
|
44424
|
-
points: getPOITypeLayer(`POI_${cat_id}(${subcat_name})`),
|
|
44425
|
-
},
|
|
44426
|
-
};
|
|
44427
|
-
});
|
|
44428
|
-
break;
|
|
44429
|
-
}
|
|
44430
|
-
default: {
|
|
44431
|
-
defaultPOI[`_${cat_id}`] = {
|
|
44432
|
-
filter: `function {
|
|
44433
|
-
const { cat_id } = feature;
|
|
44434
|
-
|
|
44435
|
-
const isFilter = +cat_id === ${cat_id};
|
|
44436
|
-
|
|
44437
|
-
return isFilter;
|
|
44438
|
-
}`,
|
|
44439
|
-
draw: {
|
|
44440
|
-
points: getPOITypeLayer(`POI_${cat_id}`),
|
|
44441
|
-
},
|
|
44442
|
-
};
|
|
44443
|
-
}
|
|
44444
|
-
}
|
|
44445
|
-
return defaultPOI;
|
|
44446
|
-
};
|
|
44447
|
-
const getPOITypeLayer = (texture) => {
|
|
44448
|
-
const typeLayer = {
|
|
44449
|
-
texture,
|
|
44450
|
-
sprite: 'base',
|
|
44451
|
-
size: '20px',
|
|
44452
|
-
placement: 'midpoint',
|
|
44052
|
+
const getPOITypeLayer = (texture) => {
|
|
44053
|
+
const typeLayer = {
|
|
44054
|
+
texture,
|
|
44055
|
+
sprite: 'base',
|
|
44056
|
+
size: '20px',
|
|
44057
|
+
placement: 'midpoint',
|
|
44453
44058
|
};
|
|
44454
44059
|
return typeLayer;
|
|
44455
44060
|
};
|
|
@@ -44729,13 +44334,15 @@ const getWaterAreaLayers = (source) => {
|
|
|
44729
44334
|
};
|
|
44730
44335
|
|
|
44731
44336
|
const getWaterLinkLayers = (source) => {
|
|
44337
|
+
const layers = [];
|
|
44732
44338
|
const sublayers = {};
|
|
44339
|
+
const data = {
|
|
44340
|
+
source,
|
|
44341
|
+
layer: '"MapWaterLink"',
|
|
44342
|
+
};
|
|
44733
44343
|
const layer = {
|
|
44734
44344
|
id: uuid(),
|
|
44735
|
-
data
|
|
44736
|
-
source,
|
|
44737
|
-
layer: '"MapWaterLink"',
|
|
44738
|
-
},
|
|
44345
|
+
data,
|
|
44739
44346
|
};
|
|
44740
44347
|
sublayers.geometry = {
|
|
44741
44348
|
draw: {
|
|
@@ -44763,10 +44370,12 @@ const getWaterLinkLayers = (source) => {
|
|
|
44763
44370
|
},
|
|
44764
44371
|
};
|
|
44765
44372
|
layer.sublayers = sublayers;
|
|
44766
|
-
|
|
44373
|
+
layers.push(layer);
|
|
44374
|
+
return layers;
|
|
44767
44375
|
};
|
|
44768
44376
|
|
|
44769
44377
|
const getOceanAreaLayers = (source) => {
|
|
44378
|
+
const layers = [];
|
|
44770
44379
|
const geometryLayer = {
|
|
44771
44380
|
id: uuid(),
|
|
44772
44381
|
data: {
|
|
@@ -44796,691 +44405,1165 @@ const getOceanAreaLayers = (source) => {
|
|
|
44796
44405
|
},
|
|
44797
44406
|
},
|
|
44798
44407
|
};
|
|
44799
|
-
|
|
44408
|
+
layers.push(geometryLayer, textLayer);
|
|
44409
|
+
return layers;
|
|
44800
44410
|
};
|
|
44801
44411
|
|
|
44802
44412
|
const getLanduseAreaLayers = (source) => {
|
|
44803
44413
|
const layers = [];
|
|
44804
|
-
|
|
44805
|
-
|
|
44806
|
-
|
|
44807
|
-
|
|
44808
|
-
|
|
44809
|
-
|
|
44810
|
-
|
|
44811
|
-
|
|
44812
|
-
|
|
44813
|
-
|
|
44814
|
-
interactive: true,
|
|
44815
|
-
color: `function() {
|
|
44414
|
+
const geometryLayer = {
|
|
44415
|
+
id: uuid(),
|
|
44416
|
+
data: {
|
|
44417
|
+
source,
|
|
44418
|
+
layer: '"MapLanduseArea"',
|
|
44419
|
+
},
|
|
44420
|
+
draw: {
|
|
44421
|
+
polygons: {
|
|
44422
|
+
interactive: true,
|
|
44423
|
+
color: `function() {
|
|
44816
44424
|
const { feature_type } = feature;
|
|
44817
44425
|
|
|
44818
44426
|
switch (feature_type) {
|
|
44819
|
-
case '
|
|
44427
|
+
case '509998': {
|
|
44428
|
+
return '#ECD175';
|
|
44429
|
+
}
|
|
44430
|
+
|
|
44431
|
+
case '600102':
|
|
44432
|
+
case '900140': {
|
|
44433
|
+
return '#3E9A8C';
|
|
44434
|
+
}
|
|
44435
|
+
|
|
44436
|
+
case '900202':
|
|
44437
|
+
case '900130':
|
|
44438
|
+
case '900150':
|
|
44439
|
+
case '900103': {
|
|
44820
44440
|
return '#96BE7D';
|
|
44821
44441
|
}
|
|
44822
44442
|
|
|
44823
|
-
|
|
44443
|
+
case '9997010': {
|
|
44824
44444
|
return null;
|
|
44825
44445
|
}
|
|
44826
44446
|
}
|
|
44827
44447
|
}`,
|
|
44828
|
-
|
|
44829
|
-
},
|
|
44830
|
-
};
|
|
44831
|
-
layers.push(geometryLayer);
|
|
44832
|
-
break;
|
|
44833
|
-
}
|
|
44834
|
-
default: {
|
|
44835
|
-
const geometryLayer = {
|
|
44836
|
-
id: uuid(),
|
|
44837
|
-
data: {
|
|
44838
|
-
source,
|
|
44839
|
-
layer: '"MapLanduseArea"',
|
|
44840
|
-
},
|
|
44841
|
-
draw: {
|
|
44842
|
-
polygons: {
|
|
44843
|
-
interactive: true,
|
|
44844
|
-
color: `function() {
|
|
44448
|
+
order: `function() {
|
|
44845
44449
|
const { feature_type } = feature;
|
|
44846
44450
|
|
|
44847
|
-
switch
|
|
44451
|
+
switch(feature_type) {
|
|
44452
|
+
case '900150':
|
|
44453
|
+
case '900130':
|
|
44848
44454
|
case '509998': {
|
|
44849
|
-
return
|
|
44455
|
+
return 300;
|
|
44456
|
+
}
|
|
44457
|
+
|
|
44458
|
+
default: {
|
|
44459
|
+
return 299;
|
|
44460
|
+
}
|
|
44461
|
+
}
|
|
44462
|
+
}`,
|
|
44463
|
+
},
|
|
44464
|
+
},
|
|
44465
|
+
};
|
|
44466
|
+
const labelLayer = {
|
|
44467
|
+
id: uuid(),
|
|
44468
|
+
data: {
|
|
44469
|
+
source,
|
|
44470
|
+
layer: '"MapLanduseAreaLabel"',
|
|
44471
|
+
},
|
|
44472
|
+
filter: `function() {
|
|
44473
|
+
return $zoom >= 15;
|
|
44474
|
+
}`,
|
|
44475
|
+
draw: {
|
|
44476
|
+
text: {
|
|
44477
|
+
text_source: 'name',
|
|
44478
|
+
font: {
|
|
44479
|
+
size: '13px',
|
|
44480
|
+
fill: `function() {
|
|
44481
|
+
const { feature_type } = feature;
|
|
44482
|
+
|
|
44483
|
+
switch(feature_type) {
|
|
44484
|
+
case '509998': {
|
|
44485
|
+
return '#CD7F32';
|
|
44486
|
+
}
|
|
44487
|
+
|
|
44488
|
+
default: {
|
|
44489
|
+
return '#00541F';
|
|
44490
|
+
}
|
|
44850
44491
|
}
|
|
44492
|
+
}`,
|
|
44493
|
+
stroke: { color: 'white', width: '3px' },
|
|
44494
|
+
},
|
|
44495
|
+
},
|
|
44496
|
+
},
|
|
44497
|
+
};
|
|
44498
|
+
layers.push(geometryLayer, labelLayer);
|
|
44499
|
+
return layers;
|
|
44500
|
+
};
|
|
44501
|
+
|
|
44502
|
+
const getBuildingLayers = (source) => {
|
|
44503
|
+
const layers = [];
|
|
44504
|
+
const data = {
|
|
44505
|
+
source,
|
|
44506
|
+
layer: '"MapBuildingECArea"',
|
|
44507
|
+
minzoom: 15,
|
|
44508
|
+
};
|
|
44509
|
+
const layer = {
|
|
44510
|
+
id: uuid(),
|
|
44511
|
+
data,
|
|
44512
|
+
extruded: {
|
|
44513
|
+
draw: {
|
|
44514
|
+
polygons: {
|
|
44515
|
+
interactive: true,
|
|
44516
|
+
style: 'buildings',
|
|
44517
|
+
extrude: `function() {
|
|
44518
|
+
return $zoom >= 17;
|
|
44519
|
+
}`,
|
|
44520
|
+
},
|
|
44521
|
+
},
|
|
44522
|
+
},
|
|
44523
|
+
draw: {
|
|
44524
|
+
polygons: {
|
|
44525
|
+
color: '#DDB07B',
|
|
44526
|
+
height: { property: 'height' },
|
|
44527
|
+
},
|
|
44528
|
+
lines: {
|
|
44529
|
+
color: '#DB933F',
|
|
44530
|
+
width: '2px',
|
|
44531
|
+
cap: 'round',
|
|
44532
|
+
join: 'round',
|
|
44533
|
+
},
|
|
44534
|
+
},
|
|
44535
|
+
};
|
|
44536
|
+
layers.push(layer);
|
|
44537
|
+
return layers;
|
|
44538
|
+
};
|
|
44539
|
+
|
|
44540
|
+
const getFacilityAreaLayers = (source) => {
|
|
44541
|
+
const layers = [];
|
|
44542
|
+
const geometryLayer = {
|
|
44543
|
+
id: uuid(),
|
|
44544
|
+
data: {
|
|
44545
|
+
source,
|
|
44546
|
+
layer: '"MapFacilityArea"',
|
|
44547
|
+
},
|
|
44548
|
+
draw: {
|
|
44549
|
+
polygons: {
|
|
44550
|
+
color: `function() {
|
|
44551
|
+
const { feature_type } = feature;
|
|
44552
|
+
|
|
44553
|
+
switch (feature_type) {
|
|
44554
|
+
case '2000408': {
|
|
44555
|
+
return '#DBBAC4';
|
|
44556
|
+
}
|
|
44557
|
+
|
|
44558
|
+
case '1900403': {
|
|
44559
|
+
return '#B6C3C7';
|
|
44560
|
+
}
|
|
44561
|
+
|
|
44562
|
+
case '1907403': {
|
|
44563
|
+
return '#A3B9C0';
|
|
44564
|
+
}
|
|
44565
|
+
|
|
44566
|
+
case '2000123': {
|
|
44567
|
+
return '#E4BA7D';
|
|
44568
|
+
}
|
|
44569
|
+
|
|
44570
|
+
case '2000124': {
|
|
44571
|
+
return '#BFE6E3';
|
|
44572
|
+
}
|
|
44573
|
+
|
|
44574
|
+
case '2000200': {
|
|
44575
|
+
return '#A0A9A8';
|
|
44576
|
+
}
|
|
44577
|
+
|
|
44578
|
+
case '2000403': {
|
|
44579
|
+
return '#AF7136';
|
|
44580
|
+
}
|
|
44581
|
+
|
|
44582
|
+
case '2000420': {
|
|
44583
|
+
return '#89AC76';
|
|
44584
|
+
}
|
|
44585
|
+
|
|
44586
|
+
case '2000457': {
|
|
44587
|
+
return '#9494C0';
|
|
44588
|
+
}
|
|
44589
|
+
|
|
44590
|
+
default: {
|
|
44591
|
+
return '#E1D4D4';
|
|
44592
|
+
}
|
|
44593
|
+
}
|
|
44594
|
+
}`,
|
|
44595
|
+
order: `function() {
|
|
44596
|
+
const { feature_type } = feature;
|
|
44597
|
+
|
|
44598
|
+
switch (feature_type) {
|
|
44599
|
+
case '1907403': {
|
|
44600
|
+
return 301;
|
|
44601
|
+
}
|
|
44602
|
+
|
|
44603
|
+
default: {
|
|
44604
|
+
return 300;
|
|
44605
|
+
}
|
|
44606
|
+
}
|
|
44607
|
+
}`,
|
|
44608
|
+
},
|
|
44609
|
+
lines: {
|
|
44610
|
+
color: '#857F7F',
|
|
44611
|
+
width: '2px',
|
|
44612
|
+
cap: 'round',
|
|
44613
|
+
join: 'round',
|
|
44614
|
+
},
|
|
44615
|
+
},
|
|
44616
|
+
};
|
|
44617
|
+
const labelLayer = {
|
|
44618
|
+
id: uuid(),
|
|
44619
|
+
data: {
|
|
44620
|
+
source,
|
|
44621
|
+
layer: '"MapFacilityAreaLabel"',
|
|
44622
|
+
},
|
|
44623
|
+
draw: {
|
|
44624
|
+
text: {
|
|
44625
|
+
text_source: 'name',
|
|
44626
|
+
font: {
|
|
44627
|
+
fill: `function() {
|
|
44628
|
+
const { feature_type } = feature;
|
|
44629
|
+
|
|
44630
|
+
switch(feature_type) {
|
|
44631
|
+
case '1900403':
|
|
44632
|
+
case '1907403': {
|
|
44633
|
+
return '#256D7B';
|
|
44634
|
+
}
|
|
44635
|
+
|
|
44636
|
+
case '2000420':
|
|
44637
|
+
case '2000460':
|
|
44638
|
+
case '2000123': {
|
|
44639
|
+
return '#00541F';
|
|
44640
|
+
}
|
|
44851
44641
|
|
|
44852
|
-
|
|
44853
|
-
|
|
44854
|
-
|
|
44855
|
-
}
|
|
44642
|
+
case '2000408': {
|
|
44643
|
+
return '#5E2129';
|
|
44644
|
+
}
|
|
44856
44645
|
|
|
44857
|
-
|
|
44858
|
-
|
|
44859
|
-
|
|
44860
|
-
case '900103': {
|
|
44861
|
-
return '#96BE7D';
|
|
44862
|
-
}
|
|
44646
|
+
case '2000124': {
|
|
44647
|
+
return '#3E5F8A';
|
|
44648
|
+
}
|
|
44863
44649
|
|
|
44864
|
-
|
|
44865
|
-
|
|
44866
|
-
}
|
|
44650
|
+
case '2000200': {
|
|
44651
|
+
return '#464451';
|
|
44867
44652
|
}
|
|
44868
|
-
}`,
|
|
44869
|
-
order: `function() {
|
|
44870
|
-
const { feature_type } = feature;
|
|
44871
44653
|
|
|
44872
|
-
|
|
44873
|
-
|
|
44874
|
-
|
|
44875
|
-
case '509998': {
|
|
44876
|
-
return 300;
|
|
44877
|
-
}
|
|
44654
|
+
case '2000403': {
|
|
44655
|
+
return '#B03F35';
|
|
44656
|
+
}
|
|
44878
44657
|
|
|
44879
|
-
|
|
44880
|
-
|
|
44881
|
-
}
|
|
44658
|
+
case '2000457': {
|
|
44659
|
+
return '#6A5ACD';
|
|
44882
44660
|
}
|
|
44883
|
-
}`,
|
|
44884
|
-
},
|
|
44885
|
-
},
|
|
44886
|
-
};
|
|
44887
|
-
const labelLayer = {
|
|
44888
|
-
id: uuid(),
|
|
44889
|
-
data: {
|
|
44890
|
-
source,
|
|
44891
|
-
layer: '"MapLanduseAreaLabel"',
|
|
44892
|
-
},
|
|
44893
|
-
filter: `function() {
|
|
44894
|
-
return $zoom >= 15;
|
|
44895
|
-
}`,
|
|
44896
|
-
draw: {
|
|
44897
|
-
text: {
|
|
44898
|
-
text_source: 'name',
|
|
44899
|
-
font: {
|
|
44900
|
-
size: '13px',
|
|
44901
|
-
fill: `function() {
|
|
44902
|
-
const { feature_type } = feature;
|
|
44903
44661
|
|
|
44904
|
-
|
|
44905
|
-
|
|
44906
|
-
|
|
44907
|
-
|
|
44662
|
+
case '1700215':
|
|
44663
|
+
case '900159':
|
|
44664
|
+
case '900158': {
|
|
44665
|
+
return '#474A51';
|
|
44666
|
+
}
|
|
44908
44667
|
|
|
44909
|
-
|
|
44910
|
-
|
|
44911
|
-
|
|
44912
|
-
|
|
44913
|
-
|
|
44914
|
-
|
|
44915
|
-
|
|
44668
|
+
default: {
|
|
44669
|
+
return black;
|
|
44670
|
+
}
|
|
44671
|
+
}
|
|
44672
|
+
}`,
|
|
44673
|
+
size: '12px',
|
|
44674
|
+
stroke: {
|
|
44675
|
+
color: 'white',
|
|
44676
|
+
width: '3px',
|
|
44916
44677
|
},
|
|
44917
44678
|
},
|
|
44918
|
-
}
|
|
44919
|
-
|
|
44920
|
-
|
|
44921
|
-
|
|
44679
|
+
},
|
|
44680
|
+
},
|
|
44681
|
+
};
|
|
44682
|
+
layers.push(geometryLayer, labelLayer);
|
|
44922
44683
|
return layers;
|
|
44923
44684
|
};
|
|
44924
44685
|
|
|
44925
|
-
const
|
|
44686
|
+
const adminAreaLayerName = '"MapAdminArea"';
|
|
44687
|
+
|
|
44688
|
+
const getAdminAreaLayers = (source) => {
|
|
44926
44689
|
const layers = [];
|
|
44927
44690
|
const data = {
|
|
44928
44691
|
source,
|
|
44929
|
-
layer:
|
|
44930
|
-
minzoom: 15,
|
|
44692
|
+
layer: adminAreaLayerName,
|
|
44931
44693
|
};
|
|
44932
44694
|
const layer = {
|
|
44933
44695
|
id: uuid(),
|
|
44934
44696
|
data,
|
|
44935
|
-
|
|
44936
|
-
|
|
44937
|
-
|
|
44938
|
-
interactive: true,
|
|
44939
|
-
style: 'buildings',
|
|
44940
|
-
extrude: `function() {
|
|
44941
|
-
return $zoom >= 17;
|
|
44942
|
-
}`,
|
|
44943
|
-
},
|
|
44697
|
+
draw: {
|
|
44698
|
+
polygons: {
|
|
44699
|
+
color: '#D3D2CF',
|
|
44944
44700
|
},
|
|
44945
44701
|
},
|
|
44702
|
+
};
|
|
44703
|
+
const borderRegionLayer = {
|
|
44704
|
+
id: uuid(),
|
|
44705
|
+
data,
|
|
44706
|
+
filter: `function() {
|
|
44707
|
+
const { type } = feature;
|
|
44708
|
+
|
|
44709
|
+
const isFilter = type === 'R';
|
|
44710
|
+
|
|
44711
|
+
return isFilter;
|
|
44712
|
+
}`,
|
|
44946
44713
|
draw: {
|
|
44947
|
-
|
|
44948
|
-
color: '#
|
|
44949
|
-
|
|
44714
|
+
lines: {
|
|
44715
|
+
color: '#696969',
|
|
44716
|
+
width: '1px',
|
|
44717
|
+
cap: 'round',
|
|
44718
|
+
join: 'round',
|
|
44950
44719
|
},
|
|
44720
|
+
},
|
|
44721
|
+
};
|
|
44722
|
+
const borderDistrictLayer = {
|
|
44723
|
+
id: uuid(),
|
|
44724
|
+
data,
|
|
44725
|
+
filter: `function() {
|
|
44726
|
+
const { type } = feature;
|
|
44727
|
+
|
|
44728
|
+
const isFilter = type === 'D' && $zoom >= 12;
|
|
44729
|
+
|
|
44730
|
+
return isFilter;
|
|
44731
|
+
}`,
|
|
44732
|
+
draw: {
|
|
44951
44733
|
lines: {
|
|
44952
|
-
color: '#
|
|
44953
|
-
|
|
44734
|
+
color: '#696969',
|
|
44735
|
+
dash: [4, 7],
|
|
44736
|
+
width: '1px',
|
|
44954
44737
|
cap: 'round',
|
|
44955
44738
|
join: 'round',
|
|
44956
44739
|
},
|
|
44957
44740
|
},
|
|
44958
44741
|
};
|
|
44959
|
-
layers.push(layer);
|
|
44742
|
+
layers.push(layer, borderRegionLayer, borderDistrictLayer);
|
|
44960
44743
|
return layers;
|
|
44961
44744
|
};
|
|
44962
44745
|
|
|
44963
|
-
const
|
|
44746
|
+
const getNatureFieldLayers = () => {
|
|
44964
44747
|
const layers = [];
|
|
44965
|
-
const
|
|
44748
|
+
const data = {
|
|
44749
|
+
source: exports.TangramSourceNames.NATURE_TILE,
|
|
44750
|
+
layer: '"MapNatureField"',
|
|
44751
|
+
};
|
|
44752
|
+
const layer = {
|
|
44966
44753
|
id: uuid(),
|
|
44967
|
-
data
|
|
44968
|
-
source,
|
|
44969
|
-
layer: '"MapFacilityArea"',
|
|
44970
|
-
},
|
|
44754
|
+
data,
|
|
44971
44755
|
draw: {
|
|
44972
44756
|
polygons: {
|
|
44973
|
-
|
|
44974
|
-
|
|
44757
|
+
interactive: true,
|
|
44758
|
+
color: '#EBEEC7',
|
|
44759
|
+
},
|
|
44760
|
+
},
|
|
44761
|
+
};
|
|
44762
|
+
layers.push(layer);
|
|
44763
|
+
return layers;
|
|
44764
|
+
};
|
|
44975
44765
|
|
|
44976
|
-
|
|
44977
|
-
|
|
44978
|
-
|
|
44979
|
-
|
|
44766
|
+
const linkLayerName = '"Link"';
|
|
44767
|
+
const zLvlOrders = [
|
|
44768
|
+
'-1.0',
|
|
44769
|
+
'-0.5',
|
|
44770
|
+
'-0.3',
|
|
44771
|
+
'0.0',
|
|
44772
|
+
'0.3',
|
|
44773
|
+
'0.5',
|
|
44774
|
+
'0.7',
|
|
44775
|
+
'1.0',
|
|
44776
|
+
'1.5',
|
|
44777
|
+
'2.0',
|
|
44778
|
+
];
|
|
44779
|
+
const functionInterval = [[5], [3, 4], [1, 2]];
|
|
44780
|
+
const colorFunction = `function() {
|
|
44781
|
+
const { functional_class, tunnel, tollway } = feature;
|
|
44980
44782
|
|
|
44981
|
-
|
|
44982
|
-
return '#B6C3C7';
|
|
44983
|
-
}
|
|
44783
|
+
const alpha = tunnel ? 0.89 : 1;
|
|
44984
44784
|
|
|
44985
|
-
|
|
44986
|
-
|
|
44987
|
-
|
|
44785
|
+
const getRGB = (hex, alpha) => {
|
|
44786
|
+
const r = +(parseInt(hex.slice(1, 3), 16) / 255).toFixed(2);
|
|
44787
|
+
const g = +(parseInt(hex.slice(3, 5), 16) / 255).toFixed(2);
|
|
44788
|
+
const b = +(parseInt(hex.slice(5, 7), 16) / 255).toFixed(2);
|
|
44988
44789
|
|
|
44989
|
-
|
|
44990
|
-
|
|
44991
|
-
|
|
44790
|
+
return [r, g, b, alpha];
|
|
44791
|
+
}
|
|
44792
|
+
|
|
44793
|
+
if (tollway) {
|
|
44794
|
+
return '#D72740';
|
|
44795
|
+
}
|
|
44796
|
+
|
|
44797
|
+
switch (functional_class) {
|
|
44798
|
+
case 1:
|
|
44799
|
+
case 2: {
|
|
44800
|
+
const color = getRGB('#D1747F', alpha);
|
|
44801
|
+
|
|
44802
|
+
return color;
|
|
44803
|
+
}
|
|
44804
|
+
|
|
44805
|
+
case 3:
|
|
44806
|
+
case 4: {
|
|
44807
|
+
const color = getRGB('#B1A7AA', alpha);
|
|
44808
|
+
|
|
44809
|
+
return color;
|
|
44810
|
+
}
|
|
44811
|
+
|
|
44812
|
+
case 5: {
|
|
44813
|
+
const color = getRGB('#D5CEC3', alpha);
|
|
44814
|
+
|
|
44815
|
+
return color;
|
|
44816
|
+
}
|
|
44817
|
+
}
|
|
44818
|
+
}`;
|
|
44819
|
+
const widthFunction = `function() {
|
|
44820
|
+
const { functional_class, road_number } = feature;
|
|
44821
|
+
|
|
44822
|
+
const getScale = () => {
|
|
44823
|
+
if ($zoom <= 15 && $zoom >= 14) { return 7; }
|
|
44824
|
+
|
|
44825
|
+
if ($zoom <= 13 && $zoom >= 12) { return 9; }
|
|
44826
|
+
|
|
44827
|
+
if ($zoom <= 5) { return 400; }
|
|
44828
|
+
|
|
44829
|
+
if ($zoom <= 7) { return 200; }
|
|
44830
|
+
|
|
44831
|
+
if ($zoom < 12) { return 50; }
|
|
44832
|
+
|
|
44833
|
+
return 1;
|
|
44834
|
+
}
|
|
44835
|
+
|
|
44836
|
+
const scale = getScale();
|
|
44837
|
+
|
|
44838
|
+
switch(functional_class) {
|
|
44839
|
+
case 1:
|
|
44840
|
+
case 2: {
|
|
44841
|
+
return 8 * scale;
|
|
44842
|
+
}
|
|
44843
|
+
|
|
44844
|
+
case 3:
|
|
44845
|
+
case 4: {
|
|
44846
|
+
return 7 * scale;
|
|
44847
|
+
}
|
|
44848
|
+
|
|
44849
|
+
case 5: {
|
|
44850
|
+
if (Boolean(road_number)) {
|
|
44851
|
+
return 7 * scale;
|
|
44852
|
+
}
|
|
44992
44853
|
|
|
44993
|
-
|
|
44994
|
-
|
|
44995
|
-
|
|
44854
|
+
return 6;
|
|
44855
|
+
}
|
|
44856
|
+
}
|
|
44857
|
+
}`;
|
|
44858
|
+
const outlineColorFunction = `function() {
|
|
44859
|
+
const { functional_class, access_id, tollway } = feature;
|
|
44996
44860
|
|
|
44997
|
-
|
|
44998
|
-
|
|
44999
|
-
|
|
44861
|
+
if (tollway) {
|
|
44862
|
+
return '#B9263B';
|
|
44863
|
+
}
|
|
45000
44864
|
|
|
45001
|
-
|
|
45002
|
-
|
|
45003
|
-
|
|
44865
|
+
switch(functional_class) {
|
|
44866
|
+
case 5: {
|
|
44867
|
+
return '#989898';
|
|
44868
|
+
}
|
|
45004
44869
|
|
|
45005
|
-
|
|
45006
|
-
|
|
45007
|
-
|
|
44870
|
+
case 3:
|
|
44871
|
+
case 4: {
|
|
44872
|
+
return '#8F6E78';
|
|
44873
|
+
}
|
|
45008
44874
|
|
|
45009
|
-
|
|
45010
|
-
|
|
45011
|
-
|
|
44875
|
+
case 1:
|
|
44876
|
+
case 2: {
|
|
44877
|
+
return '#9A414B';
|
|
44878
|
+
}
|
|
44879
|
+
}
|
|
44880
|
+
}`;
|
|
44881
|
+
const outlineWidthFunction = `function() {
|
|
44882
|
+
const { functional_class, access_id } = feature;
|
|
45012
44883
|
|
|
45013
|
-
|
|
45014
|
-
|
|
45015
|
-
|
|
45016
|
-
|
|
45017
|
-
|
|
45018
|
-
|
|
45019
|
-
const { feature_type } = feature;
|
|
44884
|
+
switch(functional_class) {
|
|
44885
|
+
case 5: {
|
|
44886
|
+
switch (access_id) {
|
|
44887
|
+
case 32: {
|
|
44888
|
+
return 0;
|
|
44889
|
+
}
|
|
45020
44890
|
|
|
45021
|
-
|
|
45022
|
-
|
|
45023
|
-
|
|
45024
|
-
|
|
44891
|
+
default: {
|
|
44892
|
+
return 1;
|
|
44893
|
+
}
|
|
44894
|
+
}
|
|
44895
|
+
}
|
|
45025
44896
|
|
|
45026
|
-
|
|
45027
|
-
|
|
45028
|
-
|
|
45029
|
-
|
|
45030
|
-
|
|
45031
|
-
|
|
45032
|
-
|
|
45033
|
-
|
|
45034
|
-
|
|
45035
|
-
|
|
45036
|
-
|
|
45037
|
-
},
|
|
45038
|
-
},
|
|
44897
|
+
default: {
|
|
44898
|
+
return 1;
|
|
44899
|
+
}
|
|
44900
|
+
}
|
|
44901
|
+
}`;
|
|
44902
|
+
|
|
44903
|
+
const getLinkLayers = (source) => {
|
|
44904
|
+
const layers = [];
|
|
44905
|
+
const data = {
|
|
44906
|
+
source,
|
|
44907
|
+
layer: linkLayerName,
|
|
45039
44908
|
};
|
|
45040
|
-
const
|
|
44909
|
+
const roadNumberLayer = {
|
|
45041
44910
|
id: uuid(),
|
|
45042
|
-
data
|
|
45043
|
-
source,
|
|
45044
|
-
layer: '"MapFacilityAreaLabel"',
|
|
45045
|
-
},
|
|
44911
|
+
data,
|
|
45046
44912
|
draw: {
|
|
45047
44913
|
text: {
|
|
45048
|
-
text_source: '
|
|
44914
|
+
text_source: 'road_number',
|
|
45049
44915
|
font: {
|
|
45050
|
-
fill:
|
|
45051
|
-
|
|
45052
|
-
|
|
45053
|
-
|
|
45054
|
-
|
|
45055
|
-
|
|
45056
|
-
|
|
45057
|
-
|
|
45058
|
-
|
|
45059
|
-
|
|
45060
|
-
|
|
45061
|
-
|
|
45062
|
-
|
|
45063
|
-
|
|
45064
|
-
|
|
45065
|
-
|
|
45066
|
-
|
|
45067
|
-
|
|
44916
|
+
fill: '#181bff',
|
|
44917
|
+
size: '16px',
|
|
44918
|
+
weight: 'bold',
|
|
44919
|
+
underline: true,
|
|
44920
|
+
background: {
|
|
44921
|
+
color: 'black',
|
|
44922
|
+
},
|
|
44923
|
+
},
|
|
44924
|
+
},
|
|
44925
|
+
},
|
|
44926
|
+
};
|
|
44927
|
+
layers.push(roadNumberLayer);
|
|
44928
|
+
const text = {
|
|
44929
|
+
text_source: 'street_name',
|
|
44930
|
+
font: {
|
|
44931
|
+
fill: 'black',
|
|
44932
|
+
size: '14px',
|
|
44933
|
+
stroke: { color: 'white', width: '3px' },
|
|
44934
|
+
},
|
|
44935
|
+
};
|
|
44936
|
+
zLvlOrders.forEach((zLvl) => {
|
|
44937
|
+
const filter = `function() {
|
|
44938
|
+
const { z_lvl = '0.0' } = feature;
|
|
45068
44939
|
|
|
45069
|
-
|
|
45070
|
-
return '#3E5F8A';
|
|
45071
|
-
}
|
|
44940
|
+
const isFilter = z_lvl === '${zLvl}';
|
|
45072
44941
|
|
|
45073
|
-
|
|
45074
|
-
|
|
45075
|
-
|
|
44942
|
+
return isFilter;
|
|
44943
|
+
}`;
|
|
44944
|
+
const getBaseLayerDraw = () => ({
|
|
44945
|
+
text,
|
|
44946
|
+
lines: {
|
|
44947
|
+
color: colorFunction,
|
|
44948
|
+
width: widthFunction,
|
|
44949
|
+
cap: 'round',
|
|
44950
|
+
join: 'round',
|
|
44951
|
+
},
|
|
44952
|
+
});
|
|
44953
|
+
const getBorderLayerDraw = () => ({
|
|
44954
|
+
lines: {
|
|
44955
|
+
color: colorFunction,
|
|
44956
|
+
width: widthFunction,
|
|
44957
|
+
cap: 'round',
|
|
44958
|
+
join: 'round',
|
|
44959
|
+
outline: {
|
|
44960
|
+
color: outlineColorFunction,
|
|
44961
|
+
width: outlineWidthFunction,
|
|
44962
|
+
},
|
|
44963
|
+
},
|
|
44964
|
+
});
|
|
44965
|
+
switch (zLvl) {
|
|
44966
|
+
case '0.0': {
|
|
44967
|
+
functionInterval.forEach((functionClasses) => {
|
|
44968
|
+
functionClasses.forEach((functionClass) => {
|
|
44969
|
+
const baseLayer = {
|
|
44970
|
+
id: uuid(),
|
|
44971
|
+
data,
|
|
44972
|
+
filter: `function() {
|
|
44973
|
+
const { functional_class, z_lvl = '0.0' } = feature;
|
|
45076
44974
|
|
|
45077
|
-
|
|
45078
|
-
return '#B03F35';
|
|
45079
|
-
}
|
|
44975
|
+
const isFilter = z_lvl === '${zLvl}' && functional_class === ${functionClass};
|
|
45080
44976
|
|
|
45081
|
-
|
|
45082
|
-
|
|
45083
|
-
|
|
44977
|
+
return isFilter;
|
|
44978
|
+
}`,
|
|
44979
|
+
draw: getBaseLayerDraw(),
|
|
44980
|
+
sublayers: {
|
|
44981
|
+
construction: {
|
|
44982
|
+
filter: `function() {
|
|
44983
|
+
return global.links.getIsConstruction(feature);
|
|
44984
|
+
}`,
|
|
44985
|
+
draw: {
|
|
44986
|
+
lines: {
|
|
44987
|
+
width: 3,
|
|
44988
|
+
color: '#9AA096',
|
|
44989
|
+
dash: [2, 1],
|
|
44990
|
+
},
|
|
44991
|
+
},
|
|
44992
|
+
},
|
|
44993
|
+
functionalClassAccessId32: {
|
|
44994
|
+
filter: `function() {
|
|
44995
|
+
return global.links.getIsFunctionalClass(feature);
|
|
44996
|
+
}`,
|
|
44997
|
+
draw: {
|
|
44998
|
+
lines: {
|
|
44999
|
+
width: 2,
|
|
45000
|
+
color: '#9AA096',
|
|
45001
|
+
dash: [2, 1],
|
|
45002
|
+
},
|
|
45003
|
+
},
|
|
45004
|
+
},
|
|
45005
|
+
lowMobility: {
|
|
45006
|
+
filter: `function() {
|
|
45007
|
+
return global.links.getIsLowMobility(feature);
|
|
45008
|
+
}`,
|
|
45009
|
+
draw: {
|
|
45010
|
+
lines: {
|
|
45011
|
+
width: 4,
|
|
45012
|
+
},
|
|
45013
|
+
},
|
|
45014
|
+
},
|
|
45015
|
+
},
|
|
45016
|
+
};
|
|
45017
|
+
const borderLayer = {
|
|
45018
|
+
id: uuid(),
|
|
45019
|
+
data,
|
|
45020
|
+
filter: `function() {
|
|
45021
|
+
const { functional_class, z_lvl = '0.0' } = feature;
|
|
45084
45022
|
|
|
45085
|
-
|
|
45086
|
-
case '900159':
|
|
45087
|
-
case '900158': {
|
|
45088
|
-
return '#474A51';
|
|
45089
|
-
}
|
|
45023
|
+
const isFilter = z_lvl === '${zLvl}' && functional_class === ${functionClass} && !global.links.getIsConstruction(feature) && !global.links.getIsFunctionalClass(feature);
|
|
45090
45024
|
|
|
45091
|
-
|
|
45092
|
-
|
|
45093
|
-
|
|
45025
|
+
return isFilter;
|
|
45026
|
+
}`,
|
|
45027
|
+
draw: getBorderLayerDraw(),
|
|
45028
|
+
sublayers: {
|
|
45029
|
+
lowMobility: {
|
|
45030
|
+
filter: `function() {
|
|
45031
|
+
return global.links.getIsLowMobility(feature);
|
|
45032
|
+
}`,
|
|
45033
|
+
draw: {
|
|
45034
|
+
lines: {
|
|
45035
|
+
width: 4,
|
|
45036
|
+
},
|
|
45037
|
+
},
|
|
45038
|
+
},
|
|
45039
|
+
},
|
|
45040
|
+
};
|
|
45041
|
+
layers.push(baseLayer, borderLayer);
|
|
45042
|
+
});
|
|
45043
|
+
});
|
|
45044
|
+
break;
|
|
45094
45045
|
}
|
|
45095
|
-
|
|
45096
|
-
|
|
45097
|
-
|
|
45098
|
-
|
|
45099
|
-
|
|
45100
|
-
|
|
45101
|
-
}
|
|
45102
|
-
|
|
45103
|
-
|
|
45104
|
-
|
|
45105
|
-
|
|
45046
|
+
default: {
|
|
45047
|
+
const baseLayer = {
|
|
45048
|
+
id: uuid(),
|
|
45049
|
+
data,
|
|
45050
|
+
filter,
|
|
45051
|
+
draw: getBaseLayerDraw(),
|
|
45052
|
+
};
|
|
45053
|
+
const borderLayer = {
|
|
45054
|
+
id: uuid(),
|
|
45055
|
+
data,
|
|
45056
|
+
filter,
|
|
45057
|
+
draw: getBorderLayerDraw(),
|
|
45058
|
+
};
|
|
45059
|
+
layers.push(baseLayer, borderLayer);
|
|
45060
|
+
}
|
|
45061
|
+
}
|
|
45062
|
+
});
|
|
45106
45063
|
return layers;
|
|
45107
45064
|
};
|
|
45108
45065
|
|
|
45109
|
-
const
|
|
45110
|
-
|
|
45111
|
-
const getAdminAreaLayers = (source) => {
|
|
45066
|
+
const getNatureForestLayers = () => {
|
|
45112
45067
|
const layers = [];
|
|
45113
45068
|
const data = {
|
|
45114
|
-
source,
|
|
45115
|
-
layer:
|
|
45069
|
+
source: exports.TangramSourceNames.NATURE_TILE,
|
|
45070
|
+
layer: '"MapNatureForest"',
|
|
45116
45071
|
};
|
|
45117
45072
|
const layer = {
|
|
45118
45073
|
id: uuid(),
|
|
45119
45074
|
data,
|
|
45120
45075
|
draw: {
|
|
45121
45076
|
polygons: {
|
|
45122
|
-
|
|
45123
|
-
|
|
45124
|
-
|
|
45125
|
-
};
|
|
45126
|
-
const borderRegionLayer = {
|
|
45127
|
-
id: uuid(),
|
|
45128
|
-
data,
|
|
45129
|
-
filter: `function() {
|
|
45130
|
-
const { type } = feature;
|
|
45131
|
-
|
|
45132
|
-
const isFilter = type === 'R';
|
|
45133
|
-
|
|
45134
|
-
return isFilter;
|
|
45135
|
-
}`,
|
|
45136
|
-
draw: {
|
|
45137
|
-
lines: {
|
|
45138
|
-
color: '#696969',
|
|
45139
|
-
width: '1px',
|
|
45140
|
-
cap: 'round',
|
|
45141
|
-
join: 'round',
|
|
45142
|
-
},
|
|
45143
|
-
},
|
|
45144
|
-
};
|
|
45145
|
-
const borderDistrictLayer = {
|
|
45146
|
-
id: uuid(),
|
|
45147
|
-
data,
|
|
45148
|
-
filter: `function() {
|
|
45149
|
-
const { type } = feature;
|
|
45077
|
+
interactive: true,
|
|
45078
|
+
color: `function() {
|
|
45079
|
+
const { feature_type } = feature;
|
|
45150
45080
|
|
|
45151
|
-
|
|
45081
|
+
switch (feature_type) {
|
|
45082
|
+
case '900202': {
|
|
45083
|
+
return '#96BE7D';
|
|
45084
|
+
}
|
|
45152
45085
|
|
|
45153
|
-
|
|
45154
|
-
|
|
45155
|
-
|
|
45156
|
-
|
|
45157
|
-
|
|
45158
|
-
dash: [4, 7],
|
|
45159
|
-
width: '1px',
|
|
45160
|
-
cap: 'round',
|
|
45161
|
-
join: 'round',
|
|
45086
|
+
default : {
|
|
45087
|
+
return null;
|
|
45088
|
+
}
|
|
45089
|
+
}
|
|
45090
|
+
}`,
|
|
45162
45091
|
},
|
|
45163
45092
|
},
|
|
45164
45093
|
};
|
|
45165
|
-
layers.push(layer
|
|
45094
|
+
layers.push(layer);
|
|
45166
45095
|
return layers;
|
|
45167
45096
|
};
|
|
45168
45097
|
|
|
45169
|
-
const
|
|
45170
|
-
const
|
|
45171
|
-
|
|
45172
|
-
data: {
|
|
45173
|
-
source,
|
|
45174
|
-
layer: '"MapNatureField"',
|
|
45175
|
-
},
|
|
45176
|
-
draw: {
|
|
45177
|
-
polygons: {
|
|
45178
|
-
interactive: true,
|
|
45179
|
-
color: '#EBEEC7',
|
|
45180
|
-
},
|
|
45181
|
-
},
|
|
45182
|
-
};
|
|
45183
|
-
return [layer];
|
|
45098
|
+
const getLayerName = ({ id, data: { source, layer }, }) => {
|
|
45099
|
+
const layerName = `${id}-${source}-${layer}`;
|
|
45100
|
+
return layerName;
|
|
45184
45101
|
};
|
|
45185
|
-
|
|
45186
|
-
const
|
|
45187
|
-
const
|
|
45188
|
-
|
|
45189
|
-
|
|
45190
|
-
|
|
45191
|
-
|
|
45192
|
-
|
|
45193
|
-
|
|
45194
|
-
|
|
45195
|
-
|
|
45196
|
-
|
|
45197
|
-
|
|
45198
|
-
|
|
45199
|
-
|
|
45200
|
-
|
|
45201
|
-
|
|
45202
|
-
|
|
45203
|
-
|
|
45204
|
-
|
|
45205
|
-
|
|
45206
|
-
|
|
45207
|
-
|
|
45208
|
-
|
|
45209
|
-
|
|
45210
|
-
|
|
45211
|
-
|
|
45212
|
-
|
|
45213
|
-
|
|
45214
|
-
|
|
45215
|
-
|
|
45216
|
-
|
|
45217
|
-
|
|
45218
|
-
|
|
45219
|
-
|
|
45220
|
-
|
|
45221
|
-
|
|
45222
|
-
|
|
45223
|
-
|
|
45224
|
-
|
|
45225
|
-
case 3:
|
|
45226
|
-
case 4: {
|
|
45227
|
-
const color = getRGB('#B1A7AA', alpha);
|
|
45228
|
-
|
|
45229
|
-
return color;
|
|
45230
|
-
}
|
|
45231
|
-
|
|
45232
|
-
case 5: {
|
|
45233
|
-
const color = getRGB('#D5CEC3', alpha);
|
|
45234
|
-
|
|
45235
|
-
return color;
|
|
45236
|
-
}
|
|
45237
|
-
}
|
|
45238
|
-
}`;
|
|
45239
|
-
const widthFunction = `function() {
|
|
45240
|
-
const { functional_class, road_number } = feature;
|
|
45241
|
-
|
|
45242
|
-
const getScale = () => {
|
|
45243
|
-
if ($zoom <= 15 && $zoom >= 14) { return 7; }
|
|
45244
|
-
|
|
45245
|
-
if ($zoom <= 13 && $zoom >= 12) { return 9; }
|
|
45246
|
-
|
|
45247
|
-
if ($zoom <= 5) { return 400; }
|
|
45248
|
-
|
|
45249
|
-
if ($zoom <= 7) { return 200; }
|
|
45250
|
-
|
|
45251
|
-
if ($zoom < 12) { return 50; }
|
|
45252
|
-
|
|
45253
|
-
return 1;
|
|
45254
|
-
}
|
|
45255
|
-
|
|
45256
|
-
const scale = getScale();
|
|
45257
|
-
|
|
45258
|
-
switch(functional_class) {
|
|
45259
|
-
case 1:
|
|
45260
|
-
case 2: {
|
|
45261
|
-
return 8 * scale;
|
|
45262
|
-
}
|
|
45263
|
-
|
|
45264
|
-
case 3:
|
|
45265
|
-
case 4: {
|
|
45266
|
-
return 7 * scale;
|
|
45267
|
-
}
|
|
45268
|
-
|
|
45269
|
-
case 5: {
|
|
45270
|
-
if (Boolean(road_number)) {
|
|
45271
|
-
return 7 * scale;
|
|
45272
|
-
}
|
|
45273
|
-
|
|
45274
|
-
return 6;
|
|
45275
|
-
}
|
|
45276
|
-
}
|
|
45277
|
-
}`;
|
|
45278
|
-
const outlineColorFunction = `function() {
|
|
45279
|
-
const { functional_class, access_id, tollway } = feature;
|
|
45280
|
-
|
|
45281
|
-
if (tollway) {
|
|
45282
|
-
return '#B9263B';
|
|
45283
|
-
}
|
|
45284
|
-
|
|
45285
|
-
switch(functional_class) {
|
|
45286
|
-
case 5: {
|
|
45287
|
-
return '#989898';
|
|
45102
|
+
const setLayerOrder = ({ layer, order, }) => {
|
|
45103
|
+
const cloneLayer = structuredClone(layer);
|
|
45104
|
+
const { draw, sublayers } = cloneLayer;
|
|
45105
|
+
if (draw) {
|
|
45106
|
+
const { points, lines, polygons, text, styles } = draw;
|
|
45107
|
+
if (points) {
|
|
45108
|
+
draw.points = {
|
|
45109
|
+
...structuredClone(points),
|
|
45110
|
+
order,
|
|
45111
|
+
};
|
|
45112
|
+
}
|
|
45113
|
+
if (lines) {
|
|
45114
|
+
draw.lines = {
|
|
45115
|
+
...structuredClone(lines),
|
|
45116
|
+
order,
|
|
45117
|
+
};
|
|
45118
|
+
}
|
|
45119
|
+
if (polygons) {
|
|
45120
|
+
draw.polygons = {
|
|
45121
|
+
...structuredClone(polygons),
|
|
45122
|
+
order,
|
|
45123
|
+
};
|
|
45124
|
+
}
|
|
45125
|
+
if (text) {
|
|
45126
|
+
draw.text = {
|
|
45127
|
+
...structuredClone(text),
|
|
45128
|
+
order,
|
|
45129
|
+
};
|
|
45130
|
+
}
|
|
45131
|
+
if (styles) {
|
|
45132
|
+
draw.styles = Object.entries(styles).reduce((accum, [name, style]) => ({
|
|
45133
|
+
...accum,
|
|
45134
|
+
[name]: {
|
|
45135
|
+
...structuredClone(style),
|
|
45136
|
+
order,
|
|
45137
|
+
},
|
|
45138
|
+
}), {});
|
|
45139
|
+
}
|
|
45140
|
+
cloneLayer.draw = structuredClone(draw);
|
|
45288
45141
|
}
|
|
45289
|
-
|
|
45290
|
-
|
|
45291
|
-
|
|
45292
|
-
|
|
45142
|
+
if (sublayers) {
|
|
45143
|
+
Object.entries(sublayers).forEach(([name, sublayer]) => {
|
|
45144
|
+
if (sublayer) {
|
|
45145
|
+
const { draw } = sublayer;
|
|
45146
|
+
if (draw) {
|
|
45147
|
+
const { points, lines, polygons } = draw;
|
|
45148
|
+
if (points) {
|
|
45149
|
+
points.order = order;
|
|
45150
|
+
draw.points = points;
|
|
45151
|
+
}
|
|
45152
|
+
if (lines) {
|
|
45153
|
+
lines.order = order;
|
|
45154
|
+
draw.lines = lines;
|
|
45155
|
+
}
|
|
45156
|
+
if (polygons) {
|
|
45157
|
+
polygons.order = order;
|
|
45158
|
+
draw.polygons = polygons;
|
|
45159
|
+
}
|
|
45160
|
+
sublayer.draw = structuredClone(draw);
|
|
45161
|
+
}
|
|
45162
|
+
sublayers[name] = structuredClone(sublayer);
|
|
45163
|
+
}
|
|
45164
|
+
});
|
|
45165
|
+
cloneLayer.sublayers = structuredClone(sublayers);
|
|
45293
45166
|
}
|
|
45294
|
-
|
|
45295
|
-
|
|
45296
|
-
|
|
45297
|
-
|
|
45167
|
+
return cloneLayer;
|
|
45168
|
+
};
|
|
45169
|
+
const getAllPolygonLayers = (source) => {
|
|
45170
|
+
const adminAreaLayers = getAdminAreaLayers(source);
|
|
45171
|
+
const natureFieldLayers = getNatureFieldLayers();
|
|
45172
|
+
const natureForestLayers = getNatureForestLayers();
|
|
45173
|
+
const builtupAreaLayers = getBuiltupAreaLayers(source);
|
|
45174
|
+
const facilityAreaLayers = getFacilityAreaLayers(source);
|
|
45175
|
+
const landuseAreaLayers = getLanduseAreaLayers(source);
|
|
45176
|
+
const waterAreaLayers = getWaterAreaLayers(source);
|
|
45177
|
+
const oceanAreaLayers = getOceanAreaLayers(source);
|
|
45178
|
+
const allPolygonLayers = [];
|
|
45179
|
+
switch (source) {
|
|
45180
|
+
case exports.TangramSourceNames.MSK: {
|
|
45181
|
+
allPolygonLayers.push(...adminAreaLayers, ...builtupAreaLayers, ...facilityAreaLayers, ...landuseAreaLayers, ...waterAreaLayers, ...oceanAreaLayers);
|
|
45182
|
+
break;
|
|
45183
|
+
}
|
|
45184
|
+
default: {
|
|
45185
|
+
allPolygonLayers.push(...adminAreaLayers, ...builtupAreaLayers, ...facilityAreaLayers, ...natureFieldLayers, ...natureForestLayers, ...landuseAreaLayers, ...waterAreaLayers, ...oceanAreaLayers);
|
|
45186
|
+
}
|
|
45298
45187
|
}
|
|
45299
|
-
|
|
45300
|
-
}
|
|
45301
|
-
const
|
|
45302
|
-
|
|
45303
|
-
|
|
45304
|
-
|
|
45305
|
-
|
|
45306
|
-
|
|
45307
|
-
|
|
45308
|
-
|
|
45188
|
+
return allPolygonLayers;
|
|
45189
|
+
};
|
|
45190
|
+
const getAllPolylineLayers = (source) => {
|
|
45191
|
+
const linkLayers = getLinkLayers(source);
|
|
45192
|
+
const railroadLayers = getRailroadLayers(source);
|
|
45193
|
+
const waterLinkLayers = getWaterLinkLayers(source);
|
|
45194
|
+
const oneWayLayers = getOneWayLayers(source);
|
|
45195
|
+
const conditionLayers = getConditionLayers(source);
|
|
45196
|
+
const allPolylineLayers = [
|
|
45197
|
+
...waterLinkLayers,
|
|
45198
|
+
...railroadLayers,
|
|
45199
|
+
...linkLayers,
|
|
45200
|
+
];
|
|
45201
|
+
switch (source) {
|
|
45202
|
+
case exports.TangramSourceNames.MSK: {
|
|
45203
|
+
allPolylineLayers.push(...waterLinkLayers, ...railroadLayers, ...linkLayers);
|
|
45204
|
+
break;
|
|
45309
45205
|
}
|
|
45310
|
-
|
|
45311
45206
|
default: {
|
|
45312
|
-
|
|
45207
|
+
allPolylineLayers.push(...waterLinkLayers, ...railroadLayers, ...linkLayers, ...oneWayLayers, ...conditionLayers);
|
|
45313
45208
|
}
|
|
45314
|
-
}
|
|
45315
45209
|
}
|
|
45316
|
-
|
|
45317
|
-
|
|
45318
|
-
|
|
45210
|
+
return allPolylineLayers;
|
|
45211
|
+
};
|
|
45212
|
+
const getAllPointLayers = (source) => {
|
|
45213
|
+
const POILayers = getPOILayers(source);
|
|
45214
|
+
const cityPOILayers = getCityPOILayers(source);
|
|
45215
|
+
const pointAddressLayers = getPointAddressLayers(source);
|
|
45216
|
+
const allPointLayers = [
|
|
45217
|
+
...POILayers,
|
|
45218
|
+
...pointAddressLayers,
|
|
45219
|
+
...cityPOILayers,
|
|
45220
|
+
];
|
|
45221
|
+
return allPointLayers;
|
|
45222
|
+
};
|
|
45223
|
+
const getAllLayers = (source) => {
|
|
45224
|
+
const allLayers = [];
|
|
45225
|
+
const buildingLayers = getBuildingLayers(source);
|
|
45226
|
+
const allPolygonLayers = getAllPolygonLayers(source);
|
|
45227
|
+
const allPolylineLayers = getAllPolylineLayers(source);
|
|
45228
|
+
const allPointLayers = getAllPointLayers(source);
|
|
45229
|
+
const roadPolyLayers = getRoadPolyLayers(source);
|
|
45230
|
+
const laneMarkingPolyLayers = getLaneMarkingPolyLayers(source);
|
|
45231
|
+
const laneMarkingLineLayers = getLaneMarkingLineLayers(source);
|
|
45232
|
+
const laneMarkingPointLayers = getLaneMarkingPointLayers(source);
|
|
45233
|
+
const parkingLineLayers = getParkingLineLayers(source);
|
|
45234
|
+
switch (source) {
|
|
45235
|
+
case exports.TangramSourceNames.MSK: {
|
|
45236
|
+
allLayers.push(...allPolygonLayers, ...allPolylineLayers, ...roadPolyLayers, ...laneMarkingPolyLayers, ...laneMarkingLineLayers, ...laneMarkingPointLayers, ...parkingLineLayers, ...buildingLayers, ...allPointLayers);
|
|
45237
|
+
break;
|
|
45238
|
+
}
|
|
45239
|
+
default: {
|
|
45240
|
+
allLayers.push(...allPolygonLayers, ...allPolylineLayers, ...buildingLayers, ...allPointLayers);
|
|
45241
|
+
}
|
|
45319
45242
|
}
|
|
45320
|
-
|
|
45321
|
-
}
|
|
45243
|
+
return allLayers;
|
|
45244
|
+
};
|
|
45322
45245
|
|
|
45323
|
-
const
|
|
45324
|
-
const
|
|
45325
|
-
const
|
|
45326
|
-
|
|
45327
|
-
|
|
45246
|
+
const useGetLeafletLayer = () => {
|
|
45247
|
+
const { instance: { isValidApiKey }, } = GlobalConfig;
|
|
45248
|
+
const [layer, setLayer] = React__namespace.useState(null);
|
|
45249
|
+
const [scene, setScene] = React__namespace.useState(null);
|
|
45250
|
+
const [config, setConfig] = React__namespace.useState(null);
|
|
45251
|
+
const getLeafletLayer = () => {
|
|
45252
|
+
Promise.resolve().then(function () { return tangram_min; }).then(() => {
|
|
45253
|
+
if (window.Tangram) {
|
|
45254
|
+
const leafletLayer = window.Tangram.leafletLayer({
|
|
45255
|
+
scene: sceneTiles,
|
|
45256
|
+
});
|
|
45257
|
+
const { scene } = leafletLayer;
|
|
45258
|
+
setLayer(leafletLayer);
|
|
45259
|
+
setScene(scene);
|
|
45260
|
+
}
|
|
45261
|
+
});
|
|
45328
45262
|
};
|
|
45329
|
-
const
|
|
45330
|
-
|
|
45331
|
-
|
|
45332
|
-
|
|
45333
|
-
|
|
45334
|
-
|
|
45335
|
-
|
|
45336
|
-
|
|
45337
|
-
|
|
45338
|
-
|
|
45339
|
-
|
|
45340
|
-
|
|
45341
|
-
|
|
45263
|
+
const addSource = React__namespace.useCallback((sourceConfig) => {
|
|
45264
|
+
if (!scene) {
|
|
45265
|
+
console.warn('Scene не инициализирована');
|
|
45266
|
+
return;
|
|
45267
|
+
}
|
|
45268
|
+
if (!config) {
|
|
45269
|
+
console.warn('Config не инициализирована');
|
|
45270
|
+
return;
|
|
45271
|
+
}
|
|
45272
|
+
const { name } = sourceConfig;
|
|
45273
|
+
config.sources[name] = structuredClone(sourceConfig);
|
|
45274
|
+
scene.updateConfig({ rebuild: true });
|
|
45275
|
+
return getSources();
|
|
45276
|
+
}, [scene, config]);
|
|
45277
|
+
const getSource = React__namespace.useCallback((sourceName) => {
|
|
45278
|
+
if (!config) {
|
|
45279
|
+
console.warn('Config не инициализирована');
|
|
45280
|
+
return;
|
|
45281
|
+
}
|
|
45282
|
+
return structuredClone(config.sources[sourceName]);
|
|
45283
|
+
}, [config]);
|
|
45284
|
+
const updateSource = React__namespace.useCallback((sourceName, newUrl) => {
|
|
45285
|
+
if (!scene) {
|
|
45286
|
+
console.warn('Scene не инициализирована');
|
|
45287
|
+
return;
|
|
45288
|
+
}
|
|
45289
|
+
if (!config) {
|
|
45290
|
+
console.warn('Config не инициализирована');
|
|
45291
|
+
return;
|
|
45292
|
+
}
|
|
45293
|
+
config.sources[sourceName].url = newUrl;
|
|
45294
|
+
scene.updateConfig({ rebuild: true });
|
|
45295
|
+
return getSources();
|
|
45296
|
+
}, [config, scene]);
|
|
45297
|
+
const addLayer = React__namespace.useCallback((layer) => {
|
|
45298
|
+
if (!scene) {
|
|
45299
|
+
console.warn('Scene не инициализирован');
|
|
45300
|
+
return;
|
|
45301
|
+
}
|
|
45302
|
+
if (!config) {
|
|
45303
|
+
console.warn('Config не инициализирован');
|
|
45304
|
+
return;
|
|
45305
|
+
}
|
|
45306
|
+
const order = getLayers().length + 1;
|
|
45307
|
+
const layerWithOrder = setLayerOrder({
|
|
45308
|
+
layer,
|
|
45309
|
+
order,
|
|
45310
|
+
});
|
|
45311
|
+
const layerName = getLayerName(layerWithOrder);
|
|
45312
|
+
const { sublayers = {}, draw } = layerWithOrder;
|
|
45313
|
+
if (draw) {
|
|
45314
|
+
const { styles = {} } = draw;
|
|
45315
|
+
if (styles) {
|
|
45316
|
+
layerWithOrder.draw = {
|
|
45317
|
+
...structuredClone(draw),
|
|
45318
|
+
...structuredClone(styles),
|
|
45319
|
+
};
|
|
45320
|
+
}
|
|
45321
|
+
}
|
|
45322
|
+
config.layers[layerName] = {
|
|
45323
|
+
...structuredClone(layerWithOrder),
|
|
45324
|
+
...structuredClone(sublayers),
|
|
45325
|
+
};
|
|
45326
|
+
scene.updateConfig({ rebuild: true });
|
|
45327
|
+
return getLayers();
|
|
45328
|
+
}, [config, scene]);
|
|
45329
|
+
const removeLayer = React__namespace.useCallback((layer) => {
|
|
45330
|
+
if (!scene) {
|
|
45331
|
+
console.warn('Scene не инициализирован');
|
|
45332
|
+
return;
|
|
45333
|
+
}
|
|
45334
|
+
if (!config) {
|
|
45335
|
+
console.warn('Config не инициализирован');
|
|
45336
|
+
return;
|
|
45337
|
+
}
|
|
45338
|
+
const layerName = getLayerName(layer);
|
|
45339
|
+
if (config.layers[layerName]) {
|
|
45340
|
+
delete config.layers[layerName];
|
|
45341
|
+
}
|
|
45342
|
+
scene.updateConfig({ rebuild: true });
|
|
45343
|
+
return getLayers();
|
|
45344
|
+
}, [config, scene]);
|
|
45345
|
+
const addStyle = React__namespace.useCallback(({ name, style }) => {
|
|
45346
|
+
if (!scene) {
|
|
45347
|
+
console.warn('Scene не инициализирована');
|
|
45348
|
+
return;
|
|
45349
|
+
}
|
|
45350
|
+
if (!config) {
|
|
45351
|
+
console.warn('Config не инициализирована');
|
|
45352
|
+
return;
|
|
45353
|
+
}
|
|
45354
|
+
config.styles[name] = structuredClone(style);
|
|
45355
|
+
scene.updateConfig({ rebuild: true });
|
|
45356
|
+
}, [config, scene]);
|
|
45357
|
+
const getLayerVisibility = React__namespace.useCallback((layer) => {
|
|
45358
|
+
if (!config) {
|
|
45359
|
+
console.warn('Config не инициализирована');
|
|
45360
|
+
return;
|
|
45361
|
+
}
|
|
45362
|
+
const layerName = getLayerName(layer);
|
|
45363
|
+
const { visible: layerVisibility } = config.layers[layerName];
|
|
45364
|
+
return layerVisibility;
|
|
45365
|
+
}, [config]);
|
|
45366
|
+
const toggleLayerVisibility = React__namespace.useCallback(({ layer, visible }) => {
|
|
45367
|
+
if (!scene) {
|
|
45368
|
+
console.warn('Scene не инициализирована');
|
|
45369
|
+
return;
|
|
45370
|
+
}
|
|
45371
|
+
if (!config) {
|
|
45372
|
+
console.warn('Config не инициализирована');
|
|
45373
|
+
return;
|
|
45374
|
+
}
|
|
45375
|
+
const layerName = getLayerName(layer);
|
|
45376
|
+
config.layers[layerName].visible = visible;
|
|
45377
|
+
scene.updateConfig();
|
|
45378
|
+
return getLayerVisibility(layer);
|
|
45379
|
+
}, [config, scene]);
|
|
45380
|
+
const getLayers = React__namespace.useCallback(() => {
|
|
45381
|
+
if (!config)
|
|
45382
|
+
return [];
|
|
45383
|
+
const { layers } = config;
|
|
45384
|
+
return Object.keys(layers);
|
|
45385
|
+
}, [config]);
|
|
45386
|
+
const removeLayers = React__namespace.useCallback(() => {
|
|
45387
|
+
if (!config)
|
|
45388
|
+
return [];
|
|
45389
|
+
const { layers } = config;
|
|
45390
|
+
Object.values(layers).forEach(removeLayer);
|
|
45391
|
+
}, [config]);
|
|
45392
|
+
const getSources = React__namespace.useCallback(() => {
|
|
45393
|
+
if (!config)
|
|
45394
|
+
return [];
|
|
45395
|
+
const { sources } = config;
|
|
45396
|
+
return Object.keys(sources);
|
|
45397
|
+
}, [config]);
|
|
45398
|
+
React__namespace.useEffect(() => {
|
|
45399
|
+
if (isValidApiKey) {
|
|
45400
|
+
getLeafletLayer();
|
|
45401
|
+
}
|
|
45402
|
+
return () => {
|
|
45403
|
+
setLayer(null);
|
|
45404
|
+
setScene(null);
|
|
45405
|
+
setConfig(null);
|
|
45406
|
+
};
|
|
45407
|
+
}, [isValidApiKey]);
|
|
45408
|
+
React__namespace.useEffect(() => {
|
|
45409
|
+
if (scene) {
|
|
45410
|
+
scene.subscribe({
|
|
45411
|
+
load: ({ config }) => {
|
|
45412
|
+
setConfig(config);
|
|
45413
|
+
},
|
|
45414
|
+
});
|
|
45415
|
+
}
|
|
45416
|
+
}, [scene]);
|
|
45417
|
+
React__namespace.useEffect(() => {
|
|
45418
|
+
addStyle({
|
|
45419
|
+
name: 'space-tile',
|
|
45420
|
+
style: {
|
|
45421
|
+
shaders: {
|
|
45422
|
+
defines: {
|
|
45423
|
+
TILE_SCALE: 0.0002445,
|
|
45424
|
+
'NORMALIZED_SHORT(x)': '(x * 32767.)',
|
|
45425
|
+
},
|
|
45426
|
+
blocks: {
|
|
45427
|
+
global: `
|
|
45428
|
+
varying vec3 v_pos;
|
|
45429
|
+
vec2 getTileCoords() {
|
|
45430
|
+
return fract(v_pos.xy);
|
|
45431
|
+
}
|
|
45432
|
+
`,
|
|
45433
|
+
position: `
|
|
45434
|
+
v_pos = modelPosition().xyz;
|
|
45435
|
+
`,
|
|
45436
|
+
},
|
|
45437
|
+
},
|
|
45438
|
+
},
|
|
45439
|
+
});
|
|
45440
|
+
addStyle({
|
|
45441
|
+
name: 'tools-aastep',
|
|
45442
|
+
style: {
|
|
45443
|
+
shaders: {
|
|
45444
|
+
extensions: 'OES_standard_derivatives',
|
|
45445
|
+
blocks: {
|
|
45446
|
+
global: `
|
|
45447
|
+
float aastep(float threshold, float value) {
|
|
45448
|
+
#ifdef TANGRAM_FRAGMENT_SHADER
|
|
45449
|
+
#ifdef TANGRAM_EXTENSION_OES_standard_derivatives
|
|
45450
|
+
float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
|
|
45451
|
+
return smoothstep(threshold-afwidth, threshold+afwidth, value);
|
|
45452
|
+
#else
|
|
45453
|
+
return step(threshold, value);
|
|
45454
|
+
#endif
|
|
45455
|
+
#else
|
|
45456
|
+
return step(threshold, value);
|
|
45457
|
+
#endif
|
|
45458
|
+
}
|
|
45459
|
+
`,
|
|
45342
45460
|
},
|
|
45343
45461
|
},
|
|
45344
45462
|
},
|
|
45345
|
-
}
|
|
45346
|
-
|
|
45347
|
-
|
|
45348
|
-
|
|
45349
|
-
|
|
45350
|
-
|
|
45351
|
-
|
|
45352
|
-
|
|
45353
|
-
|
|
45354
|
-
|
|
45355
|
-
|
|
45356
|
-
|
|
45357
|
-
|
|
45358
|
-
|
|
45359
|
-
|
|
45360
|
-
|
|
45361
|
-
|
|
45362
|
-
|
|
45363
|
-
|
|
45364
|
-
|
|
45365
|
-
|
|
45366
|
-
|
|
45367
|
-
color: colorFunction,
|
|
45368
|
-
width: widthFunction,
|
|
45369
|
-
cap: 'round',
|
|
45370
|
-
join: 'round',
|
|
45463
|
+
});
|
|
45464
|
+
addStyle({
|
|
45465
|
+
name: 'pattern-diagonal-grid',
|
|
45466
|
+
style: {
|
|
45467
|
+
mix: ['space-tile', 'tools-aastep'],
|
|
45468
|
+
shaders: {
|
|
45469
|
+
blocks: {
|
|
45470
|
+
global: `
|
|
45471
|
+
float DiagonalGrid(float scale, float lineWidth) {
|
|
45472
|
+
vec2 st = getTileCoords() * scale;
|
|
45473
|
+
|
|
45474
|
+
float d1 = mod(st.x + st.y, 1.0);
|
|
45475
|
+
float line1 = aastep(lineWidth, d1) * aastep(1.0 - lineWidth, d1);
|
|
45476
|
+
|
|
45477
|
+
float d2 = mod(st.x - st.y, 1.0);
|
|
45478
|
+
float line2 = aastep(lineWidth, d2) * aastep(1.0 - lineWidth, d2);
|
|
45479
|
+
|
|
45480
|
+
return max(line1, line2);
|
|
45481
|
+
}
|
|
45482
|
+
`,
|
|
45483
|
+
},
|
|
45484
|
+
},
|
|
45371
45485
|
},
|
|
45372
45486
|
});
|
|
45373
|
-
|
|
45374
|
-
|
|
45375
|
-
|
|
45376
|
-
|
|
45377
|
-
|
|
45378
|
-
|
|
45379
|
-
|
|
45380
|
-
|
|
45381
|
-
|
|
45487
|
+
addStyle({
|
|
45488
|
+
name: 'diagonal-grid',
|
|
45489
|
+
style: {
|
|
45490
|
+
mix: 'pattern-diagonal-grid',
|
|
45491
|
+
blend: 'overlay',
|
|
45492
|
+
base: 'polygons',
|
|
45493
|
+
shaders: {
|
|
45494
|
+
blocks: {
|
|
45495
|
+
color: `
|
|
45496
|
+
float grid = DiagonalGrid(12.0, 0.08);
|
|
45497
|
+
|
|
45498
|
+
color.a = grid;
|
|
45499
|
+
`,
|
|
45500
|
+
},
|
|
45382
45501
|
},
|
|
45383
45502
|
},
|
|
45384
45503
|
});
|
|
45385
|
-
|
|
45386
|
-
|
|
45387
|
-
|
|
45388
|
-
|
|
45389
|
-
|
|
45390
|
-
|
|
45391
|
-
|
|
45392
|
-
|
|
45393
|
-
|
|
45394
|
-
|
|
45395
|
-
|
|
45396
|
-
|
|
45397
|
-
|
|
45398
|
-
|
|
45399
|
-
|
|
45400
|
-
|
|
45401
|
-
|
|
45402
|
-
|
|
45403
|
-
|
|
45404
|
-
|
|
45405
|
-
|
|
45406
|
-
|
|
45407
|
-
|
|
45408
|
-
|
|
45409
|
-
|
|
45410
|
-
|
|
45411
|
-
|
|
45412
|
-
|
|
45413
|
-
|
|
45414
|
-
|
|
45415
|
-
|
|
45416
|
-
|
|
45417
|
-
|
|
45418
|
-
|
|
45419
|
-
|
|
45420
|
-
|
|
45421
|
-
|
|
45422
|
-
|
|
45423
|
-
|
|
45424
|
-
|
|
45425
|
-
|
|
45426
|
-
|
|
45427
|
-
|
|
45428
|
-
|
|
45429
|
-
|
|
45430
|
-
|
|
45431
|
-
|
|
45432
|
-
|
|
45433
|
-
|
|
45434
|
-
|
|
45435
|
-
|
|
45436
|
-
|
|
45437
|
-
|
|
45438
|
-
|
|
45439
|
-
|
|
45440
|
-
|
|
45441
|
-
|
|
45442
|
-
|
|
45443
|
-
|
|
45444
|
-
|
|
45445
|
-
|
|
45446
|
-
|
|
45447
|
-
|
|
45448
|
-
sublayers: {
|
|
45449
|
-
lowMobility: {
|
|
45450
|
-
filter: `function() {
|
|
45451
|
-
return global.links.getIsLowMobility(feature);
|
|
45452
|
-
}`,
|
|
45453
|
-
draw: {
|
|
45454
|
-
lines: {
|
|
45455
|
-
width: 4,
|
|
45456
|
-
},
|
|
45457
|
-
},
|
|
45458
|
-
},
|
|
45459
|
-
},
|
|
45460
|
-
};
|
|
45461
|
-
layers.push(baseLayer, borderLayer);
|
|
45462
|
-
});
|
|
45463
|
-
});
|
|
45464
|
-
break;
|
|
45465
|
-
}
|
|
45466
|
-
default: {
|
|
45467
|
-
const baseLayer = {
|
|
45468
|
-
id: uuid(),
|
|
45469
|
-
data,
|
|
45470
|
-
filter,
|
|
45471
|
-
draw: getBaseLayerDraw(),
|
|
45472
|
-
};
|
|
45473
|
-
const borderLayer = {
|
|
45474
|
-
id: uuid(),
|
|
45475
|
-
data,
|
|
45476
|
-
filter,
|
|
45477
|
-
draw: getBorderLayerDraw(),
|
|
45478
|
-
};
|
|
45479
|
-
layers.push(baseLayer, borderLayer);
|
|
45480
|
-
}
|
|
45481
|
-
}
|
|
45482
|
-
});
|
|
45483
|
-
return layers;
|
|
45504
|
+
addStyle({
|
|
45505
|
+
name: 'zebra_crossing',
|
|
45506
|
+
style: {
|
|
45507
|
+
base: 'polygons',
|
|
45508
|
+
lighting: false,
|
|
45509
|
+
shaders: {
|
|
45510
|
+
attributes: {
|
|
45511
|
+
a_angle: {
|
|
45512
|
+
type: 'float',
|
|
45513
|
+
default: 0.0,
|
|
45514
|
+
},
|
|
45515
|
+
},
|
|
45516
|
+
uniforms: {
|
|
45517
|
+
u_stripe_width: 1,
|
|
45518
|
+
},
|
|
45519
|
+
blocks: {
|
|
45520
|
+
filter: `
|
|
45521
|
+
vec3 pos = worldPosition().xyz;
|
|
45522
|
+
|
|
45523
|
+
float ang = radians(a_angle);
|
|
45524
|
+
|
|
45525
|
+
vec2 dir = vec2(sin(ang), cos(ang));
|
|
45526
|
+
|
|
45527
|
+
float positionAlongLine = dot(pos.xy, dir);
|
|
45528
|
+
|
|
45529
|
+
float stripe = step(1.0, mod(positionAlongLine / u_stripe_width, 2.0));
|
|
45530
|
+
|
|
45531
|
+
color.rgb = mix(vec3(1.0, 1.0, 1.0), vec3(1.0, 0.8, 0.0), stripe);
|
|
45532
|
+
|
|
45533
|
+
color.a = 1.0;
|
|
45534
|
+
`,
|
|
45535
|
+
},
|
|
45536
|
+
},
|
|
45537
|
+
},
|
|
45538
|
+
});
|
|
45539
|
+
}, [addStyle]);
|
|
45540
|
+
React__namespace.useEffect(() => {
|
|
45541
|
+
Object.values(exports.TangramSourceNames).forEach((name) => {
|
|
45542
|
+
const url = sourceUrl[name];
|
|
45543
|
+
addSource({
|
|
45544
|
+
tile_size,
|
|
45545
|
+
name,
|
|
45546
|
+
url,
|
|
45547
|
+
type: 'MVT',
|
|
45548
|
+
});
|
|
45549
|
+
});
|
|
45550
|
+
}, [addSource]);
|
|
45551
|
+
return {
|
|
45552
|
+
layer,
|
|
45553
|
+
scene,
|
|
45554
|
+
config,
|
|
45555
|
+
addSource,
|
|
45556
|
+
getSource,
|
|
45557
|
+
updateSource,
|
|
45558
|
+
addLayer,
|
|
45559
|
+
removeLayer,
|
|
45560
|
+
addStyle,
|
|
45561
|
+
getLayerVisibility,
|
|
45562
|
+
toggleLayerVisibility,
|
|
45563
|
+
getSources,
|
|
45564
|
+
getLayers,
|
|
45565
|
+
removeLayers,
|
|
45566
|
+
};
|
|
45484
45567
|
};
|
|
45485
45568
|
|
|
45486
45569
|
const LeafletLayer = () => {
|
|
@@ -45492,22 +45575,7 @@ const LeafletLayer = () => {
|
|
|
45492
45575
|
}
|
|
45493
45576
|
}, [layer]);
|
|
45494
45577
|
React__namespace.useEffect(() => {
|
|
45495
|
-
|
|
45496
|
-
const linkLayers = getLinkLayers(exports.TangramSourceNames.MSK);
|
|
45497
|
-
const roadPolyLayers = getRoadPolyLayers(exports.TangramSourceNames.MSK);
|
|
45498
|
-
const markingPolyLayers = getLaneMarkingPolyLayers(exports.TangramSourceNames.MSK);
|
|
45499
|
-
const laneMarkingLineLayers = getLaneMarkingLineLayers(exports.TangramSourceNames.MSK);
|
|
45500
|
-
const laneMarkingPointLayers = getLaneMarkingPointLayers(exports.TangramSourceNames.MSK);
|
|
45501
|
-
const parkingLineLayers = getParkingLineLayers(exports.TangramSourceNames.MSK);
|
|
45502
|
-
[
|
|
45503
|
-
...POILayers,
|
|
45504
|
-
...linkLayers,
|
|
45505
|
-
...roadPolyLayers,
|
|
45506
|
-
...markingPolyLayers,
|
|
45507
|
-
...laneMarkingLineLayers,
|
|
45508
|
-
...laneMarkingPointLayers,
|
|
45509
|
-
...parkingLineLayers,
|
|
45510
|
-
].map(addLayer);
|
|
45578
|
+
getAllLayers(exports.TangramSourceNames.MSK).map(addLayer);
|
|
45511
45579
|
}, [addLayer]);
|
|
45512
45580
|
return null;
|
|
45513
45581
|
};
|
|
@@ -45593,6 +45661,7 @@ exports.getLaneMarkingPointLayers = getLaneMarkingPointLayers;
|
|
|
45593
45661
|
exports.getLaneMarkingPolyLayers = getLaneMarkingPolyLayers;
|
|
45594
45662
|
exports.getLinkLayers = getLinkLayers;
|
|
45595
45663
|
exports.getNatureFieldLayers = getNatureFieldLayers;
|
|
45664
|
+
exports.getNatureForestLayers = getNatureForestLayers;
|
|
45596
45665
|
exports.getOceanAreaLayers = getOceanAreaLayers;
|
|
45597
45666
|
exports.getOneWayLayers = getOneWayLayers;
|
|
45598
45667
|
exports.getPOILayers = getPOILayers;
|