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

NTS库学习,找bug中......

 引用库:

代码如下:

using GeoAPI.Geometries;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;
using NetTopologySuite;
using NetTopologySuite.IO;
using Coordinate = NetTopologySuite.Geometries.Coordinate;
using GeoAPI;
using NetTopologySuite.Operation.Polygonize;
using System.Threading;
using Point = NetTopologySuite.Geometries.Point;
using Polygon = NetTopologySuite.Geometries.Polygon;
using IFoxCAD.Cad;
using NetTopologySuite.Index.Quadtree;
using NetTopologySuite.Index.Strtree;
using NetTopologySuite.Triangulate;
using NetTopologySuite.Operation.Linemerge;
[assembly: CommandClass(typeof(IfoxDemo.NTS自己))]//只允许此类快捷键命令namespace IfoxDemo
{public class NTS自己{[CommandMethod("xx")]public static void shp(){"ad".Print();// 创建一个点对象var point = new Point(10, 20);// 创建一条线段对象var line = new LineString(new[] { new Coordinate(0, 0),new Coordinate(10, 10),new Coordinate(20, 0)});// 创建一个多边形对象var polygon = new Polygon(new LinearRing(new[] {new Coordinate(0, 0),new Coordinate(0, 10),new Coordinate(10, 10),new Coordinate(10, 0),new Coordinate(0, 0)}));// 计算两个几何对象之间的距离var distance = point.Distance(line);// 计算一个几何对象的缓冲区var buffer = polygon.Buffer(0.5);// 判断两个几何对象是否相交var isIntersect = line.Intersects(polygon);// 创建一个包含所有几何对象的边界框// var envelope = line.Envelope.Union(polygon.Envelope);// 创建一个 Quadtree 索引var index = new Quadtree<NetTopologySuite.Geometries.Geometry>();//index.Insert(line);//有bug//index.Insert(polygon);// 在索引中查找与一个几何对象相交的对象var results = index.Query(line.EnvelopeInternal);GeometryFactory geometryFactory = new GeometryFactory();// 创建点Point point1 = geometryFactory.CreatePoint(new Coordinate(1.0, 1.0));Point point2 = geometryFactory.CreatePoint(new Coordinate(2.0, 2.0));// 创建线段LineString lineString = geometryFactory.CreateLineString(new Coordinate[] {new Coordinate(0, 0),new Coordinate(1, 1),new Coordinate(2, 2)});// 创建多边形Polygon polygon2 = geometryFactory.CreatePolygon(new Coordinate[] {new Coordinate(0, 0),new Coordinate(0, 1),new Coordinate(1, 1),new Coordinate(1, 0),new Coordinate(0, 0)});// 生成 Delaunay 三角网DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();dtb.SetSites(new MultiPoint(new Point[] { point1, point2 }));GeometryCollection triangles = (GeometryCollection)dtb.GetTriangles(geometryFactory);// 合并线段LineMerger lineMerger = new LineMerger();lineMerger.Add(lineString);System.Collections.ICollection mergedLines =(System.Collections.ICollection) lineMerger.GetMergedLineStrings();}}}


http://www.mrgr.cn/news/92203.html

相关文章:

  • 蓝桥云课python代码
  • Linux Crontab面试题及参考答案
  • C++ day5 练习
  • html中的元素(1)
  • C语言数据结构—二叉树的链式结构实现
  • hot100-二叉树
  • MySQL入门:高频操作命令大全
  • 大白话javascript如何通过原型链实现对象的继承,并指出这种继承方式的优缺点
  • ddd 文章总结分享,ddd实战代码分享, 领域驱动设计java实战源码大全,我看过的ddd java源码
  • C1车证学习笔记
  • (七)趣学设计模式 之 适配器模式!
  • 【算法】二分789. 数的范围
  • Node.js技术原理分析系列——Node.js的perf_hooks模块作用和用法
  • AIGC技术助力空军招飞,近屿智能开启智能人才培育新征程
  • ai-1、人工智能概念与学习方向
  • 毕业项目推荐:基于yolov8/yolov5/yolo11的番茄成熟度检测识别系统(python+卷积神经网络)
  • DLP数据防泄漏产品的关键性能指标
  • 电机控制的空间矢量调制 (SVPWM)
  • 【2025信息安全软考重点考点归纳】实时更新
  • 沁恒CH32V307RCT6烧写hex文件时报错“设置芯片型号失败”