Java解析dxf并利用openlayer渲染图层矢量切图

java读取CAD(dxf)文件(获取layer,block,entity) 首先需要引入kabeja这个包 直接上代码: package parse; import java.awt.Polygon; import java.io.File; import java.io.FileInputStream; import java.util.Collections; import java.util.HashSet; import java.util.List; impo... 阅读详情

数据库用的pg

pom引用(我自己是搭建的maven私服):

   <dependency>
        <groupId>org.kabeja</groupId>
        <artifactId>kabeja</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.kabeja</groupId>
        <artifactId>kabeja-svg</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>

链接:https://pan.baidu.com/s/1LSk9IKS1w0uL5SmUU3FCew
提取码:0b1d
–kabeja离线包下载地址

解析dxf如下:


```java
@Override
	public Object uploadDxf(MultipartFile file) {
		try {
			Parser dxfParser = ParserBuilder.createDefaultParser();
			dxfParser.parse(file.getInputStream(), "UTF-8");
			DXFDocument doc = dxfParser.getDocument();

			Bounds bounds = doc.getBounds();
			VectorBox box = new VectorBox();
			//包围盒必须是正方形否则进行4096切分是会拉伸变形
			Double subX = bounds.getMaximumX()-bounds.getMinimumX();
			Double subY = bounds.getMaximumY()-bounds.getMinimumY();
			if(subY>subX){
				Double minX = (bounds.getMinimumX()+subX/2)-subY/2;
				Double maxX = (bounds.getMaximumX()-subX/2)+subY/2;
				box.setxMin(minX);
				box.setyMin(bounds.getMinimumY());
				box.setxMax(maxX);
				box.setyMax(bounds.getMaximumY());
			}else{
				Double minY = (bounds.getMinimumY()+subY/2)-subX/2;
				Double maxY = (bounds.getMaximumY()-subY/2)+subX/2;
				box.setxMin(bounds.getMinimumX());
				box.setyMin(minY);
				box.setxMax(bounds.getMaximumX());
				box.setyMax(maxY);
			}
			vectorBoxService.save(box);
			Iterator<DXFLayer> dxfLayerIterator =  doc.getDXFLayerIterator();
			for (Iterator<DXFLayer> it = dxfLayerIterator; it.hasNext(); ) {
				DXFLayer dxfLayer = it.next();
				VectorLayer vectorLayer = new VectorLayer();
				vectorLayer.setName(dxfLayer.getName());
				vectorLayerService.save(vectorLayer);
			}
			List<VectorLayer> vectorLayers = vectorLayerService.list();

			Map<String,VectorLayer> vectorLayerMap = vectorLayers.stream().collect(Collectors.toMap(VectorLayer::getName, e -> e));
			List<DXFEntity> dxfEntities = DXFUtil.getDXFEntities(doc);
			List<VectorTile> vectorTiles = new ArrayList<>();
			for (DXFEntity d : dxfEntities) {
				if (d instanceof DXFLine) {
				    //直线
					DXFLine line = (DXFLine) d;
					VectorTile vectorTile = new VectorTile();
					vectorTile.setName(line.getLayerName());
					String coordinateWkt = "LINESTRING(" + line.getStartPoint().getX() + " " + line.getStartPoint().getY() + "," +
							line.getEndPoint().getX() + " " + line.getEndPoint().getY() +
							")";
					vectorTile.setGeom(coordinateWkt);
					vectorTile.setColor(DXFUtil.getColor(line.getColor()));
					vectorTile.setType("LINESTRING");
					vectorTile.setLineWidth(line.getLineWeight());
					vectorTile.setLayerId(vectorLayerMap.get(line.getLayerName()).getId());
					vectorTiles.add(vectorTile);
				}
				if (d instanceof DXFArc) {
				    //曲线
					DXFArc arc = (DXFArc) d;
					VectorTile vectorTile = new VectorTile();
					vectorTile.setName(arc.getLayerName());
					Point middlePoint = arc.getPointAt(arc.getStartAngle()+arc.getTotalAngle()/2);
					String coordinateWkt = "CIRCULARSTRING(" + arc.getStartPoint().getX() + " " + arc.getStartPoint().getY() + "," +
							middlePoint.getX() + " " + middlePoint.getY() + " "  + "," +
							arc.getEndPoint().getX() + " " + arc.getEndPoint().getY() + " " +
							")";
					vectorTile.setGeom(coordinateWkt);
					vectorTile.setColor(DXFUtil.getColor(arc.getColor()));
					vectorTile.setType("CIRCULARSTRING");
					vectorTile.setLineWidth(arc.getLineWeight());
					vectorTile.setLayerId(vectorLayerMap.get(arc.getLayerName()).getId());
					vectorTiles.add(vectorTile);
				}
				if(d instanceof DXFCircle){
				    //圆或半圆
					DXFCircle circle = (DXFCircle) d;
					VectorTile vectorTile = new VectorTile();
					vectorTile.setName(circle.getLayerName());
					Point startPoint = circle.getPointAt(0);
					Point topPoint = circle.getPointAt(90);
					Point farPoint = circle.getPointAt(180);
					Point bottomPoint = circle.getPointAt(270);
					Point endPoint = circle.getPointAt(360);
					String coordinateWkt = "CIRCULARSTRING(" + startPoint.getX() + " " + startPoint.getY() + "," +
							topPoint.getX() + " " + topPoint.getY() + " "  + "," +
							farPoint.getX() + " " + farPoint.getY() + " "  + "," +
							bottomPoint.getX() + " " + bottomPoint.getY() + " "  + "," +
							endPoint.getX() + " " + endPoint.getY() + " " +
							")";
					vectorTile.setGeom(coordinateWkt);
					vectorTile.setColor(DXFUtil.getColor(circle.getColor()));
					vectorTile.setType("CIRCLE");
					vectorTile.setLineWidth(circle.getLineWeight());
					vectorTile.setLayerId(vectorLayerMap.get(circle.getLayerName()).getId());
					vectorTiles.add(vectorTile);
				}
				if(d instanceof DXFPolyline){
				    //线段
					DXFPolyline dxfPolyline = (DXFPolyline) d;
					VectorTile vectorTile = new VectorTile();
					vectorTile.setName(dxfPolyline.getLayerName());
					Iterator<DXFVertex> lineIte =   dxfPolyline.getVertexIterator();
					List<DXFVertex> lines = new ArrayList<>();
					lineIte.forEachRemaining(lines::add);
					StringBuilder coordinateWkt = new StringBuilder("LINESTRING(");
					for (int i=0; i<lines.size();i++) {
						if(Double.isInfinite(lines.get(i).getPoint().getX()) || Double.isInfinite(lines.get(i).getPoint().getY())){
							break;
						}
						coordinateWkt.append(lines.get(i).getPoint().getX()).append(" ").append(lines.get(i).getPoint().getY());
						if(i!=(lines.size()-1)){
							coordinateWkt.append(" ,");
						}
					}
					coordinateWkt.append(")");
					vectorTile.setGeom(coordinateWkt.toString());
					vectorTile.setColor(DXFUtil.getColor(dxfPolyline.getColor()));
					vectorTile.setType("POLYLINE");
					vectorTile.setLineWidth(dxfPolyline.getLineWeight());
					vectorTile.setLayerId(vectorLayerMap.get(dxfPolyline.getLayerName()).getId());
					vectorTiles.add(vectorTile);
				}
				if(d instanceof DXFText){
				    //TODO 文字还有问题欢迎评论区讨论
                    DXFText dxfText = (DXFText) d;
					Font font = new Font("宋体",Font.PLAIN,(int)Math.rint(dxfText.getHeight()));
//					FontRenderContext frc = new FontRenderContext(AffineTransform.getRotateInstance(360-dxfText.getRotation(),dxfText.getInsertPoint().getX(),dxfText.getInsertPoint().getY()), false, false);
					FontRenderContext frc = new FontRenderContext((AffineTransform)null, false, false);
					GlyphVector v = font.createGlyphVector(FontDesignMetrics.getMetrics(font, frc).getFontRenderContext(), dxfText.getText());
					Shape shape = v.getOutline();
//					Shape shape = v.getGlyphOutline(0,new Double(dxfText.getInsertPoint().getX()).floatValue(),new Double(dxfText.getInsertPoint().getY()).floatValue());
					AffineTransform transform = new AffineTransform();
					transform.setToRotation(Math.toRadians(180));
					transform.setToTranslation(dxfText.getInsertPoint().getX(),dxfText.getInsertPoint().getY());
//					shape = transform.createTransformedShape(shape);
					PathIterator pathIterator = shape.getPathIterator(transform);
					List<Coordinate> path = new ArrayList<>();
					List<List<Coordinate>> pathList = new ArrayList<>();
					while (!pathIterator.isDone()){
						float[] coords = new float[6];
						int type = pathIterator.currentSegment(coords);
						if(PathIterator.SEG_CLOSE == type){
							pathList.add(path);
							path = new ArrayList<>();
							pathIterator.next();
							continue;
						}
						if(PathIterator.SEG_MOVETO == type){
							if(path.size()>0){
								pathList.add(path);
							}
							path = new ArrayList<>();
							pathIterator.next();
							continue;
						}
						if(PathIterator.SEG_LINETO == type){
							Coordinate coordinate = new Coordinate(coords[0],coords[1]);
							path.add(coordinate);
						}
						if(PathIterator.SEG_CUBICTO == type){
							VectorTile vectorTile = new VectorTile();
							vectorTile.setName(dxfText.getLayerName());
							String coordinateWkt = "CIRCULARSTRING(" + coords[0] + " " + coords[1] + "," +
									coords[2] + " " + coords[3] + " "  + "," +
									coords[4] + " " + coords[5] + " " +
									")";
							vectorTile.setGeom(coordinateWkt);
							vectorTile.setColor(DXFUtil.getColor(dxfText.getColor()));
							vectorTile.setType("TEXT");
							vectorTile.setRotation(dxfText.getRotation());
							vectorTile.setLayerId(vectorLayerMap.get(dxfText.getLayerName()).getId());
							vectorTiles.add(vectorTile);
							path = new ArrayList<>();
							pathIterator.next();
							continue;
						}
						if(PathIterator.SEG_QUADTO == type){
							Coordinate c1 = new Coordinate(coords[0],coords[1]);
							Coordinate c2 = new Coordinate(coords[2],coords[3]);
							path.add(c1);
							path.add(c2);
						}
						pathIterator.next();
					}
					for(List<Coordinate> p:pathList){
						VectorTile vectorTile = new VectorTile();
						vectorTile.setName(dxfText.getLayerName());
						StringBuilder coordinateWkt = new StringBuilder("LINESTRING(");
						for (int i=0; i<p.size();i++) {
							coordinateWkt.append(p.get(i).getX()).append(" ").append(p.get(i).getY());
							if(i!=(p.size()-1)){
								coordinateWkt.append(" ,");
							}
						}
						coordinateWkt.append(")");
						vectorTile.setColor(DXFUtil.getColor(dxfText.getColor()));
						vectorTile.setGeom(coordinateWkt.toString());
						vectorTile.setType("TEXT");
						vectorTile.setRotation(dxfText.getRotation());
						vectorTile.setLayerId(vectorLayerMap.get(dxfText.getLayerName()).getId());
						vectorTiles.add(vectorTile);
					}
				}
			}
			this.saveBatch(vectorTiles);
		}catch (Exception e){
			e.printStackTrace();
		}
		return null;
	}

查询矢量切图代码如下:

@Override
public byte[] selectVectorTile(Integer x, Integer y, Integer z, List<Long> layerIds) {
	VectorBox vectorBox = vectorBoxService.lambdaQuery().one();
	 VectorTile vTile=this.baseMapper.selectTile(x,y,z,vectorBox.getxMin(),vectorBox.getyMin(),vectorBox.getxMax(),vectorBox.getyMax(),layerIds);
	return vTile.getTile();
}

查询SQL如下:

        SELECT
            ST_AsMVT (a, 'points',4096,'geom') As tile
        FROM
            (
                SELECT t.id,
                       st_asmvtgeom (
                           (case st_geometrytype(t.geom)
                               when 'ST_CircularString'
                                   then st_curvetoline(t.geom)
                               else t.geom
                               end),
                           ST_TileEnvelope( #{z}, #{x}, #{y},
                               st_makeenvelope (
                                   #{xMin} ,
                                   #{yMin} ,
                                   #{xMax} ,
                                   #{yMax} , 4775)),
                                     4096,
                                     64,
                                     true
                           ) AS geom,
                        t.color AS color
                FROM
                    vector_tile t
                <where>
                    <if test="layerIds !=null ">
                        and t.layer_id in
                        <foreach collection="layerIds" separator="," open="(" close=")" item="item">
                            #{item}
                        </foreach>
                    </if>
                </where>
            ) AS a where a.geom is not null


前端openlayer渲染

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <!--<link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">-->
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/openlayers/4.6.5/ol-debug.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/openlayers/4.6.5/ol-debug.js"></script>
    <style>
        html, body, #map {
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
            background-color: black;
        }
    </style>
</head>
<body>
<div id="map">
</div>
</body>
<script>

    const projection = new ol.proj.Projection({
        code: 'EPSG:4775',
        units: 'degrees',
    });

    const defaultView = new ol.View({
        projection: projection,
        center: [114.15, 22.65],
        //new ol.proj.fromLonLat([114.15, 22.65]),
        zoom: 2
        //旋转
        // rotation: Math.PI/3
    });

    const styleFunction = function (feature) {
        const color = feature.get("color");
        const width = feature.get("linewidth")/100;
        console.log(width)
        const type = feature.get("type");
        const text = feature.get("text");
        const zoom = map.getView().getZoom();
        const textScale = calculateTextScale(zoom);
        const rotation = (360-feature.get("rotation"))*(Math.PI/180);
        if(type=="TEXT"){
            const retStyle = new ol.style.Style({
                text: new ol.style.Text({
                    text: text,
                    placement: 'point',
                    rotation: rotation,
                    rotateWithView:true,
                    font: '14px Microsoft YaHei',
                    fill: new ol.style.Fill({
                        color: color
                    }),
                    textAlign: 'center',
                    textBaseline: 'middle',
                    scale: textScale // 根据地图缩放级别设置文字缩放比例
                })
            });
            return retStyle;
        }else{
            const retStyle = new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: color,
                    // width: width
                })
            });
            return retStyle;
        }
    };

    const vectorLayer = new ol.layer.VectorTile({
        projection: projection,
        source: new ol.source.VectorTile({
            format: new ol.format.MVT(),
            projection: projection,
            tilePixelRatio: 1,
            url: 'http://127.0.0.1/zgis/vector/tile/{z}/{x}/{y}'
        }),
        style: styleFunction,
    });


    const layers = [
        new ol.layer.Tile({
            source: new ol.source.OSM()
        })
    ];

    layers.push(vectorLayer);

    const map = new ol.Map({
        layers: layers,
        target: 'map',
        view: defaultView
    });

</script>
</html>

目前文字和填充还有些问题,其他可正常支持。
使用JAVA 绘制一条直线并导出dxf(CAD)文件 / 输出的DXF文件路径。//方法:绘制直线 //参数:writer对象,起点的X坐标,起点的Y坐标,终点的X坐标,终点的Y坐标。// 调用方法写入直线的实体信息。// 写入DXF文件头部信息。// 写入直线的实体信息。 阅读详情

相关推荐

Java开发者必看:如何用kabeja-0.4.jar解析DXF文件(附Maven配置避坑指南)

本文为Java开发者提供使用kabeja-0.4.jar解析DXF文件的完整解决方案,涵盖Maven依赖配置、核心代码实现及性能优化技巧。详细介绍了如何手动安装jar包到本地仓库,解析DXF图层和实体,处理颜色索引,并提供了常见问题排查指南,帮助开发者高效处理CAD数据。

n4o5p6q7r的博客 302

Java解析DXF文件并返回JSON格式的工具类示例

Java解析DXF文件并返回JSON格式的工具类示例

DKPT的博客 1239

用java解析DXF文件中的实体信息

用java解析DXF文件中的实体信息,包括circle,ellipse,line,lwpolyline等,同时解决了解析过程中遇到中文的乱码问题。

JAVA解析cad图纸DXF文件

[JAVA解析cad图纸DXF文件]

yt971208711的博客 2286

java读取解析DXF文件信息.rar

java解析DXF文件信息,这里涉及到各种转换字符串编码的操作,解决了解析过程中遇到中文的乱码问题,包括circle,ellipse,line,lwpolyline等,还涉及到从DXF文件中读取一个字符串、判断CIRCLE实体、判断ellipse实体、判断ARC实体、判断LWPOLYLINE实体,示例中自带有dxf文件样例。

java解析dxf文件返回json工具类

java解析dxf文件返回json工具类

JAVA 解析 DXF 文件 点线面圆

一、DXF 文件简介 1.人肉解析 观察几个具有代表性的 dxf 文件,点、文本、线。 使用文本工具直接打开 DXF 文件,可以看到很多字段,这里根据官方文档找规律,找到具有代表性的一些字段如下: 点的特点: 都是 POINT 开头 8 下面对应的图层名称 10 下面的是 x 坐标 20 下面的是 y 坐标 30 下面的是 z 坐标 POINT 5 668B 330 1F 100 AcDbEntity 8 井号 6 Continuous 100 AcDbPoint 10 398266.5

WS的小屋 4080

Gromacs实战:从蛋白质-小分子对接到分子动力学模拟全流程解析

本文详细解析了使用Gromacs进行蛋白质-小分子对接和分子动力学模拟的全流程,包括文件准备、拓扑生成、复合物构建、溶剂化处理、能量最小化及平衡模拟等关键步骤。通过实战案例,帮助研究者验证药物分子与靶标蛋白的结合稳定性,提升分子动力学模拟的效率和准确性。

weixin_29216353的博客 385

CAD数据文件格式DXF部分实体(圆弧、椭圆、凸度)解析[原理讲解+公式推导+java实现]

本文档介绍了从CAD的DXF文件中读取并显示图形的方法,重点讨论了通过离散化技术将复杂图形实体转换为一系列点以便绘制。文中详细解释了圆弧的离散化过程,并提供了Java代码示例。此外,还探讨了如何根据给定的凸度计算优化多段线中的圆弧信息,并给出了椭圆离散化的实现方案,包括处理椭圆旋转和平移的技巧。通过本文档,读者可以了解到离散化技术在CAD图形显示中的具体应用。

我只管埋头前行,剩下的交给时间。 8683

浮点数加法器设计

一.设计内容及其要求 内容 根据浮点数的运算规则和IEEE754标准,实现浮点数的加法运算器。 要求: 浮点数格式:符号位1位,阶码8位,尾数23位 要求该实验能完整的体现浮点数的运算的五个步骤:对阶、尾数求和、规格化、舍入(要求使用对偶舍入)、溢出判断。 二.基本要素 浮点数 浮点数即实数,实数是所有有理数和无理数的集合。它之所以被称作浮点数,是因为小数点在数中的位置并不是固定的。一个浮点数值分为两部分存储:数值以及小数点在数值中的位置。 计算机中的浮点运算的计算结果一般是不确定的,一块芯片的浮点运算

Phoenix_ZengHao的博客 1万+

上证指数30年k线图_金融占星简单解读上证指数30年历史行情

阅读此文需要一定的占星基础知识,本人对于金融知识了解甚少,如有描述错误请包涵指正!影响大众事件发展趋势的都是外行星,即木星-冥王星这5颗,由于时间跨度长达30年,绘制社会行星的K线图工作量太大,所以只以时代行星对这30年行情的简单解读作为分享,在今后的短期分析中会逐渐加入社会行星,甚至在个股分析上还会加入个人行星。那即使只绘制时代行星,所展现出来的信息也无法在一张图上画出来,否则太乱难以分辨,所以...

weixin_39831242的博客 1675

数据交换文件DXF简单java解析

DXF是AutoCAD与其他应用程序交换数据时使用的文件,有多种格式,这里所说的是指ASCII DXF 格式文件. 这里主要实现java程序对DXF文件的解析,将几何体进行分类存储,便于各个程序间进行调用.下面进行文件的解析过程介绍: 1.既然是解析文件,一定要先定义实体类,这里以LwPolyline为例,还有解析成json的实体类 public class LwPolyLine exten

Su*yWGAtH26Q 9008

从零构建:用Simulink搭建固定翼无人机六自由度模型的避坑指南

本文详细介绍了使用Simulink从零构建固定翼无人机六自由度动力学模型的完整流程和避坑指南。重点解析了模型架构设计、气动力计算、参数配置、仿真求解器选择等关键环节的常见问题与解决方案,帮助开发者快速建立准确可靠的无人机控制系统仿真模型。

hhh00的博客 1002

使用kabeja库解析DXF格式文件

DXF格式是一种开源的CAD文件格式,如何实现Java代码对齐的解析,在网上找了很久,也没有找到非常成熟的库。很奇怪,开源的格式,正常应该会有很多的库来支持。只找到了一个kabeja库,最新版本还是2008年出的0.4版本,而且官网还是提供jar和exe运行文件的支持方式。在研究它的过程中遇到了一些问题,这里记录下来,希望大家少踩一些坑吧。

做GIS梦的人 3472

从东南大学906被刷到调剂过程(内含个人感想)

介绍了自己在看到初试成绩,到后期复习以及调剂的全过程,当中也包含了自己的复试中的感想,希望大家理性看待。

Philo的博客 2856

别再让步进电机‘发烧’了!用FOC闭环驱动实现精准力矩控制(基于P0斩波恒流版)

本文详细介绍了如何利用FOC闭环驱动技术(基于P0斩波恒流版)解决步进电机过热和力矩控制不精准的问题。通过对比传统开环控制的缺陷,展示了FOC在降低温度、提升精度和能效方面的显著优势,并提供了硬件配置、软件实现及性能优化的完整方案。

weixin_30872157的博客 567

kabeja一个用于解析CAD文件的java库,DXF转JPEG、PNG、SVG、TIFF、PDF、XML

abeja是一个用于解析CAD文件的java库,处理Autodesk的DXF格式转换。转换DXF为不同的输出格式(JPEG,PNG,SVG,TIFF,PDF,XML)。 网上对kabeja的资料不多,使用方法也很少。虽然在2008年后这个java库就没有更新了,但是其功能还是十分强大的,我使用后感觉很好用,在这分享一下。 Kabeja官网http://kabeja.sourceforge.net/...

IManiy的博客 1万+

UMI——斯坦福刷盘机器人:通过手持夹爪革新数据收集方式,且使用视觉SLAM和Diffusion Policy预测动作

没想到今年年初的斯坦福mobilealoha的热度刚过,而到今年2月的下旬,斯坦福另一个团队又推出了UMI刷盘机器人,且这两个团队还互相认识、还在一块共同切磋(顺带小小感叹一下,斯坦福的氛围是真好而且真高产)斯坦福UMI刷盘机器人其与mobile aloha(以及AirExo: Low-Cost Exoskeletons for Learning Whole-Arm Manipulation in the Wild)最大的不同在于其收集数据处理的非真实的机器人,而是一个手持夹持器(从而大幅降低成本)

u013250861的博客 1357

java绘制cad文件 dxf或者dwg

最近研究了一下java绘制cad, 推荐大家用一gdal 来实现。绘制出了点,线,面,块,和标签等数据,下面是我这边绘制的效果图!后面有时间整理一下代码贴出来供大家参考 gdal javaAPI地址:https://gdal.org/java/overview-summary.html gdal官方地址:https://gdal.org/drivers/vector/dxf.html ...

weixin_42286976的博客 6287

《拉依达的嵌入式\驱动面试宝典》—计算机硬件篇(一)

《拉依达的嵌入式\驱动面试宝典》 整合了所有我认为可能遇到的技术面试问题。所有问题及其答案均是我个人学习后查阅资料总结,每个回答都做了仔细的分析,在嵌入式及其驱动面试相关问题解析做到全网独一无二。学习或者转行到嵌入式、驱动开发领域学习的不二之选

拉依达不拉跨的博客 768

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Openlayers3加载DXF文件作为底图实现

主要记录本人对于DXF文件作为静态底图进行渲染的实现思路

kuaikelong的博客 4273

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【免费下载】 探索jdxf:一款强大的Java DXF库

`jdxf`是一款基于Java的DXF文件处理库,它源自于[jsevy.com](https://jsevy.com/wordpress/index.php/java-and-android/jdxf-java-dxf-library/)的DXF库。DXF(Drawing Interchange Format)是一种用于CAD(计算机辅助设计)软件的文件格式,广泛应用于工程图纸的交换和存储。`jd...

