zoukankan      html  css  js  c++  java
  • [NetTopologySuite](1)线面相交

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

      1 Polygon inputGeometry = null;
      2         LineString analysisGeoemtry = null;
      3         private void button1_Click(object sender, EventArgs e)
      4         {
      5             var coords = new Coordinate[7];
      6             // Shell Coordinates
      7             var coordscheck = new Coordinate[7];
      8             double[] Xs = new double[] { 30, 260, 130, 350, 250, 330, 320, 180, 250, 50, 70, 60, 30, 260 };
      9             double[] Ys = new double[] { 140, 260, 110, 150, 230, 210, 140, 260 };
     10             for (var i = 0; i < Xs.Length / 2; i++)
     11             {
     12                 var x = Xs[i * 2];
     13                 var y = Xs[i * 2 + 1];
     14                 coords[i] = new Coordinate(x, y);
     15                 coordscheck[i] = new Coordinate(x, y);
     16             }
     17             //coordscheck[19] = new Coordinate(coords[0].X, coords[0].Y);
     18             //coords[19] = new Coordinate(coords[0].X, coords[0].Y);
     19             // Shell Rings
     20             var ring = new LinearRing(coords);
     21             var gf = new GeometryFactory();
     22             var ringCheck = gf.CreateLinearRing(coordscheck);
     23             // Hole Coordinates
     24             var coordsholecheck = new Coordinate[4];
     25             var coordshole = new Coordinate[4];
     26             for (var i = 0; i < Ys.Length / 2; i++)
     27             {
     28                 var x = Ys[i * 2];
     29                 var y = Ys[i * 2 + 1];
     30                 coordshole[i] = new Coordinate(x, y);
     31                 coordsholecheck[i] = new Coordinate(x, y);
     32             }
     33             // Hole LinearRing Arrays
     34             var hole = new LinearRing(coordshole);
     35             var holes = new ILinearRing[1];
     36             var holeCheck = gf.CreateLinearRing(coordsholecheck);
     37             var holescheck = new ILinearRing[1];
     38             holes[0] = hole;
     39             holescheck[0] = holeCheck;
     40             Polygon pg = new Polygon(ring, holes);//
     41             var polygonCheck = gf.CreatePolygon(ringCheck, holescheck);
     42             var areaCheck = polygonCheck.Area;
     43             var area = pg.Area;
     44             //
     45             inputGeometry = pg;
     46 
     47             double[] Lines = new double[] { 30, 50, 320, 360 };
     48             var coords1 = new Coordinate[2];
     49             var rnd1 = new Random();
     50             var coordscheck1 = new Coordinate[2];
     51             for (var i = 0; i < Lines.Length / 2; i++)
     52             {
     53                 var x = Lines[i * 2];
     54                 var y = Lines[i * 2 + 1];
     55                 coords1[i] = new Coordinate(x, y);
     56                 coordscheck1[i] = new Coordinate(x, y);
     57             }
     58 
     59             var gf1 = new GeometryFactory();
     60             var lscheck = gf1.CreateLineString(coordscheck1);
     61             LineString ls = new LineString(coords1);
     62             analysisGeoemtry = ls;
     63             intersectionOutput = analysisGeoemtry.Intersection(inputGeometry);
     64             this.Invalidate();
     65         }
     66         IGeometry intersectionOutput = null;
     67         private void Form1_Paint(object sender, PaintEventArgs e)
     68         {
     69             Graphics gc = this.CreateGraphics();
     70             if (inputGeometry != null)
     71             {
     72                 GraphicsHelper.DrawPolygon(gc, inputGeometry, new SolidBrush(Color.Red), new Pen(new SolidBrush(Color.LightYellow)), false);
     73             }
     74             if (analysisGeoemtry != null)
     75             {
     76                 GraphicsHelper.DrawLineString(gc, analysisGeoemtry, new Pen(new SolidBrush(Color.Blue)));
     77             }
     78             if (intersectionOutput != null)
     79             {
     80                 if (intersectionOutput is LineString)
     81                 {
     82                     LineString lsr = intersectionOutput as LineString;
     83                     Pen mp = new Pen(new SolidBrush(Color.Yellow));
     84                     mp.Width = 2;
     85                     GraphicsHelper.DrawLineString(gc, lsr, mp);
     86                 }
     87                 if (intersectionOutput is MultiLineString)
     88                 {
     89                     MultiLineString mlsr = intersectionOutput as MultiLineString;
     90                     for (int i = 0; i < mlsr.NumGeometries; i++)
     91                     {
     92                         if (mlsr.Geometries[i] is LineString)
     93                         {
     94                             LineString lsr = mlsr.Geometries[i] as LineString;
     95                             Pen mp = new Pen(new SolidBrush(Color.Yellow));
     96                             mp.Width = 2;
     97                             GraphicsHelper.DrawLineString(gc, lsr, mp);
     98                         }
     99                     }
    100                 }
    101             }
    102             gc.Dispose();
    103         }

  • 相关阅读:
    二十三、DBMS_METADATA(提供提取数据库对象的完整定义的接口)
    二十二、utl_inaddr(用于取得局域网或Internet环境中的主机名和IP地址)
    二十一、utl_file(用于读写OS文件)
    二十、dbms_stats(用于搜集,查看,修改数据库对象的优化统计信息)
    十九、dbms_resource_manager(用于维护资源计划,资源使用组和资源计划指令)
    十八、dbms_repair(用于检测,修复在表和索引上的损坏数据块)
    十七、dbms_tts(检查表空间集合是否是自包含)
    十六、dbms_space_admin(提供了局部管理表空间的功能)
    十五、dbms_space(分析段增长和空间的需求)
    vuex—actions
  • 原文地址:https://www.cnblogs.com/yhlx125/p/4547963.html
Copyright © 2011-2022 走看看