private void adjustOrder(UpOrDown upOrDown) { string focusedColName = listBoxControl1.Text; int index = listColName.IndexOf(focusedColName); if (upOrDown == UpOrDown.移) { if (index == 0) { Function.Alert("已经是第一列了,不能上移了", "提示"); return; } index--; } if (upOrDown == UpOrDown.移) { if (index == listColName.Count - 1) { Function.Alert("已经是最后一列了,不能下移了", "提示"); return; } index++; } listColName.Remove(focusedColName); listColName.Insert(index, focusedColName); listBoxControl1.Refresh(); listBoxControl1.SelectedIndex = index; }
public void UpOrDown(UpOrDown Model, string UserID) { using (var _c = db) { var _Category = GetByID(Model.CategoryID, _c); Can(_Category.SiteID, UserID, _c); var _P = _c.Categories.Where(m => m.CategoryParentID == _Category.CategoryParentID && m.SiteID == _Category.SiteID); if (Model.Up) { if (_P.Select(m => m.Priority).Min() < _Category.Priority) { var _Next = _P.Where(m => m.Priority < _Category.Priority).OrderBy(m => m.Priority).ToList().Last(); _Next.Priority++; _Category.Priority--; } } else { if (_P.Select(m => m.Priority).Max() > _Category.Priority) { var _Next = _P.Where(m => m.Priority > _Category.Priority).OrderBy(m => m.Priority).ToList().First(); _Next.Priority--; _Category.Priority++; } } _c.SaveChanges(); } }
public DanhSachMayTinh SortTheoLoai <T>(MayTinh.Tinh tinh, UpOrDown upOrDown) { DanhSachMayTinh result = new DanhSachMayTinh(); switch (upOrDown) { case UpOrDown.Increase: result.listMayTinh = listMayTinh.OrderBy(x => x.TinhTheoLoai <T>(tinh)).ToList(); return(result); case UpOrDown.Decrease: result.listMayTinh = listMayTinh.OrderByDescending(x => x.TinhTheoLoai <T>(tinh)).ToList(); return(result); } return(null); }
///////////////////////////////////////////// /// Functions ///////////////////////////////////////////// //constructor public FlipCardTask(RectTransform cardTransform, UpOrDown flipDir) { this.cardTransform = cardTransform; this.flipDir = flipDir; }
private void DoStats() { if (string.IsNullOrEmpty(this._sysFieldName)) { return; } //string value = this.cbProperty.Text.Trim(); //if (value.Length > 1) //{ // int lastindex = value.LastIndexOf(';'); // if (lastindex == (value.Length - 1)) // value = value.Substring(0, value.Length - 1); //} dttemp = new DataTable(); dttemp.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) }); dtstats = new DataTable(); dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("LENGTH", typeof(double)) }); if (this.treelist.GetAllCheckedNodes() != null) { foreach (TreeListNode node in this.treelist.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string[] arrFc2DId = sc.Parent.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } double subclasslength = 0.0; int indexStart = dttemp.Rows.Count; foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(this._sysFieldName); DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D"); if (fi == null || fiPipeLength == null) { continue; } int index = fc.Fields.FindField(fi.Name); if (index == -1) { continue; } int indexPipeLength = fc.Fields.FindField(fiPipeLength.Name); if (indexPipeLength == -1) { continue; } IField fcfi = fc.Fields.get_Field(index); IQueryFilter filter = new QueryFilter(); filter.SubFields = fiPipeLength.Name; //string[] arrvalue = value.Split(';'); if (list.Count <= 0) { return; } foreach (string strValue in list) { if (string.IsNullOrEmpty(strValue)) { continue; } switch (fcfi.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; } filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " = '" + sc.Name + "' and " + fi.Name + " = " + strValue; IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; double subfieldlength = 0.0; bool bHave = false; #region try { pFeatureCursor = fc.Search(filter, true); while ((pFeature = pFeatureCursor.NextFeature()) != null) { object tempobj = pFeature.get_Value(indexPipeLength); double dtemp = 0.0; if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp)) { bHave = true; subfieldlength += dtemp; } } } catch { } finally { if (pFeatureCursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor); pFeatureCursor = null; } if (pFeature != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature); pFeature = null; } } #endregion if (bHave) { DataRow dr = dttemp.NewRow(); dr["PIPELINETYPE"] = sc; dr["FIELDNAME"] = fi; dr["PVALUE"] = strValue; subclasslength += subfieldlength; dr["LENGTH"] = subfieldlength.ToString("0.00"); dttemp.Rows.Add(dr); DataRow dr1 = dtstats.NewRow(); dr1["PIPELINETYPE"] = sc; dr1["FIELDNAME"] = strValue; dr1["LENGTH"] = subfieldlength.ToString("0.00"); dtstats.Rows.Add(dr1); } } } int indexEnd = dttemp.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dttemp.Rows[i]; dr["TOTALLENGTH"] = subclasslength.ToString("0.00"); } } } } }
private DataTable DoStats() { DataTable dtResult = new DataTable(); dtResult.TableName = "DataStats"; dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) }); string localDataPath = SystemInfo.Instance.LocalDataPath; string tmpPath = ""; tmpPath = Path.Combine(localDataPath, "Stats"); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } string filePath = tmpPath + "\\全库2D管点统计.xml"; bool bHaveXml = false; if (File.Exists(filePath)) { dtResult.ReadXml(filePath); if (dtResult != null && dtResult.Rows.Count != 0) { bHaveXml = true; return(dtResult); } else { bHaveXml = false; } } List <MajorClass> list = LogicDataStructureManage2D.Instance.GetAllMajorClass(); foreach (MajorClass mc in list) { string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } long majorclasscount = 0; int indexStart = dtResult.Rows.Count; foreach (SubClass sc in mc.SubClasses) { long sccount = 0; bool bHave = false; foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != "PipeNode") { continue; } IQueryFilter filter = new QueryFilter(); filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; int count = fc.FeatureCount(filter); if (count == 0) { continue; } bHave = true; sccount += count; } if (bHave) { DataRow dr = dtResult.NewRow(); dr["PIPENODETYPE"] = mc; dr["FIELDNAME"] = ""; dr["PVALUE"] = sc; dr["NUMBER"] = sccount; majorclasscount += sccount; dtResult.Rows.Add(dr); } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALNUMBER"] = majorclasscount; } } if (!bHaveXml) { dtResult.WriteXml(filePath); } return(dtResult); }
private DataTable DoStats() { DataTable dtResult = new DataTable(); dtResult.TableName = "DataStats"; dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) }); string localDataPath = SystemInfo.Instance.LocalDataPath; string tmpPath = ""; tmpPath = Path.Combine(localDataPath, "Stats"); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } string filePath = tmpPath + "\\全库2D管线统计.xml"; bool bHaveXml = false; if (File.Exists(filePath)) { dtResult.ReadXml(filePath); if (dtResult != null && dtResult.Rows.Count != 0) { bHaveXml = true; return(dtResult); } else { bHaveXml = false; } } List <MajorClass> list = LogicDataStructureManage2D.Instance.GetAllMajorClass(); foreach (MajorClass mc in list) { string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } double majorclasslength = 0.0; int indexStart = dtResult.Rows.Count; double subclasslength = 0.0; foreach (SubClass sc in mc.SubClasses) { foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D"); if (fiPipeLength == null) { continue; } int indexPipeLength = fc.FindField(fiPipeLength.Name); if (indexPipeLength == -1) { continue; } IField fcfi = fc.Fields.get_Field(indexPipeLength); switch (fcfi.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; } IQueryFilter filter = new QueryFilter(); filter.SubFields = fcfi.Name; filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; double subfieldlength = 0.0; bool bHave = false; #region try { pFeatureCursor = fc.Search(filter, true); while ((pFeature = pFeatureCursor.NextFeature()) != null) { object tempobj = pFeature.get_Value(indexPipeLength); double dtemp = 0.0; if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp)) { bHave = true; subfieldlength += dtemp; } } } catch { } finally { if (pFeatureCursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor); pFeatureCursor = null; } if (pFeature != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature); pFeature = null; } } #endregion if (bHave) { DataRow dr = dtResult.NewRow(); dr["PIPELINETYPE"] = mc; dr["FIELDNAME"] = ""; dr["PVALUE"] = sc; subclasslength += subfieldlength; dr["LENGTH"] = subfieldlength.ToString("0.00"); dtResult.Rows.Add(dr); } } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALLENGTH"] = subclasslength.ToString("0.00"); } } if (!bHaveXml) { dtResult.WriteXml(filePath); } return(dtResult); }
private void treelist_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e) { IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; valuelist.Clear(); if (string.IsNullOrEmpty(this._sysFieldName)) { return; } try { WaitForm.Start("正在加载列表...", "请稍后"); foreach (TreeListNode node in this.treelist.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string[] arrFc2DId = sc.Parent.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } FacilityClass facClass = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facClass == null || facClass.Name != "PipeNode") { continue; } DFDataConfig.Class.FieldInfo fi = facClass.GetFieldInfoBySystemName(this._sysFieldName); if (fi == null) { continue; } IFields pFields = fc.Fields; int index = pFields.FindField(fi.Name); if (index < 0) { continue; } IField pField = pFields.get_Field(index); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.SubFields = pField.Name; pQueryFilter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " = " + "'" + sc.Name + "'"; pFeatureCursor = fc.Search(pQueryFilter, false); pFeature = pFeatureCursor.NextFeature(); while (pFeature != null) { object temp = pFeature.get_Value(index); if (temp == null) { continue; } string strtemp = ""; switch (pField.Type) { case esriFieldType.esriFieldTypeDouble: case esriFieldType.esriFieldTypeInteger: case esriFieldType.esriFieldTypeOID: case esriFieldType.esriFieldTypeSingle: case esriFieldType.esriFieldTypeSmallInteger: strtemp = temp.ToString(); break; case esriFieldType.esriFieldTypeDate: case esriFieldType.esriFieldTypeString: case esriFieldType.esriFieldTypeGUID: strtemp = "'" + temp.ToString() + "'"; break; case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeGlobalID: case esriFieldType.esriFieldTypeRaster: case esriFieldType.esriFieldTypeXML: default: continue; } if (temp != null) { valuelist.Add(strtemp); } pFeature = pFeatureCursor.NextFeature(); } } } } } catch { } finally { if (pFeatureCursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor); pFeatureCursor = null; } if (pFeature != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature); pFeature = null; } WaitForm.Stop(); } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; if (app == null || app.Current2DMapControl == null) { return; } IActiveView m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; IGeometry pGeo = null; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; IRubberBand pRubberBand; pRubberBand = new RubberLineClass(); IGeometry pLine = pRubberBand.TrackNew(m_Display, null); object symbol = pLineSym as object; app.Current2DMapControl.DrawShape(pLine, ref symbol); if ((pLine as IPolyline).Length > 500) { XtraMessageBox.Show("横断面线超过500米,分析效率很低,请重新绘制", "提示"); return; } WaitForm.Start("正在进行横断面分析...", "请稍后"); pGeo = pLine; if (pGeo == null) { return; } string road1 = ""; string road2 = ""; bool bAlert = false; double hmax = double.MinValue; double hmin = double.MaxValue; List <PPLine2D> pplines = new List <PPLine2D>(); IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) { foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } //查找管径长宽字段,获得该要素类下字段索引值,若为圆管,则长宽相等 DFDataConfig.Class.FieldInfo fiDia = facc.GetFieldInfoBySystemName("Diameter"); DFDataConfig.Class.FieldInfo fiDia1 = facc.GetFieldInfoBySystemName("Diameter1"); DFDataConfig.Class.FieldInfo fiDia2 = facc.GetFieldInfoBySystemName("Diameter2"); int indexDia = fc.Fields.FindField(fiDia.Name); int indexDiaWith = fc.Fields.FindField(fiDia1.Name); int indexDiaHeight = fc.Fields.FindField(fiDia2.Name); if (indexDiaWith == -1 || indexDiaHeight == -1 || indexDia == -1) { continue; } //查找道路字段索引 DFDataConfig.Class.FieldInfo fiRoad = facc.GetFieldInfoBySystemName("Road"); int indexRoad = fc.Fields.FindField(fiRoad.Name); //查找管线高类别索引 DFDataConfig.Class.FieldInfo fiHLB = facc.GetFieldInfoBySystemName("HLB"); int indexHLB = fc.Fields.FindField(fiHLB.Name); //二级分类名索引 int indexClassify = fc.Fields.FindField(mc.ClassifyField); ISpatialFilter pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; int count = fc.FeatureCount(pSpatialFilter); if (count == 0) { continue; } pFeatureCursor = fc.Search(pSpatialFilter, true); while ((pFeature = pFeatureCursor.NextFeature()) != null) { if (indexRoad != -1) { if (road2 == "") { road1 = pFeature.get_Value(indexRoad).ToString(); road2 = pFeature.get_Value(indexRoad).ToString(); } else { road1 = pFeature.get_Value(indexRoad).ToString(); if (road1 != road2) { if (!bAlert) { XtraMessageBox.Show("横断面线跨越多条道路,当前只绘制在【" + road2 + "】上的管线横断面图。", "提示"); bAlert = true; } continue; } } } //查找管线的起点终点地面高 double startSurfHeight = double.MaxValue; double endSurfHeight = double.MaxValue; DFDataConfig.Class.FieldInfo fiStartSurfHeight = facc.GetFieldInfoBySystemName("StartSurfH"); if (fiStartSurfHeight == null) { continue; } int indexStartSurfHeight = pFeature.Fields.FindField(fiStartSurfHeight.Name); if (indexStartSurfHeight == -1) { continue; } DFDataConfig.Class.FieldInfo fiEndSurfHeight = facc.GetFieldInfoBySystemName("EndSurfH"); if (fiEndSurfHeight == null) { continue; } int indexEndSurfHeight = pFeature.Fields.FindField(fiEndSurfHeight.Name); if (indexEndSurfHeight == -1) { continue; } //若管线属性地面高字段为null,则从DEM取值 if (pFeature.get_Value(indexStartSurfHeight).ToString() == "" || pFeature.get_Value(indexEndSurfHeight).ToString() == "") { startSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).FromPoint); endSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).ToPoint); } else { startSurfHeight = Convert.ToDouble(pFeature.get_Value(indexStartSurfHeight).ToString()); endSurfHeight = Convert.ToDouble(pFeature.get_Value(indexEndSurfHeight).ToString()); } //查找管线起点高程和终点高程 double startDepthHeight = double.MaxValue; double endDepthHeight = double.MaxValue; DFDataConfig.Class.FieldInfo fiStartDepthHeight = facc.GetFieldInfoBySystemName("StartHeight2D"); if (fiStartDepthHeight == null) { continue; } int indexStartDepthHeight = pFeature.Fields.FindField(fiStartDepthHeight.Name); if (indexStartDepthHeight == -1) { continue; } DFDataConfig.Class.FieldInfo fiEndDepthHeight = facc.GetFieldInfoBySystemName("EndHeight"); if (fiEndDepthHeight == null) { continue; } int indexEndDepthHeight = pFeature.Fields.FindField(fiEndDepthHeight.Name); if (indexEndDepthHeight == -1) { continue; } startDepthHeight = Convert.ToDouble(pFeature.get_Value(indexStartDepthHeight).ToString()); endDepthHeight = Convert.ToDouble(pFeature.get_Value(indexEndDepthHeight).ToString()); //计算管线和断面的交点 IGeometry ppGeo = pFeature.Shape; ITopologicalOperator pTopo = ppGeo as ITopologicalOperator; IGeometry geoIntersect = pTopo.Intersect(pGeo, esriGeometryDimension.esriGeometry0Dimension); if (geoIntersect == null) { continue; } PPLine2D ppline = new PPLine2D(); if (indexClassify == -1) { ppline.facType = mc.Name; } else { ppline.facType = pFeature.get_Value(indexClassify).ToString(); } //查找管线的管径,判断其是方管还是圆管 string diameter = pFeature.get_Value(indexDia).ToString(); string diameter1 = pFeature.get_Value(indexDiaWith).ToString(); string diameter2 = pFeature.get_Value(indexDiaHeight).ToString(); if (diameter.Trim() == "") { continue; } ppline.dia = diameter; int indexSplit = diameter.IndexOf('*'); if (indexSplit != -1) { ppline.isrect = true; int iDia1; bool bDia1 = int.TryParse(diameter.Substring(0, indexSplit), out iDia1); if (!bDia1) { continue; } int iDia2; bool bDia2 = int.TryParse(diameter.Substring(indexSplit + 1, diameter.Length - indexSplit - 1), out iDia2); if (!bDia2) { continue; } ppline.gj.Add(iDia1); ppline.gj.Add(iDia2); } else { ppline.isrect = false; int iDia; bool bDia = int.TryParse(diameter, out iDia); if (!bDia) { continue; } ppline.gj.Add(iDia); ppline.gj.Add(iDia); } //判断管线高方式 int hlb = 0; if (indexHLB != -1) { string strhlb = pFeature.get_Value(indexHLB).ToString(); if (strhlb.Contains("内")) { hlb = 1; } else if (strhlb.Contains("外")) { hlb = -1; } else { hlb = 0; } ppline.hlb = hlb; } #region 交点为一个 if (geoIntersect.GeometryType == esriGeometryType.esriGeometryPoint) { IPolyline polyline = pFeature.Shape as IPolyline; IPoint ptIntersect = geoIntersect as IPoint; ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y); ppline.clh = GetInterPointHeight(ptIntersect, polyline, startDepthHeight, endDepthHeight); if (ppline.clh > hmax) { hmax = ppline.clh; } if (ppline.clh < hmin) { hmin = ppline.clh; } ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight) * Math.Sqrt((polyline.FromPoint.X - ptIntersect.X) * (polyline.FromPoint.X - ptIntersect.X) + (polyline.FromPoint.Y - ptIntersect.Y) * (polyline.FromPoint.Y - ptIntersect.Y)) / polyline.Length; if (ppline.cgh > hmax) { hmax = ppline.cgh; } if (ppline.cgh < hmin) { hmin = ppline.cgh; } // 辅助画图 IPolyline l = pGeo as IPolyline; ppline.startPt = new PPPoint(l.FromPoint.X, l.FromPoint.Y); pplines.Add(ppline); } #endregion #region 交点为多个 else if (geoIntersect.GeometryType == esriGeometryType.esriGeometryMultipoint) { IPolyline polyline = pFeature.Shape as IPolyline; IPointCollection geoCol = geoIntersect as IPointCollection; for (int i = 0; i < geoCol.PointCount; i++) { IPoint ptIntersect = geoCol.get_Point(i); ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y); ppline.clh = GetInterPointHeight(ptIntersect, polyline, startDepthHeight, endDepthHeight); if (ppline.clh > hmax) { hmax = ppline.clh; } if (ppline.clh < hmin) { hmin = ppline.clh; } ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight) * Math.Sqrt((polyline.FromPoint.X - ptIntersect.X) * (polyline.FromPoint.X - ptIntersect.X) + (polyline.FromPoint.Y - ptIntersect.Y) * (polyline.FromPoint.Y - ptIntersect.Y)) / polyline.Length; if (ppline.cgh > hmax) { hmax = ppline.cgh; } if (ppline.cgh < hmin) { hmin = ppline.cgh; } // 辅助画图 IPolyline l = pGeo as IPolyline; ppline.startPt = new PPPoint(l.FromPoint.X, l.FromPoint.Y); pplines.Add(ppline); } } else { continue; } #endregion } } } } WaitForm.Stop(); if (pplines.Count < 2) { XtraMessageBox.Show("相交管线少于2个", "提示"); return; } pplines.Sort(new PPLineCompare2D()); double spacesum = 0.0; for (int i = 1; i < pplines.Count; i++) { PPLine2D line1 = pplines[i - 1]; PPLine2D line2 = pplines[i]; line2.space = Math.Sqrt((line1.interPoint.X - line2.interPoint.X) * (line1.interPoint.X - line2.interPoint.X) + (line1.interPoint.Y - line2.interPoint.Y) * (line1.interPoint.Y - line2.interPoint.Y)); spacesum += line2.space; } ; var str1 = (pplines[0].interPoint.X / 1000).ToString("0.00"); var str2 = (pplines[0].interPoint.Y / 1000).ToString("0.00"); string mapNum = str2 + "-" + str1; string mapName = SystemInfo.Instance.SystemFullName + "横断面图"; FrmSectionAnalysis dialog = new FrmSectionAnalysis("横断面分析结果", 0); dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2); dialog.Show(); } } catch { WaitForm.Stop(); } }
private void DoQuery() { if (string.IsNullOrEmpty(this._sysFieldName)) { return; } string value = this.teValue.Text.Trim(); if (value.Length > 1) { int lastindex = value.LastIndexOf(';'); if (lastindex == (value.Length - 1)) { value = value.Substring(0, value.Length - 1); } } string[] arr1 = value.Split(';'); if (arr1 == null || arr1.Length == 0) { return; } string temp1 = ""; foreach (string str1 in arr1) { temp1 += str1; } if (this.treeLayer.GetAllCheckedNodes() != null) { DF2DPipe.Class.Query query = new DF2DPipe.Class.Query(); foreach (TreeListNode node in this.treeLayer.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string classifyField = sc.Parent.ClassifyField; string[] arrFc2DId = sc.Parent.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (this._sysFieldName == "Additional") { if (fc == null || facc == null || facc.Name != "PipeNode") { continue; } } else { if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } } DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(this._sysFieldName); if (fc == null || facc == null || fi == null) { continue; } int index = fc.FindField(fi.Name); if (index == -1) { continue; } IFields pFields = fc.Fields; IField pField = pFields.get_Field(index); string whereClause = UpOrDown.DecorateWhereClasuse(fc) + classifyField + "='" + sc.Name + "'" + " AND "; foreach (string str1 in arr1) { whereClause += pField.Name + "=" + str1 + " OR "; } whereClause = whereClause.Substring(0, whereClause.Length - 3); IFeature pFeature = null; IFeatureCursor pFeatureCusor = null; try { IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = whereClause; pFeatureCusor = fc.Search(pQueryFilter, true); DataTable dt = new DataTable(); dt.TableName = facc.Name; DataColumn oidcol = new DataColumn(); oidcol.ColumnName = "oid"; oidcol.Caption = "ID"; dt.Columns.Add(oidcol); foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection) { if (!fitemp.CanQuery) { continue; } DataColumn col = new DataColumn(); col.ColumnName = fitemp.Name; col.Caption = fitemp.Alias; dt.Columns.Add(col); } while ((pFeature = pFeatureCusor.NextFeature()) != null) { DataRow dtRow = dt.NewRow(); dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")); foreach (DataColumn col in dt.Columns) { int index1 = pFeature.Fields.FindField(col.ColumnName); if (index1 < 0) { continue; } object obj1 = pFeature.get_Value(index1); string str = ""; if (obj1 != null) { IField field = pFeature.Fields.get_Field(index1); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; case esriFieldType.esriFieldTypeDouble: double d; if (double.TryParse(obj1.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj1.ToString(); break; } } dtRow[col.ColumnName] = str; } dt.Rows.Add(dtRow); } if (dt.Rows.Count > 0) { this._dict[sc.Name] = dt; } } catch { } finally { if (pFeatureCusor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCusor); pFeatureCusor = null; } if (pFeature != null) { pFeature = null; } } } } } } }
private DataTable RegionAnalysis(IGeometry geo) { DataTable dtResult = new DataTable(); dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) }); dtstats = new DataTable(); dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("NUMBER", typeof(int)) }); List <MajorClass> list = LogicDataStructureManage2D.Instance.GetAllMajorClass(); foreach (MajorClass mc in list) { string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } long majorclasscount = 0; int indexStart = dtResult.Rows.Count; foreach (SubClass sc in mc.SubClasses) { long sccount = 0; bool bHave = false; foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != "PipeNode") { continue; } ISpatialFilter filter = new SpatialFilter(); filter.Geometry = geo; filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains; int count = fc.FeatureCount(filter); if (count == 0) { continue; } bHave = true; sccount += count; } if (bHave) { DataRow dr = dtResult.NewRow(); dr["PIPENODETYPE"] = mc; dr["FIELDNAME"] = ""; dr["PVALUE"] = sc; dr["NUMBER"] = sccount; majorclasscount += sccount; dtResult.Rows.Add(dr); DataRow dr1 = dtstats.NewRow(); dr1["PIPENODETYPE"] = mc; dr1["FIELDNAME"] = sc; dr1["NUMBER"] = sccount; dtstats.Rows.Add(dr1); } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALNUMBER"] = majorclasscount; } } return(dtResult); }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; this._dict.Clear(); bool ready = true; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } app.Workbench.SetMenuEnable(true); m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; IGeometry pGeo = null; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; //pColor = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16); IRubberBand pRubberBand; pRubberBand = new RubberLineClass(); IGeometry pLine; pLine = pRubberBand.TrackNew(m_Display, null); //IPolyline pLine = app.Current2DMapControl.TrackLine() as IPolyline; object symbol = pLineSym as object; app.Current2DMapControl.DrawShape(pLine, ref symbol); WaitForm.Start("正在查询...", "请稍后"); //if (GlobalValue.System_Selection_Environment(m_ActiveView).CombinationMethod == 0)//new selection //{ // this.m_ActiveView.FocusMap.ClearSelection(); //} pGeo = PublicFunction.DoBuffer(pLine, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); if (pGeo == null) { return; } //m_ActiveView.FocusMap.SelectByShape(pGeo, GlobalValue.System_Selection_Environment(m_ActiveView), false); //if (m_ActiveView.FocusMap.SelectionCount > 0) //{ // ready = true; // m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //} //else //{ // m_ActiveView.Refresh(); //} if (ready) { //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups) //{ foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses) { foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } if (fc == null || pGeo == null) { continue; } ISpatialFilter pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; pSpatialFilter.WhereClause = whereClause; pFeatureCursor = fc.Search(pSpatialFilter, false); if (pFeatureCursor == null) { continue; } DataTable dt = new DataTable(); dt.TableName = facc.Name; DataColumn oidcol = new DataColumn(); oidcol.ColumnName = "oid"; oidcol.Caption = "ID"; dt.Columns.Add(oidcol); foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection) { if (!fitemp.CanQuery) { continue; } DataColumn col = new DataColumn(); col.ColumnName = fitemp.Name; col.Caption = fitemp.Alias; dt.Columns.Add(col); } while ((pFeature = pFeatureCursor.NextFeature()) != null) { DataRow dtRow = dt.NewRow(); dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")); foreach (DataColumn col in dt.Columns) { int index1 = pFeature.Fields.FindField(col.ColumnName); if (index1 < 0) { continue; } object obj1 = pFeature.get_Value(index1); string str = ""; if (obj1 != null) { IField field = pFeature.Fields.get_Field(index1); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; case esriFieldType.esriFieldTypeDouble: double d; if (double.TryParse(obj1.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj1.ToString(); break; } } dtRow[col.ColumnName] = str; } dt.Rows.Add(dtRow); } if (dt.Rows.Count > 0) { this._dict.Add(sc.Name, dt); } } } } } } WaitForm.Stop(); try { this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; if (this._ucPropInfo2D == null) { this._ucPropInfo2D = new UCPropertyInfo2D(); } this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._ucPropInfo2D); this._ucPropInfo2D.Init(); this._ucPropInfo2D.SetPropertyInfo(this._dict); } catch { } //} } catch { } }
///////////////////////////////////////////// /// Functions ///////////////////////////////////////////// //constructor public LiftWallTask(Transform wall, UpOrDown currentAction) { this.wall = wall; this.currentAction = currentAction; }
public IHttpActionResult PostUpOrDown(UpOrDown Model) { _CategoryService.UpOrDown(Model, User.Identity.GetUserId()); return(Ok()); }
public string WriteMsgBase() { isCorrect = false; ROW = 1; if (!Enum.IsDefined(typeof(WaterBaseProtocol.UpOrDown), (int)UpOrDown)) { if (ShowLog) { logHelper.Error("上下行标识非法,0或8!" + UpOrDown); } return("上下行标识非法,0或8!" + UpOrDown); } if (DataBeginChar == (byte)WaterBaseProtocol.DataBeginChar.SYN) { if (TotalPackage > 0xFFF || TotalPackage < 0) { if (ShowLog) { logHelper.Error("包总数非法,0-4095!" + TotalPackage); } return("包总数非法,0-4095!" + TotalPackage); } if (CurrentPackage > 0xFFF || CurrentPackage < 0) { if (ShowLog) { logHelper.Error("序列号非法,0-4095!" + CurrentPackage); } return("序列号非法,0-4095!" + CurrentPackage); } Length = 3 + UserDataBytes.Length; } else { DataBeginChar = (byte)WaterBaseProtocol.DataBeginChar.STX; Length = UserDataBytes.Length; } if (Length > 0xFFF || Length < 0x001) { if (ShowLog) { logHelper.Error("长度非法,0-4095!" + Length); } return("长度非法,0-4095!" + Length); } try { List <byte> list = new List <byte>(); list.AddRange(BeginChar); if (UpOrDown == (int)WaterBaseProtocol.UpOrDown.Up) { list.Add(CenterStation); list.AddRange(HexStringUtility.HexStringToByteArray(RemoteStation)); } else if (UpOrDown == (int)WaterBaseProtocol.UpOrDown.Down) { list.AddRange(HexStringUtility.HexStringToByteArray(RemoteStation)); list.Add(CenterStation); } list.AddRange(HexStringUtility.HexStringToByteArray(PW)); list.Add(AFN); list.AddRange(HexStringUtility.HexStringToByteArray(UpOrDown.ToString() + Convert.ToString(Length, 16).ToUpper().PadLeft(3, '0'))); list.Add(DataBeginChar); if (DataBeginChar == (byte)WaterBaseProtocol.DataBeginChar.SYN) { list.AddRange(HexStringUtility.HexStringToByteArray(Convert.ToString(TotalPackage, 16).ToUpper().PadLeft(3, '0') + Convert.ToString(CurrentPackage, 16).ToUpper().PadLeft(3, '0'))); } if (UserDataBytes.Length > 0) { list.AddRange(UserDataBytes); } list.Add(DataEndChar); CC = CRC.crc16(list.ToArray()); Array.Reverse(CC); list.AddRange(CC); RawDataChar = list.ToArray(); RawDataStr = HexStringUtility.ByteArrayToHexString(RawDataChar).ToUpper(); UserData = HexStringUtility.ByteArrayToHexString(UserDataBytes).ToUpper(); isCorrect = true; return(""); } catch (Exception ex) { if (ShowLog) { logHelper.Error("出错!" + ex.Message); } return("出错!" + ex.Message); } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; if (app == null || app.Current2DMapControl == null) { return; } IActiveView m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; IGeometry pGeo = null; IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; try { if (button == 1) { PointClass searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); if (pGeo == null) { return; } WaitForm.Start("正在进行纵断面分析...", "请稍后"); string road1 = ""; string road2 = ""; bool bAlert = false; double hmax = double.MinValue; double hmin = double.MaxValue; List <PPLine2D> pplines = new List <PPLine2D>(); bool haveone = false; List <MajorClass> listMC = LogicDataStructureManage2D.Instance.GetAllMajorClass(); foreach (MajorClass mc in listMC) { if (haveone) { break; } foreach (SubClass sc in mc.SubClasses) { if (haveone) { break; } if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { if (haveone) { break; } DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } if (fc == null || pGeo == null) { continue; } ISpatialFilter pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " = '" + sc.Name + "'"; pFeatureCursor = fc.Search(pSpatialFilter, true); if (pFeatureCursor == null) { continue; } pFeature = pFeatureCursor.NextFeature(); if (pFeature == null) { continue; } //查找管径长宽字段,获得该要素类下字段索引值,若为圆管,则长宽相等 DFDataConfig.Class.FieldInfo fiDia = facc.GetFieldInfoBySystemName("Diameter"); DFDataConfig.Class.FieldInfo fiDia1 = facc.GetFieldInfoBySystemName("Diameter1"); DFDataConfig.Class.FieldInfo fiDia2 = facc.GetFieldInfoBySystemName("Diameter2"); int indexDia = fc.Fields.FindField(fiDia.Name); int indexDiaWith = fc.Fields.FindField(fiDia1.Name); int indexDiaHeight = fc.Fields.FindField(fiDia2.Name); if (indexDiaWith == -1 || indexDiaHeight == -1 || indexDia == -1) { continue; } //查找道路字段索引 DFDataConfig.Class.FieldInfo fiRoad = facc.GetFieldInfoBySystemName("Road"); int indexRoad = fc.Fields.FindField(fiRoad.Name); //查找管线高类别索引 DFDataConfig.Class.FieldInfo fiHLB = facc.GetFieldInfoBySystemName("HLB"); int indexHLB = fc.Fields.FindField(fiHLB.Name); //二级分类名索引 int indexClassify = fc.Fields.FindField(mc.ClassifyField); if (indexRoad != -1) { if (road2 == "") { road1 = pFeature.get_Value(indexRoad).ToString(); road2 = pFeature.get_Value(indexRoad).ToString(); } else { road1 = pFeature.get_Value(indexRoad).ToString(); if (road1 != road2) { if (!bAlert) { XtraMessageBox.Show("横断面线跨越多条道路,当前只绘制在【" + road2 + "】上的管线纵断面图。", "提示"); bAlert = true; } continue; } } } //查找管线的起点终点地面高 double startSurfHeight = double.MaxValue; double endSurfHeight = double.MaxValue; DFDataConfig.Class.FieldInfo fiStartSurfHeight = facc.GetFieldInfoBySystemName("StartSurfH"); if (fiStartSurfHeight == null) { continue; } int indexStartSurfHeight = pFeature.Fields.FindField(fiStartSurfHeight.Name); if (indexStartSurfHeight == -1) { continue; } DFDataConfig.Class.FieldInfo fiEndSurfHeight = facc.GetFieldInfoBySystemName("EndSurfH"); if (fiEndSurfHeight == null) { continue; } int indexEndSurfHeight = pFeature.Fields.FindField(fiEndSurfHeight.Name); if (indexEndSurfHeight == -1) { continue; } //若管线属性地面高字段为null,则从DEM取值 if (pFeature.get_Value(indexStartSurfHeight).ToString() == "" || pFeature.get_Value(indexEndSurfHeight).ToString() == "") { startSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).FromPoint); endSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).ToPoint); } else { startSurfHeight = Convert.ToDouble(pFeature.get_Value(indexStartSurfHeight).ToString()); endSurfHeight = Convert.ToDouble(pFeature.get_Value(indexEndSurfHeight).ToString()); } //查找管线起点高程和终点高程 double startDepthHeight = double.MaxValue; double endDepthHeight = double.MaxValue; DFDataConfig.Class.FieldInfo fiStartDepthHeight = facc.GetFieldInfoBySystemName("StartHeight2D"); if (fiStartDepthHeight == null) { continue; } int indexStartDepthHeight = pFeature.Fields.FindField(fiStartDepthHeight.Name); if (indexStartDepthHeight == -1) { continue; } DFDataConfig.Class.FieldInfo fiEndDepthHeight = facc.GetFieldInfoBySystemName("EndHeight"); if (fiEndDepthHeight == null) { continue; } int indexEndDepthHeight = pFeature.Fields.FindField(fiEndDepthHeight.Name); if (indexEndDepthHeight == -1) { continue; } startDepthHeight = Convert.ToDouble(pFeature.get_Value(indexStartDepthHeight).ToString()); endDepthHeight = Convert.ToDouble(pFeature.get_Value(indexEndDepthHeight).ToString()); //查找管线的管径,判断其是方管还是圆管 string diameter = pFeature.get_Value(indexDia).ToString(); string diameter1 = pFeature.get_Value(indexDiaWith).ToString(); string diameter2 = pFeature.get_Value(indexDiaHeight).ToString(); IPolyline pline = pFeature.Shape as IPolyline; IPoint startpoint = pline.FromPoint; IPoint endpoint = pline.ToPoint; IPoint[] points = new IPoint[] { startpoint, endpoint }; for (int i = 0; i < points.Length; i++) { PPLine2D ppline = new PPLine2D(); if (indexClassify == -1) { ppline.facType = mc.Name; } else { ppline.facType = pFeature.get_Value(indexClassify).ToString(); } if (diameter.Trim() == "") { continue; } ppline.dia = diameter; int indexSplit = diameter.IndexOf('*'); if (indexSplit != -1) { ppline.isrect = true; int iDia1; bool bDia1 = int.TryParse(diameter.Substring(0, indexSplit), out iDia1); if (!bDia1) { continue; } int iDia2; bool bDia2 = int.TryParse(diameter.Substring(indexSplit + 1, diameter.Length - indexDia - 1), out iDia2); if (!bDia2) { continue; } ppline.gj.Add(iDia1); ppline.gj.Add(iDia2); } else { ppline.isrect = false; int iDia; bool bDia = int.TryParse(diameter, out iDia); if (!bDia) { continue; } ppline.gj.Add(iDia); ppline.gj.Add(iDia); } //判断管线高方式 int hlb = 0; if (indexHLB != -1) { string strhlb = pFeature.get_Value(indexHLB).ToString(); if (strhlb.Contains("内")) { hlb = 1; } else if (strhlb.Contains("外")) { hlb = -1; } else { hlb = 0; } ppline.hlb = hlb; } ppline.interPoint = new PPPoint(points[i].X, points[i].Y); if (i == 0) { ppline.clh = startDepthHeight; UpdateH(ppline.clh, ref hmax, ref hmin); ppline.cgh = startSurfHeight; UpdateH(ppline.cgh, ref hmax, ref hmin); } else { ppline.clh = endDepthHeight; UpdateH(ppline.clh, ref hmax, ref hmin); ppline.cgh = endSurfHeight; UpdateH(ppline.cgh, ref hmax, ref hmin); } // 辅助画图 double deltaX = points[1].X - points[0].X; double deltaY = points[1].Y - points[0].Y; ppline.startPt = new PPPoint(points[0].X - deltaX, points[0].Y - deltaY); pplines.Add(ppline); } } } } WaitForm.Stop(); pplines.Sort(new PPLineCompare2D()); double spacesum = 0.0; for (int i = 1; i < pplines.Count; i++) { PPLine2D line1 = pplines[i - 1]; PPLine2D line2 = pplines[i]; line2.space = Math.Sqrt((line1.interPoint.X - line2.interPoint.X) * (line1.interPoint.X - line2.interPoint.X) + (line1.interPoint.Y - line2.interPoint.Y) * (line1.interPoint.Y - line2.interPoint.Y)); spacesum += line2.space; } ; var str1 = (pplines[0].interPoint.X / 1000).ToString("0.00"); var str2 = (pplines[0].interPoint.Y / 1000).ToString("0.00"); string mapNum = str2 + "-" + str1; string mapName = SystemInfo.Instance.SystemFullName + "纵断面图"; FrmSectionAnalysis dialog = new FrmSectionAnalysis("纵断面分析结果", 1); dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2); dialog.Show(); } } catch (System.Exception ex) { WaitForm.Stop(); } finally { if (pFeatureCursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor); pFeatureCursor = null; } if (pFeature != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature); pFeature = null; } } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; this._dict.Clear(); m_ActiveView = app.Current2DMapControl.ActiveView; if (this.m_ActiveView.FocusMap.FeatureSelection != null) { this.m_ActiveView.FocusMap.ClearSelection(); } bool ready = false; bool haveone = false; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } app.Workbench.SetMenuEnable(true); IGeometry pGeo = null; try { if (button == 1) { WaitForm.Start("正在查询...", "请稍后"); PointClass searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); if (pGeo == null) { return; } ready = true; if (ready == true) { //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups) //{ IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; ISpatialFilter pSpatialFilter = new SpatialFilter(); IFeatureClass fc; DF2DFeatureClass dffc; //foreach (MajorClass mc in lg.MajorClasses) foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses) { foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } if (fc == null || pGeo == null) { continue; } pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; pSpatialFilter.WhereClause = whereClause; pFeatureCursor = fc.Search(pSpatialFilter, false); if (pFeatureCursor == null) { continue; } pFeature = pFeatureCursor.NextFeature(); if (pFeature == null) { continue; } DataTable dt = new DataTable(); dt.TableName = facc.Name; DataColumn oidcol = new DataColumn(); oidcol.ColumnName = "oid"; oidcol.Caption = "ID"; dt.Columns.Add(oidcol); foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection) { if (!fitemp.CanQuery) { continue; } DataColumn col = new DataColumn(); col.ColumnName = fitemp.Name; col.Caption = fitemp.Alias; dt.Columns.Add(col); } DataRow dtRow = dt.NewRow(); dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")); foreach (DataColumn col in dt.Columns) { int index1 = pFeature.Fields.FindField(col.ColumnName); if (index1 < 0) { continue; } object obj1 = GetFieldValueByIndex(pFeature, index1); string str = ""; if (obj1 != null) { IField field = pFeature.Fields.get_Field(index1); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; case esriFieldType.esriFieldTypeDouble: double d; if (double.TryParse(obj1.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj1.ToString(); break; } } dtRow[col.ColumnName] = str; } dt.Rows.Add(dtRow); if (dt.Rows.Count > 0) { this._dict[sc.Name] = dt; } haveone = true; break; } if (haveone) { break; } } if (haveone) { break; } } } #region 查询建筑物 if (!haveone) { FacilityClass facBuild = FacilityClassManager.Instance.GetFacilityClassByName("Building"); if (facBuild != null) { haveone = HaveOne(facBuild, pGeo); } if (!haveone) { FacilityClass facStruct = FacilityClassManager.Instance.GetFacilityClassByName("Structure"); if (facStruct != null) { haveone = HaveOne(facStruct, pGeo); } } } #endregion try { if (!haveone) { WaitForm.Stop(); XtraMessageBox.Show("未选中要素,请重新选择", "提示"); return; } this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; if (this._ucPropInfo2D == null) { this._ucPropInfo2D = new UCPropertyInfo2D(); } this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._ucPropInfo2D); this._ucPropInfo2D.Init(); this._ucPropInfo2D.SetPropertyInfo(this._dict); WaitForm.Stop(); } catch { WaitForm.Stop(); } } //} } catch { WaitForm.Stop(); } finally { } }
private void Flick(AndroidDriver <AppiumWebElement> driver, AppiumWebElement element, UpOrDown direction) { int moveYDirection; if (direction == UpOrDown.Down) { moveYDirection = 600; } else { moveYDirection = -600; } var input = new PointerInputDevice(PointerKind.Touch); ActionSequence FlickUp = new ActionSequence(input); FlickUp.AddAction(input.CreatePointerMove(element, 0, 0, TimeSpan.Zero)); FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left)); FlickUp.AddAction(input.CreatePointerMove(element, 0, moveYDirection, TimeSpan.FromMilliseconds(200))); FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left)); driver.PerformActions(new List <ActionSequence>() { FlickUp }); }
private DataTable RegionAnalysis(IGeometry geo) { DataTable dtResult = new DataTable(); dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) });//初始化统计用数据表的列 dtstats = new DataTable(); dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("LENGTH", typeof(double)) }); //初始化生成统计图表用数据表的列 foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) //对所有二级大类进行遍历 { string[] arrFc2DId = mc.Fc2D.Split(';'); //将二级大类所对应的要素类ID转换为数组 if (arrFc2DId == null) { continue; } double majorclasslength = 0.0; int indexStart = dtResult.Rows.Count; //获得数据表当前的行数 double subclasslength = 0.0; foreach (SubClass sc in mc.SubClasses) //对当前二级大类的子类进行遍历 { if (!sc.Visible2D) { continue; } double subfieldlength = 0.0; bool bHave = false; foreach (string fc2DId in arrFc2DId) //遍历二级子类所对应的要素类ID { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); //得到设施类 IFeatureClass fc = dffc.GetFeatureClass(); //得到要素类 if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D");//得到设施类的管线长度字段 if (fiPipeLength == null) { continue; } IFields pFields = fc.Fields; //得到要素类字段集 int indexPipeLength = pFields.FindField(fiPipeLength.Name); //根据管线长度字段名得到要素类管线长度字段的索引 if (indexPipeLength < 0) { continue; } IField pField = pFields.get_Field(indexPipeLength); //根据管线长度字段索引得到管线长度字段 ISpatialFilter filter = new SpatialFilter(); //初始化空间过滤类 filter.Geometry = geo; filter.SubFields = pField.Name; filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//选择过滤的空间条件 if (fc == null || geo == null) { return(null); } IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; try { pFeatureCursor = fc.Search(filter, false);//获得过滤结果的游标 while ((pFeature = pFeatureCursor.NextFeature()) != null) { object tempobj = pFeature.get_Value(indexPipeLength); //获得当前要素管线长度字段的值 double dtemp = 0.0; if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp)) //将管线长度转换为double { bHave = true; subfieldlength += dtemp;//累加到当前二级子类总长度 } } } catch { } finally { if (pFeatureCursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor); pFeatureCursor = null; } if (pFeature != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature); pFeature = null; } } if (bHave) { DataRow dr = dtResult.NewRow();//将对应数据填写到统计用数据表的新行 dr["PIPELINETYPE"] = mc; dr["FIELDNAME"] = ""; dr["PVALUE"] = sc; subclasslength += subfieldlength; dr["LENGTH"] = subfieldlength.ToString("0.00"); dtResult.Rows.Add(dr); DataRow dr1 = dtstats.NewRow();//将对应数据填写到统计图表用数据表的新行 dr1["PIPELINETYPE"] = mc; dr1["FIELDNAME"] = sc; dr1["LENGTH"] = subfieldlength.ToString("0.00"); dtstats.Rows.Add(dr1); } } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALLENGTH"] = subclasslength.ToString("0.00"); } } return(dtResult); }
private void DoStats() { try { dtResult = new DataTable(); dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) }); dtstats = new DataTable(); dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("NUMBER", typeof(int)) }); List <MajorClass> list = LogicDataStructureManage2D.Instance.GetAllMajorClass(); if (this.treelist.GetAllCheckedNodes() != null) { long majorclasscount = 0; foreach (TreeListNode node in this.treelist.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } //if (sc.Name == "其他") continue; string[] arrFc2DId = sc.Parent.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } int indexStart = dtResult.Rows.Count; int indexEnd = dtResult.Rows.Count; long sccount = 0; long valuecount = 0; bool bHave = false; foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != "PipeNode") { continue; } DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(this._sysFieldName); IQueryFilter filter = new QueryFilter(); if (valuelist.Count <= 0) { continue; } foreach (string strValue in valuelist) { filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " = '" + sc.Name + "' and " + fi.Name + " = " + strValue;; int count = fc.FeatureCount(filter); if (count == 0) { continue; } bHave = true; if (bHave) { DataRow dr = dtResult.NewRow(); dr["PIPENODETYPE"] = sc; dr["FIELDNAME"] = ""; dr["PVALUE"] = strValue; dr["NUMBER"] = count; sccount += count; dtResult.Rows.Add(dr); bHave = false; DataRow dr1 = dtstats.NewRow(); dr1["PIPENODETYPE"] = sc; dr1["FIELDNAME"] = strValue; dr1["NUMBER"] = count; dtstats.Rows.Add(dr1); } } } majorclasscount += sccount; indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALNUMBER"] = sccount; } } } //for (int i = 0; i < dtResult.Rows.Count; i++) //{ // DataRow dr = dtResult.Rows[i]; // dr["TOTALNUMBER"] = majorclasscount; //} } } catch (System.Exception ex) { } }