gitblog_00774的博客 1562

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Java读取DXF文件的底层原理与源码分析:解决复杂图形数据解析问题

DXF(Drawing Exchange Format)是AutoCAD创建的一种矢量图形文件格式,用于不同CAD应用程序之间的数据交换。DXF文件采用纯文本格式,结构清晰但复杂,包含多个段(SECTION),每个段由多条记录组成。Java解析DXF文件是一个复杂但有序的过程,关键在于理解DXF文件的组码系统和层次结构。掌握DXF文件的基本结构和解析机制实现各种复杂图形实体的解析逻辑处理DXF文件中的高级特性和扩展数据优化解析性能以处理大型文件实现健壮的容错机制。

2501_93833390的博客 541

java平台读写dxf文件

想通过dxf文件生成通风网络拓扑图, 第一个问题是dxf文件的读取, 基于java的平台中寻入dxf文件的关键技巧 TWaver导入导出AutoCAD DXF图纸中提到了方法,但是效果不好, http://twaver.servasoft.com/twaver-java/twaver%E5%AF%BC%E5%85%A5%E5%AF%BC%E5%87%BAautocad-dxf%E5%9B%

tianyatest的专栏 1万+

JVM中对象的回收过程

当我们的程序开启运行之后就,就会在我们的java堆中不断的产生新的对象,而这是需要占用我们的存储空间的,因为创建一个新的对象需要分配对应的内存空间,显然我的内存空间是固定有限的,所以我们需要对没有用的对象进行回收,本文就来记录下JVM中对象的销毁过程。1.怎么判断对象是没用的了引用计数算法我们在很多场景中会听到java对象判断存活的方式是计算该对象的引用计数器是否为0,如果为0就说明没有其他变量引...

weixin_34208185的博客 242

基于JAVA实现GIS导出DXF文件的功能

其中startPoint.getX()是获取一条线段的开始点x坐标,依次开始点的y坐标,开始点的z坐标,那么前边的10、20、30是怎么来的呢?这是DxfLine的对象,可以看到继承自一个BaseDxfEntity一个基础类,里面提供了一些所有图形的公共的属性:颜色、线宽、是否填充。其中的绿色部分是项目所需要的一些图标,也都是通过程序生成的,下面我将和大家学习一下dxf-lib项目。首先我也是先下载的项目,并且阅读提供的例子和组码值,根据这些就可以画出自己想要的图形了。这里拿绘制线的代码距离说明。

m0_62431591的博客 743
上一篇: FFMPEG+Nginx搭建视频推流
下一篇: Cesium加载3dtile并且点击获取3dtile经纬度
指尖飘烟手留香
博客等级 码龄11年 34粉丝 4原创
评论 7
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值