当前位置: 首页 > news >正文

基于openlayers 开发vue地图组件

先看效果
在这里插入图片描述
在这里插入图片描述

主要功能如下:

  • 测量
  • 图源更换
  • 放大缩小
  • 地图添加点
  • hover点数据
  • 切换到地图位置;也设定层级
  • 2D3D切换,3D为cesium开发,
  • 技术交流可以加V:bloxed
    地图工具做了插槽,分为toolbar(左上角工具) 和mode(右下角功能区),对应mapTools.vue和mapMode.vue 文件
    上代码:
    commonmap.vue文件
<!--* @Author: shangyc* @Date: 2024-011-07 09:54:54* @LastEditors: shangyc* @LastEditTime: 2024-011-07 09:54:54* @Description: file content
-->
<template><div class="map-container h100 w100"><div class="mouseInfo" v-show="mouseInfo.scale"><span  class="btn-item">坐标:{{ mouseInfo.coords }}</span><span class="btn-item">比例尺:{{ mouseInfo.scale }}</span><span class="btn-item">视野:{{ mouseInfo.zoom }}</span></div><div id="map" class="map h100"></div><slot name="toolbar" ></slot><slot name="mode"></slot><!-- tooltip --><div ref="tooltip" class="tooltip" v-if="tooltipVisible"><el-row v-if="tooltipContents.length"><el-col v-for="item in tooltipContents" :key="item.value" @click="tooltipClick" class="content-col"><span>{{ item.name }}</span><span>{{ item.value }}</span><span>&nbsp;{{ item.unit ?? "" }}</span></el-col></el-row><el-row v-else><el-col class="content-col">暂无数据</el-col></el-row></div><!--end  --></div>
</template><script setup lang="ts">
import { onMounted, reactive, ref } from "vue";
import Map from "ol/Map";
import TileLayer from "ol/layer/Tile";
import View from "ol/View";
import { defaults as defaultControls } from "ol/control";import { Overlay } from "ol";
import { fromLonLat, get as getProjection, toLonLat } from "ol/proj";
import { Cluster, Vector as SourceVector, XYZ } from "ol/source";
import { Vector as LayerVector } from "ol/layer";
import GeoJSON from "ol/format/GeoJSON";
import { Fill, Icon, Stroke, Style, Text } from "ol/style";
import CircleStyle from "ol/style/Circle";
import { Polygon } from "ol/geom";
import LineString from "ol/geom/LineString";
import { getArea, getLength } from "ol/sphere";
import GeometryType from "ol/geom/GeometryType";
import { Draw } from "ol/interaction";
import { unByKey } from "ol/Observable";
import OverlayPositioning from "ol/OverlayPositioning";
import areaLabel from "/@/assets/map/areaLabel.png";import Mask from "ol-ext/filter/Mask";
import Crop from "ol-ext/filter/Crop";
import { getVectorContext } from "ol/render";const { VITE_APP_2DMAP_URL } = import.meta.env;
const tooltipVisible = ref<boolean>(false);
const props = defineProps({imageSource: {type: String,default: "img",},toolBox: {type: Boolean,default: true,},
});
const imgSource = ref<string>("yx");
const emit = defineEmits(["mapSingleClick"]); // 自定义事件 会回传也是point数据
const center:any = [];
// start地图以及图层显示
const map = ref<any>(null);
//鼠标信息
const mouseInfo = reactive<any>({coords: "",scale: "",zoom: "",
});
let vector: any;
const drawObj = ref<any>(null);
const helpTooltipElement = ref<any>(null);
const helpTooltip = ref<any>(null);
const measureTooltipElement = ref<any>(null);
const measureTooltip = ref<any>(null);
let timer = null;
let flashTimer = null;
const clickPoint = ref<any>();const tooltip = ref(null);
const tooltipContents = ref<any[]>([]);
//底图图源
const env = import.meta.env.VITE_APP_ENV;
const imgpublicUrl =  `${VITE_APP_2DMAP_URL}/yx/{z}/{x}/{-y}.png`;
const cvapublicUrl =  `${VITE_APP_2DMAP_URL}/dz/{z}/{x}/{-y}.png`;
const imgLayer = ref<any>(new TileLayer({source: new XYZ({// wrapX: true,url: imgpublicUrl}),visible: true})
);
const vecLayer = ref<any>(new TileLayer({source: new XYZ({url: cvapublicUrl,projection: getProjection("EPSG:3857"),// wrapX: true}),visible: true})
);// 用于存储事件监听器键的数组
const eventKeys = ref<any[]>([]);let start = new Date().getTime();
const disableMapEvent = ref<boolean>(false); // 关闭地图上面事件//地图操作事件
const zoomInOut = (number: any) => {if (map.value) {const view = map.value.getView();const zoom = view.getZoom();view.setZoom(zoom + number);}
};
const toCenter = (coordinates?: any[]) => {if (map.value) {map.value.getView().animate({center: fromLonLat(coordinates ?? center),duration: 2500, // 动画持续时间,单位为毫秒(这里设置为2秒)});}
};
const points: any = {type: "FeatureCollection",features: [],
};
//查询到站点添加到地图
const addStation = (stations: any[]) => {mapInteractionSource.value.clear();map.value?.getOverlays().clear();points.features = [];stations.forEach((point, index) => {point.lng &&point.lat &&points.features.push({type: "Feature",geometry: {type: "Point",coordinates: fromLonLat([point.lng, point.lat]),},properties: {id: index + point.stcd,name: point.stnm,type: point.sttp,info: point,icon: point.icon,},id: index + point.stcd,});});new GeoJSON({ featureProjection: "EPSG:4326" }).readFeatures({type: "FeatureCollection",features: [...points.features],}).forEach((item: any) => {mapInteractionSource.value.addFeature(item);});
};
const mapInteractionSource = ref<any>(new SourceVector({ wrapX: false }));
const imagSourceClick = (type: any) => {imgSource.value = type;if (type == "yx") {imgLayer.value.setVisible(true);vecLayer.value.setVisible(false);} else {imgLayer.value.setVisible(false);vecLayer.value.setVisible(true);}
};
const initMap = () => {if (map.value) {map.value.setTarget(null);}// 聚合var cluster = new Cluster({source: mapInteractionSource.value,distance: 30,});const cluster1Style = (feature: any, resolution: any) => {const { name, icon } = feature.get("features")[0].getProperties();return new Style({//把点的样式换成ICON图标fill: new Fill({//填充颜色color: "rgba(37,241,239,0.2)",}),//图形样式,主要适用于点样式image: new Icon({opacity: 1,scale: 0.5,src: icon ?? areaLabel,}),text: new Text({// 字体与大小font: "bold 13px Microsoft YaHei",//文字填充色fill: new Fill({color: "#fff",}),// 显示文本,数字需要转换为文本string类型!text: name,offsetY: -35,}),});};map.value = new Map({layers: [vecLayer.value,imgLayer.value,new LayerVector({source: cluster,style: cluster1Style,}),],keyboardEventTarget: document,target: "map", // 对应页面里 id 为 map 的元素view: new View({center: fromLonLat([110.105931,22.422299]),zoom: 15,}),//控件初始默认不显示controls: defaultControls({attribution: false,zoom: false,rotate: false,}).extend([]),});const tdtStyle = new Style({fill: new Fill({color: "black",}),});imgLayer.value.on("postrender", (e: any) => {const vectorContext = getVectorContext(e);e.context.globalCompositeOperation = "destination-in";e.context.globalCompositeOperation = "source-over";});map.value.on("pointermove", handleMouseMove);map.value.on("pointermove", (evt: any) => {const pixel = map?.value?.getEventPixel(evt.originalEvent);const hit = map?.value?.hasFeatureAtPixel(pixel);map.value.forEachFeatureAtPixel(evt.pixel, function (feature: any) {let geometry: any = null;try {geometry = JSON.parse(new GeoJSON().writeFeature(feature));} catch (error) {geometry = feature;}if (geometry.geometry.type == "Point") {const coordinate = geometry.geometry.coordinates;const data =geometry.properties?.features[0]?.values_?.info?.data || [];if (data.length) {clickPoint.value = geometry.properties?.features[0]?.values_?.info;tooltipContents.value = data;tooltipVisible.value = true;try {map.value.addOverlay(new Overlay({position: coordinate,offset: [0, 0],element: tooltip.value,stopEvent: true,}));} catch (error) {console.warn(error);}}}});});map.value.on("singleclick", (evt: any) => {var pixel = map?.value?.getEventPixel(evt.originalEvent);var hit = map?.value?.hasFeatureAtPixel(pixel);map.value.forEachFeatureAtPixel(evt.pixel, function (feature: any) {let geometry: any = null;try {geometry = JSON.parse(new GeoJSON().writeFeature(feature));} catch (error) {geometry = feature;}if (geometry.geometry.type == "Point") {const coordinate = geometry.geometry.coordinates;mapSingleClick(geometry.properties?.features[0]?.values_?.info);const data =geometry.properties?.features[0]?.values_?.info?.data || [];if (data.length) {clickPoint.value = geometry.properties?.features[0]?.values_?.info;tooltipClick();}}});});
};
const mapSingleClick = (point: any) => {emit("mapSingleClick", point);
};
const handleMouseMove = (event: any) => {const coordinate = event.coordinate;const lonLat = toLonLat(map.value?.getCoordinateFromPixel(event.pixel));const scale = map.value?.getView().getResolution(); // 近似计算比例尺(米)const zoom = map.value?.getView().getZoom();mouseInfo.coords = ` ${lonLat[0].toFixed(5)},  ${lonLat[1].toFixed(5)}`;mouseInfo.scale = `1:${ Math.round(scale * 10000) / 100} m`;mouseInfo.zoom = `${zoom.toFixed(0)}`;
};
/*** 绘画* @param measureType line*/
const draw = (measureType: any) => {// 移除所有事件监听器// eventKeys.value.forEach(key => unByKey(key));// eventKeys.value = []; // 清空数组,以便后续可能重新添加事件if (disableMapEvent.value) {return ElMessage.warning("请先结束之前的绘制");}drawObj.value && map.value.removeInteraction(drawObj.value);const source = new SourceVector();// if (!vector) {vector = new LayerVector({name: "drawLayer",zIndex: 10000,source: source,style: new Style({fill: new Fill({color: "rgba(255, 255, 255, 0.2)",}),stroke: new Stroke({color: "#ffcc33",width: 2,}),image: new CircleStyle({radius: 7,fill: new Fill({color: "#ffcc33",}),}),}),});map.value.addLayer(vector);// }/*** Currently drawn feature.* @type {module:ol/Feature~Feature}*/let sketch: any = null;/*** Message to show when the user is drawing a polygon.* @type {string}*/const continuePolygonMsg = "继续点击绘制多边形";/*** Message to show when the user is drawing a line.* @type {string}*/const continueLineMsg = "继续点击绘制线";/*** Handle pointer move.* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt The event.*/const pointerMoveHandler = (evt: any) => {if (evt.dragging) {return;}/** @type {string} */let helpMsg = "请点击开始绘制";if (sketch) {const geom = sketch.getGeometry();if (geom instanceof Polygon) {helpMsg = continuePolygonMsg;} else if (geom instanceof LineString) {helpMsg = continueLineMsg;}}helpTooltipElement.value.innerHTML = `<div style="color:#fff;background-color: rgba(0,0,0,0.6);padding: 4px;border-radius: 6px">${helpMsg}</div>`;helpTooltip.value.setPosition(evt.coordinate);helpTooltipElement.value?.lassList?.remove("hidden");};map.value.on("pointermove", pointerMoveHandler);map.value.getViewport().addEventListener("mouseout", function () {helpTooltipElement.value?.classList?.add("hidden");});const formatLength = (line: any) => {const sourceProj = map.value.getView().getProjection();// @ts-ignoreconst length = getLength(line, { projection: sourceProj });let output;if (length > 100) {output = Math.round((length / 1000) * 100) / 100 + " " + "km";} else {output = Math.round(length * 100) / 100 + " " + "m";}return output;};const formatArea = (polygon: any) => {const area = getArea(polygon, {projection: "EPSG:4326",});let output;if (area > 10000) {output =Math.round((area / 1000000) * 100) / 100 + " " + "km<sup>2</sup>";} else {output = Math.round(area * 100) / 100 + " " + "m<sup>2</sup>";}return output;};const addInteraction = () => {const type =measureType == "area" ? GeometryType.POLYGON : GeometryType.LINE_STRING;drawObj.value = new Draw({source: source,type: type,// condition: mouseOnly,// freehandCondition: noModifierKeys,style: new Style({fill: new Fill({color: "rgba(255, 255, 255, 0.2)",}),stroke: new Stroke({color: "red",lineDash: [10, 10],width: 2,}),image: new CircleStyle({radius: 5,stroke: new Stroke({color: "red",}),fill: new Fill({color: "rgba(255, 255, 255, 0.2)",}),}),}),});map.value.addInteraction(drawObj.value);createHelpTooltip();let listener: any;drawObj.value.on("drawstart", function (evt: any) {createMeasureTooltip();disableMapEvent.value = true;// set sketchsketch = evt.feature;/** @type {module:ol/coordinate~Coordinate|undefined} */let tooltipCoord: any;listener = sketch.getGeometry()?.on("change", function (evt: any) {const geom = evt.target;let output = "";if (geom instanceof Polygon) {output = formatArea(geom);tooltipCoord = geom.getInteriorPoint().getCoordinates();} else if (geom instanceof LineString) {output = formatLength(geom);tooltipCoord = geom.getLastCoordinate();}measureTooltipElement.value.innerHTML = output;measureTooltip.value.setPosition(tooltipCoord);});});drawObj.value.on("drawend", function () {disableMapEvent.value = false;measureTooltip.value.setOffset([0, -7]);// unset sketchsketch.dispose();// unset tooltip so that a new one can be createdmeasureTooltipElement.value = document.createElement("div");listener && unByKey(listener);});};const createHelpTooltip = () => {helpTooltipElement.value?.parentNode?.removeChild(helpTooltipElement.value);helpTooltipElement.value = document.createElement("div");helpTooltipElement.value.className = "tooltip hidden";helpTooltip.value = new Overlay({id: "helpTooltip",element: helpTooltipElement.value,offset: [15, 0],zIndex: 10000,positioning: OverlayPositioning.CENTER_LEFT,});map.value.addOverlay(helpTooltip.value);};const createMeasureTooltip = () => {// measureTooltipElement?.parentNode?.removeChild(measureTooltipElement);measureTooltipElement.value = document.createElement("div");measureTooltipElement.value.className = "ol-tooltip ol-tooltip-measure";// measureTooltipElement.setAttribute('class', comStyle['ol-tooltip-measure']);measureTooltip.value = new Overlay({oId: "measureTooltip",element: measureTooltipElement.value,offset: [0, -15],zIndex: 10000,positioning: OverlayPositioning.BOTTOM_CENTER,});map.value.addOverlay(measureTooltip.value);//@ts-ignorewindow["measureTooltip"] = measureTooltip.value;};addInteraction();
};
/*** 清除*/
const clear = () => {disableMapEvent.value = false;drawObj.value && map.value.removeInteraction(drawObj.value);vector && map.value.removeLayer(vector);const overlays = map.value.getOverlays().getArray();if (overlays) {overlays.filter((o: any) =>o &&(o.options?.oId === "measureTooltip" || o.getId() === "helpTooltip")).forEach(function (o: any) {map.value.removeOverlay(o);});}const layers = map.value.getLayers();if (layers) {layers.getArray().filter((o: any) => o?.get("name") === "drawLayer").forEach(function (o: any) {o.getSource().clear();map.value.removeLayer(o);});}drawObj.value = null;
};
const tooltipClick = () => {
};
onMounted(() => {initMap();
});
defineExpose({map, //地图/**@desc 添加站点 @param [{stcd:0000,stnm:"xxxx",sttp:'',icon:'xxxx',lng:number,lat:number}data:[{name:'xx',value:'',unit:''}]  //data地图鼠标悬浮展示内容}]*/addStation,  /*** 缩放 地图* @param {number} zoom 缩放级别*/zoomInOut, /*** 地图中心点* @param {number} center 地图中心点参数格式 [lng,lat]* @param {number} zoom 缩放级别 15*/ toCenter,  /*** 清除地图分析*/clear,/*** 地图分析* @param {string} type 分析类型  'area' 面积  'line' 距离*/draw,  /*** 图源切换事件* @param {string} type 图层类型*/imagSourceClick});
</script><style scoped lang="less">
.map-container {height: 100%;position: relative;background: url("/@/assets/map/mapbg.png");.btn {position: absolute;z-index: 10;top: 20px;left: 10px;.btn-item {background-color: #139eb1;margin: 0px 10px;color: #fff;border: none;height: 30px;border-radius: 4px 4px 4px 4px;}}.mouseInfo {position: absolute;z-index: 10;left: 40%;bottom: 20px;pointer-events: none;.btn-item {margin: 0px 10px;color: #fff;border: none;height: 30px;border-radius: 4px 4px 4px 4px;}}.map {height: 100%;}.tooltip {position: absolute;width: 250px;background: rgba(255, 255, 255, 0.9);box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.25);border-radius: 4px 4px 4px 4px;padding: 5px 12px;border-top: 4px solid #0fe2ff;.content-col {margin-top: 8px;font-family:PingFang SC,PingFang SC;font-weight: 400;font-size: 14px;color: #666666;line-height: 16px;text-align: left;font-style: normal;text-transform: none;border-radius: 4px 4px 0px 0px;}}:deep(.ant-popover, .ant-popover-content) {border-radius: 10px;}
}.tyxz {border-radius: 10px;.tybox {cursor: pointer;padding-left: 5px;padding-top: 5px;}.desc {text-align: center;font-size: 12px;margin-top: 5px;}.activeimg {background: #139eb1;color: #fff;}
}
</style>

maptools.vue 文件

<template><div><el-popover  placement="top" :width="160"><template #reference><el-button  size="small" type="primary"  v-show="mapType=='2D'" > 图源选择 </el-button></template><el-row :gutter="20" style="width: 280px" class="tyxz"><el-col :span="12" :class="'tybox ' + (imgSource == 'dz' ? ' activeimg' : '')"@click="imagSourceClick('dz')"><img :src="dzs" alt="" width="120" height="120" srcset="" /><p class="desc">电子</p></el-col><el-col :span="12" :class="'tybox ' + (imgSource == 'yx' ? ' activeimg' : '')"@click="imagSourceClick('yx')"><img :src="yxs" alt="" srcset="" width="120" height="120" /><p class="desc">影像</p>    </el-col></el-row></el-popover><el-button size="small" type="primary" v-for="item in tools" v-show="item.type.indexOf(mapType) > -1" @click="item.click" :key="item.id">{{ item.name }}</el-button></div>
</template>
<script lang="ts" setup>
import dzs from "/@/assets/map/dz.png";
import yxs from "/@/assets/map/yx.png";
const props = defineProps({map:Object,mapType:{type:String,default:'3D'}
})
const mapType = ref(props.mapType);
const tools = [{id:1,name:'点位',type:'3D',click:()=>{measurePoint()}},{id:2,name:'距离',type:'2D,3D',click:()=>{measureLine()}},{id:2,name:'高度',type:'3D',click:()=>{measureHeight()}},{id:3,name:'面积',type:'2D,3D',click:()=>{measureArea()}},// {id:6,name:"挖坑",type:'3D',click:()=>{console.log('点击了')}},{id:7,name:"体积",type:'3D',click:()=>{measureVolume()}},{id:8,name:"清除测量",type:'2D,3D',click:()=>{clear()}}]
const imgSource = ref<string>("yx");
const imagSourceClick = (type:any) => {imgSource.value = type;props.map?.imagSourceClick(type)
};
const measurePoint = () => {props.map?.draw('point');
}
const measureHeight = () => {props.map?.draw('height');
}
const measureLine = () => {props.map?.draw('line');
}const measureArea = () => {props.map?.draw('area');
}
const measureVolume = () => {props.map?.draw('volume');
}
const clear = () => {props.map?.clear();
}
</script>
<style scoped lang="scss">
.tyxz {border-radius: 10px;.tybox {cursor: pointer;padding-left: 5px;padding-top: 5px;}.desc {text-align: center;font-size: 12px;margin-top: 5px;}.activeimg {background: #139eb1;color: #fff;}
}
</style>

mapMode.vue文件

<template><div class="map-mode"><el-icon class="icon" @click="toCenter"><Promotion /></el-icon><el-icon  class="icon" @click="zoomIn"><CirclePlusFilled /></el-icon><el-icon  class="icon" @click="zoomOut"><RemoveFilled /></el-icon><span  v-if="mapType==='3D'" class="icon D23" @click="changeMapType('2D')">2D</span><span v-if="mapType==='2D'" class="icon D23" @click="changeMapType('3D')">3D</span></div>
</template>
<script lang="ts" setup>
const props = defineProps({map:Object,mapType:{type:String,default:'2D'}
})
const mapType = ref(props.mapType);
const emit = defineEmits(['changeMapType'])
const changeMapType = (type:string) =>{mapType.value = type;emit('changeMapType',type)
}
const  zoomIn = () =>{props.map?.zoomInOut(0.5);
}
const zoomOut = () =>{props.map?.zoomInOut(-0.5);
}
const toCenter = () =>{props.map?.toCenter([110.105931,22.422299],16);
}
</script>
<style scoped lang="scss">
.map-mode{display: flex;flex-direction: column;align-items: center;background-color: rgba(31,60,113,.66);padding: 5px;border-radius: 5px;.icon{font-size: 20px;cursor: pointer;margin:10px 0px;color: #00cdff;font-weight: bold;}.D23{font-size: 15px;}
}
</style>```

相关文章:

基于openlayers 开发vue地图组件

先看效果 主要功能如下&#xff1a; 测量图源更换放大缩小地图添加点hover点数据切换到地图位置&#xff1b;也设定层级2D3D切换&#xff0c;3D为cesium开发&#xff0c;技术交流可以加V&#xff1a;bloxed 地图工具做了插槽&#xff0c;分为toolbar&#xff08;左上角工具…...

音视频入门基础:AAC专题(13)——FFmpeg源码中,获取ADTS格式的AAC裸流音频信息的实现

音视频入门基础&#xff1a;AAC专题系列文章&#xff1a; 音视频入门基础&#xff1a;AAC专题&#xff08;1&#xff09;——AAC官方文档下载 音视频入门基础&#xff1a;AAC专题&#xff08;2&#xff09;——使用FFmpeg命令生成AAC裸流文件 音视频入门基础&#xff1a;AAC…...

【C++】B2069 求分数序列和题目解析与优化详解

博客主页&#xff1a; [小ᶻ☡꙳ᵃⁱᵍᶜ꙳] 本文专栏: C 文章目录 &#x1f4af;前言&#x1f4af;题目描述输入格式输出格式输入输出样例输入&#xff1a;输出&#xff1a; &#x1f4af;解题思路分析题目解题步骤 &#x1f4af;代码实现我的代码实现实现特点 老师的代码…...

4.FPGA如何实现设计

在前面分别引入了&#xff0c;LUT的知识&#xff0c;全局时钟网络&#xff0c;以及FPGA内部的资源。 LUT的知识&#xff1a; 在FPGA设计中实现的逻辑运算在不借用其他的硬核的基础上都是在LUT中通过查表的方式进行完成的&#xff0c;比如实现的c a & b;就是将a&b的所…...

SO-CNN-LSTM-MATT蛇群算法优化注意力机制深度学习多特征分类预测

SO-CNN-LSTM-MATT蛇群算法优化注意力机制深度学习多特征分类预测&#xff08;多输入单输出&#xff09; 目录 SO-CNN-LSTM-MATT蛇群算法优化注意力机制深度学习多特征分类预测&#xff08;多输入单输出&#xff09;分类效果基本描述程序设计参考资料 分类效果 基本描述 1.Matl…...

大模型-Ollama使用相关的笔记

大模型-Ollama使用相关的笔记 解决Ollama外网访问问题&#xff08;配置ollama跨域访问&#xff09;Postman请求样例 解决Ollama外网访问问题&#xff08;配置ollama跨域访问&#xff09; 安装Ollama完毕后&#xff0c; /etc/systemd/system/ollama.service进行如下修改&#…...

OpenCV计算机视觉 02 图片修改 图像运算 边缘填充 阈值处理

目录 图片修改&#xff08;打码、组合、缩放&#xff09; 图像运算 边缘填充 ​阈值处理 上一篇文章&#xff1a; OpenCV计算机视觉 01 图像与视频的读取操作&颜色通道 图片修改&#xff08;打码、组合、缩放&#xff09; # 图片打码 import numpy as np a cv2.imre…...

langchain使用FewShotPromptTemplate出现KeyError的解决方案

大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作的方式对所学的…...

tryhackme-Cyber Security 101-Linux Shells(linux命令框)

目的&#xff1a;了解脚本和不同类型的 Linux shell。 任务1&#xff1a;Introduction to Linux Shells&#xff08;Linux Shell 简介&#xff09; 作为操作系统的常规用户&#xff0c;我们都广泛使用图形用户界面 &#xff08;GUI&#xff09; 来执行大多数操作。只需点击几…...

亚远景-ISO 21434标准涵盖了哪些方面?

ISO 21434标准《道路车辆—网络安全工程》全面涵盖了汽车网络安全领域&#xff0c;其目的是确保汽车电子系统在整个产品生命周期中的网络安全性能。具体来说&#xff0c;该标准包括以下几个方面&#xff1a; 1. 术语和定义 &#xff1a;提供汽车网络安全相关的术语、概念和定义…...

第3章 集合与关系

2024年12月24日一稿 2024年12月26日二稿 &#x1f430;3.1 集合的概念和表示法 &#x1f998;3.1.1 集合的表示 &#x1f998;3.1.2 基本概念 &#x1f430;3.2 集合的运算 &#x1f998;3.2.1 集合的基本运算 &#x1f998;3.2.2 有穷计数集 &#x1f998;3.2.3 广义交和广义…...

【vmware】|设置共享文件夹

目的: 虚拟机中设置共享文件夹&#xff0c;本地物理机中可以搜到该共享文件夹 1、虚拟机&#xff1a; 设置共享文件夹 右键属性-共享页码进行下列设置 点击网络和共享中心&#xff0c;检查下列选项 二、在本地物理机中启用网络发现&#xff1a; 此时&#xff0c;刷新网络…...

Log4j1.27配置日志输出级别不起效

起因&#xff1a;构建独立版本debezuim使用时&#xff0c;日志一直打印debug信息。 原因&#xff1a;包冲突问题&#xff0c;进行排包操作。 参考log4j日志级别配置完成后不生效 系统一直打印debug日志_log4j不起作用-CSDN博客 1、application.properties logging.configc…...

计算机图形学知识点汇总

一、计算机图形学定义与内容 1.图形 图形分为“图”和“形”两部分。 其中&#xff0c;“形”指形体或形状&#xff0c;存在于客观世界和虚拟世界&#xff0c;它的本质是“表示”&#xff1b;而图则是包含几何信息与属性信息的点、线等基本图元构成的画面&#xff0c;用于表达…...

详解下c语言中struct和union的对齐规则

接触过c语言的同学应该都知道字节对齐。有些时候我们很容易弄错字节对齐的方式&#xff0c;特别是涉及到struct&#xff08;结构体&#xff09;和union&#xff08;联合体&#xff09;时。今天我们通过详细例子来说明下struct和union的对齐规则&#xff0c;以便了解各种struct和…...

ubuntu安装sublime安装与免费使用

1. ubuntu安装sublime 参考官网: Linux Package Manager Repositories 2. 破解过程 打开如下网址,打开/opt/sublime_text/sublime_text https://hexed.it/ 3. 替换在hexed打开的文件中查找并替换: 4180激活方法 使用二进制编辑器 8079 0500 0f94 c2替换为 c641 05…...

攻防世界 cookie

开启场景 Cookie&#xff08;HTTP cookie&#xff09;是一种存储在用户计算机上的小型文本文件。它由网站通过用户的浏览器在用户访问网站时创建&#xff0c;并存储一些用于跟踪和识别用户的信息。Cookie 主要用于在网站和浏览器之间传递数据&#xff0c;以便网站可以根据用户的…...

深度学习笔记1:神经网络与模型训练过程

参考博客&#xff1a;PyTorch深度学习实战&#xff08;1&#xff09;——神经网络与模型训练过程详解_pytorch 实战-CSDN博客 人工神经网络 ANN&#xff1a;张量及数学运算的集合&#xff0c;排列方式近似于松散的人脑神经元排列 组成 1&#xff09;输入层 2&#xff09;隐…...

什么是 DevOps 自动化?

DevOps 自动化是一种现代软件开发方法&#xff0c;它使用工具和流程来自动化任务并简化工作流程。它将开发人员、IT 运营和安全团队聚集在一起&#xff0c;帮助他们有效协作并交付可靠的软件。借助 DevOps 自动化&#xff0c;组织能够处理重复性任务、优化流程并更快地将应用程…...

使用 Python 操作 MySQL 数据库的实用工具类:MySQLHandler

操作数据库是非常常见的需求&#xff0c;使用 Python 和 pymysql 库封装一个通用的 MySQL 数据库操作工具类&#xff0c;并通过示例演示如何使用这个工具类高效地管理数据库。 工具类的核心代码解析 MySQLHandler 类简介 MySQLHandler 是一个 Python 类&#xff0c;用于简化…...

[2025CVPR]DeepVideo-R1:基于难度感知回归GRPO的视频强化微调框架详解

突破视频大语言模型推理瓶颈,在多个视频基准上实现SOTA性能 一、核心问题与创新亮点 1.1 GRPO在视频任务中的两大挑战 ​安全措施依赖问题​ GRPO使用min和clip函数限制策略更新幅度,导致: 梯度抑制:当新旧策略差异过大时梯度消失收敛困难:策略无法充分优化# 传统GRPO的梯…...

CentOS下的分布式内存计算Spark环境部署

一、Spark 核心架构与应用场景 1.1 分布式计算引擎的核心优势 Spark 是基于内存的分布式计算框架&#xff0c;相比 MapReduce 具有以下核心优势&#xff1a; 内存计算&#xff1a;数据可常驻内存&#xff0c;迭代计算性能提升 10-100 倍&#xff08;文档段落&#xff1a;3-79…...

【项目实战】通过多模态+LangGraph实现PPT生成助手

PPT自动生成系统 基于LangGraph的PPT自动生成系统&#xff0c;可以将Markdown文档自动转换为PPT演示文稿。 功能特点 Markdown解析&#xff1a;自动解析Markdown文档结构PPT模板分析&#xff1a;分析PPT模板的布局和风格智能布局决策&#xff1a;匹配内容与合适的PPT布局自动…...

高等数学(下)题型笔记(八)空间解析几何与向量代数

目录 0 前言 1 向量的点乘 1.1 基本公式 1.2 例题 2 向量的叉乘 2.1 基础知识 2.2 例题 3 空间平面方程 3.1 基础知识 3.2 例题 4 空间直线方程 4.1 基础知识 4.2 例题 5 旋转曲面及其方程 5.1 基础知识 5.2 例题 6 空间曲面的法线与切平面 6.1 基础知识 6.2…...

多模态大语言模型arxiv论文略读(108)

CROME: Cross-Modal Adapters for Efficient Multimodal LLM ➡️ 论文标题&#xff1a;CROME: Cross-Modal Adapters for Efficient Multimodal LLM ➡️ 论文作者&#xff1a;Sayna Ebrahimi, Sercan O. Arik, Tejas Nama, Tomas Pfister ➡️ 研究机构: Google Cloud AI Re…...

dify打造数据可视化图表

一、概述 在日常工作和学习中&#xff0c;我们经常需要和数据打交道。无论是分析报告、项目展示&#xff0c;还是简单的数据洞察&#xff0c;一个清晰直观的图表&#xff0c;往往能胜过千言万语。 一款能让数据可视化变得超级简单的 MCP Server&#xff0c;由蚂蚁集团 AntV 团队…...

关键领域软件测试的突围之路:如何破解安全与效率的平衡难题

在数字化浪潮席卷全球的今天&#xff0c;软件系统已成为国家关键领域的核心战斗力。不同于普通商业软件&#xff0c;这些承载着国家安全使命的软件系统面临着前所未有的质量挑战——如何在确保绝对安全的前提下&#xff0c;实现高效测试与快速迭代&#xff1f;这一命题正考验着…...

九天毕昇深度学习平台 | 如何安装库?

pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple --user 举个例子&#xff1a; 报错 ModuleNotFoundError: No module named torch 那么我需要安装 torch pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple --user pip install 库名&#x…...

Java毕业设计:WML信息查询与后端信息发布系统开发

JAVAWML信息查询与后端信息发布系统实现 一、系统概述 本系统基于Java和WML(无线标记语言)技术开发&#xff0c;实现了移动设备上的信息查询与后端信息发布功能。系统采用B/S架构&#xff0c;服务器端使用Java Servlet处理请求&#xff0c;数据库采用MySQL存储信息&#xff0…...

力扣热题100 k个一组反转链表题解

题目: 代码: func reverseKGroup(head *ListNode, k int) *ListNode {cur : headfor i : 0; i < k; i {if cur nil {return head}cur cur.Next}newHead : reverse(head, cur)head.Next reverseKGroup(cur, k)return newHead }func reverse(start, end *ListNode) *ListN…...