OpenLayers矢量数据可视化高级技巧(进阶二)
1. 高级样式技术
矢量数据的样式直接影响可视化效果的表达能力和美观度。OpenLayers提供了丰富的样式API,通过组合和创新,可以实现各种复杂的视觉效果。
1.1 动态样式
// 根据属性值动态设置样式
const vectorLayer = new ol.layer.Vector({source: new ol.source.Vector({url: 'data.geojson',format: new ol.format.GeoJSON()}),style: function(feature) {// 获取要素属性const value = feature.get('value');// 根据属性值计算颜色(线性渐变)const color = calculateColor(value, [0, 100], ['#0000ff', '#ff0000']);return new ol.style.Style({fill: new ol.style.Fill({color: color}),stroke: new ol.style.Stroke({color: '#000000',width: 1})});}
});// 计算颜色插值
function calculateColor(value, range, colors) {const ratio = (value - range[0]) / (range[1] - range[0]);const r = Math.round(parseInt(colors[0].slice(1, 3), 16) * (1 - ratio) + parseInt(colors[1].slice(1, 3), 16) * ratio);const g = Math.round(parseInt(colors[0].slice(3, 5), 16) * (1 - ratio) + parseInt(colors[1].slice(3, 5), 16) * ratio);const b = Math.round(parseInt(colors[0].slice(5, 7), 16) * (1 - ratio) + parseInt(colors[1].slice(5, 7), 16) * ratio);return `rgba(${r}, ${g}, ${b}, 0.8)`;
}
1.2 复合样式
// 创建多层次样式
function createCompoundStyle(feature) {const styles = [];// 底层填充styles.push(new ol.style.Style({fill: new ol.style.Fill({color: 'rgba(255, 255, 255, 0.4)'}),zIndex: 1}));// 中间层描边styles.push(new ol.style.Style({stroke: new ol.style.Stroke({color: 'rgba(0, 0, 0, 0.7)',width: 3}),zIndex: 2}));// 顶层细线描边styles.push(new ol.style.Style({stroke: new ol.style.Stroke({color: 'rgba(255, 165, 0, 0.9)',width: 1}),zIndex: 3}));// 添加标签if (feature.get('name')) {styles.push(new ol.style.Style({text: new ol.style.Text({text: feature.get('name'),font: '12px Calibri,sans-serif',fill: new ol.style.Fill({color: '#000'}),stroke: new ol.style.Stroke({color: '#fff',width: 3}),offsetY: -15}),zIndex: 4}));}return styles;
}
1.3 自定义几何图形
// 创建自定义几何符号
function createCustomSymbol(color, size) {const canvas = document.createElement('canvas');const context = canvas.getContext('2d');const centerX = size / 2;const centerY = size / 2;canvas.width = size;canvas.height = size;// 绘制五角星context.beginPath();for (let i = 0; i < 5; i++) {const x = centerX + Math.cos((Math.PI / 180) * (i * 72 - 90)) * (size / 2);const y = centerY + Math.sin((Math.PI / 180) * (i * 72 - 90)) * (size / 2);if (i === 0) {context.moveTo(x, y);} else {context.lineTo(x, y);}}context.closePath();// 填充和描边context.fillStyle = color;context.fill();context.strokeStyle = 'rgba(0, 0, 0, 0.8)';context.lineWidth = 1;context.stroke();return new ol.style.Icon({img: canvas,imgSize: [size, size],anchor: [0.5, 0.5]});
}
2. 高级交互技术
除了基本的地图导航,OpenLayers还支持创建复杂的用户交互体验,显著提升地图的可用性。
2.1 自定义选择交互
// 自定义选择交互行为
const selectInteraction = new ol.interaction.Select({// 条件:点击同时按住Shift键condition: function(evt) {return ol.events.condition.click(evt) && ol.events.condition.shiftKeyOnly(evt);},// 自定义样式style: function(feature) {return new ol.style.Style({fill: new ol.style.Fill({color: 'rgba(255, 255, 0, 0.5)'}),stroke: new ol.style.Stroke({color: '#ffcc33',width: 4}),image: new ol.style.Circle({radius: 8,fill: new ol.style.Fill({color: '#ffcc33'})})});},// 应用于特定图层layers: function(layer) {return layer.get('selectable') === true;}
});
map.addInteraction(selectInteraction);// 监听选择变化事件
selectInteraction.on('select', function(e) {const selected = e.selected;const deselected = e.deselected;// 处理新选中的要素selected.forEach(function(feature) {console.log('选中要素:', feature.getId());// 显示要素信息面板等操作});// 处理取消选中的要素deselected.forEach(function(feature) {console.log('取消选择:', feature.getId());// 隐藏要素信息面板等操作});
});
2.2 自定义悬停交互
// 创建自定义悬停交互
const pointerMoveInteraction = new ol.interaction.Pointer({handleMoveEvent: function(evt) {// 检查鼠标下是否有要素const hit = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {return true;});// 更改鼠标光标样式map.getTargetElement().style.cursor = hit ? 'pointer' : '';// 如果需要,可以查找具体的要素并执行其他操作if (hit) {const feature = map.forEachFeatureAtPixel(evt.pixel, function(feature) {return feature;});if (feature) {showTooltip(feature, evt.coordinate);}} else {hideTooltip();}}
});
map.addInteraction(pointerMoveInteraction);// 显示工具提示
function showTooltip(feature, coordinate) {const tooltip = document.getElementById('map-tooltip');tooltip.innerHTML = `<h3>${feature.get('name')}</h3><p>${feature.get('description')}</p>`;tooltip.style.display = 'block';// 定位工具提示const overlay = new ol.Overlay({element: tooltip,offset: [10, 0],positioning: 'top-left'});overlay.setPosition(coordinate);map.addOverlay(overlay);// 存储当前工具提示覆盖层map.set('currentTooltip', overlay);
}// 隐藏工具提示
function hideTooltip() {const tooltip = document.getElementById('map-tooltip');tooltip.style.display = 'none';// 移除当前工具提示覆盖层const currentTooltip = map.get('currentTooltip');if (currentTooltip) {map.removeOverlay(currentTooltip);map.set('currentTooltip', null);}
}
2.3 自定义绘图工具
// 创建绘图交互
function createDrawTool(type) {// 销毁任何现有的绘图交互const existingInteractions = map.getInteractions().getArray().filter(interaction => interaction instanceof ol.interaction.Draw);existingInteractions.forEach(interaction => map.removeInteraction(interaction));// 创建新的绘图交互const drawInteraction = new ol.interaction.Draw({source: vectorSource,type: type,style: new ol.style.Style({fill: new ol.style.Fill({color: 'rgba(255, 255, 255, 0.4)'}),stroke: new ol.style.Stroke({color: '#ff0000',lineDash: [10, 10],width: 2}),image: new ol.style.Circle({radius: 5,stroke: new ol.style.Stroke({color: '#ff0000'}),fill: new ol.style.Fill({color: 'rgba(255, 255, 255, 0.4)'})})})});// 绘制开始事件drawInteraction.on('drawstart', function(event) {console.log('开始绘制', type);});// 绘制结束事件drawInteraction.on('drawend', function(event) {const feature = event.feature;console.log('绘制完成', type);// 设置要素属性feature.set('type', type);feature.set('timestamp', new Date().toISOString());// 如果需要,可以触发自定义事件const evt = new CustomEvent('featureDrawn', {detail: {feature: feature,type: type}});document.dispatchEvent(evt);});map.addInteraction(drawInteraction);return drawInteraction;
}
3. 高级数据处理
OpenLayers不仅可以显示矢量数据,还可以对其进行复杂处理和分析。
3.1 数据过滤和聚合
// 数据过滤
function filterFeatures(source, filterFn) {const filteredFeatures = source.getFeatures().filter(filterFn);// 创建一个新的源用于显示过滤结果const filteredSource = new ol.source.Vector({features: filteredFeatures});return filteredSource;
}// 示例:过滤出特定类型的要素
const roadSource = filterFeatures(mainSource, function(feature) {return feature.get('type') === 'road';
});// 数据聚合
const clusterSource = new ol.source.Cluster({distance: 50, // 聚合距离(像素)source: mainSource
});const clusterLayer = new ol.layer.Vector({source: clusterSource,style: function(feature) {const size = feature.get('features').length;// 根据聚合大小设置样式return new ol.style.Style({image: new ol.style.Circle({radius: Math.min(20, 10 + Math.log2(size) * 5),fill: new ol.style.Fill({color: 'rgba(255, 153, 0, 0.8)'}),stroke: new ol.style.Stroke({color: '#fff',width: 2})}),text: new ol.style.Text({text: size.toString(),fill: new ol.style.Fill({color: '#fff'}),font: 'bold 12px Arial'})});}
});
3.2 空间分析与计算
// 引入拓扑库(如Turf.js)
import * as turf from '@turf/turf';// 缓冲区分析
function createBuffer(feature, distance, units = 'kilometers') {const geometry = feature.getGeometry();const format = new ol.format.GeoJSON();// 转换为GeoJSONconst geoJson = format.writeFeatureObject(feature);// 使用Turf.js创建缓冲区const buffered = turf.buffer(geoJson, distance, { units: units });// 转回OpenLayers Featureconst bufferedFeature = format.readFeature(buffered, {featureProjection: map.getView().getProjection()});return bufferedFeature;
}// 空间查询
function spatialQuery(source, geometry, relation = 'intersects') {const format = new ol.format.GeoJSON();const features = source.getFeatures();const results = [];// 转换查询几何为GeoJSONconst geoJson = format.writeGeometryObject(geometry, {featureProjection: map.getView().getProjection(),dataProjection: 'EPSG:4326'});// 遍历所有要素执行空间关系检查features.forEach(feature => {const featureGeoJson = format.writeFeatureObject(feature, {featureProjection: map.getView().getProjection(),dataProjection: 'EPSG:4326'});let match = false;switch(relation) {case 'intersects':match = turf.booleanIntersects(geoJson, featureGeoJson);break;case 'within':match = turf.booleanWithin(featureGeoJson, geoJson);break;case 'contains':match = turf.booleanContains(geoJson, featureGeoJson);break;}if (match) {results.push(feature);}});return results;
}
3.3 数据统计与可视化
// 数据统计与分类
function analyzeData(features, propertyName) {// 提取所有值const values = features.map(f => f.get(propertyName)).filter(v => v !== undefined);// 计算基本统计量const statistics = {count: values.length,sum: values.reduce((a, b) => a + b, 0),min: Math.min(...values),max: Math.max(...values),mean: values.reduce((a, b) => a + b, 0) / values.length,// 更多统计计算...};// 创建分位数分类const sortedValues = [...values].sort((a, b) => a - b);const quantiles = [0.2, 0.4, 0.6, 0.8].map(q => {const position = Math.floor(sortedValues.length * q);return sortedValues[position];});return {statistics: statistics,breaks: [statistics.min, ...quantiles, statistics.max]};
}// 创建分类渲染样式
function createClassifiedStyle(breaks, colorScheme) {return function(feature) {const value = feature.get('value');let color;// 确定值所属的分类for (let i = 0; i < breaks.length - 1; i++) {if (value >= breaks[i] && value <= breaks[i + 1]) {color = colorScheme[i];break;}}return new ol.style.Style({fill: new ol.style.Fill({color: color}),stroke: new ol.style.Stroke({color: '#000',width: 1})});};
}// 使用示例
const analysis = analyzeData(vectorSource.getFeatures(), 'population');
const colorScheme = ['#ffffb2', '#fecc5c', '#fd8d3c', '#f03b20', '#bd0026'];
vectorLayer.setStyle(createClassifiedStyle(analysis.breaks, colorScheme));
4. 高级动画效果
动画效果可以有效传达数据的变化,增强用户体验。
4.1 要素动画
// 要素闪烁效果
function animateFeature(feature, duration = 3000) {const start = Date.now();const originalStyle = feature.getStyle();function animate() {const elapsed = Date.now() - start;if (elapsed > duration) {// 动画结束,恢复原始样式feature.setStyle(originalStyle);return;}// 计算动画进度(0-1之间)const progress = (elapsed % 1000) / 1000;// 创建闪烁效果(透明度变化)const opacity = 0.4 + Math.sin(progress * Math.PI * 2) * 0.6;feature.setStyle(new ol.style.Style({fill: new ol.style.Fill({color: `rgba(255, 0, 0, ${opacity})`}),stroke: new ol.style.Stroke({color: `rgba(255, 0, 0, ${Math.min(1, opacity + 0.2)})`,width: 2})}));// 请求下一帧window.requestAnimationFrame(animate);}// 启动动画animate();
}
4.2 轨迹动画
// 创建路径动画
function createPathAnimation(lineFeature, duration = 5000) {const line = lineFeature.getGeometry();const length = line.getLength();const start = Date.now();// 创建点要素用于动画const pointFeature = new ol.Feature({geometry: new ol.geom.Point(line.getFirstCoordinate())});// 样式设置pointFeature.setStyle(new ol.style.Style({image: new ol.style.Circle({radius: 7,fill: new ol.style.Fill({color: '#ff0000'}),stroke: new ol.style.Stroke({color: '#ffffff',width: 2})})}));// 添加到图层const animationLayer = new ol.layer.Vector({source: new ol.source.Vector({features: [pointFeature]})});map.addLayer(animationLayer);function animate() {const elapsed = Date.now() - start;const progress = Math.min(1, elapsed / duration);if (progress === 1) {// 动画结束return;}// 计算当前位置const currentCoordinate = line.getCoordinateAt(progress);pointFeature.getGeometry().setCoordinates(currentCoordinate);// 请求下一帧window.requestAnimationFrame(animate);}// 启动动画animate();return animationLayer;
}
4.3 数据流动画
// 模拟数据流,如交通流量或水流方向
function createFlowAnimation(lineFeature, count = 20, speed = 100) {const line = lineFeature.getGeometry();const source = new ol.source.Vector();// 创建流动点图层const flowLayer = new ol.layer.Vector({source: source,style: new ol.style.Style({image: new ol.style.Circle({radius: 4,fill: new ol.style.Fill({color: '#0099ff'})})})});map.addLayer(flowLayer);// 创建初始点for (let i = 0; i < count; i++) {const progress = i / count;const coordinate = line.getCoordinateAt(progress);const pointFeature = new ol.Feature({geometry: new ol.geom.Point(coordinate),// 存储进度信息progress: progress});source.addFeature(pointFeature);}// 动画函数function animateFlow() {const features = source.getFeatures();features.forEach(feature => {let progress = feature.get('progress');// 更新进度progress += 0.01 * (speed / 100);if (progress > 1) {progress = 0;}// 更新位置const coordinate = line.getCoordinateAt(progress);feature.getGeometry().setCoordinates(coordinate);feature.set('progress', progress);});}// 创建动画间隔const interval = setInterval(animateFlow, 50);// 返回控制对象return {layer: flowLayer,stop: function() {clearInterval(interval);}};
}
5. 案例研究:交互式人口密度地图
5.1 数据准备
// 加载人口数据
const populationSource = new ol.source.Vector({url: 'population-data.geojson',format: new ol.format.GeoJSON()
});// 数据加载完成后进行处理
populationSource.once('change', function() {if (populationSource.getState() === 'ready') {// 分析人口数据const features = populationSource.getFeatures();// 计算人口密度features.forEach(feature => {const population = feature.get('population');const area = feature.get('area_km2');if (population && area) {const density = population / area;feature.set('density', density);}});// 对密度进行分类const densityAnalysis = analyzeData(features, 'density');console.log('人口密度分析:', densityAnalysis);// 设置分类样式populationLayer.setStyle(createDensityStyle(densityAnalysis.breaks));}
});
5.2 可视化实现
// 创建人口密度样式
function createDensityStyle(breaks) {// 定义颜色方案(从浅到深)const colors = ['rgba(255, 255, 178, 0.8)','rgba(254, 217, 118, 0.8)','rgba(254, 178, 76, 0.8)','rgba(253, 141, 60, 0.8)','rgba(240, 59, 32, 0.8)','rgba(189, 0, 38, 0.8)'];return function(feature) {const density = feature.get('density');let color = colors[0]; // 默认颜色// 确定密度对应的颜色for (let i = 0; i < breaks.length - 1; i++) {if (density >= breaks[i] && density < breaks[i + 1]) {color = colors[i];break;}}// 如果密度大于最大断点,使用最深的颜色if (density >= breaks[breaks.length - 1]) {color = colors[colors.length - 1];}return new ol.style.Style({fill: new ol.style.Fill({color: color}),stroke: new ol.style.Stroke({color: 'rgba(0, 0, 0, 0.4)',width: 1})});};
}// 创建人口密度图层
const populationLayer = new ol.layer.Vector({source: populationSource,style: new ol.style.Style({fill: new ol.style.Fill({color: 'rgba(128, 128, 128, 0.4)'}),stroke: new ol.style.Stroke({color: 'rgba(0, 0, 0, 0.4)',width: 1})})
});
map.addLayer(populationLayer);
5.3 交互功能
// 添加信息弹窗
const popup = new ol.Overlay({element: document.getElementById('popup'),positioning: 'bottom-center',stopEvent: false,offset: [0, -10]
});
map.addOverlay(popup);// 添加点击事件处理
map.on('click', function(evt) {const feature = map.forEachFeatureAtPixel(evt.pixel, function(feature) {return feature;});const popupElement = popup.getElement();if (feature) {const geometry = feature.getGeometry();const coordinate = evt.coordinate;// 填充弹窗内容popupElement.innerHTML = `<div class="popup-content"><h3>${feature.get('name')}</h3><table><tr><td>人口:</td><td>${numberWithCommas(feature.get('population'))}</td></tr><tr><td>面积:</td><td>${feature.get('area_km2')} km²</td></tr><tr><td>密度:</td><td>${Math.round(feature.get('density'))} 人/km²</td></tr></table></div>`;popup.setPosition(coordinate);} else {popup.setPosition(undefined);}
});// 数字格式化
function numberWithCommas(x) {return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}// 添加悬停高亮效果
const highlightStyle = new ol.style.Style({fill: new ol.style.Fill({color: 'rgba(255, 255, 255, 0.7)'}),stroke: new ol.style.Stroke({color: '#3399CC',width: 3})
});let highlightedFeature = null;// 鼠标移动处理
map.on('pointermove', function(evt) {if (evt.dragging) {return;}const pixel = map.getEventPixel(evt.originalEvent);const hit = map.hasFeatureAtPixel(pixel);map.getTargetElement().style.cursor = hit ? 'pointer' : '';// 处理高亮效果const feature = hit ? map.forEachFeatureAtPixel(pixel, feature => feature) : null;if (feature !== highlightedFeature) {// 恢复之前高亮的要素样式if (highlightedFeature) {highlightedFeature.setStyle(null); // 恢复到图层样式}highlightedFeature = feature;// 设置新的高亮样式if (highlightedFeature) {highlightedFeature.setStyle(highlightStyle);}}
});
5.4 图例与控件
// 创建图例
function createLegend(title, breaks, colors) {const legendElement = document.createElement('div');legendElement.className = 'ol-legend ol-unselectable ol-control';let html = `<div class="legend-title">${title}</div>`;html += '<div class="legend-content">';// 创建图例项for (let i = 0; i < breaks.length - 1; i++) {html += `<div class="legend-item"><span class="legend-color" style="background-color: ${colors[i]}"></span><span class="legend-text">${Math.round(breaks[i])} - ${Math.round(breaks[i + 1])}</span></div>`;}html += '</div>';legendElement.innerHTML = html;// 创建自定义控件const legend = new ol.control.Control({element: legendElement});return legend;
}// 添加图例到地图
populationSource.once('change', function() {if (populationSource.getState() === 'ready') {const densityAnalysis = analyzeData(populationSource.getFeatures(), 'density');const colors = ['rgba(255, 255, 178, 0.8)','rgba(254, 217, 118, 0.8)','rgba(254, 178, 76, 0.8)','rgba(253, 141, 60, 0.8)','rgba(240, 59, 32, 0.8)'];const legend = createLegend('人口密度 (人/km²)', densityAnalysis.breaks, colors);map.addControl(legend);}
});// 添加统计信息控件
function createStatisticsControl(source, propertyName, format = val => val) {const element = document.createElement('div');element.className = 'ol-statistics ol-unselectable ol-control';const control = new ol.control.Control({element: element});// 源数据变化时更新统计信息source.on('change', function() {if (source.getState() === 'ready') {const features = source.getFeatures();const values = features.map(f => f.get(propertyName)).filter(v => v !== undefined);// 如果没有值,不显示统计信息if (values.length === 0) {element.style.display = 'none';return;}// 计算统计量const sum = values.reduce((a, b) => a + b, 0);const mean = sum / values.length;const min = Math.min(...values);const max = Math.max(...values);element.innerHTML = `<div class="statistics-content"><div class="statistics-title">${propertyName} 统计</div><div>平均值: ${format(mean)}</div><div>最小值: ${format(min)}</div><div>最大值: ${format(max)}</div><div>总计: ${format(sum)}</div></div>`;element.style.display = 'block';}});return control;
}// 添加人口统计控件
const statsControl = createStatisticsControl(populationSource,'population',val => Math.round(val).toLocaleString()
);
map.addControl(statsControl);
6. 最佳实践
6.1 性能优化
-
分级加载数据
- 根据缩放级别加载不同详细程度的数据
- 在低缩放级别使用简化的几何图形
- 使用WebGL渲染大量点数据
-
视图范围过滤
- 只加载当前视图范围内的数据
- 使用空间索引快速查找可见要素
-
懒加载和缓存
- 按需加载矢量数据
- 缓存已加载的要素以避免重复请求
-
样式优化
- 对相似要素复用样式对象
- 避免在渲染循环中创建新样式
- 使用简单样式提高渲染速度
6.2 可维护性建议
-
模块化开发
- 将复杂功能拆分成小型可复用模块
- 使用类封装相关功能和状态
-
统一数据处理
- 创建标准化数据处理流程
- 使用适配器模式处理不同数据源
-
事件驱动架构
- 使用事件通知机制解耦组件
- 通过事件传递状态变化
-
文档和测试
- 为复杂函数编写清晰文档
- 实现自动化测试验证功能正确性
6.3 用户体验建议
-
提供反馈
- 在长时间操作期间显示加载指示器
- 通过动画提示用户操作结果
-
渐进式界面
- 从简单到复杂逐步展示功能
- 根据用户熟悉度调整界面复杂性
-
容错设计
- 优雅处理错误情况
- 提供明确的错误消息和恢复选项
-
辅助功能
- 确保地图控件可通过键盘访问
- 提供颜色对比度选项以增强可读性
相关文章:
OpenLayers矢量数据可视化高级技巧(进阶二)
1. 高级样式技术 矢量数据的样式直接影响可视化效果的表达能力和美观度。OpenLayers提供了丰富的样式API,通过组合和创新,可以实现各种复杂的视觉效果。 1.1 动态样式 // 根据属性值动态设置样式 const vectorLayer new ol.layer.Vector({source: ne…...
实用的java技术架构组件汇总
1.后端数据校验 引入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId> </dependency>校验注解 jakarta.validation-api 规范提供如下: size hibern…...
Rmarkdown输出为pdf的方法与问题解决
R 是一种在数据分析与统计计算领域广泛使用的编程语言。其关键优势之一是能够生成高质量的报告和文档,这些报告和文档可以使用 RMarkdown 轻松定制和更新。在本文中,我们将探讨使用 R 从 RMarkdown 文件生成.pdf 文件 1.生成方法 新建Rmarkdown…...
【超详细讲解】什么是序列化和反序列化?
目录 一、什么是序列化(Serialization)? 举个直观的例子 二、什么是反序列化(Deserialization)? 三、为什么需要序列化? 四、常见的序列化格式对比 五、序列化底层是怎么做的?…...
深入浅出JavaScript常见设计模式:从原理到实战(2)
深入浅出JavaScript常见设计模式:从原理到实战(2) 本文是深入浅出JavaScript常见设计模式:从原理到实战(1)的续集 设计模式是一种在特定情境下解决软件设计中常见问题的通用方案或模板。在特定的开发场景中使用特定的设计模式,可以提升代码质…...
MySQL 主从复制
数据的高可用性、读写分离以及数据备份是至关重要的需求。MySQL 作为一款广泛使用的开源关系型数据库,其主从复制功能为解决这些问题提供了有效的方案。本文将详细介绍 MySQL 主从复制的原理、搭建步骤以及实际应用。 一、MySQL 主从复制原理 1.1 基本概念 MySQL…...
小目标检测的集成融合论文阅读
摘要 小目标检测常因图像模糊和分辨率低而受到阻碍,这给小目标的精确检测和定位带来了重大挑战。此外,传统的特征提取方法往往难以捕捉到这些目标的有效表征,因为下采样和卷积操作会导致小目标细节的模糊化。为了解决这些问题,本研究提出了一种基于集成融合的方法,通过利…...
IP SSL证书常见问题:快速实现HTTPS加密
SSL证书作为实现HTTPS加密和身份验证的关键工具,不仅适用于域名,还能直接绑定IP地址,为IP通信提供安全保障。 一、什么是IP SSL证书? IP SSL证书(IP HTTPS证书)是一种专为IP地址设计的SSL/TLS证书…...
Scratch——第20课 辗转相除法/绳子算法
辗转相除法是用于求取最大公约数时需要用到的方法,它还有个名字称为绳子算法,这类题目只要理解辗转相处的原理即可拿下。 一、辗转相除法的基本原理 两个整数的最大公约数不变,当较大数减去较小数后,得到的差值与较小数的最大公…...
MYOJ_1349:(洛谷P3951)[NOIP 2017 提高组] 小凯的疑惑(数学公式套用,两步搞定代码)
提示 本题代码纯属数学的结晶,因此肥肠简单,但需要一定理解。 题目描述 小凯手中有两种面值的金币,两种面值均为正整数且彼此互素。每种金币小凯都有无数个。在不找零的情况下,仅凭这两种金币,有些物品他是无法准确支付…...
如何免费把PPT的页面输出为透明的图片-快速制作图新说汇报内容
0.序 经常有朋友问想把PPT中的内容输出为图片,但是PPT里面的officePlus还得付费才可以。不付费就带水印还不高清,关键是还不透明,如果需要透明就设置纯底色去PS里面抠图(可自动化),或者手动右键挨个输出。…...
操作系统——第四章(文件管理与文件的逻辑结构)
一、文件系统基础 1.文件的属性 文件名:由创建文件的用户决定文件名,主要是为了方便用户找到文件,同一目录下不允许有重名文件标识符:一个系统内的各文件标识符唯一,对用户来说毫无可读性。因此标识符只是操作系统用…...
剑指offer经典题目(七)
目录 动态规划 字符串相关 排序思想相关 链表相关 动态规划 题目1:输入一个长度为n的整型数组array,数组中的一个或连续多个整数组成一个子数组,子数组最小长度为1。求所有子数组的和的最大值。OJ地址 图示如下。 题目解析:…...
[RoarCTF 2019]Easy Calc 详解
[RoarCTF 2019]Easy Calc 1 ajax 是进行前后端交互的 但是我们发现一个waf 就是他提示的"calc.php?num"encodeURIComponent($("#content").val()) ?num 的值必须是数字审计一下 foreach 发现了num的限制但是eval是rce的标志所以我们首选的就是使用命令…...
AI日报 - 2025年04月29日
🌟 今日概览(60秒速览) ▎🤖 AGI突破 | 巨头CEO预测AGI时间线,5年内或达人类认知水平;Yann LeCun强调多模态训练重要性。 关于AGI定义和实现时间的讨论升温,对超越纯文本训练的需求成为共识。 ▎💼 商业动向…...
Kubernetes的错误信息处理
报错信息 E0428 13:18:25.531614 3193818 memcache.go:287] couldn’t get resource list for metrics.k8s.io/v1beta1: the server is currently unable to handle the request 以下是处理该 Kubernetes 指标服务报错的系统化解决方案: 错误诊断流程 # 1. 检查 …...
杰理-安卓通过map获取时间的时候,部分手机切换sbc和aac时候单耳无声音
杰理-安卓通过map获取时间的时候,部分手机切换sbc和aac时候单耳无声音 #if USER_SUPPORT_PROFILE_MAPif(tws_api_get_role()0){ //主机才获取,否则切换sbc 和 aac 的时候影响单耳无声音user_send_cmd_prepare(USER_CTRL_MAP_READ_TIME,0,NULL);} #endif…...
基于 Python 的实现:居民用电量数据分析与可视化
基于 Python 的实现:居民用电量数据分析与可视化 本文将介绍如何利用 Python 技术栈(包括 pymysql、pandas、matplotlib 等库)对居民用电量数据进行分析和可视化,以帮助我们更好地理解用电行为模式。 数据准备 在MySQL数据库中创建数据,,数据库表结构如下: date:记录…...
el-transfer穿梭框数据量过大的解决方案
一:背景 我们这个穿梭框获取的是项目的全量数据,在左边大概有5000条,自己测试了一下5000条数据的效果,发现异常的卡顿,本来打算像el-select一样去解决的(只显示一部分,在搜索的时候去全量搜索&a…...
【3D基础】深入解析OBJ与MTL文件格式:Blender导出模型示例及3D开发应用
引言 在3D模型开发和3D引擎加载过程中,OBJ格式是最基础、最常见的标准之一。即便在今天流行的GLTF、USDZ格式出现后,OBJ依然是建模软件和渲染引擎普遍支持的基本格式。 本文以Blender导出的立方体模型为例,详细讲解OBJ与MTL文件每一部分的含…...
Fiddler+Yakit实现手机流量抓包和小程序抓包
文章目录 一、小程序抓包1、配置Fiddler2、配置Yakit 二、手机流量抓包1、配置Fiddler2、手机连接电脑热点并配置代理服务器3、手机安装证书4、配置Yakit 三、总结 操作工具:Yakit Fiddler 一、小程序抓包 1、配置Fiddler 点击Tools—>Options进入如下配置页面…...
C++实时统计数据均值、方差和标准差
文章目录 1. 算法原理2. 类设计3. 完整代码实现4. 总结 本文采用了一种递推计算方法(Welford 算法)实时更新数据的均值、方差和标准差,其算法原理及实现如下。 1. 算法原理 Welford算法是由B.P.Welford于1962年提出的,用于计…...
【广州华锐视点】AR 远程协同:突破时空限制的利器
AR 远程协同,简单来说,就是利用增强现实(AR)技术,打破地理空间的束缚,让身处不同地方的人们能够在同一虚拟空间中进行实时协作。它就像是为人们搭建了一座无形的桥梁,将现实与虚拟紧密相连,让沟通和协作变得…...
【Docker】——在Docker工具上安装创建容器并完成项目部署
🎼个人主页:【Y小夜】 😎作者简介:一位双非学校的大三学生,编程爱好者, 专注于基础和实战分享,欢迎私信咨询! 🎆入门专栏:🎇【MySQL࿰…...
9. 使用Gazebo和Rviz显示机器人(包括运动控制,雷达,摄像头仿真以及显示)
概述:通过Gazebo和Rviz集成机器人,机器人的组件包括底盘,雷达,摄像头,可以在Gazebo中仿真和显示。并且能够订阅运动控制话题,雷达话题,摄像头话题在Rviz中仿真和显示。 1.新建功能包和导入依赖 …...
跨语言哈希一致性:C# 与 Java 的 MD5 之战?
在跨平台或异构系统集成的场景中,我们经常需要在不同的编程语言之间交换数据或验证数据一致性。MD5 作为一种广泛使用的哈希算法,就常常扮演着生成唯一标识或校验数据完整性的角色。然而,不少开发者可能会遇到这样一个令人困惑的问题…...
赋能航天教育:高校卫星仿真教学实验平台解决方案
随着全球航天事业的飞速发展,对高素质航天人才的需求日益增长。如何在高校阶段提前锻炼学生的航天工程实践能力,成为教育界的重要命题。作为领先的通信与网络技术供应商,IPLOOK基于自身在5G核心网、卫星通信及仿真平台领域的深…...
H指数(中等)
可以先对数组从小到大排序,然后数组后面往前遍历,计算h的值。 如果从后往前遍历,当前位置的数,如果大于h,就说明又找到了一个引用次数大于h的文献,h指数可以加一了。 class Solution {public int hIndex(…...
推荐 1 款 9.3k stars 的全景式开源数据分析与可视化工具
Orama 是一个开源的数据分析与可视化项目,由askorama团队开发和维护。该项目旨在为用户提供一套强大而易用的工具集,帮助用户轻松处理和理解大规模数据,通过创建交互式且引人入胜的数据可视化图表,揭示隐藏在数据背后的深层次洞察…...
无人船 | 图解基于LQR控制的路径跟踪算法(以全驱动无人艇WAMV为例)
目录 1 最优控制线性二次型问题2 LQR的价值迭代推导3 基于全驱动无人船动力学的LQR4 跟踪效果分析 1 最优控制线性二次型问题 最优控制理论是一种数学和工程领域的理论,旨在寻找如何使系统在给定约束条件下达到最佳性能的方法。它的基本思想是通过选择合适的控制输…...
检查IBM MQ SSL配置是否成功
使用 DISPLAY 命令检查任务是否已成功完成。 如果任务成功,那么生成的输出类似于以下示例中显示的输出。 从队列管理器 QM1,输入以下命令: DISPLAY CHS(QM1.TO.QM2) SSLPEER SSLCERTI 生成的输出类似于以下示例: DISPLAY CHSTATUS(QM1.TO.QM2) SSLPE…...
EasyRTC嵌入式音视频通信SDK智能安防与监控系统的全方位升级解决方案
一、方案背景 随着安全防范意识的提升以及物联网、人工智能技术的发展,智能安防与监控系统在各领域的应用愈发广泛。传统监控系统多以单向视频传输为主,缺乏实时交互能力。EasyRTC凭借其低延迟、高可靠的实时音视频通信技术,能为智能安防与…...
Meta 推出 WebSSL 模型:探索 AI 无语言视觉学习,纯图训练媲美 OpenAI CLIP
Web-SSL 探索了视觉自监督学习(SSL)在网络规模数据上的扩展潜力。通过调整模型大小和训练数据,我们证明了纯视觉模型可以与 CLIP 等语言监督方法相媲美,甚至超越它们,从而对 "语言监督是学习多模态建模所需的强大…...
node.js puppeteer 实践
puppeteer 介绍 Puppeteer 是 Google 推出的一个 Node.js 库,它通过 Chromium 提供了一个高效、简洁的 API,用于操作无头浏览器或具有 UI 的完整浏览器。它广泛应用于 自动化测试、数据抓取、页面性能分析和 UI 测试等领域。 Puppeteer 是一个 Node 库&…...
【现代深度学习技术】循环神经网络07:通过时间反向传播
【作者主页】Francek Chen 【专栏介绍】 ⌈ ⌈ ⌈PyTorch深度学习 ⌋ ⌋ ⌋ 深度学习 (DL, Deep Learning) 特指基于深层神经网络模型和方法的机器学习。它是在统计机器学习、人工神经网络等算法模型基础上,结合当代大数据和大算力的发展而发展出来的。深度学习最重…...
如何在idea中写spark程序
一、环境准备 1. 安装 IntelliJ IDEA: 下载并安装 IntelliJ IDEA(推荐使用 Community 版本,它已经支持 Scala 和 Spark 开发)。 官方下载地址:[JetBrains IntelliJ IDEA](https://www.jetbrains.com/idea/downlo…...
硬件加密+本地部署,大模型一体机如何打造AI安全护城河?
2025年,大模型技术加速渗透千行百业,但随之而来的安全风险也引发广泛关注。数据显示,近九成企业部署的大模型服务器存在“裸奔”隐患,数据泄露、模型篡改、算力劫持等问题频发。 在此背景下,大模型一体机凭借“开箱即…...
在另外一台可以科学下载的电脑用ollama下载模型后,怎么导入到另外一台服务器的ollama使用
环境: Win10专业版 Ubuntu20.04 问题描述: 在另外一台可以科学下载的电脑用ollama下载模型后,怎么导入到另外一台服务器的ollama使用,原电脑win10上的ollama下载的模型,复制到ubuntu20.04的ollama上推理 解决方案:…...
鼠标滚动字体缩放
在VsCode中编辑文件时,有时候发现Ctrl鼠标滚轮并不能缩放字体,下面是启用这个功能的方法。 第一步: 进入设置,可以从左下角按钮菜单进入,也可以使用【Ctrl,】。 第二步: 启用鼠标滚轮缩放功能 第三步&…...
什么是VR相机?VR相机的发展历史
VR相机:沉浸式体验的未来科技 VR相机,全称为虚拟现实相机,是专门用于捕捉和记录三维空间和场景的设备,能够拍摄360度全景照片和视频。通过模拟人的双眼视觉差异,利用多个镜头和传感器同时捕捉周围环境的图像ÿ…...
Java面试:Spring及Spring Cloud技术深度剖析
Spring及Spring Cloud技术深度剖析 前言 在Java开发领域,Spring框架一直是企业级应用开发的中流砥柱,而Spring Boot的出现更是极大地简化了Spring应用的开发过程。同时,Spring Cloud为构建分布式系统提供了强大的支持。本文将围绕Spring及S…...
论文阅读_Search-R1_大模型+搜索引擎
英文名称:Search-R1: Training LLMs to Reason and Leverage Search Engines with Reinforcement Learning 中文名称:Search-R1:训练大型语言模型进行推理并利用搜索引擎的强化学习 链接: http://arxiv.org/pdf/2503.09516v2 代码: https://g…...
零成本AI抠图终极指南:蓝耘元生代AIDC OS+ComfyUI实现商业级效果
引言:AI抠图革命已经到来 在数字内容创作爆炸式增长的今天,高质量的图像处理已成为刚需。无论是电商平台的商品展示、自媒体博主的封面设计,还是摄影爱好者的后期处理,抠图都是最基础也是最繁琐的工作之一。 传统抠图方式面临三…...
深入理解CSS3:Flex/Grid布局、动画与媒体查询实战指南
引言 在现代Web开发中,CSS3已经成为构建响应式、美观且高性能网站的核心技术。它不仅提供了更强大的布局系统(Flexbox和Grid),还引入了令人惊艳的动画效果和精准的媒体查询能力。本文将深入探讨这些关键技术,帮助您提…...
VLM-E2E:通过多模态驾驶员注意融合增强端到端自动驾驶——论文阅读
《VLM-E2E Enhancing End-to-End Autonomous Driving with Multimodal Driver Attention Fusion》2025年2月发表,来自香港科大广州分校、理想汽车和厦门大学的论文。 一、核心问题与动机 现有端到端(E2E)自动驾驶系统直接从传感器输入映射到…...
蓝牙BLE
1、简介 蓝牙BR/EDR和BLE是蓝牙技术的两个重要分支,它们各自具有独特的特点和应用场景。 1.1、蓝牙BR/EDR 蓝牙BR(Basic Rate) 定义:蓝牙技术的首个开发版本,采用高斯频移键控(GFSK)调制技术…...
在VS2022中使用Lua与c交互(二)
一、核心交互机制:Lua 虚拟栈 Lua 与 C 的交互通过一个 虚拟栈(Stack) 完成,所有数据传递、函数调用均通过此栈实现。栈的每个元素可以是任意 Lua 类型(如数字、字符串、表、函数等)。 栈的结构与…...
论文阅读_Citrus_在医学语言模型中利用专家认知路径以支持高级医疗决策
英文名称:Citrus: Leveraging Expert Cognitive Pathways in a Medical Language Model for Advanced Medical Decision Support 中文名称:Citrus:在医学语言模型中利用专家认知路径以支持高级医疗决策 链接: http://arxiv.org/pdf/2502.18…...
浅谈PCB传输线(一)
前言:浅谈传输线的类型,以及传输线的一些行为特性。 1.传输线的种类 2.互连线被视为传输线的场景 3.传输线的行为特性*** 1.传输线的种类 PCB 中的信号传输线通常有两种基本类型: 微带线和带状线。此外,还有第三种类型–共面线(没有参考平面…...
Spring-全面详解(学习总结)
一:概述 1.1 为什么学 解决了两个主要问题 1. 2 学什么 1.3 怎么学 二:系统架构 作用:web开发、微服务开发、分布式系统开发 容器:用于管理对象 AOP:面向切面编程(不惊动原始程序下对其进行加强) 事…...