diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index e2dfcad..aadbd3f 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -48,20 +48,7 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -130,21 +117,8 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
sheet1.Name = "水平距离";
for (int i = 0; i < dt1.Columns.Count; i++)
@@ -161,21 +135,8 @@
sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[1, dt1.Columns.Count]];
- //重新选择单元格范围
- int rowscount1 = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount1 = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er1.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er1.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt1);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -204,172 +165,147 @@
///
///
///
- public static void ExpToExcel(DataGridView dt, string strSaveFile, string str, List lineStrcut, List featsList)
+ public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
{
+ if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
- string layer = "";
- string hxName = "";
+ string layerName = "";
+ string redLineName = "";
- //创建一个EXCEL应用程序
- Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
- excel.Visible = false;
- //定义缺省值
- Missing miss = Missing.Value;
- //创建一个新的工作簿
- Workbooks workbooks = excel.Workbooks;
+ Application excel = new Application();//创建一个EXCEL应用程序
+ excel.Visible = false; //是否显示导出过程(显示创建后的EXCEL)
+ Missing miss = Missing.Value;//定义缺省值
+ Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = null;
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ sheet.Name = str;
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ }
+ //填充数据
+ for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ }
+ }
+ sheetStype(sheet, dt);
+
+ for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
{
if (workbook.Worksheets.Count > sheetCount)
- {
sheet = workbook.Worksheets[sheetCount + 1];
- }
else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- sheet = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ dataTable.Columns.Add("编号");
- if (sheetCount == 0)
+ layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
+ redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
+
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == layerName
+ && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ DataRow row = dataTable.NewRow();
+ row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption;
+ row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name;
+ dataTable.Rows.Add(row);
}
-
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
-
}
- else
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0)
{
-
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layer = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- hxName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- for (int i = 0; i < lineStrcut.Count; i++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length;j++)
{
- if (lineStrcut[i].layerName == layer && lineStrcut[i].hxName == hxName)
+ GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
+ if (feats[0].Dataset.Caption.Contains(layerName))
{
- DataRow row = dataTable.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dataTable.Rows.Add(row);
- }
- }
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
+ for (int n = 0; n < feats.Length; n++)
{
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dataTable.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dataTable.Rows.Add(pointRow);
- }
+ DataRow pointRow = dataTable.NewRow();
+ pointRow[0] = feats[n].Dataset.Caption;
+ pointRow[1] = feats[n].GetFieldAsString("编号");
+ dataTable.Rows.Add(pointRow);
}
}
}
-
- if (!sheetNameList.Contains(layer))
- {
- sheet.Name = layer;
- sheetNameList.Add(layer);
- }
- else
- {
- sheet.Name = layer + "1";
- sheetNameList.Add(layer + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
-
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
-
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dataTable.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dataTable.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
-
+
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
+ }
+
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ sheetStype(sheet, dataTable);
}
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
+ if (File.Exists(strSaveFile))
{
int z = 1;
do
{
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
+ strSaveFile = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
z++;
- } while (File.Exists(strSaveFile2));
+ } while (File.Exists(strSaveFile));
}
-
- workbook.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
+ workbook.SaveAs(strSaveFile, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
+ workbook.Close(false, miss, miss); //关闭表格
workbooks.Close();
- //释放资源
- excel.Quit();
-
+ excel.Quit();//释放资源
}
+ static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
+
+ static void sheetStype(Worksheet sheet, DataTable dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
///
/// 杀死进程
///
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index e2dfcad..aadbd3f 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -48,20 +48,7 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -130,21 +117,8 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
sheet1.Name = "水平距离";
for (int i = 0; i < dt1.Columns.Count; i++)
@@ -161,21 +135,8 @@
sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[1, dt1.Columns.Count]];
- //重新选择单元格范围
- int rowscount1 = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount1 = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er1.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er1.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt1);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -204,172 +165,147 @@
///
///
///
- public static void ExpToExcel(DataGridView dt, string strSaveFile, string str, List lineStrcut, List featsList)
+ public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
{
+ if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
- string layer = "";
- string hxName = "";
+ string layerName = "";
+ string redLineName = "";
- //创建一个EXCEL应用程序
- Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
- excel.Visible = false;
- //定义缺省值
- Missing miss = Missing.Value;
- //创建一个新的工作簿
- Workbooks workbooks = excel.Workbooks;
+ Application excel = new Application();//创建一个EXCEL应用程序
+ excel.Visible = false; //是否显示导出过程(显示创建后的EXCEL)
+ Missing miss = Missing.Value;//定义缺省值
+ Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = null;
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ sheet.Name = str;
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ }
+ //填充数据
+ for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ }
+ }
+ sheetStype(sheet, dt);
+
+ for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
{
if (workbook.Worksheets.Count > sheetCount)
- {
sheet = workbook.Worksheets[sheetCount + 1];
- }
else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- sheet = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ dataTable.Columns.Add("编号");
- if (sheetCount == 0)
+ layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
+ redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
+
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == layerName
+ && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ DataRow row = dataTable.NewRow();
+ row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption;
+ row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name;
+ dataTable.Rows.Add(row);
}
-
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
-
}
- else
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0)
{
-
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layer = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- hxName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- for (int i = 0; i < lineStrcut.Count; i++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length;j++)
{
- if (lineStrcut[i].layerName == layer && lineStrcut[i].hxName == hxName)
+ GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
+ if (feats[0].Dataset.Caption.Contains(layerName))
{
- DataRow row = dataTable.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dataTable.Rows.Add(row);
- }
- }
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
+ for (int n = 0; n < feats.Length; n++)
{
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dataTable.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dataTable.Rows.Add(pointRow);
- }
+ DataRow pointRow = dataTable.NewRow();
+ pointRow[0] = feats[n].Dataset.Caption;
+ pointRow[1] = feats[n].GetFieldAsString("编号");
+ dataTable.Rows.Add(pointRow);
}
}
}
-
- if (!sheetNameList.Contains(layer))
- {
- sheet.Name = layer;
- sheetNameList.Add(layer);
- }
- else
- {
- sheet.Name = layer + "1";
- sheetNameList.Add(layer + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
-
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
-
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dataTable.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dataTable.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
-
+
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
+ }
+
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ sheetStype(sheet, dataTable);
}
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
+ if (File.Exists(strSaveFile))
{
int z = 1;
do
{
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
+ strSaveFile = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
z++;
- } while (File.Exists(strSaveFile2));
+ } while (File.Exists(strSaveFile));
}
-
- workbook.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
+ workbook.SaveAs(strSaveFile, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
+ workbook.Close(false, miss, miss); //关闭表格
workbooks.Close();
- //释放资源
- excel.Quit();
-
+ excel.Quit();//释放资源
}
+ static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
+
+ static void sheetStype(Worksheet sheet, DataTable dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
///
/// 杀死进程
///
diff --git a/FrmAnalysisGuiHuaResult.Designer.cs b/FrmAnalysisGuiHuaResult.Designer.cs
index c7d026d..eb3d275 100644
--- a/FrmAnalysisGuiHuaResult.Designer.cs
+++ b/FrmAnalysisGuiHuaResult.Designer.cs
@@ -49,7 +49,7 @@
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(384, 186);
this.dataGridView1.TabIndex = 0;
- this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
+ //this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
//
// timer1
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index e2dfcad..aadbd3f 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -48,20 +48,7 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -130,21 +117,8 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
sheet1.Name = "水平距离";
for (int i = 0; i < dt1.Columns.Count; i++)
@@ -161,21 +135,8 @@
sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[1, dt1.Columns.Count]];
- //重新选择单元格范围
- int rowscount1 = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount1 = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er1.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er1.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt1);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -204,172 +165,147 @@
///
///
///
- public static void ExpToExcel(DataGridView dt, string strSaveFile, string str, List lineStrcut, List featsList)
+ public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
{
+ if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
- string layer = "";
- string hxName = "";
+ string layerName = "";
+ string redLineName = "";
- //创建一个EXCEL应用程序
- Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
- excel.Visible = false;
- //定义缺省值
- Missing miss = Missing.Value;
- //创建一个新的工作簿
- Workbooks workbooks = excel.Workbooks;
+ Application excel = new Application();//创建一个EXCEL应用程序
+ excel.Visible = false; //是否显示导出过程(显示创建后的EXCEL)
+ Missing miss = Missing.Value;//定义缺省值
+ Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = null;
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ sheet.Name = str;
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ }
+ //填充数据
+ for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ }
+ }
+ sheetStype(sheet, dt);
+
+ for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
{
if (workbook.Worksheets.Count > sheetCount)
- {
sheet = workbook.Worksheets[sheetCount + 1];
- }
else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- sheet = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ dataTable.Columns.Add("编号");
- if (sheetCount == 0)
+ layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
+ redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
+
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == layerName
+ && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ DataRow row = dataTable.NewRow();
+ row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption;
+ row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name;
+ dataTable.Rows.Add(row);
}
-
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
-
}
- else
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0)
{
-
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layer = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- hxName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- for (int i = 0; i < lineStrcut.Count; i++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length;j++)
{
- if (lineStrcut[i].layerName == layer && lineStrcut[i].hxName == hxName)
+ GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
+ if (feats[0].Dataset.Caption.Contains(layerName))
{
- DataRow row = dataTable.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dataTable.Rows.Add(row);
- }
- }
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
+ for (int n = 0; n < feats.Length; n++)
{
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dataTable.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dataTable.Rows.Add(pointRow);
- }
+ DataRow pointRow = dataTable.NewRow();
+ pointRow[0] = feats[n].Dataset.Caption;
+ pointRow[1] = feats[n].GetFieldAsString("编号");
+ dataTable.Rows.Add(pointRow);
}
}
}
-
- if (!sheetNameList.Contains(layer))
- {
- sheet.Name = layer;
- sheetNameList.Add(layer);
- }
- else
- {
- sheet.Name = layer + "1";
- sheetNameList.Add(layer + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
-
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
-
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dataTable.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dataTable.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
-
+
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
+ }
+
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ sheetStype(sheet, dataTable);
}
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
+ if (File.Exists(strSaveFile))
{
int z = 1;
do
{
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
+ strSaveFile = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
z++;
- } while (File.Exists(strSaveFile2));
+ } while (File.Exists(strSaveFile));
}
-
- workbook.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
+ workbook.SaveAs(strSaveFile, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
+ workbook.Close(false, miss, miss); //关闭表格
workbooks.Close();
- //释放资源
- excel.Quit();
-
+ excel.Quit();//释放资源
}
+ static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
+
+ static void sheetStype(Worksheet sheet, DataTable dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
///
/// 杀死进程
///
diff --git a/FrmAnalysisGuiHuaResult.Designer.cs b/FrmAnalysisGuiHuaResult.Designer.cs
index c7d026d..eb3d275 100644
--- a/FrmAnalysisGuiHuaResult.Designer.cs
+++ b/FrmAnalysisGuiHuaResult.Designer.cs
@@ -49,7 +49,7 @@
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(384, 186);
this.dataGridView1.TabIndex = 0;
- this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
+ //this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
//
// timer1
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 2e2adfd..6d9c10c 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -3,7 +3,6 @@
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;
-using DevComponents.DotNetBar.Controls;
using GeoScene.Data;
using GeoScene.Globe;
@@ -11,33 +10,18 @@
{
public partial class FrmAnalysisGuiHuaResult : Office2007Form
{
-
- //DataTable dt = null;
- //定位和闪烁初始化定义
int count;
- private string flashflag = "single";
GSOFeature hlfeature;
public GSOGlobeControl globleControl1;
+ string layerName;
+ string redLineName;
- DataGridViewX dataGridView2;
- List lineStrcut = new List();
- PanelEx panel;
- //ToolStripStatusLabel toolStripNumbers;
- //ToolStripStatusLabel toolStripFeatureLength;
- string layer;
- string hxName;
- List featsList = new List();
-
- public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, List _lineStrcut, List _featsList,PanelEx p, DataGridViewX _dataGridView1,string _layer,string _hxName)
+ public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, string _layerName,string _redLineName)
{
InitializeComponent();
- lineStrcut = _lineStrcut;
- panel = p;
globleControl1 = _globleControl1;
- dataGridView2 = _dataGridView1;
- layer = _layer;
- hxName = _hxName;
- featsList = _featsList;
+ layerName = _layerName;
+ redLineName = _redLineName;
}
private void FrmAnalysisGuiHuaResult_Load(object sender, EventArgs e)
@@ -45,88 +29,50 @@
DataTable dt = new DataTable();
dt.Columns.Add("图层类型");
dt.Columns.Add("编号");
+ if (RedLineAnalysisTool.redLineResultList.Count == 0) return;
- for (int i = 0; i < lineStrcut.Count;i++ )
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList.Count; i++)
{
- if (lineStrcut[i].layerName == layer&&lineStrcut[i].hxName==hxName)
+ if (RedLineAnalysisTool.redLineResultList[i].LayerName == layerName
+ && RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
- DataRow row = dt.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dt.Rows.Add(row);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
- {
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dt.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dt.Rows.Add(pointRow);
- }
- }
- }
- }
-
+
dataGridView1.DataSource = dt;
dataGridView1.Columns[1].Width = 200;
}
+ void addDataToDataTable(DataTable dt,GSOFeatures features)
+ {
+ for (int m = 0; m < features.Length; m++)
+ {
+ DataRow row = dt.NewRow();
+ row[0] = features[m].Dataset.Caption;
+ row[1] = features[m].Name;
+ dt.Rows.Add(row);
+ }
+ }
+
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
- if (e.RowIndex > -1)
+ if (e.RowIndex <= -1) return;
+
+ string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
+
+ GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName);
+ GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
+ if (rowFeatures.Length == 0)
{
- string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
-
- GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer);
- GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- if (rowFeatures.Length == 0)
- {
- gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer + "附属物");
- rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- }
- GSOFeature feature = rowFeatures[0];
- hlfeature = feature;
- highlight();
- //globleControl1.Globe.FlyToFeature(feature, 0, 45, 3);
- globleControl1.Globe.JumpToFeature(feature, 10);
-
- #region
- //string layer = dataGridView1.Rows[e.RowIndex].Cells["管线类型"].Value.ToString();
-
- //string sql = "select " + getpipeLineFields.getFields(layer, globleControl1) + " from " + layer + " where 编号 = ";
- //for (int i = 0; i < lineStrcut.Count; i++)
- //{
- // if (i == lineStrcut.Count - 1)
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'";
- // }
- // else
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'" + " or 编号 = ";
- // }
-
- //}
-
- //DataTable table = OledbHelper.QueryTable(sql);
- //if (table != null && table.Rows.Count > 0)
- //{
- // dataGridView2.DataSource = table;
- // panel.Visible = true;
- // toolStripNumbers.Text =layer;
- // toolStripFeatureLength.Text = " 共有:" + table.Rows.Count + "条";
- //}
- //else
- //{
- //}
- #endregion
+ gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName + "附属物");
+ rowFeatures = gsoLayer.GetFeatureByName(BH, true);
}
+ GSOFeature feature = rowFeatures[0];
+ hlfeature = feature;
+ highlight();
+ globleControl1.Globe.JumpToFeature(feature, 10);
}
///
@@ -134,7 +80,6 @@
///
public void highlight()
{
- flashflag = "single";
timer1.Start();
}
@@ -147,20 +92,17 @@
if (count < 100)
{
count++;
- if (flashflag == "single")
+ if (rowFeature != null)
{
- if (rowFeature != null)
+ if (count%2 != 0)
{
- if (count % 2 != 0)
- {
- rowFeature.HighLight = true;
- globleControl1.Refresh();
- }
- else
- {
- rowFeature.HighLight = false;
- globleControl1.Refresh();
- }
+ rowFeature.HighLight = true;
+ globleControl1.Refresh();
+ }
+ else
+ {
+ rowFeature.HighLight = false;
+ globleControl1.Refresh();
}
}
}
@@ -170,25 +112,12 @@
rowFeature.HighLight = false;
count = 0;
}
-
}
private void FrmAnalysisGuiHuaResult_FormClosing(object sender, FormClosingEventArgs e)
{
- //dataGridView2.DataSource = null;
- //dataGridView2.Refresh();
- //panel.Visible = false;
- //toolStripNumbers.Text = " 类型:";
- //toolStripFeatureLength.Text = " 管线里程:";
- //lineStrcut.Clear();
-
timer1.Stop();
}
- int rowIndex;
- private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- rowIndex = e.RowIndex;
- }
}
}
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index e2dfcad..aadbd3f 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -48,20 +48,7 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -130,21 +117,8 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
sheet1.Name = "水平距离";
for (int i = 0; i < dt1.Columns.Count; i++)
@@ -161,21 +135,8 @@
sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[1, dt1.Columns.Count]];
- //重新选择单元格范围
- int rowscount1 = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount1 = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er1.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er1.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt1);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -204,172 +165,147 @@
///
///
///
- public static void ExpToExcel(DataGridView dt, string strSaveFile, string str, List lineStrcut, List featsList)
+ public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
{
+ if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
- string layer = "";
- string hxName = "";
+ string layerName = "";
+ string redLineName = "";
- //创建一个EXCEL应用程序
- Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
- excel.Visible = false;
- //定义缺省值
- Missing miss = Missing.Value;
- //创建一个新的工作簿
- Workbooks workbooks = excel.Workbooks;
+ Application excel = new Application();//创建一个EXCEL应用程序
+ excel.Visible = false; //是否显示导出过程(显示创建后的EXCEL)
+ Missing miss = Missing.Value;//定义缺省值
+ Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = null;
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ sheet.Name = str;
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ }
+ //填充数据
+ for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ }
+ }
+ sheetStype(sheet, dt);
+
+ for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
{
if (workbook.Worksheets.Count > sheetCount)
- {
sheet = workbook.Worksheets[sheetCount + 1];
- }
else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- sheet = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ dataTable.Columns.Add("编号");
- if (sheetCount == 0)
+ layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
+ redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
+
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == layerName
+ && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ DataRow row = dataTable.NewRow();
+ row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption;
+ row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name;
+ dataTable.Rows.Add(row);
}
-
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
-
}
- else
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0)
{
-
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layer = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- hxName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- for (int i = 0; i < lineStrcut.Count; i++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length;j++)
{
- if (lineStrcut[i].layerName == layer && lineStrcut[i].hxName == hxName)
+ GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
+ if (feats[0].Dataset.Caption.Contains(layerName))
{
- DataRow row = dataTable.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dataTable.Rows.Add(row);
- }
- }
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
+ for (int n = 0; n < feats.Length; n++)
{
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dataTable.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dataTable.Rows.Add(pointRow);
- }
+ DataRow pointRow = dataTable.NewRow();
+ pointRow[0] = feats[n].Dataset.Caption;
+ pointRow[1] = feats[n].GetFieldAsString("编号");
+ dataTable.Rows.Add(pointRow);
}
}
}
-
- if (!sheetNameList.Contains(layer))
- {
- sheet.Name = layer;
- sheetNameList.Add(layer);
- }
- else
- {
- sheet.Name = layer + "1";
- sheetNameList.Add(layer + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
-
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
-
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dataTable.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dataTable.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
-
+
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
+ }
+
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ sheetStype(sheet, dataTable);
}
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
+ if (File.Exists(strSaveFile))
{
int z = 1;
do
{
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
+ strSaveFile = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
z++;
- } while (File.Exists(strSaveFile2));
+ } while (File.Exists(strSaveFile));
}
-
- workbook.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
+ workbook.SaveAs(strSaveFile, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
+ workbook.Close(false, miss, miss); //关闭表格
workbooks.Close();
- //释放资源
- excel.Quit();
-
+ excel.Quit();//释放资源
}
+ static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
+
+ static void sheetStype(Worksheet sheet, DataTable dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
///
/// 杀死进程
///
diff --git a/FrmAnalysisGuiHuaResult.Designer.cs b/FrmAnalysisGuiHuaResult.Designer.cs
index c7d026d..eb3d275 100644
--- a/FrmAnalysisGuiHuaResult.Designer.cs
+++ b/FrmAnalysisGuiHuaResult.Designer.cs
@@ -49,7 +49,7 @@
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(384, 186);
this.dataGridView1.TabIndex = 0;
- this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
+ //this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
//
// timer1
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 2e2adfd..6d9c10c 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -3,7 +3,6 @@
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;
-using DevComponents.DotNetBar.Controls;
using GeoScene.Data;
using GeoScene.Globe;
@@ -11,33 +10,18 @@
{
public partial class FrmAnalysisGuiHuaResult : Office2007Form
{
-
- //DataTable dt = null;
- //定位和闪烁初始化定义
int count;
- private string flashflag = "single";
GSOFeature hlfeature;
public GSOGlobeControl globleControl1;
+ string layerName;
+ string redLineName;
- DataGridViewX dataGridView2;
- List lineStrcut = new List();
- PanelEx panel;
- //ToolStripStatusLabel toolStripNumbers;
- //ToolStripStatusLabel toolStripFeatureLength;
- string layer;
- string hxName;
- List featsList = new List();
-
- public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, List _lineStrcut, List _featsList,PanelEx p, DataGridViewX _dataGridView1,string _layer,string _hxName)
+ public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, string _layerName,string _redLineName)
{
InitializeComponent();
- lineStrcut = _lineStrcut;
- panel = p;
globleControl1 = _globleControl1;
- dataGridView2 = _dataGridView1;
- layer = _layer;
- hxName = _hxName;
- featsList = _featsList;
+ layerName = _layerName;
+ redLineName = _redLineName;
}
private void FrmAnalysisGuiHuaResult_Load(object sender, EventArgs e)
@@ -45,88 +29,50 @@
DataTable dt = new DataTable();
dt.Columns.Add("图层类型");
dt.Columns.Add("编号");
+ if (RedLineAnalysisTool.redLineResultList.Count == 0) return;
- for (int i = 0; i < lineStrcut.Count;i++ )
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList.Count; i++)
{
- if (lineStrcut[i].layerName == layer&&lineStrcut[i].hxName==hxName)
+ if (RedLineAnalysisTool.redLineResultList[i].LayerName == layerName
+ && RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
- DataRow row = dt.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dt.Rows.Add(row);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
- {
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dt.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dt.Rows.Add(pointRow);
- }
- }
- }
- }
-
+
dataGridView1.DataSource = dt;
dataGridView1.Columns[1].Width = 200;
}
+ void addDataToDataTable(DataTable dt,GSOFeatures features)
+ {
+ for (int m = 0; m < features.Length; m++)
+ {
+ DataRow row = dt.NewRow();
+ row[0] = features[m].Dataset.Caption;
+ row[1] = features[m].Name;
+ dt.Rows.Add(row);
+ }
+ }
+
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
- if (e.RowIndex > -1)
+ if (e.RowIndex <= -1) return;
+
+ string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
+
+ GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName);
+ GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
+ if (rowFeatures.Length == 0)
{
- string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
-
- GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer);
- GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- if (rowFeatures.Length == 0)
- {
- gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer + "附属物");
- rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- }
- GSOFeature feature = rowFeatures[0];
- hlfeature = feature;
- highlight();
- //globleControl1.Globe.FlyToFeature(feature, 0, 45, 3);
- globleControl1.Globe.JumpToFeature(feature, 10);
-
- #region
- //string layer = dataGridView1.Rows[e.RowIndex].Cells["管线类型"].Value.ToString();
-
- //string sql = "select " + getpipeLineFields.getFields(layer, globleControl1) + " from " + layer + " where 编号 = ";
- //for (int i = 0; i < lineStrcut.Count; i++)
- //{
- // if (i == lineStrcut.Count - 1)
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'";
- // }
- // else
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'" + " or 编号 = ";
- // }
-
- //}
-
- //DataTable table = OledbHelper.QueryTable(sql);
- //if (table != null && table.Rows.Count > 0)
- //{
- // dataGridView2.DataSource = table;
- // panel.Visible = true;
- // toolStripNumbers.Text =layer;
- // toolStripFeatureLength.Text = " 共有:" + table.Rows.Count + "条";
- //}
- //else
- //{
- //}
- #endregion
+ gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName + "附属物");
+ rowFeatures = gsoLayer.GetFeatureByName(BH, true);
}
+ GSOFeature feature = rowFeatures[0];
+ hlfeature = feature;
+ highlight();
+ globleControl1.Globe.JumpToFeature(feature, 10);
}
///
@@ -134,7 +80,6 @@
///
public void highlight()
{
- flashflag = "single";
timer1.Start();
}
@@ -147,20 +92,17 @@
if (count < 100)
{
count++;
- if (flashflag == "single")
+ if (rowFeature != null)
{
- if (rowFeature != null)
+ if (count%2 != 0)
{
- if (count % 2 != 0)
- {
- rowFeature.HighLight = true;
- globleControl1.Refresh();
- }
- else
- {
- rowFeature.HighLight = false;
- globleControl1.Refresh();
- }
+ rowFeature.HighLight = true;
+ globleControl1.Refresh();
+ }
+ else
+ {
+ rowFeature.HighLight = false;
+ globleControl1.Refresh();
}
}
}
@@ -170,25 +112,12 @@
rowFeature.HighLight = false;
count = 0;
}
-
}
private void FrmAnalysisGuiHuaResult_FormClosing(object sender, FormClosingEventArgs e)
{
- //dataGridView2.DataSource = null;
- //dataGridView2.Refresh();
- //panel.Visible = false;
- //toolStripNumbers.Text = " 类型:";
- //toolStripFeatureLength.Text = " 管线里程:";
- //lineStrcut.Clear();
-
timer1.Stop();
}
- int rowIndex;
- private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- rowIndex = e.RowIndex;
- }
}
}
diff --git a/MainFrm.cs b/MainFrm.cs
index 736aba3..3c5b756 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -5511,10 +5511,9 @@
{
DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y);
if (hittestinfo.RowIndex < 0) return;
- string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
- string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
- FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList,
- panelOfTable, dataGridViewX1, layer, hxName);
+ string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
+ string redLineName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
+ FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, layerName, redLineName);
frm.Location = new Point(Width - frm.Width - 10, Height - frm.Height - 20);
frm.Show(this);
from = frm;
@@ -6547,8 +6546,6 @@
LogManager.saveLog(Utility.userName, buttonItemBZ5.Text);
globeControl1.Globe.Action = EnumAction3D.TrackPolyline;
- //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure;
-// distanceMarker = true;
}
///
/// 自定义标注
@@ -6618,24 +6615,6 @@
}
}
///
- /// 红线工具
- ///
- ///
- ///
-// private void buttonItemBZ10_Click(object sender, EventArgs e)
-// {
-// //日志记录
-// LogManager.saveLog(Utility.userName, buttonItemBZ10.Text);
-// setMarkerLayerUnVisible("红线工具");
-// GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("红线工具");
-// if (l == null) return;
-// l.Visible = true;
-// globeControl1.Globe.DestLayerFeatureAdd = l;
-// l.Editable = true;
-// globeControl1.Globe.Action = EnumAction3D.DrawPolygon;
-// m_isDrawRedPology = true;
-// }
- ///
/// 标注管理
///
///
@@ -7450,19 +7429,7 @@
MessageBox.Show("删除成功!", "提示");
globeControl1.Globe.Action = EnumAction3D.ActionNull;
}
-
- public struct LineStruct
- {
- public string layerName;
- public string layerCode;
- public string lineLength;
- public string hxName;
- }
-
- List lineStruct = new List();
- List featsList = new List();
-
- ///
+
/// 红线审核
///
///
@@ -7470,47 +7437,61 @@
private void buttonItemHX2_Click(object sender, EventArgs e)
{
LogManager.saveLog(Utility.userName, buttonItemHX2.Text);
- redSH = true;
- featsList.Clear();
- lineStruct.Clear();
- List listPipelineLayers = new List();
+ RedLineAnalysisTool.redLineResultList.Clear();
- GSOLayer layer = null;
- for (int i = 0; i < Utility.m_PipelineLayerNames.Count; i++)
- {
- layer = globeControl1.Globe.Layers.GetLayerByCaption(Utility.m_PipelineLayerNames[i]);
- if (layer == null) continue;
- listPipelineLayers.Add(layer);
- }
- //yanxiaowei 重构
GSOFeatures selectFeatures = new GSOFeatures();
+ GSOLayer layer = null;
for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++)
{
GSOFeature feature = null;
globeControl1.Globe.GetSelectObject(i, out feature, out layer);
selectFeatures.Add(feature);
}
- DataTable table = new DataTable();
-
- ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1,
- listPipelineLayers, out lineStruct, out featsList);
-
- if (table!=null&&table.Rows.Count == 0)
+ try
{
- MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
- dataGridViewX1.DataSource = null;
- panelOfTable.Visible = false;
- }
- else
- AddDatagridView(table);
- }
+ RedLineAnalysisTool.redLineResultList =
+ RedLineAnalysisTool.Anaylysis(selectFeatures, Utility.m_PipelineLayerNames, globeControl1);
- private void AddDatagridView(DataTable table)
+ if (RedLineAnalysisTool.redLineResultList == null || RedLineAnalysisTool.redLineResultList.Count != 0)
+ addRedLineDataToDataGridView(RedLineAnalysisTool.redLineResultList, dataGridViewX1);
+ else
+ {
+ MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
+ dataGridViewX1.DataSource = null;
+ panelOfTable.Visible = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ redSH = false;
+ LogHelper.WriteLog(typeof(MainFrm), ex);
+ }
+ }
+ void addRedLineDataToDataGridView(List dt, DataGridView dataGridView)
{
- dataGridViewX1.DataSource = table;
+ DataTable table=new DataTable();
+ table.Columns.Add("红线编号");
+ table.Columns.Add("管线类型");
+ table.Columns.Add("侵占面积/m³");
+ table.Columns.Add("侵入长度/m");
+ table.Columns.Add("侵入管线长度");
+ table.Columns.Add("侵入附属物个数");
+ for (int i = 0; i < dt.Count; i++)
+ {
+ DataRow row = table.NewRow();
+ row[0] = dt[i].RedLineName;
+ row[1] = dt[i].LayerName;
+ row[2] = dt[i].MinArea.ToString("0.00");
+ row[3] = dt[i].Length.ToString("0.00");
+ row[4] = dt[i].LineFeaturesInRedLine == null ? 0 : dt[i].LineFeaturesInRedLine.Length;
+ row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
+ table.Rows.Add(row);
+ }
+ dataGridView.DataSource = table;
+ redSH = true;
panelOfTable.Visible = true;
panelOfTable.Height = 200;
- toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条";
+ toolStripNumbers.Text = "红线审核 |共有:" + dataGridView.Rows.Count + "条";
toolStripDropDownButton3.Visible = true;
}
@@ -7535,7 +7516,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList);
+ ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index e2dfcad..aadbd3f 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -48,20 +48,7 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -130,21 +117,8 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
sheet1.Name = "水平距离";
for (int i = 0; i < dt1.Columns.Count; i++)
@@ -161,21 +135,8 @@
sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[1, dt1.Columns.Count]];
- //重新选择单元格范围
- int rowscount1 = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount1 = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er1.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er1.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt1);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -204,172 +165,147 @@
///
///
///
- public static void ExpToExcel(DataGridView dt, string strSaveFile, string str, List lineStrcut, List featsList)
+ public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
{
+ if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
- string layer = "";
- string hxName = "";
+ string layerName = "";
+ string redLineName = "";
- //创建一个EXCEL应用程序
- Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
- excel.Visible = false;
- //定义缺省值
- Missing miss = Missing.Value;
- //创建一个新的工作簿
- Workbooks workbooks = excel.Workbooks;
+ Application excel = new Application();//创建一个EXCEL应用程序
+ excel.Visible = false; //是否显示导出过程(显示创建后的EXCEL)
+ Missing miss = Missing.Value;//定义缺省值
+ Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = null;
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ sheet.Name = str;
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ }
+ //填充数据
+ for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ }
+ }
+ sheetStype(sheet, dt);
+
+ for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
{
if (workbook.Worksheets.Count > sheetCount)
- {
sheet = workbook.Worksheets[sheetCount + 1];
- }
else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- sheet = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ dataTable.Columns.Add("编号");
- if (sheetCount == 0)
+ layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
+ redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
+
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == layerName
+ && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ DataRow row = dataTable.NewRow();
+ row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption;
+ row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name;
+ dataTable.Rows.Add(row);
}
-
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
-
}
- else
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0)
{
-
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layer = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- hxName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- for (int i = 0; i < lineStrcut.Count; i++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length;j++)
{
- if (lineStrcut[i].layerName == layer && lineStrcut[i].hxName == hxName)
+ GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
+ if (feats[0].Dataset.Caption.Contains(layerName))
{
- DataRow row = dataTable.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dataTable.Rows.Add(row);
- }
- }
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
+ for (int n = 0; n < feats.Length; n++)
{
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dataTable.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dataTable.Rows.Add(pointRow);
- }
+ DataRow pointRow = dataTable.NewRow();
+ pointRow[0] = feats[n].Dataset.Caption;
+ pointRow[1] = feats[n].GetFieldAsString("编号");
+ dataTable.Rows.Add(pointRow);
}
}
}
-
- if (!sheetNameList.Contains(layer))
- {
- sheet.Name = layer;
- sheetNameList.Add(layer);
- }
- else
- {
- sheet.Name = layer + "1";
- sheetNameList.Add(layer + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
-
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
-
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dataTable.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dataTable.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
-
+
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
+ }
+
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ sheetStype(sheet, dataTable);
}
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
+ if (File.Exists(strSaveFile))
{
int z = 1;
do
{
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
+ strSaveFile = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
z++;
- } while (File.Exists(strSaveFile2));
+ } while (File.Exists(strSaveFile));
}
-
- workbook.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
+ workbook.SaveAs(strSaveFile, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
+ workbook.Close(false, miss, miss); //关闭表格
workbooks.Close();
- //释放资源
- excel.Quit();
-
+ excel.Quit();//释放资源
}
+ static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
+
+ static void sheetStype(Worksheet sheet, DataTable dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
///
/// 杀死进程
///
diff --git a/FrmAnalysisGuiHuaResult.Designer.cs b/FrmAnalysisGuiHuaResult.Designer.cs
index c7d026d..eb3d275 100644
--- a/FrmAnalysisGuiHuaResult.Designer.cs
+++ b/FrmAnalysisGuiHuaResult.Designer.cs
@@ -49,7 +49,7 @@
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(384, 186);
this.dataGridView1.TabIndex = 0;
- this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
+ //this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
//
// timer1
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 2e2adfd..6d9c10c 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -3,7 +3,6 @@
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;
-using DevComponents.DotNetBar.Controls;
using GeoScene.Data;
using GeoScene.Globe;
@@ -11,33 +10,18 @@
{
public partial class FrmAnalysisGuiHuaResult : Office2007Form
{
-
- //DataTable dt = null;
- //定位和闪烁初始化定义
int count;
- private string flashflag = "single";
GSOFeature hlfeature;
public GSOGlobeControl globleControl1;
+ string layerName;
+ string redLineName;
- DataGridViewX dataGridView2;
- List lineStrcut = new List();
- PanelEx panel;
- //ToolStripStatusLabel toolStripNumbers;
- //ToolStripStatusLabel toolStripFeatureLength;
- string layer;
- string hxName;
- List featsList = new List();
-
- public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, List _lineStrcut, List _featsList,PanelEx p, DataGridViewX _dataGridView1,string _layer,string _hxName)
+ public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, string _layerName,string _redLineName)
{
InitializeComponent();
- lineStrcut = _lineStrcut;
- panel = p;
globleControl1 = _globleControl1;
- dataGridView2 = _dataGridView1;
- layer = _layer;
- hxName = _hxName;
- featsList = _featsList;
+ layerName = _layerName;
+ redLineName = _redLineName;
}
private void FrmAnalysisGuiHuaResult_Load(object sender, EventArgs e)
@@ -45,88 +29,50 @@
DataTable dt = new DataTable();
dt.Columns.Add("图层类型");
dt.Columns.Add("编号");
+ if (RedLineAnalysisTool.redLineResultList.Count == 0) return;
- for (int i = 0; i < lineStrcut.Count;i++ )
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList.Count; i++)
{
- if (lineStrcut[i].layerName == layer&&lineStrcut[i].hxName==hxName)
+ if (RedLineAnalysisTool.redLineResultList[i].LayerName == layerName
+ && RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
- DataRow row = dt.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dt.Rows.Add(row);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
- {
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dt.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dt.Rows.Add(pointRow);
- }
- }
- }
- }
-
+
dataGridView1.DataSource = dt;
dataGridView1.Columns[1].Width = 200;
}
+ void addDataToDataTable(DataTable dt,GSOFeatures features)
+ {
+ for (int m = 0; m < features.Length; m++)
+ {
+ DataRow row = dt.NewRow();
+ row[0] = features[m].Dataset.Caption;
+ row[1] = features[m].Name;
+ dt.Rows.Add(row);
+ }
+ }
+
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
- if (e.RowIndex > -1)
+ if (e.RowIndex <= -1) return;
+
+ string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
+
+ GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName);
+ GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
+ if (rowFeatures.Length == 0)
{
- string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
-
- GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer);
- GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- if (rowFeatures.Length == 0)
- {
- gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer + "附属物");
- rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- }
- GSOFeature feature = rowFeatures[0];
- hlfeature = feature;
- highlight();
- //globleControl1.Globe.FlyToFeature(feature, 0, 45, 3);
- globleControl1.Globe.JumpToFeature(feature, 10);
-
- #region
- //string layer = dataGridView1.Rows[e.RowIndex].Cells["管线类型"].Value.ToString();
-
- //string sql = "select " + getpipeLineFields.getFields(layer, globleControl1) + " from " + layer + " where 编号 = ";
- //for (int i = 0; i < lineStrcut.Count; i++)
- //{
- // if (i == lineStrcut.Count - 1)
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'";
- // }
- // else
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'" + " or 编号 = ";
- // }
-
- //}
-
- //DataTable table = OledbHelper.QueryTable(sql);
- //if (table != null && table.Rows.Count > 0)
- //{
- // dataGridView2.DataSource = table;
- // panel.Visible = true;
- // toolStripNumbers.Text =layer;
- // toolStripFeatureLength.Text = " 共有:" + table.Rows.Count + "条";
- //}
- //else
- //{
- //}
- #endregion
+ gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName + "附属物");
+ rowFeatures = gsoLayer.GetFeatureByName(BH, true);
}
+ GSOFeature feature = rowFeatures[0];
+ hlfeature = feature;
+ highlight();
+ globleControl1.Globe.JumpToFeature(feature, 10);
}
///
@@ -134,7 +80,6 @@
///
public void highlight()
{
- flashflag = "single";
timer1.Start();
}
@@ -147,20 +92,17 @@
if (count < 100)
{
count++;
- if (flashflag == "single")
+ if (rowFeature != null)
{
- if (rowFeature != null)
+ if (count%2 != 0)
{
- if (count % 2 != 0)
- {
- rowFeature.HighLight = true;
- globleControl1.Refresh();
- }
- else
- {
- rowFeature.HighLight = false;
- globleControl1.Refresh();
- }
+ rowFeature.HighLight = true;
+ globleControl1.Refresh();
+ }
+ else
+ {
+ rowFeature.HighLight = false;
+ globleControl1.Refresh();
}
}
}
@@ -170,25 +112,12 @@
rowFeature.HighLight = false;
count = 0;
}
-
}
private void FrmAnalysisGuiHuaResult_FormClosing(object sender, FormClosingEventArgs e)
{
- //dataGridView2.DataSource = null;
- //dataGridView2.Refresh();
- //panel.Visible = false;
- //toolStripNumbers.Text = " 类型:";
- //toolStripFeatureLength.Text = " 管线里程:";
- //lineStrcut.Clear();
-
timer1.Stop();
}
- int rowIndex;
- private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- rowIndex = e.RowIndex;
- }
}
}
diff --git a/MainFrm.cs b/MainFrm.cs
index 736aba3..3c5b756 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -5511,10 +5511,9 @@
{
DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y);
if (hittestinfo.RowIndex < 0) return;
- string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
- string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
- FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList,
- panelOfTable, dataGridViewX1, layer, hxName);
+ string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
+ string redLineName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
+ FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, layerName, redLineName);
frm.Location = new Point(Width - frm.Width - 10, Height - frm.Height - 20);
frm.Show(this);
from = frm;
@@ -6547,8 +6546,6 @@
LogManager.saveLog(Utility.userName, buttonItemBZ5.Text);
globeControl1.Globe.Action = EnumAction3D.TrackPolyline;
- //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure;
-// distanceMarker = true;
}
///
/// 自定义标注
@@ -6618,24 +6615,6 @@
}
}
///
- /// 红线工具
- ///
- ///
- ///
-// private void buttonItemBZ10_Click(object sender, EventArgs e)
-// {
-// //日志记录
-// LogManager.saveLog(Utility.userName, buttonItemBZ10.Text);
-// setMarkerLayerUnVisible("红线工具");
-// GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("红线工具");
-// if (l == null) return;
-// l.Visible = true;
-// globeControl1.Globe.DestLayerFeatureAdd = l;
-// l.Editable = true;
-// globeControl1.Globe.Action = EnumAction3D.DrawPolygon;
-// m_isDrawRedPology = true;
-// }
- ///
/// 标注管理
///
///
@@ -7450,19 +7429,7 @@
MessageBox.Show("删除成功!", "提示");
globeControl1.Globe.Action = EnumAction3D.ActionNull;
}
-
- public struct LineStruct
- {
- public string layerName;
- public string layerCode;
- public string lineLength;
- public string hxName;
- }
-
- List lineStruct = new List();
- List featsList = new List();
-
- ///
+
/// 红线审核
///
///
@@ -7470,47 +7437,61 @@
private void buttonItemHX2_Click(object sender, EventArgs e)
{
LogManager.saveLog(Utility.userName, buttonItemHX2.Text);
- redSH = true;
- featsList.Clear();
- lineStruct.Clear();
- List listPipelineLayers = new List();
+ RedLineAnalysisTool.redLineResultList.Clear();
- GSOLayer layer = null;
- for (int i = 0; i < Utility.m_PipelineLayerNames.Count; i++)
- {
- layer = globeControl1.Globe.Layers.GetLayerByCaption(Utility.m_PipelineLayerNames[i]);
- if (layer == null) continue;
- listPipelineLayers.Add(layer);
- }
- //yanxiaowei 重构
GSOFeatures selectFeatures = new GSOFeatures();
+ GSOLayer layer = null;
for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++)
{
GSOFeature feature = null;
globeControl1.Globe.GetSelectObject(i, out feature, out layer);
selectFeatures.Add(feature);
}
- DataTable table = new DataTable();
-
- ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1,
- listPipelineLayers, out lineStruct, out featsList);
-
- if (table!=null&&table.Rows.Count == 0)
+ try
{
- MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
- dataGridViewX1.DataSource = null;
- panelOfTable.Visible = false;
- }
- else
- AddDatagridView(table);
- }
+ RedLineAnalysisTool.redLineResultList =
+ RedLineAnalysisTool.Anaylysis(selectFeatures, Utility.m_PipelineLayerNames, globeControl1);
- private void AddDatagridView(DataTable table)
+ if (RedLineAnalysisTool.redLineResultList == null || RedLineAnalysisTool.redLineResultList.Count != 0)
+ addRedLineDataToDataGridView(RedLineAnalysisTool.redLineResultList, dataGridViewX1);
+ else
+ {
+ MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
+ dataGridViewX1.DataSource = null;
+ panelOfTable.Visible = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ redSH = false;
+ LogHelper.WriteLog(typeof(MainFrm), ex);
+ }
+ }
+ void addRedLineDataToDataGridView(List dt, DataGridView dataGridView)
{
- dataGridViewX1.DataSource = table;
+ DataTable table=new DataTable();
+ table.Columns.Add("红线编号");
+ table.Columns.Add("管线类型");
+ table.Columns.Add("侵占面积/m³");
+ table.Columns.Add("侵入长度/m");
+ table.Columns.Add("侵入管线长度");
+ table.Columns.Add("侵入附属物个数");
+ for (int i = 0; i < dt.Count; i++)
+ {
+ DataRow row = table.NewRow();
+ row[0] = dt[i].RedLineName;
+ row[1] = dt[i].LayerName;
+ row[2] = dt[i].MinArea.ToString("0.00");
+ row[3] = dt[i].Length.ToString("0.00");
+ row[4] = dt[i].LineFeaturesInRedLine == null ? 0 : dt[i].LineFeaturesInRedLine.Length;
+ row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
+ table.Rows.Add(row);
+ }
+ dataGridView.DataSource = table;
+ redSH = true;
panelOfTable.Visible = true;
panelOfTable.Height = 200;
- toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条";
+ toolStripNumbers.Text = "红线审核 |共有:" + dataGridView.Rows.Count + "条";
toolStripDropDownButton3.Visible = true;
}
@@ -7535,7 +7516,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList);
+ ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/RedLineAnalysisTool.cs b/RedLineAnalysisTool.cs
index 8da0ca9..1970d6a 100644
--- a/RedLineAnalysisTool.cs
+++ b/RedLineAnalysisTool.cs
@@ -43,6 +43,7 @@
get { return _redLineName; }
set { _redLineName = value; }
}
+
public double MinArea
{
get { return _minArea; }
@@ -56,6 +57,8 @@
}
}
+ public static List redLineResultList=new List();
+
public static List Anaylysis(GSOFeatures redLineFeatures,
List layerNames, GSOGlobeControl globe)
{
@@ -65,10 +68,8 @@
{
GSOFeature redLineFeature = redLineFeatures[i];
GSOGeoPolyline3D polyline3D = redLineFeature.Geometry as GSOGeoPolyline3D;
- if(polyline3D==null)
- {
+ if (polyline3D == null)
continue;
- }
GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
polygon.AddPart(polyline3D[0]);
@@ -79,13 +80,12 @@
{
RedLineResult redLineResult = new RedLineResult();
redLineResult.LayerName = layerName;
-
+ redLineResult.RedLineName = redLineFeature.Name;
+
GSOLayer lineLayer = globe.Globe.Layers.GetLayerByCaption(layerName);
GSOLayer pointLayer = globe.Globe.Layers.GetLayerByCaption(layerName + "附属物");
if (lineLayer == null)
- {
continue;
- }
// 保存在红线地块范围内的附属物要素
if (pointLayer != null)
{
@@ -111,6 +111,9 @@
}
redLineResult.MinArea = area;*/
redLineResult.MinArea = 0;
+ if (redLineResult.LineFeaturesInRedLine.Length == 0 &&
+ redLineResult.PointFeaturesInRedLine.Length == 0)
+ continue;
results.Add(redLineResult);
}
}
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index e2dfcad..aadbd3f 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -48,20 +48,7 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -130,21 +117,8 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
sheet1.Name = "水平距离";
for (int i = 0; i < dt1.Columns.Count; i++)
@@ -161,21 +135,8 @@
sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[1, dt1.Columns.Count]];
- //重新选择单元格范围
- int rowscount1 = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount1 = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er1.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er1.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt1);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -204,172 +165,147 @@
///
///
///
- public static void ExpToExcel(DataGridView dt, string strSaveFile, string str, List lineStrcut, List featsList)
+ public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
{
+ if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
- string layer = "";
- string hxName = "";
+ string layerName = "";
+ string redLineName = "";
- //创建一个EXCEL应用程序
- Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
- excel.Visible = false;
- //定义缺省值
- Missing miss = Missing.Value;
- //创建一个新的工作簿
- Workbooks workbooks = excel.Workbooks;
+ Application excel = new Application();//创建一个EXCEL应用程序
+ excel.Visible = false; //是否显示导出过程(显示创建后的EXCEL)
+ Missing miss = Missing.Value;//定义缺省值
+ Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = null;
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ sheet.Name = str;
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ }
+ //填充数据
+ for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ }
+ }
+ sheetStype(sheet, dt);
+
+ for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
{
if (workbook.Worksheets.Count > sheetCount)
- {
sheet = workbook.Worksheets[sheetCount + 1];
- }
else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- sheet = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ dataTable.Columns.Add("编号");
- if (sheetCount == 0)
+ layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
+ redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
+
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == layerName
+ && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ DataRow row = dataTable.NewRow();
+ row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption;
+ row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name;
+ dataTable.Rows.Add(row);
}
-
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
-
}
- else
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0)
{
-
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layer = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- hxName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- for (int i = 0; i < lineStrcut.Count; i++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length;j++)
{
- if (lineStrcut[i].layerName == layer && lineStrcut[i].hxName == hxName)
+ GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
+ if (feats[0].Dataset.Caption.Contains(layerName))
{
- DataRow row = dataTable.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dataTable.Rows.Add(row);
- }
- }
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
+ for (int n = 0; n < feats.Length; n++)
{
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dataTable.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dataTable.Rows.Add(pointRow);
- }
+ DataRow pointRow = dataTable.NewRow();
+ pointRow[0] = feats[n].Dataset.Caption;
+ pointRow[1] = feats[n].GetFieldAsString("编号");
+ dataTable.Rows.Add(pointRow);
}
}
}
-
- if (!sheetNameList.Contains(layer))
- {
- sheet.Name = layer;
- sheetNameList.Add(layer);
- }
- else
- {
- sheet.Name = layer + "1";
- sheetNameList.Add(layer + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
-
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
-
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dataTable.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dataTable.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
-
+
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
+ }
+
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ sheetStype(sheet, dataTable);
}
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
+ if (File.Exists(strSaveFile))
{
int z = 1;
do
{
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
+ strSaveFile = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
z++;
- } while (File.Exists(strSaveFile2));
+ } while (File.Exists(strSaveFile));
}
-
- workbook.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
+ workbook.SaveAs(strSaveFile, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
+ workbook.Close(false, miss, miss); //关闭表格
workbooks.Close();
- //释放资源
- excel.Quit();
-
+ excel.Quit();//释放资源
}
+ static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
+
+ static void sheetStype(Worksheet sheet, DataTable dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
///
/// 杀死进程
///
diff --git a/FrmAnalysisGuiHuaResult.Designer.cs b/FrmAnalysisGuiHuaResult.Designer.cs
index c7d026d..eb3d275 100644
--- a/FrmAnalysisGuiHuaResult.Designer.cs
+++ b/FrmAnalysisGuiHuaResult.Designer.cs
@@ -49,7 +49,7 @@
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(384, 186);
this.dataGridView1.TabIndex = 0;
- this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
+ //this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
//
// timer1
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 2e2adfd..6d9c10c 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -3,7 +3,6 @@
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;
-using DevComponents.DotNetBar.Controls;
using GeoScene.Data;
using GeoScene.Globe;
@@ -11,33 +10,18 @@
{
public partial class FrmAnalysisGuiHuaResult : Office2007Form
{
-
- //DataTable dt = null;
- //定位和闪烁初始化定义
int count;
- private string flashflag = "single";
GSOFeature hlfeature;
public GSOGlobeControl globleControl1;
+ string layerName;
+ string redLineName;
- DataGridViewX dataGridView2;
- List lineStrcut = new List();
- PanelEx panel;
- //ToolStripStatusLabel toolStripNumbers;
- //ToolStripStatusLabel toolStripFeatureLength;
- string layer;
- string hxName;
- List featsList = new List();
-
- public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, List _lineStrcut, List _featsList,PanelEx p, DataGridViewX _dataGridView1,string _layer,string _hxName)
+ public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, string _layerName,string _redLineName)
{
InitializeComponent();
- lineStrcut = _lineStrcut;
- panel = p;
globleControl1 = _globleControl1;
- dataGridView2 = _dataGridView1;
- layer = _layer;
- hxName = _hxName;
- featsList = _featsList;
+ layerName = _layerName;
+ redLineName = _redLineName;
}
private void FrmAnalysisGuiHuaResult_Load(object sender, EventArgs e)
@@ -45,88 +29,50 @@
DataTable dt = new DataTable();
dt.Columns.Add("图层类型");
dt.Columns.Add("编号");
+ if (RedLineAnalysisTool.redLineResultList.Count == 0) return;
- for (int i = 0; i < lineStrcut.Count;i++ )
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList.Count; i++)
{
- if (lineStrcut[i].layerName == layer&&lineStrcut[i].hxName==hxName)
+ if (RedLineAnalysisTool.redLineResultList[i].LayerName == layerName
+ && RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
- DataRow row = dt.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dt.Rows.Add(row);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
- {
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dt.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dt.Rows.Add(pointRow);
- }
- }
- }
- }
-
+
dataGridView1.DataSource = dt;
dataGridView1.Columns[1].Width = 200;
}
+ void addDataToDataTable(DataTable dt,GSOFeatures features)
+ {
+ for (int m = 0; m < features.Length; m++)
+ {
+ DataRow row = dt.NewRow();
+ row[0] = features[m].Dataset.Caption;
+ row[1] = features[m].Name;
+ dt.Rows.Add(row);
+ }
+ }
+
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
- if (e.RowIndex > -1)
+ if (e.RowIndex <= -1) return;
+
+ string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
+
+ GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName);
+ GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
+ if (rowFeatures.Length == 0)
{
- string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
-
- GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer);
- GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- if (rowFeatures.Length == 0)
- {
- gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer + "附属物");
- rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- }
- GSOFeature feature = rowFeatures[0];
- hlfeature = feature;
- highlight();
- //globleControl1.Globe.FlyToFeature(feature, 0, 45, 3);
- globleControl1.Globe.JumpToFeature(feature, 10);
-
- #region
- //string layer = dataGridView1.Rows[e.RowIndex].Cells["管线类型"].Value.ToString();
-
- //string sql = "select " + getpipeLineFields.getFields(layer, globleControl1) + " from " + layer + " where 编号 = ";
- //for (int i = 0; i < lineStrcut.Count; i++)
- //{
- // if (i == lineStrcut.Count - 1)
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'";
- // }
- // else
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'" + " or 编号 = ";
- // }
-
- //}
-
- //DataTable table = OledbHelper.QueryTable(sql);
- //if (table != null && table.Rows.Count > 0)
- //{
- // dataGridView2.DataSource = table;
- // panel.Visible = true;
- // toolStripNumbers.Text =layer;
- // toolStripFeatureLength.Text = " 共有:" + table.Rows.Count + "条";
- //}
- //else
- //{
- //}
- #endregion
+ gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName + "附属物");
+ rowFeatures = gsoLayer.GetFeatureByName(BH, true);
}
+ GSOFeature feature = rowFeatures[0];
+ hlfeature = feature;
+ highlight();
+ globleControl1.Globe.JumpToFeature(feature, 10);
}
///
@@ -134,7 +80,6 @@
///
public void highlight()
{
- flashflag = "single";
timer1.Start();
}
@@ -147,20 +92,17 @@
if (count < 100)
{
count++;
- if (flashflag == "single")
+ if (rowFeature != null)
{
- if (rowFeature != null)
+ if (count%2 != 0)
{
- if (count % 2 != 0)
- {
- rowFeature.HighLight = true;
- globleControl1.Refresh();
- }
- else
- {
- rowFeature.HighLight = false;
- globleControl1.Refresh();
- }
+ rowFeature.HighLight = true;
+ globleControl1.Refresh();
+ }
+ else
+ {
+ rowFeature.HighLight = false;
+ globleControl1.Refresh();
}
}
}
@@ -170,25 +112,12 @@
rowFeature.HighLight = false;
count = 0;
}
-
}
private void FrmAnalysisGuiHuaResult_FormClosing(object sender, FormClosingEventArgs e)
{
- //dataGridView2.DataSource = null;
- //dataGridView2.Refresh();
- //panel.Visible = false;
- //toolStripNumbers.Text = " 类型:";
- //toolStripFeatureLength.Text = " 管线里程:";
- //lineStrcut.Clear();
-
timer1.Stop();
}
- int rowIndex;
- private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- rowIndex = e.RowIndex;
- }
}
}
diff --git a/MainFrm.cs b/MainFrm.cs
index 736aba3..3c5b756 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -5511,10 +5511,9 @@
{
DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y);
if (hittestinfo.RowIndex < 0) return;
- string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
- string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
- FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList,
- panelOfTable, dataGridViewX1, layer, hxName);
+ string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
+ string redLineName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
+ FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, layerName, redLineName);
frm.Location = new Point(Width - frm.Width - 10, Height - frm.Height - 20);
frm.Show(this);
from = frm;
@@ -6547,8 +6546,6 @@
LogManager.saveLog(Utility.userName, buttonItemBZ5.Text);
globeControl1.Globe.Action = EnumAction3D.TrackPolyline;
- //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure;
-// distanceMarker = true;
}
///
/// 自定义标注
@@ -6618,24 +6615,6 @@
}
}
///
- /// 红线工具
- ///
- ///
- ///
-// private void buttonItemBZ10_Click(object sender, EventArgs e)
-// {
-// //日志记录
-// LogManager.saveLog(Utility.userName, buttonItemBZ10.Text);
-// setMarkerLayerUnVisible("红线工具");
-// GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("红线工具");
-// if (l == null) return;
-// l.Visible = true;
-// globeControl1.Globe.DestLayerFeatureAdd = l;
-// l.Editable = true;
-// globeControl1.Globe.Action = EnumAction3D.DrawPolygon;
-// m_isDrawRedPology = true;
-// }
- ///
/// 标注管理
///
///
@@ -7450,19 +7429,7 @@
MessageBox.Show("删除成功!", "提示");
globeControl1.Globe.Action = EnumAction3D.ActionNull;
}
-
- public struct LineStruct
- {
- public string layerName;
- public string layerCode;
- public string lineLength;
- public string hxName;
- }
-
- List lineStruct = new List();
- List featsList = new List();
-
- ///
+
/// 红线审核
///
///
@@ -7470,47 +7437,61 @@
private void buttonItemHX2_Click(object sender, EventArgs e)
{
LogManager.saveLog(Utility.userName, buttonItemHX2.Text);
- redSH = true;
- featsList.Clear();
- lineStruct.Clear();
- List listPipelineLayers = new List();
+ RedLineAnalysisTool.redLineResultList.Clear();
- GSOLayer layer = null;
- for (int i = 0; i < Utility.m_PipelineLayerNames.Count; i++)
- {
- layer = globeControl1.Globe.Layers.GetLayerByCaption(Utility.m_PipelineLayerNames[i]);
- if (layer == null) continue;
- listPipelineLayers.Add(layer);
- }
- //yanxiaowei 重构
GSOFeatures selectFeatures = new GSOFeatures();
+ GSOLayer layer = null;
for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++)
{
GSOFeature feature = null;
globeControl1.Globe.GetSelectObject(i, out feature, out layer);
selectFeatures.Add(feature);
}
- DataTable table = new DataTable();
-
- ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1,
- listPipelineLayers, out lineStruct, out featsList);
-
- if (table!=null&&table.Rows.Count == 0)
+ try
{
- MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
- dataGridViewX1.DataSource = null;
- panelOfTable.Visible = false;
- }
- else
- AddDatagridView(table);
- }
+ RedLineAnalysisTool.redLineResultList =
+ RedLineAnalysisTool.Anaylysis(selectFeatures, Utility.m_PipelineLayerNames, globeControl1);
- private void AddDatagridView(DataTable table)
+ if (RedLineAnalysisTool.redLineResultList == null || RedLineAnalysisTool.redLineResultList.Count != 0)
+ addRedLineDataToDataGridView(RedLineAnalysisTool.redLineResultList, dataGridViewX1);
+ else
+ {
+ MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
+ dataGridViewX1.DataSource = null;
+ panelOfTable.Visible = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ redSH = false;
+ LogHelper.WriteLog(typeof(MainFrm), ex);
+ }
+ }
+ void addRedLineDataToDataGridView(List dt, DataGridView dataGridView)
{
- dataGridViewX1.DataSource = table;
+ DataTable table=new DataTable();
+ table.Columns.Add("红线编号");
+ table.Columns.Add("管线类型");
+ table.Columns.Add("侵占面积/m³");
+ table.Columns.Add("侵入长度/m");
+ table.Columns.Add("侵入管线长度");
+ table.Columns.Add("侵入附属物个数");
+ for (int i = 0; i < dt.Count; i++)
+ {
+ DataRow row = table.NewRow();
+ row[0] = dt[i].RedLineName;
+ row[1] = dt[i].LayerName;
+ row[2] = dt[i].MinArea.ToString("0.00");
+ row[3] = dt[i].Length.ToString("0.00");
+ row[4] = dt[i].LineFeaturesInRedLine == null ? 0 : dt[i].LineFeaturesInRedLine.Length;
+ row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
+ table.Rows.Add(row);
+ }
+ dataGridView.DataSource = table;
+ redSH = true;
panelOfTable.Visible = true;
panelOfTable.Height = 200;
- toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条";
+ toolStripNumbers.Text = "红线审核 |共有:" + dataGridView.Rows.Count + "条";
toolStripDropDownButton3.Visible = true;
}
@@ -7535,7 +7516,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList);
+ ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/RedLineAnalysisTool.cs b/RedLineAnalysisTool.cs
index 8da0ca9..1970d6a 100644
--- a/RedLineAnalysisTool.cs
+++ b/RedLineAnalysisTool.cs
@@ -43,6 +43,7 @@
get { return _redLineName; }
set { _redLineName = value; }
}
+
public double MinArea
{
get { return _minArea; }
@@ -56,6 +57,8 @@
}
}
+ public static List redLineResultList=new List();
+
public static List Anaylysis(GSOFeatures redLineFeatures,
List layerNames, GSOGlobeControl globe)
{
@@ -65,10 +68,8 @@
{
GSOFeature redLineFeature = redLineFeatures[i];
GSOGeoPolyline3D polyline3D = redLineFeature.Geometry as GSOGeoPolyline3D;
- if(polyline3D==null)
- {
+ if (polyline3D == null)
continue;
- }
GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
polygon.AddPart(polyline3D[0]);
@@ -79,13 +80,12 @@
{
RedLineResult redLineResult = new RedLineResult();
redLineResult.LayerName = layerName;
-
+ redLineResult.RedLineName = redLineFeature.Name;
+
GSOLayer lineLayer = globe.Globe.Layers.GetLayerByCaption(layerName);
GSOLayer pointLayer = globe.Globe.Layers.GetLayerByCaption(layerName + "附属物");
if (lineLayer == null)
- {
continue;
- }
// 保存在红线地块范围内的附属物要素
if (pointLayer != null)
{
@@ -111,6 +111,9 @@
}
redLineResult.MinArea = area;*/
redLineResult.MinArea = 0;
+ if (redLineResult.LineFeaturesInRedLine.Length == 0 &&
+ redLineResult.PointFeaturesInRedLine.Length == 0)
+ continue;
results.Add(redLineResult);
}
}
diff --git a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest b/bin/x86/Debug/Cyberpipe.vshost.exe.manifest
deleted file mode 100644
index 061c9ca..0000000
--- a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs
index 537934e..1287480 100644
--- a/ClassDataTableParam.cs
+++ b/ClassDataTableParam.cs
@@ -16,6 +16,4 @@
public string dis;
}
-
-
}
diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs
deleted file mode 100644
index 80427c3..0000000
--- a/ClassGSOTool.cs
+++ /dev/null
@@ -1,525 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Windows.Forms;
-using GeoScene.Data;
-using GeoScene.Engine;
-using GeoScene.Globe;
-
-namespace Cyberpipe
-{
- class ClassGSOTool
- {
- ///
- /// 红线审核
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static DataTable CalculateRedLineResult(out DataTable table, bool redSH, GSOFeatures selectFeatures,
- GSOGlobeControl m_globeControl, List listPipelineLayers, out List lineStruct,
- out List featsList)
- {
- featsList = null;
- lineStruct = null;
- table = null;
-
- if (selectFeatures.Length == 0)
- {
- MessageBox.Show("请选择地块红线!", "提示");
- return null;
- }
- try
- {
- Calculate(out table,selectFeatures, listPipelineLayers,
- m_globeControl, out lineStruct, out featsList);
- }
- catch (Exception ex)
- {
- redSH = false;
- LogError.PublishError(ex);
- MessageBox.Show("没有红线数据,请先导入地块红线!", "提示");
- }
-
- return table;
- }
- ///
- /// 红线审核算法过程
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void Calculate(out DataTable table,GSOFeatures selectFeatures,
- List listPipelineLayers,
- GSOGlobeControl m_globeControl, out List lineStruct,
- out List featsList)
- {
- GSOLayer pointLayer = null;
- GSOLayer layer = null;
-
- featsList = new List();
- lineStruct = new List();
-
- table = new DataTable();
- table.Columns.Add("红线编号");
- table.Columns.Add("管线类型");
- table.Columns.Add("侵占面积" + "\\m³");
- table.Columns.Add("侵入长度" + "\\m");
- table.Columns.Add("侵入管线数量");
- table.Columns.Add("侵入附属物个数");
-
- for (int f = 0; f < selectFeatures.Length; f++)
- {
- GSOGeoPolyline3D polyline = selectFeatures[f].Geometry as GSOGeoPolyline3D;
- GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
- polygon.AddPart(polyline[0]);
- GSOFeature featurePolygon = new GSOFeature();
- featurePolygon.Geometry = polygon;
-
- #region
- for (int j = 0; j < listPipelineLayers.Count; j++)
- {
- layer = listPipelineLayers[j];
- pointLayer = m_globeControl.Globe.Layers.GetLayerByCaption(layer.Caption + "附属物");//管线附属物计算
- GSOFeatures feats = null;
-
- if (pointLayer != null)
- {
- feats = pointLayer.FindFeaturesInPolygon(polygon, false);
- if (feats.Length != 0)
- {
- featsList.Add(feats);
- }
- }
-
- MainFrm.LineStruct lStruct = new MainFrm.LineStruct();
- //获取不完全包含在面中的所有线
- GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false);
- //获取完全包含在面中的所有线
- GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true);
- features = getFeaturesByFilter(features, "编号");
- featuresTrue = getFeaturesByFilter(featuresTrue, "编号");
-
- for (int ft = 0; ft < features.Length; ft++)
- {
- lStruct.layerName = layer.Caption;
- lStruct.layerCode = features[ft].GetFieldAsString("编号");
- lStruct.hxName = selectFeatures[f].Name;
- lineStruct.Add(lStruct);
- }
-
- double lengthTotal = 0.0;
- double areaMin = 0.0;
-
- areaMin = CalculateMinArea(features, featuresTrue, featurePolygon);
- //Predator:bug,minArea修改了features,只涵盖cross
- lengthTotal = CalculateLength(features, featuresTrue, featurePolygon);
-
- if (areaMin != 0 || lengthTotal != 0)
- {
- int lineCount = 0;
- for (int ls = 0; ls < lineStruct.Count; ls++)
- {
- if (lineStruct[ls].layerName == layer.Caption && lineStruct[ls].hxName == selectFeatures[f].Name)
- lineCount++;
- }
- DataRow row = table.NewRow();
-
- row[0] = selectFeatures[f].Name;
- row[1] = layer.Caption;
- row[2] = areaMin.ToString("0.000");
- row[3] = lengthTotal.ToString("0.000");
- row[4] = lineCount;
- row[5] = feats.Length;
- table.Rows.Add(row);
- }
- }
- #endregion
- }
- }
- ///
- /// 计算侵入面积
- ///
- ///
- ///
- ///
- ///
- private static double CalculateMinArea(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- double areaMin = 0;
- //获取面中所有对象组成的切割面的长线
- GSOFeature polygonFeature = getLineFromGSOFeatures(features, featuresTrue);
- if (polygonFeature != null && polygonFeature.Geometry != null)
- {
- GSOFeatures polygonFs = new GSOFeatures();
- int polygoRresult = 0;
- GSODataEngineUtility.GSLineClipPolygon(polygonFeature, featurePolygon, out polygonFs, out polygoRresult);
- ///////////////////////判断面积问题///////////////////////
- if (polygoRresult == 3)
- {
- areaMin = double.MaxValue;
- for (int mm = 0; mm < polygonFs.Length; mm++)
- {
- GSOFeature featurePolgyon = polygonFs[mm];
- if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D)
- {
- GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D;
- double areaPolygon = polygonAnalysis.Area;
- if (areaPolygon < areaMin)
- {
- areaMin = areaPolygon;
- }
- }
- }
- }
- }
- return areaMin;
- }
- ///
- /// 计算侵入长度
- ///
- ///
- ///
- ///
- ///
- private static double CalculateLength(GSOFeatures features, GSOFeatures featuresTrue, GSOFeature featurePolygon)
- {
- String ss = "";
-
- double lengthTotal = 0;
- for (int m = 0; m < features.Length; m++)
- {
- GSOFeature feature = features[m];
- if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- bool isFullInPolygon = false;
- for (int n = 0; n < featuresTrue.Length; n++)
- {
- if (feature.ID == featuresTrue[n].ID)
- {
- isFullInPolygon = true;
- break;
- }
- }
- if (isFullInPolygon)
- {
- GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
- double lineLength = line.GetSpaceLength(false, 6378137);
- lengthTotal += lineLength;
- ss = ss + " 全包含管段" + line.ID + "长度:" + lineLength;
- }
- else
- {
- GSOFeatures fs = new GSOFeatures();
- int result = 0;
- GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result);
- if (result == 1)
- {
- double tt = 0;
- for (int k = 0; k < fs.Length; k++)
- {
- GSOFeature featureline = fs[k];
- if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D)
- {
- GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D;
- double length = lineAnalysis.GetSpaceLength(false, 6378137);
- tt += length;
- lengthTotal += length;
- }
- }
- ss = ss + " 半包含管段" + feature.ID + "长度:" + tt;
- }
- }
- }
- }
- return lengthTotal;
- }
- ///
- /// 去除集合中重复的管线
- ///
- ///
- ///
- ///
- private static GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName)
- {
- if (features == null) return null;
-
- GSOFeatures featuresGet = new GSOFeatures();
- for (int i = 0; i < features.Length; i++)
- {
- GSOFeature featureFromFS = features[i];
- string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim();
- bool isHas = false;
- for (int j = featuresGet.Length - 1; j >= 0; j--)
- {
- GSOFeature featureFromFSGet = featuresGet[j];
- string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim();
- if (fieldValueFromFS.Equals(fieldValueFromFSGet))
- {
- isHas = true;
- break;
- }
- }
- if (isHas == false)
- {
- featuresGet.Add(featureFromFS.Clone());
- }
- }
- return featuresGet;
- }
- ///
- /// 获取切割面的线
- ///
- /// 不完全包含在面中的所有线
- /// 完全包含在面中的所有线
- /// 线
- private static GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue)
- {
- //1. 当线对象数组的长度为0时,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //2. 当线对象数组的长度为1时,返回这条线
- if (features.Length == 1)
- {
- return features[0];
- }
- //3. 当线对象数组的长度大于1时,计算所有线组成的最长线
-
- //3.1 获取所有不完全包含在面中的对象selectFeatures
- GSOFeatures selectFeatures = new GSOFeatures();
- for (int a = 0; a < features.Length; a++)
- {
- selectFeatures.Add(features[a].Clone());
- }
- //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象
- for (int a = 0; a < featuresTrue.Length; a++)
- {
- for (int b = 0; b < features.Length; b++)
- {
- if (featuresTrue[a].ID == features[b].ID)
- {
- features.Remove(b);
- break;
- }
- }
- }
- //3.3 如果和面的边界相交的线的数量为0,返回空
- if (features.Length == 0)
- {
- return null;
- }
- //3.4 获取第一条和面的边界相交的线featureInOutPolygon
- GSOFeature featureInOutPolygon = features[0];
- //3.5 从所有的线中删除featureInOutPolygon
- for (int a = 0; a < selectFeatures.Length; a++)
- {
- if (selectFeatures[a].ID == featureInOutPolygon.ID)
- {
- selectFeatures.Remove(a);
- break;
- }
- }
- //listPS存储所有从featureInOutPolygon出发的点的集合
- List listPS = new List();
- //3.5 获取与featureInOutPolygon相连的线的集合
- GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D;
- if (line != null && line.PartCount > 0)
- {
- GSOPoint3d lineStart = line[0][0];
- GSOPoint3d lineEnd = line[0][line[0].Count - 1];
- #region//获取和featureInOutPolygon的起点相连的线
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
- }
- }
- }
- #endregion
-
- #region//获取和featureInOutPolygon的终点相连的线
- GSOFeatures fsEnd = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y)
- {
- fsEnd.Add(selectFeatures[n]);
-
- }
- else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsEnd.Add(selectFeatures[n]);
-
- }
- }
- }
- #endregion
-
- //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中
- if (fsStart.Length > 0 && fsEnd.Length == 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = line[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
-
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中
- else if (fsStart.Length == 0 && fsEnd.Length > 0)
- {
- for (int n = 0; n < fsEnd.Length; n++)
- {
- GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D;
- if (lineFsEnd != null && lineFsEnd.PartCount > 0)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = 0; k < line[0].Count - 1; k++)
- {
- psAdd.Add(line[0][k]);
- }
- for (int k = 0; k < lineFsEnd[0].Count; k++)
- {
- psAdd.Add(lineFsEnd[0][k]);
- }
- //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合
- listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- }
-
- //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线
- double maxLength = 0;
- GSOFeature featureNew = new GSOFeature();
- for (int h = 0; h < listPS.Count; h++)
- {
- GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D();
- lineNew.AddPart(listPS[h]);
- GSOLabel label = new GSOLabel();
- label.Text = h.ToString();
- featureNew.Label = label;
- double length = lineNew.GetSpaceLength(true, 6378137);
- if (length > maxLength)
- {
- featureNew.Geometry = lineNew;
- }
- }
- return featureNew;
- }
- ///
- /// 获取与点相连的所有线以及线的点的集合
- ///
- /// 选定的点所在的线
- /// 选定的点
- /// 面中不完全包含的除起点线之外所有的线
- /// 选定的点所在的点的集合
- /// 所有以选定线为起点的点的集合
- ///
- private static List getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List listPS)
- {
- GSOFeatures fsStart = new GSOFeatures();
- for (int n = 0; n < selectFeatures.Length; n++)
- {
- if (featureSelect.ID == selectFeatures[n].ID)
- {
- continue;
- }
- GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D;
- if (newLine != null && newLine.PartCount > 0)
- {
- GSOPoint3d newLineStart = newLine[0][0];
- GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1];
- if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y)
- {
- GSOPoint3ds psAdd = new GSOPoint3ds();
- for (int k = newLine[0].Count - 1; k >= 0; k--)
- {
- psAdd.Add(newLine[0][k]);
- }
- newLine[0] = psAdd;
- fsStart.Add(selectFeatures[n]);
-
- }
- else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y)
- {
- fsStart.Add(selectFeatures[n]);
-
- }
- }
- }
- if (fsStart.Length > 0)
- {
- for (int m = 0; m < fsStart.Length; m++)
- {
- GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D;
- if (lineFsStart != null && lineFsStart.PartCount > 0)
- {
- GSOPoint3ds psAdd = ps.Clone();
- for (int k = 0; k < lineFsStart[0].Count; k++)
- {
- psAdd.Add(lineFsStart[0][k]);
- }
- listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS);
- }
- }
- }
- else
- {
- listPS.Add(ps);
- }
- return listPS;
- }
- }
-}
diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj
index 9dd98bf..c3f8ecc 100644
--- a/Cyberpipe.csproj
+++ b/Cyberpipe.csproj
@@ -206,7 +206,6 @@
-
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index e2dfcad..aadbd3f 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -48,20 +48,7 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -130,21 +117,8 @@
sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt);
sheet1.Name = "水平距离";
for (int i = 0; i < dt1.Columns.Count; i++)
@@ -161,21 +135,8 @@
sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
}
}
- //设置表格样式
- //设置列标题的背景颜色
- Range er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[1, dt1.Columns.Count]];
- //重新选择单元格范围
- int rowscount1 = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount1 = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er1 = sheet1.Range[sheet1.Cells[1, 1], sheet1.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er1.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er1.HorizontalAlignment = XlHAlign.xlHAlignCenter;
+ sheetStype(sheet, dt1);
//保存文件
string strSaveFile2 = strSaveFile;
@@ -204,172 +165,147 @@
///
///
///
- public static void ExpToExcel(DataGridView dt, string strSaveFile, string str, List lineStrcut, List featsList)
+ public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
{
+ if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
- string layer = "";
- string hxName = "";
+ string layerName = "";
+ string redLineName = "";
- //创建一个EXCEL应用程序
- Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
- excel.Visible = false;
- //定义缺省值
- Missing miss = Missing.Value;
- //创建一个新的工作簿
- Workbooks workbooks = excel.Workbooks;
+ Application excel = new Application();//创建一个EXCEL应用程序
+ excel.Visible = false; //是否显示导出过程(显示创建后的EXCEL)
+ Missing miss = Missing.Value;//定义缺省值
+ Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = null;
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ sheet.Name = str;
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ }
+ //填充数据
+ for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ }
+ }
+ sheetStype(sheet, dt);
+
+ for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
{
if (workbook.Worksheets.Count > sheetCount)
- {
sheet = workbook.Worksheets[sheetCount + 1];
- }
else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- sheet = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ dataTable.Columns.Add("编号");
- if (sheetCount == 0)
+ layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
+ redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
+
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == layerName
+ && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ DataRow row = dataTable.NewRow();
+ row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption;
+ row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name;
+ dataTable.Rows.Add(row);
}
-
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dt.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dt.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dt.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
-
}
- else
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0)
{
-
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layer = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- hxName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- for (int i = 0; i < lineStrcut.Count; i++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length;j++)
{
- if (lineStrcut[i].layerName == layer && lineStrcut[i].hxName == hxName)
+ GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
+ if (feats[0].Dataset.Caption.Contains(layerName))
{
- DataRow row = dataTable.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dataTable.Rows.Add(row);
- }
- }
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
+ for (int n = 0; n < feats.Length; n++)
{
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dataTable.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dataTable.Rows.Add(pointRow);
- }
+ DataRow pointRow = dataTable.NewRow();
+ pointRow[0] = feats[n].Dataset.Caption;
+ pointRow[1] = feats[n].GetFieldAsString("编号");
+ dataTable.Rows.Add(pointRow);
}
}
}
-
- if (!sheetNameList.Contains(layer))
- {
- sheet.Name = layer;
- sheetNameList.Add(layer);
- }
- else
- {
- sheet.Name = layer + "1";
- sheetNameList.Add(layer + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
-
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
-
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString();
- }
- }
- //设置表格样式
- //设置列标题的背景颜色
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];
- //重新选择单元格范围
- int rowscount = dataTable.Rows.Count;//this.dataGridView1.Rows.Count;
- int columncount = dataTable.Columns.Count;//this.dataGridView1.ColumnCount;
- //将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];
- //选中EXCEL所有表格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];
- //让EXCEL中的所有单元格的列宽碎文字的长短自动调整
- er.EntireColumn.AutoFit();
- // 让EXCEL的文本水平居中方式
- er.HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
-
+
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
+ }
+
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ sheetStype(sheet, dataTable);
}
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
+ if (File.Exists(strSaveFile))
{
int z = 1;
do
{
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
+ strSaveFile = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
z++;
- } while (File.Exists(strSaveFile2));
+ } while (File.Exists(strSaveFile));
}
-
- workbook.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
+ workbook.SaveAs(strSaveFile, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
+ workbook.Close(false, miss, miss); //关闭表格
workbooks.Close();
- //释放资源
- excel.Quit();
-
+ excel.Quit();//释放资源
}
+ static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
+
+ static void sheetStype(Worksheet sheet, DataTable dataTable)
+ {
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
+ int rowscount = dataTable.Rows.Count;//重新选择单元格范围
+ int columncount = dataTable.Columns.Count;
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
+ er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
+ er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
+ }
///
/// 杀死进程
///
diff --git a/FrmAnalysisGuiHuaResult.Designer.cs b/FrmAnalysisGuiHuaResult.Designer.cs
index c7d026d..eb3d275 100644
--- a/FrmAnalysisGuiHuaResult.Designer.cs
+++ b/FrmAnalysisGuiHuaResult.Designer.cs
@@ -49,7 +49,7 @@
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(384, 186);
this.dataGridView1.TabIndex = 0;
- this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
+ //this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
//
// timer1
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 2e2adfd..6d9c10c 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -3,7 +3,6 @@
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;
-using DevComponents.DotNetBar.Controls;
using GeoScene.Data;
using GeoScene.Globe;
@@ -11,33 +10,18 @@
{
public partial class FrmAnalysisGuiHuaResult : Office2007Form
{
-
- //DataTable dt = null;
- //定位和闪烁初始化定义
int count;
- private string flashflag = "single";
GSOFeature hlfeature;
public GSOGlobeControl globleControl1;
+ string layerName;
+ string redLineName;
- DataGridViewX dataGridView2;
- List lineStrcut = new List();
- PanelEx panel;
- //ToolStripStatusLabel toolStripNumbers;
- //ToolStripStatusLabel toolStripFeatureLength;
- string layer;
- string hxName;
- List featsList = new List();
-
- public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, List _lineStrcut, List _featsList,PanelEx p, DataGridViewX _dataGridView1,string _layer,string _hxName)
+ public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, string _layerName,string _redLineName)
{
InitializeComponent();
- lineStrcut = _lineStrcut;
- panel = p;
globleControl1 = _globleControl1;
- dataGridView2 = _dataGridView1;
- layer = _layer;
- hxName = _hxName;
- featsList = _featsList;
+ layerName = _layerName;
+ redLineName = _redLineName;
}
private void FrmAnalysisGuiHuaResult_Load(object sender, EventArgs e)
@@ -45,88 +29,50 @@
DataTable dt = new DataTable();
dt.Columns.Add("图层类型");
dt.Columns.Add("编号");
+ if (RedLineAnalysisTool.redLineResultList.Count == 0) return;
- for (int i = 0; i < lineStrcut.Count;i++ )
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList.Count; i++)
{
- if (lineStrcut[i].layerName == layer&&lineStrcut[i].hxName==hxName)
+ if (RedLineAnalysisTool.redLineResultList[i].LayerName == layerName
+ && RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
- DataRow row = dt.NewRow();
- row[0] = lineStrcut[i].layerName;
- row[1] = lineStrcut[i].layerCode;
- dt.Rows.Add(row);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
- if (featsList.Count > 0)
- {
- for (int j = 0; j < featsList.Count; j++)
- {
- GSOFeatures feats = featsList[j];
- if (feats[0].Dataset.Caption.Contains(layer))
- {
- for (int n = 0; n < feats.Length; n++)
- {
- DataRow pointRow = dt.NewRow();
- pointRow[0] = feats[n].Dataset.Caption;
- pointRow[1] = feats[n].GetFieldAsString("编号");
- dt.Rows.Add(pointRow);
- }
- }
- }
- }
-
+
dataGridView1.DataSource = dt;
dataGridView1.Columns[1].Width = 200;
}
+ void addDataToDataTable(DataTable dt,GSOFeatures features)
+ {
+ for (int m = 0; m < features.Length; m++)
+ {
+ DataRow row = dt.NewRow();
+ row[0] = features[m].Dataset.Caption;
+ row[1] = features[m].Name;
+ dt.Rows.Add(row);
+ }
+ }
+
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
- if (e.RowIndex > -1)
+ if (e.RowIndex <= -1) return;
+
+ string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
+
+ GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName);
+ GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
+ if (rowFeatures.Length == 0)
{
- string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
-
- GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer);
- GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- if (rowFeatures.Length == 0)
- {
- gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer + "附属物");
- rowFeatures = gsoLayer.GetFeatureByName(BH, true);
- }
- GSOFeature feature = rowFeatures[0];
- hlfeature = feature;
- highlight();
- //globleControl1.Globe.FlyToFeature(feature, 0, 45, 3);
- globleControl1.Globe.JumpToFeature(feature, 10);
-
- #region
- //string layer = dataGridView1.Rows[e.RowIndex].Cells["管线类型"].Value.ToString();
-
- //string sql = "select " + getpipeLineFields.getFields(layer, globleControl1) + " from " + layer + " where 编号 = ";
- //for (int i = 0; i < lineStrcut.Count; i++)
- //{
- // if (i == lineStrcut.Count - 1)
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'";
- // }
- // else
- // {
- // sql += "'" + lineStrcut[i].layerCode + "'" + " or 编号 = ";
- // }
-
- //}
-
- //DataTable table = OledbHelper.QueryTable(sql);
- //if (table != null && table.Rows.Count > 0)
- //{
- // dataGridView2.DataSource = table;
- // panel.Visible = true;
- // toolStripNumbers.Text =layer;
- // toolStripFeatureLength.Text = " 共有:" + table.Rows.Count + "条";
- //}
- //else
- //{
- //}
- #endregion
+ gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layerName + "附属物");
+ rowFeatures = gsoLayer.GetFeatureByName(BH, true);
}
+ GSOFeature feature = rowFeatures[0];
+ hlfeature = feature;
+ highlight();
+ globleControl1.Globe.JumpToFeature(feature, 10);
}
///
@@ -134,7 +80,6 @@
///
public void highlight()
{
- flashflag = "single";
timer1.Start();
}
@@ -147,20 +92,17 @@
if (count < 100)
{
count++;
- if (flashflag == "single")
+ if (rowFeature != null)
{
- if (rowFeature != null)
+ if (count%2 != 0)
{
- if (count % 2 != 0)
- {
- rowFeature.HighLight = true;
- globleControl1.Refresh();
- }
- else
- {
- rowFeature.HighLight = false;
- globleControl1.Refresh();
- }
+ rowFeature.HighLight = true;
+ globleControl1.Refresh();
+ }
+ else
+ {
+ rowFeature.HighLight = false;
+ globleControl1.Refresh();
}
}
}
@@ -170,25 +112,12 @@
rowFeature.HighLight = false;
count = 0;
}
-
}
private void FrmAnalysisGuiHuaResult_FormClosing(object sender, FormClosingEventArgs e)
{
- //dataGridView2.DataSource = null;
- //dataGridView2.Refresh();
- //panel.Visible = false;
- //toolStripNumbers.Text = " 类型:";
- //toolStripFeatureLength.Text = " 管线里程:";
- //lineStrcut.Clear();
-
timer1.Stop();
}
- int rowIndex;
- private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- rowIndex = e.RowIndex;
- }
}
}
diff --git a/MainFrm.cs b/MainFrm.cs
index 736aba3..3c5b756 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -5511,10 +5511,9 @@
{
DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y);
if (hittestinfo.RowIndex < 0) return;
- string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
- string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
- FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList,
- panelOfTable, dataGridViewX1, layer, hxName);
+ string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString();
+ string redLineName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString();
+ FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, layerName, redLineName);
frm.Location = new Point(Width - frm.Width - 10, Height - frm.Height - 20);
frm.Show(this);
from = frm;
@@ -6547,8 +6546,6 @@
LogManager.saveLog(Utility.userName, buttonItemBZ5.Text);
globeControl1.Globe.Action = EnumAction3D.TrackPolyline;
- //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure;
-// distanceMarker = true;
}
///
/// 自定义标注
@@ -6618,24 +6615,6 @@
}
}
///
- /// 红线工具
- ///
- ///
- ///
-// private void buttonItemBZ10_Click(object sender, EventArgs e)
-// {
-// //日志记录
-// LogManager.saveLog(Utility.userName, buttonItemBZ10.Text);
-// setMarkerLayerUnVisible("红线工具");
-// GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("红线工具");
-// if (l == null) return;
-// l.Visible = true;
-// globeControl1.Globe.DestLayerFeatureAdd = l;
-// l.Editable = true;
-// globeControl1.Globe.Action = EnumAction3D.DrawPolygon;
-// m_isDrawRedPology = true;
-// }
- ///
/// 标注管理
///
///
@@ -7450,19 +7429,7 @@
MessageBox.Show("删除成功!", "提示");
globeControl1.Globe.Action = EnumAction3D.ActionNull;
}
-
- public struct LineStruct
- {
- public string layerName;
- public string layerCode;
- public string lineLength;
- public string hxName;
- }
-
- List lineStruct = new List();
- List featsList = new List();
-
- ///
+
/// 红线审核
///
///
@@ -7470,47 +7437,61 @@
private void buttonItemHX2_Click(object sender, EventArgs e)
{
LogManager.saveLog(Utility.userName, buttonItemHX2.Text);
- redSH = true;
- featsList.Clear();
- lineStruct.Clear();
- List listPipelineLayers = new List();
+ RedLineAnalysisTool.redLineResultList.Clear();
- GSOLayer layer = null;
- for (int i = 0; i < Utility.m_PipelineLayerNames.Count; i++)
- {
- layer = globeControl1.Globe.Layers.GetLayerByCaption(Utility.m_PipelineLayerNames[i]);
- if (layer == null) continue;
- listPipelineLayers.Add(layer);
- }
- //yanxiaowei 重构
GSOFeatures selectFeatures = new GSOFeatures();
+ GSOLayer layer = null;
for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++)
{
GSOFeature feature = null;
globeControl1.Globe.GetSelectObject(i, out feature, out layer);
selectFeatures.Add(feature);
}
- DataTable table = new DataTable();
-
- ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1,
- listPipelineLayers, out lineStruct, out featsList);
-
- if (table!=null&&table.Rows.Count == 0)
+ try
{
- MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
- dataGridViewX1.DataSource = null;
- panelOfTable.Visible = false;
- }
- else
- AddDatagridView(table);
- }
+ RedLineAnalysisTool.redLineResultList =
+ RedLineAnalysisTool.Anaylysis(selectFeatures, Utility.m_PipelineLayerNames, globeControl1);
- private void AddDatagridView(DataTable table)
+ if (RedLineAnalysisTool.redLineResultList == null || RedLineAnalysisTool.redLineResultList.Count != 0)
+ addRedLineDataToDataGridView(RedLineAnalysisTool.redLineResultList, dataGridViewX1);
+ else
+ {
+ MessageBox.Show("没有侵入地块红线的管线数据!", "提示");
+ dataGridViewX1.DataSource = null;
+ panelOfTable.Visible = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ redSH = false;
+ LogHelper.WriteLog(typeof(MainFrm), ex);
+ }
+ }
+ void addRedLineDataToDataGridView(List dt, DataGridView dataGridView)
{
- dataGridViewX1.DataSource = table;
+ DataTable table=new DataTable();
+ table.Columns.Add("红线编号");
+ table.Columns.Add("管线类型");
+ table.Columns.Add("侵占面积/m³");
+ table.Columns.Add("侵入长度/m");
+ table.Columns.Add("侵入管线长度");
+ table.Columns.Add("侵入附属物个数");
+ for (int i = 0; i < dt.Count; i++)
+ {
+ DataRow row = table.NewRow();
+ row[0] = dt[i].RedLineName;
+ row[1] = dt[i].LayerName;
+ row[2] = dt[i].MinArea.ToString("0.00");
+ row[3] = dt[i].Length.ToString("0.00");
+ row[4] = dt[i].LineFeaturesInRedLine == null ? 0 : dt[i].LineFeaturesInRedLine.Length;
+ row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
+ table.Rows.Add(row);
+ }
+ dataGridView.DataSource = table;
+ redSH = true;
panelOfTable.Visible = true;
panelOfTable.Height = 200;
- toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条";
+ toolStripNumbers.Text = "红线审核 |共有:" + dataGridView.Rows.Count + "条";
toolStripDropDownButton3.Visible = true;
}
@@ -7535,7 +7516,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList);
+ ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/RedLineAnalysisTool.cs b/RedLineAnalysisTool.cs
index 8da0ca9..1970d6a 100644
--- a/RedLineAnalysisTool.cs
+++ b/RedLineAnalysisTool.cs
@@ -43,6 +43,7 @@
get { return _redLineName; }
set { _redLineName = value; }
}
+
public double MinArea
{
get { return _minArea; }
@@ -56,6 +57,8 @@
}
}
+ public static List redLineResultList=new List();
+
public static List Anaylysis(GSOFeatures redLineFeatures,
List layerNames, GSOGlobeControl globe)
{
@@ -65,10 +68,8 @@
{
GSOFeature redLineFeature = redLineFeatures[i];
GSOGeoPolyline3D polyline3D = redLineFeature.Geometry as GSOGeoPolyline3D;
- if(polyline3D==null)
- {
+ if (polyline3D == null)
continue;
- }
GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
polygon.AddPart(polyline3D[0]);
@@ -79,13 +80,12 @@
{
RedLineResult redLineResult = new RedLineResult();
redLineResult.LayerName = layerName;
-
+ redLineResult.RedLineName = redLineFeature.Name;
+
GSOLayer lineLayer = globe.Globe.Layers.GetLayerByCaption(layerName);
GSOLayer pointLayer = globe.Globe.Layers.GetLayerByCaption(layerName + "附属物");
if (lineLayer == null)
- {
continue;
- }
// 保存在红线地块范围内的附属物要素
if (pointLayer != null)
{
@@ -111,6 +111,9 @@
}
redLineResult.MinArea = area;*/
redLineResult.MinArea = 0;
+ if (redLineResult.LineFeaturesInRedLine.Length == 0 &&
+ redLineResult.PointFeaturesInRedLine.Length == 0)
+ continue;
results.Add(redLineResult);
}
}
diff --git a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest b/bin/x86/Debug/Cyberpipe.vshost.exe.manifest
deleted file mode 100644
index 061c9ca..0000000
--- a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bin/x86/Debug/log/2016/201611/20161122.txt b/bin/x86/Debug/log/2016/201611/20161122.txt
new file mode 100644
index 0000000..e4c5e13
--- /dev/null
+++ b/bin/x86/Debug/log/2016/201611/20161122.txt
@@ -0,0 +1,113 @@
+
+
+��¼ʱ�䣺2016-11-22 14:24:28,896
+�߳�ID:[10]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.InvalidOperationException: ������û���е� DataGridView �ؼ�����С�������������С�
+ �� System.Windows.Forms.DataGridViewRowCollection.AddInternal(Boolean newRow, Object[] values)
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7491
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 14:24:37,178
+�߳�ID:[10]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.InvalidOperationException: ������û���е� DataGridView �ؼ�����С�������������С�
+ �� System.Windows.Forms.DataGridViewRowCollection.AddInternal(Boolean newRow, Object[] values)
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7491
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 14:24:43,641
+�߳�ID:[10]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.InvalidOperationException: ������û���е� DataGridView �ؼ�����С�������������С�
+ �� System.Windows.Forms.DataGridViewRowCollection.AddInternal(Boolean newRow, Object[] values)
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7491
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 14:36:26,698
+�߳�ID:[9]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.NullReferenceException: δ�������������õ������ʵ����
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7504
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 14:46:24,990
+�߳�ID:[8]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.NullReferenceException: δ�������������õ������ʵ����
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7504
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 14:46:28,876
+�߳�ID:[8]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.NullReferenceException: δ�������������õ������ʵ����
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7504
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 14:49:25,642
+�߳�ID:[8]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.NullReferenceException: δ�������������õ������ʵ����
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7504
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 14:49:33,328
+�߳�ID:[8]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.NullReferenceException: δ�������������õ������ʵ����
+ �� Cyberpipe.MainFrm.addRedLineDataToDataGridView(List`1 dt, DataGridView dataGridView) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7504
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7473
+
+
+��¼ʱ�䣺2016-11-22 15:18:04,198
+�߳�ID:[9]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.NullReferenceException: δ�������������õ������ʵ����
+ �� Cyberpipe.RedLineAnalysisTool.Anaylysis(GSOFeatures redLineFeatures, List`1 layerNames, GSOGlobeControl globe) λ�� D:\GHFX\GHFX_REFACTOR\RedLineAnalysisTool.cs:�к� 114
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7469
+
+
+��¼ʱ�䣺2016-11-22 15:18:07,984
+�߳�ID:[9]
+��־���� ERROR
+�����ࣺCyberpipe.MainFrm property: [(null)] -
+����������Error
+
+System.NullReferenceException: δ�������������õ������ʵ����
+ �� Cyberpipe.RedLineAnalysisTool.Anaylysis(GSOFeatures redLineFeatures, List`1 layerNames, GSOGlobeControl globe) λ�� D:\GHFX\GHFX_REFACTOR\RedLineAnalysisTool.cs:�к� 114
+ �� Cyberpipe.MainFrm.buttonItemHX2_Click(Object sender, EventArgs e) λ�� D:\GHFX\GHFX_REFACTOR\MainFrm.cs:�к� 7469