用DotSpatial.Topology进行的测试,即使用NetTopologySuite类库进行测试:

 Polygon inputGeometry = null;
LineString analysisGeoemtry = null;
private void button1_Click(object sender, EventArgs e)
{
var coords = new Coordinate[];
// Shell Coordinates
var coordscheck = new Coordinate[];
double[] Xs = new double[] { , , , , , , , , , , , , , };
double[] Ys = new double[] { , , , , , , , };
for (var i = ; i < Xs.Length / ; i++)
{
var x = Xs[i * ];
var y = Xs[i * + ];
coords[i] = new Coordinate(x, y);
coordscheck[i] = new Coordinate(x, y);
}
//coordscheck[19] = new Coordinate(coords[0].X, coords[0].Y);
//coords[19] = new Coordinate(coords[0].X, coords[0].Y);
// Shell Rings
var ring = new LinearRing(coords);
var gf = new GeometryFactory();
var ringCheck = gf.CreateLinearRing(coordscheck);
// Hole Coordinates
var coordsholecheck = new Coordinate[];
var coordshole = new Coordinate[];
for (var i = ; i < Ys.Length / ; i++)
{
var x = Ys[i * ];
var y = Ys[i * + ];
coordshole[i] = new Coordinate(x, y);
coordsholecheck[i] = new Coordinate(x, y);
}
// Hole LinearRing Arrays
var hole = new LinearRing(coordshole);
var holes = new ILinearRing[];
var holeCheck = gf.CreateLinearRing(coordsholecheck);
var holescheck = new ILinearRing[];
holes[] = hole;
holescheck[] = holeCheck;
Polygon pg = new Polygon(ring, holes);//
var polygonCheck = gf.CreatePolygon(ringCheck, holescheck);
var areaCheck = polygonCheck.Area;
var area = pg.Area;
//
inputGeometry = pg; double[] Lines = new double[] { , , , };
var coords1 = new Coordinate[];
var rnd1 = new Random();
var coordscheck1 = new Coordinate[];
for (var i = ; i < Lines.Length / ; i++)
{
var x = Lines[i * ];
var y = Lines[i * + ];
coords1[i] = new Coordinate(x, y);
coordscheck1[i] = new Coordinate(x, y);
} var gf1 = new GeometryFactory();
var lscheck = gf1.CreateLineString(coordscheck1);
LineString ls = new LineString(coords1);
analysisGeoemtry = ls;
intersectionOutput = analysisGeoemtry.Intersection(inputGeometry);
this.Invalidate();
}
IGeometry intersectionOutput = null;
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics gc = this.CreateGraphics();
if (inputGeometry != null)
{
GraphicsHelper.DrawPolygon(gc, inputGeometry, new SolidBrush(Color.Red), new Pen(new SolidBrush(Color.LightYellow)), false);
}
if (analysisGeoemtry != null)
{
GraphicsHelper.DrawLineString(gc, analysisGeoemtry, new Pen(new SolidBrush(Color.Blue)));
}
if (intersectionOutput != null)
{
if (intersectionOutput is LineString)
{
LineString lsr = intersectionOutput as LineString;
Pen mp = new Pen(new SolidBrush(Color.Yellow));
mp.Width = ;
GraphicsHelper.DrawLineString(gc, lsr, mp);
}
if (intersectionOutput is MultiLineString)
{
MultiLineString mlsr = intersectionOutput as MultiLineString;
for (int i = ; i < mlsr.NumGeometries; i++)
{
if (mlsr.Geometries[i] is LineString)
{
LineString lsr = mlsr.Geometries[i] as LineString;
Pen mp = new Pen(new SolidBrush(Color.Yellow));
mp.Width = ;
GraphicsHelper.DrawLineString(gc, lsr, mp);
}
}
}
}
gc.Dispose();
}

