用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. POJ 1144 Network(Tarjan求割点)

    Network Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12707   Accepted: 5835 Descript ...

  2. UVALive 2635 匈牙利算法

    题意 给出k块地 规模n*m 需要在每块地中找至多一块h*w的地 这些地中如果包含字母 只能包含一种字母 如果一块地中选地使用了A 其余的地就不能使用A 但是全0可以重复 问 最后能最多选出来多少块地 ...

  3. python 操作excel 使用笔记

    写入excel, 保存的过程中需要注意,保存格式xls后缀,如果用xlsx会报错 def set_style(name,height,bold=False): """&q ...

  4. jquery选中将select下拉框中一项后赋值给text文本框

    jquery选中将select下拉框中一项后赋值给text文本框,出现无法将第一个下拉框的value赋值给文本框 因为select默认选中第一项..在选择第一项时,便导致无法激发onchange事件. ...

  5. PHP自动解压上传的rar文件

    PHP自动解压上传的rar文件   浏览:383 发布日期:2015/07/20 分类:功能实现 关键字: php函数 php扩展 大家都知道php有个zip类可直接操作zip压缩文件,可是用户有时候 ...

  6. PHP5.4安装xhprof扩展[不要去pecl下载]

    HP5.3或之前版本可以去pecl(http://pecl.php.net)下载xhprof扩展安装. 但pecl上的版本不支持PHP5.4 可以到github上的xhprof库中下载:https:/ ...

  7. enhance convenience rather than contribute to the fundamental power of the language

    Computer Science An Overview _J. Glenn Brookshear _11th Edition Universal Programming Languages In  ...

  8. Comparable与Comparator

    转载 Comparable与Comparator的区别 (转载) Comparable & Comparator 都是用来实现集合中元素的比较.排序的,只是 Comparable 是在集合内部 ...

  9. FTS抓包看蓝牙验证的过程

    1.概述    在进行蓝牙设备的连接时,为了保护个人隐私和数据保密的需要,需要进行验证.   2.一些Frame Frame74:本地发送Authentication requset command ...

  10. 0011 SDK测试方法&ADB语法

    h1.移动云OSS SDK测试方法,包含环境搭建 android  oss sdk 测试方法 1.          搭建测试环境 1.     A ndroid模拟器需要jdk1.6 2.      ...