用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. SDUT 2610 Boring Counting(离散化+主席树区间内的区间求和)

    Boring Counting Time Limit: 3000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Descriptio ...

  2. ASP.NET\ASP.NET MVC表单提交遇到的问题结论

    同步提交的两种基本方式 1,用type=“submit”按钮.form没有必要runat=“server” <form method="post" action=" ...

  3. bash: /usr/lib/jvm/jdk1.7.0_80/bin/java: No such file or directory 问题

    在安装java的时候,经常会遇到一些奇奇怪怪的问题. 在配置好环境变量之后,执行java -version,出现: bash: /usr/lib/jvm/jdk1.7.0_80/bin/java: N ...

  4. linux下mysql定时备份数据库

    linux下mysql定时备份数据库 (2010-10-21 12:40:17) 转载▼ 标签: 杂谈   一.用命令实现备份 首页进入mysql的bin目录 1.备份数据#mysqldump -uu ...

  5. ecshop缓存清理-限制或禁用ECShop缓存

    ecshop缓存清理-限制或禁用ECShop缓存   ECSHOP的缓存存放在templates/caches/文章夹下,时间长了这个文件夹就会非常庞大,拖慢网站速度.还有很多情况我们不需要他的缓存. ...

  6. 【转载】MySQL性能优化的最佳20+条经验

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...

  7. javaWeb中struts开发——Logic标签

    1.Struts标签的logic标签 Logic标签是逻辑标签,是Struts中比较重要的标签,完成各种逻辑运算操作,可以直接支持全局调转. 2.1<logic:present><l ...

  8. font awesome

    http://stackoverflow.com/questions/21406538/how-to-use-font-awesome-icons-from-node-modules

  9. Iphone H5上传照片被旋转

    最近做项目发现在Iphone下,我们上传图片都会被翻转,最后查阅资料发现,的确是IOS的问题 不说过程,直接解决方法 iOS下,html方式使用<input type="file&qu ...

  10. SQLServer2008:助您轻松编写T-SQL存储过程(原创)【转】

      本文主要介绍 SQLServerExpress2008不用第三方工具调试T-SQL语句,经过本文的介绍,用SQLSERVER2008 Manage studio 编写.调试T-SQL存储过程都将是 ...