[NetTopologySuite](1)线面相交的更多相关文章

  1. Axiom3D:Ogre射线与点,线,面相交,鼠标操作3维空间.

    在第一篇网络分解成点,线,面.第二篇分别点以球形,线以圆柱,面分别以MergerBatch整合批次显示.因为整合批次显示后,相应的点,线,面不能以Ogre本身的射线来选取,因为整合后,以点举例,多个点 ...

  2. 7.3---直线是否相交(CC150)

    注意:就算斜率相等,但是,如果截距也相等,那么是属于相交,所以要特殊判断. public class CrossLine { public boolean checkCrossLine(double ...

  3. POJ 3304 Segments(线的相交判断)

    Description Given n segments in the two dimensional space, write a program, which determines if ther ...

  4. visio直线交叉相交跨线修改

    在使用visio画流程图时,经常会遇到两条直线相交.下面讲如何修改使得相交点变成我们想要的方式. 可以设置如下: (1)  全局直线相交,设置跨线标志. (2)  对每条线进行相交跨线设置. (一) ...

  5. 计算几何基础——矢量和叉积 && 叉积、线段相交判断、凸包(转载)

    转载自 http://blog.csdn.net/william001zs/article/details/6213485 矢量 如果一条线段的端点是有次序之分的话,那么这种线段就称为 有向线段,如果 ...

  6. ArcMAp对线要素进行平滑处(打断)

    一:工具简单介绍 -- ArcMAp10.1的高级编辑工具中提供了对线/面要素进行概括/平滑处理的工具. 概括工具.平滑工具分别例如以下:(首先得开启编辑状态 --- 才干够对要素的属性进行更改).选 ...

  7. iOS 2D绘图 (Quartz2D)之路径(点,直线,虚线,曲线,圆弧,椭圆,矩形)

    博客原地址:http://blog.csdn.net/hello_hwc?viewmode=list 让我们继续跟着大神的脚步前进吧.这一次 我们学习一些Quartz 2D 最基本的一些用法. 前言: ...

  8. 探索性思维——How to Solve It

    我觉得这篇文章和什么都能扯上点关系,比如编程. 很多人已经讨论过数学与编程的关系了,这里不想过多探讨,只是简单提一下:有些人把数学贬低地一文不值,认为做一般的应用软件用不到数学:而有些人则把数学拔高到 ...

  9. Andrew Ng机器学习公开课笔记 -- 支持向量机

    网易公开课,第6,7,8课 notes,http://cs229.stanford.edu/notes/cs229-notes3.pdf SVM-支持向量机算法概述, 这篇讲的挺好,可以参考   先继 ...

随机推荐

  1. PHP下利用PHPMailer配合QQ邮箱下的域名邮箱发送邮件(转)

    首先确定不是开启socks openssl phpinfo就可以知道 下载phpmailer   地址:https://github.com/PHPMailer/PHPMailer 下载完整, 个人和 ...

  2. SAE saestorage.class.php文件的封装代码

    Source for file saestorage.class.php Documentation is available at saestorage.class.php <?php /** ...

  3. Apache Spark源码走读之19 -- standalone cluster模式下资源的申请与释放

    欢迎转载,转载请注明出处,徽沪一郎. 概要 本文主要讲述在standalone cluster部署模式下,Spark Application在整个运行期间,资源(主要是cpu core和内存)的申请与 ...

  4. web-content和web-info目录问题

    1.资源文件只能放在WebContent下面,如 CSS,JS,image等.放在WEB-INF下引用不了. 2.页面放在WEB-INF目录下面,这样可以限制访问,提高安全性.如JSP,html 3. ...

  5. 【翻译】Kinect v2程序设计(C++) Depth编

    Kinect SDK v2预览版,取得Depth数据的方法说明. 上一节,介绍了通过使用Kinect for Windows SDK v2预览版(以下简称为,Kinect SDK v2预览版)从Kin ...

  6. FAQ软件卸载

    今天安装了一个PDF 编辑软件pdftk,下载时提示有50多M,感觉不好用,卸载后提示释放空间只有2M,郁闷了.上网查寻,如下命令 sudo dpkg -p package_name卸载软件包及其配置 ...

  7. 20145317彭垚 《Java程序设计》第4周学习总结

    20145317彭垚 <Java程序设计>第04周学习总结 20145317彭垚 <Java程序设计>第4周学习总结 教材学习内容总结 继承 继承就是避免多个类间重复定义共同行 ...

  8. shell的if else 以及大于,小于等逻辑表达式

    if ....; then .... elif ....; then .... else .... fi 大多数情况下,可以使用测试命令来对条件进行测试.比如可以比较字符串.判断文件是否存在及是否可读 ...

  9. Bundle文件的创建和使用(二)

    1.概念: An NSBundle object represents a location in the file system that groups code and resources tha ...

  10. IOS 开发文件操作——NSFileManager

    转自:http://blog.csdn.net/xyz_lmn/article/details/8968213,留着方便查阅 iOS的沙盒机制,应用只能访问自己应用目录下的文件.iOS不像androi ...