用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. Java静态块学习

    静态块是类里面的构造器,对象有构造器那么类也有构造器,类里面的构造器叫做初始化方法.也就是new一个对象他会经过一个构造器.加载一个类,也有被初始化的一片代码,这个就称之为静态块.一个类里面可以有很多 ...

  2. HDU 1176 免费馅饼(记忆化搜索)

    免费馅饼 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  3. GDC 2016 神秘海域4中使用Substance制作Texture

    TEXTURING UNCHARTED 4: A MATTER OF SUBSTANCE 原文链接 http://www.dualshockers.com/2016/03/16/amazing-unc ...

  4. VNC与Windows之间的复制粘贴

    假设目标主机是Linux,终端主机是Windows(就是在Windows上使用VNC登陆Linux): 在Linux中执行: vncconfig -nowin& 在Linux选中文字后,无需其 ...

  5. Ubuntu下设置中文字符集支持(解决中文乱码问题)

    一. Ubuntu默认的中文字符编码 Ubuntu默认的中文字符编码为zh_CN.UTF-8,这个可以在/etc/environment中看到: sudo gedit /etc/environment ...

  6. mysql查询所有字段(*),并且联表时需要特别注意的地方

    如果不标明*是读取哪个表,确实会将所有三个表都读出来.需要小心

  7. 来到这里,我放弃了多少- UI基础-疯狂猜图,我们都疯狂了-

    小问题也要问 学习最重要的是 自律 我昨天晚上3点睡的, 这两天一点也没睡 0.99*0.99  每天差一点 日积月累就很多了 关键字,在字典里查一下,在类里面查查 瑞详博客下载器 跑步后精神多了,白 ...

  8. 发现美的眼睛 Prepared SQL Statement

    DROP PROCEDURE IF EXISTS truncate_insert_sales_rank_toparow_month; DELIMITER /w/ CREATE PROCEDURE tr ...

  9. 迷宫bfs POJ3984

    #include<stdio.h> int map[5][5]={0,1,0,0,0,       0,1,0,1,0,       0,0,0,0,0,       0,1,1,1,0, ...

  10. ubuntu中一些配置文件含义

    /var/log/apache2/mod_jk.log                          apache2 mod_jk错误日志错误 /conf/server.xml           ...