diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index cd0296f..dc56012 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -230,6 +230,8 @@ + + Form diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index cd0296f..dc56012 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -230,6 +230,8 @@ + + Form diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs new file mode 100644 index 0000000..8686f85 --- /dev/null +++ b/FeatureStatisticsService.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Data; +using GeoScene.Globe; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class FeatureStatisticsService + { + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + /// + + private GSOFeatures Intersect_PointLayerByType(GSOGeoPolygon3D polygon, GSOLayer layer, string type) + { + if (layer == null) return null; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + if (polygon == null) + { + return flayer.GetFeatureByFieldValue("附属物名称", type, true); + } + + GSOFeatures feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsString("附属物名称").EndsWith(type)) + { + newfeats.Add(feats[j]); + } + } + + + return newfeats; + } + + + /// + /// + /// 根据附属物列表,统计该类附属物个数 + /// + ///附属物列表 + /// + public Dictionary getFeatureCountByFeatures(GSOFeatures feats) + { + if (feats == null || feats.Length == 0) return null; + Dictionary result = new Dictionary(); + result.Add(feats[0].GetFieldAsString("附属物名称"),feats.Length); + return result; + } + /// + /// 获取指定图层、范围以及上下限的管线信息 + /// + /// + /// + /// + /// + /// + /// + public FeaturesClassfyResult getPipesInfoByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer, double? min, double? max, string fieldName) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult(); + double totalLength = 0.0; + int ncount = 0; + GSOFeatures features = getPipesByValueSection( polygon, layer, min, max, fieldName); + for (int i = 0; i < features.Length;i++ ) { + GSOGeoPolyline3D line = features[i].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + string filedValue = (min == null) ? "不限":min+"-"; + filedValue += (max == null) ? "不限" : max + ""; + result.layerName = layer.Caption; + result.groupFieldValue = filedValue;//上下限的拼接 + result.ncount = ncount; + result.sum = Math.Round(totalLength, 2); + + return result; + } + + /// + /// 根据绘制区域、图层以及上下限获取满足条件的管线列表 + /// + /// 绘制的区域,为空则表示全区域统计 + /// 所选的图层 + /// 下限 + /// 上限 + /// 统计类型:"起始埋深"或"管径_毫米" + /// + public GSOFeatures getPipesByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer,double? min,double? max,string fieldName) { + if (layer == null) return null; + GSOFeatures result = new GSOFeatures(); + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = ( polygon == null )? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + + double minValue = min ?? Double.MinValue ; + double maxValue = max ?? Double.MaxValue; + + //筛选出符合条件的 + for (int i = 0; i < feats.Length;i++ ) + { + double radius = feats[i].GetFieldAsDouble(fieldName); + if (radius >= min && radius <= max) + { + result.Add(feats[i]); + } + + } + + return result; + + } + //图层名称、管径、条数、总长度 + + public List groupPipeByDiameter(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + List lstDiameter = new List(); + + for (int j = 0; j < feats.Length; j++) + { + if (!lstDiameter.Contains(feats[j].GetFieldAsFloat("管径_毫米"))) + { + lstDiameter.Add(feats[j].GetFieldAsFloat("管径_毫米")); + } + } + lstDiameter.Sort(); + if (lstDiameter.Count > 0) + { + for (int m = 0; m < lstDiameter.Count; m++) + { + double totalLength = 0.00; + int ncount = 0; + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsFloat("管径_毫米") == lstDiameter[m]) + { + GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = layer.Caption; + featuresClass.groupFieldValue = lstDiameter[m].ToString(); + featuresClass.ncount = ncount; + featuresClass.sum = Math.Round(totalLength, 2); + + result.Add(featuresClass); + } + } + return result; + + } + //图层名称、附属物个数 + /// + /// 分类统计图层中附属物个数 + /// + /// + /// + /// + public List groupAccessories(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List(); + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //layer.Name是表名 + string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + + for (int j = 0; j < accessStrs.Length; j++) + { + GSOFeatures feats = null; + int ncount = 0; + if (polygon == null) + { + feats = flayer.GetFeatureByFieldValue("附属物名称", accessStrs[j], true); + ncount = feats.Length; + } + else + { + feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + //过滤 + for (int n = 0; n < feats.Length; n++) + { + if (feats[n].GetFieldAsString("附属物名称").Contains(accessStrs[j])) newfeats.Add(feats[n]); + } + ncount = newfeats.Length; + } + + + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = accessStrs[j]; + featuresClass.ncount = ncount; + + result.Add(featuresClass); + } + return result; + + } + + /// + /// 统计指定材质的管线信息 + /// + /// + /// + /// 材质 + /// + public FeaturesClassfyResult groupPipeByMaterial(GSOGeoPolygon3D polygon, GSOLayer layer,string material) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + string fixedMaterial = material == "无" ? "" : material; + double totalLength = 0.00; + int ncount = 0; + for (int i = 0; i < feats.Length;i++ ) + { + if (feats[i].GetFieldAsString("材质").Equals(fixedMaterial)) + { + GSOGeoPolyline3D line = feats[i].Geometry as GSOGeoPolyline3D; + if (line != null) + { + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + } + + result.layerName = layer.Caption; + result.groupFieldValue = material; + result.ncount = ncount; + result.sum = totalLength; + return result; + } + + + + + + + + + } +} diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index cd0296f..dc56012 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -230,6 +230,8 @@ + + Form diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs new file mode 100644 index 0000000..8686f85 --- /dev/null +++ b/FeatureStatisticsService.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Data; +using GeoScene.Globe; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class FeatureStatisticsService + { + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + /// + + private GSOFeatures Intersect_PointLayerByType(GSOGeoPolygon3D polygon, GSOLayer layer, string type) + { + if (layer == null) return null; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + if (polygon == null) + { + return flayer.GetFeatureByFieldValue("附属物名称", type, true); + } + + GSOFeatures feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsString("附属物名称").EndsWith(type)) + { + newfeats.Add(feats[j]); + } + } + + + return newfeats; + } + + + /// + /// + /// 根据附属物列表,统计该类附属物个数 + /// + ///附属物列表 + /// + public Dictionary getFeatureCountByFeatures(GSOFeatures feats) + { + if (feats == null || feats.Length == 0) return null; + Dictionary result = new Dictionary(); + result.Add(feats[0].GetFieldAsString("附属物名称"),feats.Length); + return result; + } + /// + /// 获取指定图层、范围以及上下限的管线信息 + /// + /// + /// + /// + /// + /// + /// + public FeaturesClassfyResult getPipesInfoByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer, double? min, double? max, string fieldName) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult(); + double totalLength = 0.0; + int ncount = 0; + GSOFeatures features = getPipesByValueSection( polygon, layer, min, max, fieldName); + for (int i = 0; i < features.Length;i++ ) { + GSOGeoPolyline3D line = features[i].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + string filedValue = (min == null) ? "不限":min+"-"; + filedValue += (max == null) ? "不限" : max + ""; + result.layerName = layer.Caption; + result.groupFieldValue = filedValue;//上下限的拼接 + result.ncount = ncount; + result.sum = Math.Round(totalLength, 2); + + return result; + } + + /// + /// 根据绘制区域、图层以及上下限获取满足条件的管线列表 + /// + /// 绘制的区域,为空则表示全区域统计 + /// 所选的图层 + /// 下限 + /// 上限 + /// 统计类型:"起始埋深"或"管径_毫米" + /// + public GSOFeatures getPipesByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer,double? min,double? max,string fieldName) { + if (layer == null) return null; + GSOFeatures result = new GSOFeatures(); + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = ( polygon == null )? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + + double minValue = min ?? Double.MinValue ; + double maxValue = max ?? Double.MaxValue; + + //筛选出符合条件的 + for (int i = 0; i < feats.Length;i++ ) + { + double radius = feats[i].GetFieldAsDouble(fieldName); + if (radius >= min && radius <= max) + { + result.Add(feats[i]); + } + + } + + return result; + + } + //图层名称、管径、条数、总长度 + + public List groupPipeByDiameter(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + List lstDiameter = new List(); + + for (int j = 0; j < feats.Length; j++) + { + if (!lstDiameter.Contains(feats[j].GetFieldAsFloat("管径_毫米"))) + { + lstDiameter.Add(feats[j].GetFieldAsFloat("管径_毫米")); + } + } + lstDiameter.Sort(); + if (lstDiameter.Count > 0) + { + for (int m = 0; m < lstDiameter.Count; m++) + { + double totalLength = 0.00; + int ncount = 0; + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsFloat("管径_毫米") == lstDiameter[m]) + { + GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = layer.Caption; + featuresClass.groupFieldValue = lstDiameter[m].ToString(); + featuresClass.ncount = ncount; + featuresClass.sum = Math.Round(totalLength, 2); + + result.Add(featuresClass); + } + } + return result; + + } + //图层名称、附属物个数 + /// + /// 分类统计图层中附属物个数 + /// + /// + /// + /// + public List groupAccessories(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List(); + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //layer.Name是表名 + string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + + for (int j = 0; j < accessStrs.Length; j++) + { + GSOFeatures feats = null; + int ncount = 0; + if (polygon == null) + { + feats = flayer.GetFeatureByFieldValue("附属物名称", accessStrs[j], true); + ncount = feats.Length; + } + else + { + feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + //过滤 + for (int n = 0; n < feats.Length; n++) + { + if (feats[n].GetFieldAsString("附属物名称").Contains(accessStrs[j])) newfeats.Add(feats[n]); + } + ncount = newfeats.Length; + } + + + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = accessStrs[j]; + featuresClass.ncount = ncount; + + result.Add(featuresClass); + } + return result; + + } + + /// + /// 统计指定材质的管线信息 + /// + /// + /// + /// 材质 + /// + public FeaturesClassfyResult groupPipeByMaterial(GSOGeoPolygon3D polygon, GSOLayer layer,string material) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + string fixedMaterial = material == "无" ? "" : material; + double totalLength = 0.00; + int ncount = 0; + for (int i = 0; i < feats.Length;i++ ) + { + if (feats[i].GetFieldAsString("材质").Equals(fixedMaterial)) + { + GSOGeoPolyline3D line = feats[i].Geometry as GSOGeoPolyline3D; + if (line != null) + { + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + } + + result.layerName = layer.Caption; + result.groupFieldValue = material; + result.ncount = ncount; + result.sum = totalLength; + return result; + } + + + + + + + + + } +} diff --git a/FeaturesClassfyResult.cs b/FeaturesClassfyResult.cs new file mode 100644 index 0000000..5773e51 --- /dev/null +++ b/FeaturesClassfyResult.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + class FeaturesClassfyResult + { + public string layerName; + public string groupFieldValue; + public int ncount; + public double sum; + + public FeaturesClassfyResult(string layerName, string groupFieldValue, int ncount, double sum) + { + this.layerName = layerName; + this.groupFieldValue = groupFieldValue; + this.ncount = ncount; + this.sum = sum; + + } + public FeaturesClassfyResult() + { + + + } + } +} diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index cd0296f..dc56012 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -230,6 +230,8 @@ + + Form diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs new file mode 100644 index 0000000..8686f85 --- /dev/null +++ b/FeatureStatisticsService.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Data; +using GeoScene.Globe; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class FeatureStatisticsService + { + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + /// + + private GSOFeatures Intersect_PointLayerByType(GSOGeoPolygon3D polygon, GSOLayer layer, string type) + { + if (layer == null) return null; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + if (polygon == null) + { + return flayer.GetFeatureByFieldValue("附属物名称", type, true); + } + + GSOFeatures feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsString("附属物名称").EndsWith(type)) + { + newfeats.Add(feats[j]); + } + } + + + return newfeats; + } + + + /// + /// + /// 根据附属物列表,统计该类附属物个数 + /// + ///附属物列表 + /// + public Dictionary getFeatureCountByFeatures(GSOFeatures feats) + { + if (feats == null || feats.Length == 0) return null; + Dictionary result = new Dictionary(); + result.Add(feats[0].GetFieldAsString("附属物名称"),feats.Length); + return result; + } + /// + /// 获取指定图层、范围以及上下限的管线信息 + /// + /// + /// + /// + /// + /// + /// + public FeaturesClassfyResult getPipesInfoByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer, double? min, double? max, string fieldName) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult(); + double totalLength = 0.0; + int ncount = 0; + GSOFeatures features = getPipesByValueSection( polygon, layer, min, max, fieldName); + for (int i = 0; i < features.Length;i++ ) { + GSOGeoPolyline3D line = features[i].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + string filedValue = (min == null) ? "不限":min+"-"; + filedValue += (max == null) ? "不限" : max + ""; + result.layerName = layer.Caption; + result.groupFieldValue = filedValue;//上下限的拼接 + result.ncount = ncount; + result.sum = Math.Round(totalLength, 2); + + return result; + } + + /// + /// 根据绘制区域、图层以及上下限获取满足条件的管线列表 + /// + /// 绘制的区域,为空则表示全区域统计 + /// 所选的图层 + /// 下限 + /// 上限 + /// 统计类型:"起始埋深"或"管径_毫米" + /// + public GSOFeatures getPipesByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer,double? min,double? max,string fieldName) { + if (layer == null) return null; + GSOFeatures result = new GSOFeatures(); + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = ( polygon == null )? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + + double minValue = min ?? Double.MinValue ; + double maxValue = max ?? Double.MaxValue; + + //筛选出符合条件的 + for (int i = 0; i < feats.Length;i++ ) + { + double radius = feats[i].GetFieldAsDouble(fieldName); + if (radius >= min && radius <= max) + { + result.Add(feats[i]); + } + + } + + return result; + + } + //图层名称、管径、条数、总长度 + + public List groupPipeByDiameter(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + List lstDiameter = new List(); + + for (int j = 0; j < feats.Length; j++) + { + if (!lstDiameter.Contains(feats[j].GetFieldAsFloat("管径_毫米"))) + { + lstDiameter.Add(feats[j].GetFieldAsFloat("管径_毫米")); + } + } + lstDiameter.Sort(); + if (lstDiameter.Count > 0) + { + for (int m = 0; m < lstDiameter.Count; m++) + { + double totalLength = 0.00; + int ncount = 0; + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsFloat("管径_毫米") == lstDiameter[m]) + { + GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = layer.Caption; + featuresClass.groupFieldValue = lstDiameter[m].ToString(); + featuresClass.ncount = ncount; + featuresClass.sum = Math.Round(totalLength, 2); + + result.Add(featuresClass); + } + } + return result; + + } + //图层名称、附属物个数 + /// + /// 分类统计图层中附属物个数 + /// + /// + /// + /// + public List groupAccessories(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List(); + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //layer.Name是表名 + string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + + for (int j = 0; j < accessStrs.Length; j++) + { + GSOFeatures feats = null; + int ncount = 0; + if (polygon == null) + { + feats = flayer.GetFeatureByFieldValue("附属物名称", accessStrs[j], true); + ncount = feats.Length; + } + else + { + feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + //过滤 + for (int n = 0; n < feats.Length; n++) + { + if (feats[n].GetFieldAsString("附属物名称").Contains(accessStrs[j])) newfeats.Add(feats[n]); + } + ncount = newfeats.Length; + } + + + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = accessStrs[j]; + featuresClass.ncount = ncount; + + result.Add(featuresClass); + } + return result; + + } + + /// + /// 统计指定材质的管线信息 + /// + /// + /// + /// 材质 + /// + public FeaturesClassfyResult groupPipeByMaterial(GSOGeoPolygon3D polygon, GSOLayer layer,string material) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + string fixedMaterial = material == "无" ? "" : material; + double totalLength = 0.00; + int ncount = 0; + for (int i = 0; i < feats.Length;i++ ) + { + if (feats[i].GetFieldAsString("材质").Equals(fixedMaterial)) + { + GSOGeoPolyline3D line = feats[i].Geometry as GSOGeoPolyline3D; + if (line != null) + { + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + } + + result.layerName = layer.Caption; + result.groupFieldValue = material; + result.ncount = ncount; + result.sum = totalLength; + return result; + } + + + + + + + + + } +} diff --git a/FeaturesClassfyResult.cs b/FeaturesClassfyResult.cs new file mode 100644 index 0000000..5773e51 --- /dev/null +++ b/FeaturesClassfyResult.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + class FeaturesClassfyResult + { + public string layerName; + public string groupFieldValue; + public int ncount; + public double sum; + + public FeaturesClassfyResult(string layerName, string groupFieldValue, int ncount, double sum) + { + this.layerName = layerName; + this.groupFieldValue = groupFieldValue; + this.ncount = ncount; + this.sum = sum; + + } + public FeaturesClassfyResult() + { + + + } + } +} diff --git a/bin/x86/Debug/npLocaSpacePlugin.dll b/bin/x86/Debug/npLocaSpacePlugin.dll deleted file mode 100644 index 8a7f892..0000000 --- a/bin/x86/Debug/npLocaSpacePlugin.dll +++ /dev/null Binary files differ diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index cd0296f..dc56012 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -230,6 +230,8 @@ + + Form diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs new file mode 100644 index 0000000..8686f85 --- /dev/null +++ b/FeatureStatisticsService.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Data; +using GeoScene.Globe; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class FeatureStatisticsService + { + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + /// + + private GSOFeatures Intersect_PointLayerByType(GSOGeoPolygon3D polygon, GSOLayer layer, string type) + { + if (layer == null) return null; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + if (polygon == null) + { + return flayer.GetFeatureByFieldValue("附属物名称", type, true); + } + + GSOFeatures feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsString("附属物名称").EndsWith(type)) + { + newfeats.Add(feats[j]); + } + } + + + return newfeats; + } + + + /// + /// + /// 根据附属物列表,统计该类附属物个数 + /// + ///附属物列表 + /// + public Dictionary getFeatureCountByFeatures(GSOFeatures feats) + { + if (feats == null || feats.Length == 0) return null; + Dictionary result = new Dictionary(); + result.Add(feats[0].GetFieldAsString("附属物名称"),feats.Length); + return result; + } + /// + /// 获取指定图层、范围以及上下限的管线信息 + /// + /// + /// + /// + /// + /// + /// + public FeaturesClassfyResult getPipesInfoByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer, double? min, double? max, string fieldName) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult(); + double totalLength = 0.0; + int ncount = 0; + GSOFeatures features = getPipesByValueSection( polygon, layer, min, max, fieldName); + for (int i = 0; i < features.Length;i++ ) { + GSOGeoPolyline3D line = features[i].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + string filedValue = (min == null) ? "不限":min+"-"; + filedValue += (max == null) ? "不限" : max + ""; + result.layerName = layer.Caption; + result.groupFieldValue = filedValue;//上下限的拼接 + result.ncount = ncount; + result.sum = Math.Round(totalLength, 2); + + return result; + } + + /// + /// 根据绘制区域、图层以及上下限获取满足条件的管线列表 + /// + /// 绘制的区域,为空则表示全区域统计 + /// 所选的图层 + /// 下限 + /// 上限 + /// 统计类型:"起始埋深"或"管径_毫米" + /// + public GSOFeatures getPipesByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer,double? min,double? max,string fieldName) { + if (layer == null) return null; + GSOFeatures result = new GSOFeatures(); + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = ( polygon == null )? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + + double minValue = min ?? Double.MinValue ; + double maxValue = max ?? Double.MaxValue; + + //筛选出符合条件的 + for (int i = 0; i < feats.Length;i++ ) + { + double radius = feats[i].GetFieldAsDouble(fieldName); + if (radius >= min && radius <= max) + { + result.Add(feats[i]); + } + + } + + return result; + + } + //图层名称、管径、条数、总长度 + + public List groupPipeByDiameter(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + List lstDiameter = new List(); + + for (int j = 0; j < feats.Length; j++) + { + if (!lstDiameter.Contains(feats[j].GetFieldAsFloat("管径_毫米"))) + { + lstDiameter.Add(feats[j].GetFieldAsFloat("管径_毫米")); + } + } + lstDiameter.Sort(); + if (lstDiameter.Count > 0) + { + for (int m = 0; m < lstDiameter.Count; m++) + { + double totalLength = 0.00; + int ncount = 0; + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsFloat("管径_毫米") == lstDiameter[m]) + { + GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = layer.Caption; + featuresClass.groupFieldValue = lstDiameter[m].ToString(); + featuresClass.ncount = ncount; + featuresClass.sum = Math.Round(totalLength, 2); + + result.Add(featuresClass); + } + } + return result; + + } + //图层名称、附属物个数 + /// + /// 分类统计图层中附属物个数 + /// + /// + /// + /// + public List groupAccessories(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List(); + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //layer.Name是表名 + string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + + for (int j = 0; j < accessStrs.Length; j++) + { + GSOFeatures feats = null; + int ncount = 0; + if (polygon == null) + { + feats = flayer.GetFeatureByFieldValue("附属物名称", accessStrs[j], true); + ncount = feats.Length; + } + else + { + feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + //过滤 + for (int n = 0; n < feats.Length; n++) + { + if (feats[n].GetFieldAsString("附属物名称").Contains(accessStrs[j])) newfeats.Add(feats[n]); + } + ncount = newfeats.Length; + } + + + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = accessStrs[j]; + featuresClass.ncount = ncount; + + result.Add(featuresClass); + } + return result; + + } + + /// + /// 统计指定材质的管线信息 + /// + /// + /// + /// 材质 + /// + public FeaturesClassfyResult groupPipeByMaterial(GSOGeoPolygon3D polygon, GSOLayer layer,string material) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + string fixedMaterial = material == "无" ? "" : material; + double totalLength = 0.00; + int ncount = 0; + for (int i = 0; i < feats.Length;i++ ) + { + if (feats[i].GetFieldAsString("材质").Equals(fixedMaterial)) + { + GSOGeoPolyline3D line = feats[i].Geometry as GSOGeoPolyline3D; + if (line != null) + { + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + } + + result.layerName = layer.Caption; + result.groupFieldValue = material; + result.ncount = ncount; + result.sum = totalLength; + return result; + } + + + + + + + + + } +} diff --git a/FeaturesClassfyResult.cs b/FeaturesClassfyResult.cs new file mode 100644 index 0000000..5773e51 --- /dev/null +++ b/FeaturesClassfyResult.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + class FeaturesClassfyResult + { + public string layerName; + public string groupFieldValue; + public int ncount; + public double sum; + + public FeaturesClassfyResult(string layerName, string groupFieldValue, int ncount, double sum) + { + this.layerName = layerName; + this.groupFieldValue = groupFieldValue; + this.ncount = ncount; + this.sum = sum; + + } + public FeaturesClassfyResult() + { + + + } + } +} diff --git a/bin/x86/Debug/npLocaSpacePlugin.dll b/bin/x86/Debug/npLocaSpacePlugin.dll deleted file mode 100644 index 8a7f892..0000000 --- a/bin/x86/Debug/npLocaSpacePlugin.dll +++ /dev/null Binary files differ diff --git a/bin/x86/Debug/oldDLL/npLocaSpacePlugin.dll b/bin/x86/Debug/oldDLL/npLocaSpacePlugin.dll deleted file mode 100644 index 8a7f892..0000000 --- a/bin/x86/Debug/oldDLL/npLocaSpacePlugin.dll +++ /dev/null Binary files differ diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index cd0296f..dc56012 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -230,6 +230,8 @@ + + Form diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs new file mode 100644 index 0000000..8686f85 --- /dev/null +++ b/FeatureStatisticsService.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Data; +using GeoScene.Globe; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class FeatureStatisticsService + { + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + /// + + private GSOFeatures Intersect_PointLayerByType(GSOGeoPolygon3D polygon, GSOLayer layer, string type) + { + if (layer == null) return null; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + if (polygon == null) + { + return flayer.GetFeatureByFieldValue("附属物名称", type, true); + } + + GSOFeatures feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsString("附属物名称").EndsWith(type)) + { + newfeats.Add(feats[j]); + } + } + + + return newfeats; + } + + + /// + /// + /// 根据附属物列表,统计该类附属物个数 + /// + ///附属物列表 + /// + public Dictionary getFeatureCountByFeatures(GSOFeatures feats) + { + if (feats == null || feats.Length == 0) return null; + Dictionary result = new Dictionary(); + result.Add(feats[0].GetFieldAsString("附属物名称"),feats.Length); + return result; + } + /// + /// 获取指定图层、范围以及上下限的管线信息 + /// + /// + /// + /// + /// + /// + /// + public FeaturesClassfyResult getPipesInfoByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer, double? min, double? max, string fieldName) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult(); + double totalLength = 0.0; + int ncount = 0; + GSOFeatures features = getPipesByValueSection( polygon, layer, min, max, fieldName); + for (int i = 0; i < features.Length;i++ ) { + GSOGeoPolyline3D line = features[i].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + string filedValue = (min == null) ? "不限":min+"-"; + filedValue += (max == null) ? "不限" : max + ""; + result.layerName = layer.Caption; + result.groupFieldValue = filedValue;//上下限的拼接 + result.ncount = ncount; + result.sum = Math.Round(totalLength, 2); + + return result; + } + + /// + /// 根据绘制区域、图层以及上下限获取满足条件的管线列表 + /// + /// 绘制的区域,为空则表示全区域统计 + /// 所选的图层 + /// 下限 + /// 上限 + /// 统计类型:"起始埋深"或"管径_毫米" + /// + public GSOFeatures getPipesByValueSection(GSOGeoPolygon3D polygon, GSOLayer layer,double? min,double? max,string fieldName) { + if (layer == null) return null; + GSOFeatures result = new GSOFeatures(); + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = ( polygon == null )? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + + double minValue = min ?? Double.MinValue ; + double maxValue = max ?? Double.MaxValue; + + //筛选出符合条件的 + for (int i = 0; i < feats.Length;i++ ) + { + double radius = feats[i].GetFieldAsDouble(fieldName); + if (radius >= min && radius <= max) + { + result.Add(feats[i]); + } + + } + + return result; + + } + //图层名称、管径、条数、总长度 + + public List groupPipeByDiameter(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + List lstDiameter = new List(); + + for (int j = 0; j < feats.Length; j++) + { + if (!lstDiameter.Contains(feats[j].GetFieldAsFloat("管径_毫米"))) + { + lstDiameter.Add(feats[j].GetFieldAsFloat("管径_毫米")); + } + } + lstDiameter.Sort(); + if (lstDiameter.Count > 0) + { + for (int m = 0; m < lstDiameter.Count; m++) + { + double totalLength = 0.00; + int ncount = 0; + for (int j = 0; j < feats.Length; j++) + { + if (feats[j].GetFieldAsFloat("管径_毫米") == lstDiameter[m]) + { + GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = layer.Caption; + featuresClass.groupFieldValue = lstDiameter[m].ToString(); + featuresClass.ncount = ncount; + featuresClass.sum = Math.Round(totalLength, 2); + + result.Add(featuresClass); + } + } + return result; + + } + //图层名称、附属物个数 + /// + /// 分类统计图层中附属物个数 + /// + /// + /// + /// + public List groupAccessories(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + List result = new List(); + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //layer.Name是表名 + string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + + for (int j = 0; j < accessStrs.Length; j++) + { + GSOFeatures feats = null; + int ncount = 0; + if (polygon == null) + { + feats = flayer.GetFeatureByFieldValue("附属物名称", accessStrs[j], true); + ncount = feats.Length; + } + else + { + feats = flayer.FindFeaturesInPolygon(polygon, false); + GSOFeatures newfeats = new GSOFeatures(); + //过滤 + for (int n = 0; n < feats.Length; n++) + { + if (feats[n].GetFieldAsString("附属物名称").Contains(accessStrs[j])) newfeats.Add(feats[n]); + } + ncount = newfeats.Length; + } + + + FeaturesClassfyResult featuresClass = new FeaturesClassfyResult(); + featuresClass.layerName = accessStrs[j]; + featuresClass.ncount = ncount; + + result.Add(featuresClass); + } + return result; + + } + + /// + /// 统计指定材质的管线信息 + /// + /// + /// + /// 材质 + /// + public FeaturesClassfyResult groupPipeByMaterial(GSOGeoPolygon3D polygon, GSOLayer layer,string material) + { + if (layer == null) return null; + FeaturesClassfyResult result = new FeaturesClassfyResult() ; + + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + + //TODOLIST:优化为只获取管线,目前不清楚调用方式 + GSOFeatures feats = (polygon == null) ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + + string fixedMaterial = material == "无" ? "" : material; + double totalLength = 0.00; + int ncount = 0; + for (int i = 0; i < feats.Length;i++ ) + { + if (feats[i].GetFieldAsString("材质").Equals(fixedMaterial)) + { + GSOGeoPolyline3D line = feats[i].Geometry as GSOGeoPolyline3D; + if (line != null) + { + double length = line.GetSpaceLength(true, 6378137); + totalLength += length; + ncount += 1; + } + } + } + + result.layerName = layer.Caption; + result.groupFieldValue = material; + result.ncount = ncount; + result.sum = totalLength; + return result; + } + + + + + + + + + } +} diff --git a/FeaturesClassfyResult.cs b/FeaturesClassfyResult.cs new file mode 100644 index 0000000..5773e51 --- /dev/null +++ b/FeaturesClassfyResult.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + class FeaturesClassfyResult + { + public string layerName; + public string groupFieldValue; + public int ncount; + public double sum; + + public FeaturesClassfyResult(string layerName, string groupFieldValue, int ncount, double sum) + { + this.layerName = layerName; + this.groupFieldValue = groupFieldValue; + this.ncount = ncount; + this.sum = sum; + + } + public FeaturesClassfyResult() + { + + + } + } +} diff --git a/bin/x86/Debug/npLocaSpacePlugin.dll b/bin/x86/Debug/npLocaSpacePlugin.dll deleted file mode 100644 index 8a7f892..0000000 --- a/bin/x86/Debug/npLocaSpacePlugin.dll +++ /dev/null Binary files differ diff --git a/bin/x86/Debug/oldDLL/npLocaSpacePlugin.dll b/bin/x86/Debug/oldDLL/npLocaSpacePlugin.dll deleted file mode 100644 index 8a7f892..0000000 --- a/bin/x86/Debug/oldDLL/npLocaSpacePlugin.dll +++ /dev/null Binary files differ diff --git a/obj/x64/Debug/Cyberpipe.csproj.FileListAbsolute.txt b/obj/x64/Debug/Cyberpipe.csproj.FileListAbsolute.txt index a28fa41..8940b91 100644 --- a/obj/x64/Debug/Cyberpipe.csproj.FileListAbsolute.txt +++ b/obj/x64/Debug/Cyberpipe.csproj.FileListAbsolute.txt @@ -340,6 +340,7 @@ F:\predator\codeReview\GHFX_SZ_64\obj\x64\Debug\Cyberpipe.FrmAddInstrument.resources F:\predator\codeReview\GHFX_SZ_64\obj\x64\Debug\Cyberpipe.SysRescInfoManager.resources F:\predator\codeReview\GHFX_SZ_64\obj\x64\Debug\Cyberpipe.csproj.GenerateResource.Cache +<<<<<<< HEAD D:\GHFX\GHFX_REFACTOR\bin\x86\Debug\Cyberpipe.exe.config D:\GHFX\GHFX_REFACTOR\bin\x86\Debug\Cyberpipe.exe D:\GHFX\GHFX_REFACTOR\bin\x86\Debug\Cyberpipe.pdb @@ -512,3 +513,9 @@ D:\GHFX\GHFX_REFACTOR\obj\x64\Debug\GenerateResource.write.1.tlog D:\GHFX\GHFX_REFACTOR\obj\x64\Debug\Cyberpipe.exe D:\GHFX\GHFX_REFACTOR\obj\x64\Debug\Cyberpipe.pdb +======= +E:\wxl\work\GHFX_REFACTOR\bin\x86\Debug\Cyberpipe.exe.config +E:\wxl\work\GHFX_REFACTOR\obj\x64\Debug\Cyberpipe.csproj.ResolveComReference.cache +E:\wxl\work\GHFX_REFACTOR\obj\x64\Debug\Cyberpipe.exe +E:\wxl\work\GHFX_REFACTOR\obj\x64\Debug\Cyberpipe.pdb +>>>>>>> develop