protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { try { dlg = gpExtension.elevationDlg; if (dlg == null) return; IDisplayTransformation displayTransformation = view.ScreenDisplay.DisplayTransformation; //the clicked point in map crs: IPoint mapPoint = displayTransformation.ToMapPoint(arg.X, arg.Y); //Get the polyline object from the users mouse clicks polyline = geopuntHelper.GetPolylineFromMouseClicks(view); dlg.getData(polyline); } catch (Exception ex) { MessageBox.Show(ex.Message + " : " + ex.StackTrace); } finally { base.OnMouseDown(arg); } }
//返回路径 public bool PathPolyLine() { try { IEIDInfo ipEIDInfo; IGeometry ipGeometry; if (m_ipPolyline != null) return true; m_ipPolyline = new PolylineClass(); IGeometryCollection ipNewGeometryColl = m_ipPolyline as IGeometryCollection; ISpatialReference ipSpatialReference = m_ipMap.SpatialReference; IEIDHelper ipEIDHelper = new EIDHelperClass(); ipEIDHelper.GeometricNetwork = m_ipGeometricNetwork; ipEIDHelper.OutputSpatialReference = ipSpatialReference; ipEIDHelper.ReturnGeometries = true; IEnumEIDInfo ipEnumEIDInfo = ipEIDHelper.CreateEnumEIDInfo(m_ipEnumNetEID_Edges); int count = ipEnumEIDInfo.Count; ipEnumEIDInfo.Reset(); for (int i = 0; i < count; i++) { ipEIDInfo = ipEnumEIDInfo.Next(); ipGeometry = ipEIDInfo.Geometry; ipNewGeometryColl.AddGeometryCollection(ipGeometry as IGeometryCollection); } return true; } catch (Exception) { return false; } }
public static bool CreateLineFeature(IFeatureLayer featureLayer, IPolyline pStopLine, LibEntity.StopLine stopLineEntity) { if (pStopLine == null || pStopLine.IsEmpty) { return false; } try { IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IDataset dataset = (IDataset)featureClass; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditing(false); workspaceEdit.StartEditOperation(); IFeature feature = featureClass.CreateFeature(); Common.DataEditCommon.ZMValue(feature, pStopLine); //几何图形Z值处理 feature.Shape = pStopLine; //编号 int iFieldID = feature.Fields.FindField("BID"); if (iFieldID > -1) feature.Value[iFieldID] = stopLineEntity.binding_id; //名称 iFieldID = feature.Fields.FindField("NAME"); if (iFieldID > -1) feature.Value[iFieldID] = stopLineEntity.stop_line_name; feature.Store(); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); //GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = pStopLine.Envelope; GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent.Expand(1.5, 1.5, true); GIS.Common.DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(featureLayer, feature); GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); return true; } return false; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("创建停采线要素出错:" + ex.Message); return false; } }
public static Dictionary<int, List<IPoint>> QueryIntersectPoints(IPolyline line, IFeatureClass roadFC) { var cursor = roadFC.Search(new SpatialFilterClass { Geometry = line, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects }, true); var topo = line as ITopologicalOperator; var rel = line as IRelationalOperator; var f = cursor.NextFeature(); var dict = new Dictionary<int, List<IPoint>>(); while(f!= null) { var shp = f.ShapeCopy; line.SpatialReference = shp.SpatialReference; var pc2 = shp as IPointCollection; var ret = topo.Intersect(shp, esriGeometryDimension.esriGeometry1Dimension); if (ret != null && ret.IsEmpty == false) { dict.Add(f.OID, null); } else { ret = topo.Intersect(shp, esriGeometryDimension.esriGeometry0Dimension); if(ret is IPoint) { var pt = ret as IPoint; if (IsStartOrEnd(pt, pc2) == false) { dict.Add(f.OID, new List<IPoint>(new[] { pt })); } } else if(ret is IPointCollection) { var pc = ret as IPointCollection; var list = new List<IPoint>(); for (var i = 0; i < pc.PointCount; i++) { if (IsStartOrEnd(pc.Point[i], pc2) == false) { list.Add(pc.Point[i]); } } dict.Add(f.OID, list); } else { throw new NotSupportedException(string.Format("道路相交结果的类型‘{0}’不被支持", ret.GetType())); } } f = cursor.NextFeature(); } Marshal.ReleaseComObject(cursor); return dict; }
/// <summary> /// 在掘进进尺图层创建掘进进尺线要素 /// </summary> /// <params name="featureLayer">掘进进尺图层</params> /// <params name="pJjPolyline">掘进进尺线</params> /// <params name="tunnelID">对应的巷道ID</params> /// <returns>成功返回true</returns> public static bool CreateLineFeature(IFeatureLayer featureLayer, IPolyline pJjPolyline, string bindingID, double distance) { if (pJjPolyline == null || pJjPolyline.IsEmpty) { return false; } try { IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IDataset dataset = (IDataset)featureClass; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditOperation(); IFeature feature = featureClass.CreateFeature(); Common.DataEditCommon.ZMValue(feature, pJjPolyline); //几何图形Z值处理 feature.Shape = pJjPolyline; //绑定编号 int iFieldID = feature.Fields.FindField("ID"); if (iFieldID > -1) feature.Value[iFieldID] = bindingID; //掘进距离 iFieldID = feature.Fields.FindField("Distance"); if (iFieldID > -1) feature.Value[iFieldID] = distance; feature.Store(); workspaceEdit.StopEditOperation(); //缩放到新增的线要素,并高亮该要素 GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = pJjPolyline.Envelope; GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent.Expand(1.5, 1.5, false); GIS.Common.DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(featureLayer, feature); GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); return true; } return false; } catch(Exception ex) { System.Diagnostics.Trace.WriteLine("创建掘进进尺线要素出错:" + ex.Message); return false; } }
public PointsAlongLineForm(IEditor3 editor) { InitializeComponent(); m_editor = editor; m_edSketch = m_editor as IEditSketch3; m_polyline = m_edSketch.Geometry as IPolyline; tbLineLength.Text = (m_polyline.Length.ToString("F")); //get the template m_editTemplate = m_editor.CurrentTemplate; m_featureLayer = m_editTemplate.Layer as IFeatureLayer; m_featureClass = m_featureLayer.FeatureClass; }
public List<GeoStruct> BufferAnalyseNew(IPolyline pGeom, double dist, IFeatureLayer fealyr, IGeometry Reg = null) { List<GeoStruct> geoList = new List<GeoStruct>(); ITopologicalOperator top = pGeom as ITopologicalOperator; IGeometry geom = top.Buffer(dist); IFeatureCursor searchCursor = SpatialSearch(geom, "1=1", fealyr); if (searchCursor != null) { IFeature fea = searchCursor.NextFeature(); while (fea != null) { GeoStruct geoTmp = new GeoStruct(); var fieldDict = new Dictionary<string, string>(); for (var i = 0; i < fea.Fields.FieldCount; i++) { var field = fea.Fields.Field[i]; if (field.Type != esriFieldType.esriFieldTypeGeometry) { fieldDict.Add(field.Name, fea.Value[i].ToString()); } else { geoTmp.geo = fea.Shape; } } geoTmp.geoinfos = fieldDict; IRelationalOperator relation = Reg as IRelationalOperator; bool bin = (relation.Overlaps(fea.Shape) || relation.Touches(fea.Shape) || relation.Contains(fea.Shape)); double distance = CalculateDistanceNew(pGeom, geoTmp.geo); if (bin) distance = 0.0; if (distance < Global.searchlen) { geoTmp.dist = distance; geoList.Add(geoTmp); } //geoTmp.dist = distance; //geoList.Add(geoTmp); fea = searchCursor.NextFeature(); } } return geoList; }
netDxf.Entities.Polyline CastPolyline(IPolyline item) { netDxf.Entities.Polyline polyline = null; if (item is LightWeightPolyline) { polyline = ((LightWeightPolyline)item).ToPolyline(); } else if (item is Polyline) { polyline = (netDxf.Entities.Polyline)item; } else { polyline = null; } return polyline; }
private double GetAngle(IPolyline pPolyline) { //IPolycurve pPolycurve; ILine pTangentLine = new ESRI.ArcGIS.Geometry.Line(); pPolyline.QueryTangent(esriSegmentExtension.esriNoExtension, 0.5, true, pPolyline.Length, pTangentLine); Double radian = pTangentLine.Angle; //Double angle = radian * 180 / Math.PI; //// 如果要设置正角度执行以下方法 //while (angle < 0) //{ // angle = angle + 360; //} //// 返回角度 //return angle; // 返回弧度 return radian; }
/// <summary> /// Returns nodes on the path between two points /// </summary> /// <param name="from">The start point</param> /// <param name="to">The end point</param> /// <param name="path"></param> /// <returns></returns> public static IEnumerable<IPointGeo> GetNodesBetweenPoints(IPointGeo from, IPointGeo to, IPolyline<IPointGeo> path) { var segments = path.Segments; List<IPointGeo> result = new List<IPointGeo>(); int fromIndex = -1; int toIndex = -1; for (int i = 0; i < segments.Count; i++) { if (Calculations.GetDistance2D(from, segments[i]) < Calculations.EpsLength) { if (fromIndex > -1 && toIndex > -1 && toIndex <= fromIndex) ; else fromIndex = i; } if (Calculations.GetDistance2D(to, segments[i]) < Calculations.EpsLength) { if (fromIndex > -1 && toIndex > -1 && toIndex >= fromIndex) ; else toIndex = i; } } if (fromIndex == -1 || toIndex == -1) return result; if (fromIndex == toIndex - 1) { result.Add(segments[fromIndex].EndPoint); } else if (fromIndex - 1 == toIndex) { result.Add(segments[toIndex].EndPoint); } else if (fromIndex < toIndex) { for (int i = fromIndex; i < toIndex; i++) { result.Add(segments[i].EndPoint); } } else if (toIndex < fromIndex) { for (int i = fromIndex; i > toIndex; i--) { result.Add(segments[i].StartPoint); } } return result; }
public void getData(IPolyline profileLineGeom) { try { polyLineLam72 = (IPolyline)geopuntHelper.Transform((IGeometry)profileLineGeom, lam72); int samplesCount = (int)samplesNum.Value; datacontract.geojsonLine gjs = geopuntHelper.esri2geojsonLine(polyLineLam72); profileData = dhm.getDataAlongLine(gjs, samplesCount, dataHandler.CRS.Lambert72); ArcMap.Application.CurrentTool = oldCmd; this.WindowState = FormWindowState.Normal; this.Focus(); maxH = profileData.Select(c => c[3]).Max(); minH = profileData.Where(c => c[3] > -999).Select(c => c[3]).Min(); maxD = profileData.Select(c => c[0]).Max(); profileGrp.GraphPane.YAxis.Scale.Max = maxH; profileGrp.GraphPane.YAxis.Scale.Min = minH; profileGrp.GraphPane.XAxis.Scale.Max = maxD; addLineGrapic(); createGraph(); } catch (WebException wex) { if (wex.Status == WebExceptionStatus.Timeout) MessageBox.Show("De connectie werd afgebroken." + " Het duurde te lang voor de server een resultaat terug gaf.\n" + "U kunt via de instellingen de 'timout'-tijd optrekken.", wex.Message); else if (wex.Response != null) { string resp = new StreamReader(wex.Response.GetResponseStream()).ReadToEnd(); MessageBox.Show(resp, wex.Message); } else MessageBox.Show(wex.Message, "Error"); } catch (Exception ex) { MessageBox.Show(ex.Message +" "+ ex.StackTrace, "Error"); } }
private IPolygon FlatBuffer(IPolyline pLline1, double pBufferDis) { object o = System.Type.Missing; //分别对输入的线平移两次(正方向和负方向) IConstructCurve pCurve1 = new PolylineClass(); pCurve1.ConstructOffset(pLline1, pBufferDis, ref o, ref o); IPointCollection pCol = pCurve1 as IPointCollection; IConstructCurve pCurve2 = new PolylineClass(); pCurve2.ConstructOffset(pLline1, -1 * pBufferDis, ref o, ref o); //把第二次平移的线的所有节点翻转 IPolyline pline2 = pCurve2 as IPolyline; pline2.ReverseOrientation(); //把第二条的所有节点放到第一条线的IPointCollection里面 IPointCollection pCol2 = pline2 as IPointCollection; pCol.AddPointCollection(pCol2); //用面去初始化一个IPointCollection IPointCollection pPointCol = new PolygonClass(); pPointCol.AddPointCollection(pCol); //把IPointCollection转换为面 IPolygon pPolygon = pPointCol as IPolygon; //简化节点次序 pPolygon.SimplifyPreserveFromTo(); return pPolygon; }
protected override void OnShutdown() { try { script = null; lastValue = null; intersectLayer = null; intersectTable = null; intersectLayerSelection = null; intersectTableSelection = null; qFilter = null; row = null; testField = null; curve = null; sourceLayer = null; pFS = null; _copyPoint = null; _copyPolyline = null; _copyPolygon = null; sFilter = null; try { if (fCursor != null) Marshal.ReleaseComObject(fCursor); if (cCurs != null) Marshal.ReleaseComObject(cCurs); if (sourceFeature != null) Marshal.ReleaseComObject(sourceFeature); } catch { } fCursor = null; cCurs = null; sourceFeature = null; nearestFeature = null; fieldObj = null; _currentDataset = null; proxOp = null; } catch { } try { if (AAState._sw != null) { AAState._sw.Flush(); AAState._sw.Close(); AAState._sw = null; } } catch { } try { if (ArcMap.Events != null) { ArcMap.Events.NewDocument -= ArcMap_NewOpenDocument; ArcMap.Events.OpenDocument -= ArcMap_NewOpenDocument; } if (AAState._editor != null) { if (AAState._editor != null) { //Wire editor events. AAState._editEvents = (IEditEvents_Event)AAState._editor; AAState._editEvents.OnStartEditing -= OnStartEditing; AAState._editEvents.OnStopEditing -= OnStopEditing; AAState._editEvents2 = (IEditEvents2_Event)AAState._editor;// SG Jan 2003 AAState._editor = null; AAState._editEvents = null; AAState._editEvents2 = null; // SG Jan 2003 } } try { AAState.bmpOff.Dispose(); AAState.bmpOn.Dispose(); AAState.commandItem = null; } catch { } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain5") + ex.Message); } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { IGeometry Geom = null; if (!m_bInUse) { downPoint = m_pAnchorPoint; m_pRecordPointArray.Add(downPoint); m_pCircleFeed = new NewCircleFeedbackClass(); m_bInUse = true; m_pCircleFeed.Display = m_pActiveView.ScreenDisplay; m_pLineFeed = new NewLineFeedbackClass(); m_pLineFeed.Start(downPoint); m_pCircleFeed.Start(downPoint); } else //如果命令正在使用 { if (pGraphicsContainer != null) { pGraphicsContainer.DeleteAllElements(); } movePoint = m_pAnchorPoint; //画半径线 m_pRecordPointArray.Add(movePoint); IPolyline pPolyline; pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray); Geom = (IGeometry)pPolyline; CommonFunction.AddElement(m_pMapControl, Geom); m_radius = CommonFunction.GetDistance_P12(downPoint, movePoint); //半径 //m_radius = Math.Round( m_radius,1,MidpointRounding.AwayFromZero);//保留一位小数 //缓冲半径文本 ITextElement iTextElement = new TextElementClass(); iTextElement.Text = m_radius.ToString(".##") + "米"; ITextSymbol sce = new TextSymbolClass(); sce.Size = 15 /*SystemInfo.Instance.TextSize*/; Color color = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor); IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; sce.Color = pColor; iTextElement.Symbol = sce; IElement iElement = (IElement)iTextElement; iElement.Geometry = Geom; this.m_pMapControl.ActiveView.GraphicsContainer.AddElement(iElement, 0); this.m_pMapControl.ActiveView.Refresh(); //画圆 pSegmentCollection = new PolygonClass(); pSegmentCollection.SetCircle(downPoint, m_radius); pGeom = pSegmentCollection as IGeometry; if (pGeom != null) { AddCreateCircleElement(pGeom, this.m_pMapControl.ActiveView); this.m_pMapControl.ActiveView.Refresh(); GetPipeInfo(); } if (m_pRecordPointArray.Count != 0) { m_pRecordPointArray.RemoveAll(); } m_bInUse = false; } }
private static void DeleteTargetPoints(IFeatureClass targetFC, IPolyline line, double tolerenceForDelete) { ITopologicalOperator topoOpLine = null; IPolygon poly2 = null; ISpatialFilter sFilter2 = null; IFeatureCursor fCursor2 = null; IFeature feature2 = null; try { if (targetFC != null && line != null) { //Buffer the line topoOpLine = line as ITopologicalOperator; poly2 = topoOpLine.Buffer(tolerenceForDelete) as IPolygon; sFilter2 = new SpatialFilterClass(); sFilter2.Geometry = poly2; sFilter2.GeometryField = targetFC.ShapeFieldName; sFilter2.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; fCursor2 = targetFC.Search(sFilter2, false); while ((feature2 = fCursor2.NextFeature()) != null) { feature2.Delete(); } } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + "DeleteTargetPoints: " + ex.Message); } finally { if (fCursor2 != null) Marshal.ReleaseComObject(fCursor2); topoOpLine = null; poly2 = null; sFilter2 = null; fCursor2 = null; feature2 = null; } }
/// <summary> /// 向某一个方向延申 /// </summary> /// <param name="tag">延申的方向</param> /// <param name="selected">选框元素的OID</param> /// <param name="tree">树结构</param> /// <param name="featClass">要素类</param> private void GoForward(Posi tag, double minTreeAngle, ref Tree tree, IFeatureClass featClass) { while (true) { Boolean bUpdate = false; //树是否更新过 List <Node> leaves = tree.FindLeaves(tag); foreach (Node leaf in leaves) { //寻找相接触的Polyline //寻找与polyID相接触的Polyline集合 IPoint touchPoint = null; if (leaf.exp == Posi.FROM) { touchPoint = leaf.poly.FromPoint; } else if (leaf.exp == Posi.TO) { touchPoint = leaf.poly.ToPoint; } ISpatialFilter sf = new SpatialFilterClass(); sf.Geometry = touchPoint; sf.GeometryField = "SHAPE"; sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches; IFeatureCursor fc = featClass.Search(sf, false); int num = featClass.FeatureCount(sf); IFeature fea = null; while ((fea = fc.NextFeature()) != null) { int id = fea.OID; if (id == leaf.id) { continue; //排除自身 } if (Convert.ToInt32(fea.get_Value(Program.linkIndex)) != 1) { continue; //不是link,跳过 } if (tree.FindNode(id)) { continue; //不能是本树的节点 } if (num > 2 && GetPolylineAngle(leaf.id, id, featClass) < minTreeAngle) { continue; //剪枝 } IPolyline poly = fea.ShapeCopy as IPolyline; if (GetRel(id, leaf.id, featClass) == Posi.FROM) { tree.InsertAsChild(leaf, id, poly, poly.Length, tag, Posi.TO); } else if (GetRel(id, leaf.id, featClass) == Posi.TO) { tree.InsertAsChild(leaf, id, poly, poly.Length, tag, Posi.FROM); } bUpdate = true; } } if (!bUpdate) { break; //此次无更新,退出 } } }
// 抽稀坐标点 private bool SimplifyPolyline(IGeometry geo, out IPolyline route) { route = null; try { IPolyline polyline = null; if ((geo == null) || ((polyline = geo as IPolyline) == null)) { return(false); } List <Vector> list = new List <Vector>(); IPoint p = null; IPoint point = null; route = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; int num2 = 0; IPoint pointValue = null; Vector vector = null; Vector vector2 = null; Vector vector3 = null; Vector vector4 = null; if (polyline.PointCount == 2) { list.Add(new Vector(polyline.StartPoint)); route.AppendPoint(polyline.StartPoint); list.Add(new Vector(polyline.EndPoint)); route.AppendPoint(polyline.EndPoint); } else { new Stack <int>(); p = null; for (int i = 0; i < polyline.PointCount; i++) { point = polyline.GetPoint(i); if (i == 0) { //DrawGeometry.Ocx.ObjectManager.CreateRenderPoint(point, null, this._); list.Add(new Vector(point)); route.AppendPoint(point); num2 = i; p = point; } else if (Math.Sqrt((((point.X - p.X) * (point.X - p.X)) + ((point.Y - p.Y) * (point.Y - p.Y))) + ((point.Z - p.Z) * (point.Z - p.Z))) < (this._dia1 / 2.0)) { p = point; } else { vector2 = new Vector(p); vector4 = new Vector(p.X - point.X, p.Y - point.Y, p.Z - point.Z); if ((num2 > 0) && (num2 == (i - 1))) { list.Add(new Vector(p)); route.AppendPoint(p); } else if ((vector != null) && (vector3 != null)) { pointValue = this.RadialIntersect(vector, vector3, vector2, vector4); if (pointValue != null) { route.AppendPoint(pointValue); list.Add(new Vector(pointValue.X, pointValue.Y, pointValue.Z)); } num2 = i; } vector = new Vector(point); vector3 = -vector4; p = point; if (i == (polyline.PointCount - 1)) { list.Add(new Vector(point)); route.AppendPoint(point); } } } } return(true); } catch (Exception exception) { return(false); } }
public static void MakeHatchs(IPolyline pPL, bool Ends, IPolyline pMajor, IPolyline pMinor) { ITopologicalOperator pTopo = pPL as ITopologicalOperator; pTopo.Simplify(); ISegmentCollection pSCMajor = pMajor as ISegmentCollection; ISegmentCollection pSCMinor = pMinor as ISegmentCollection; IGeometryCollection pGC = pPL as IGeometryCollection; IPath pPath; IGeometryCollection pSubPL; IMSegmentation pPLM; object missing = Type.Missing; IMAware pMAware; double Mmin; double Mmax; int cnt = pGC.GeometryCount - 1; for (int i = 0; i <= cnt - 1; i++) { pPath = pGC.get_Geometry(i) as IPath; pSubPL = new PolylineClass(); pSubPL.AddGeometry(pPath as IGeometry, ref missing, ref missing); pMAware = pSubPL as IMAware; pMAware.MAware = true; pPLM = pSubPL as IMSegmentation; Mmin = pPLM.MMin; Mmax = pPLM.MMax; } }
public bool ShowFlowDirection(int flowDir, out IRenderModelPoint rpt) { rpt = null; if (base._rowInfo == null) { return(false); } string str = Application.StartupPath + @"\..\Resource\Images\FlowDirection"; if (!Directory.Exists(str)) { return(false); } IImage _imgFlowImg = DrawGeometry.resFactory.CreateImageFromFile(str); _imgFlowImg.FrameInterval = 50; IPolyline path = null; IPipeSection pipeSection = null; string name = "FlowDirection"; IDrawDynamicFlow flow = null; IModelPoint mp = null; try { IModel model; IModel model2; IPoint pointValue = null; IPolyline polyline2 = null; polyline2 = base._geoGroup[1] as IPolyline; if ((polyline2 == null) || (polyline2.PointCount < 2)) { return(false); } path = polyline2.Clone() as IPolyline; for (int i = 0; i < path.PointCount; i++) { pointValue = path.GetPoint(i); if (pointValue != null) { pointValue.Z += this.OffsetZ; path.UpdatePoint(i, pointValue); } } pipeSection = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, 0.02, 0); flow = ParamModelFactory.Instance.CreateGeometryDraw(ModelType.DynamicFlow, Guid.NewGuid().ToString()) as IDrawDynamicFlow; flow.SetParameter(pipeSection, path, flowDir); flow.SetTextureRender(new string[] { name }); if (!flow.Draw(out mp, out model, out model2)) { return(false); } #region 需要runtime授权 IFeatureDataSet iFeatureDataSet = DF3DPipeCreateApp.App.TempLib.OpenFeatureDataset("FeatureDataSet"); IResourceManager manager = iFeatureDataSet as IResourceManager; if (!manager.ModelExist(mp.ModelName)) { manager.AddModel(mp.ModelName, model, null); } if (!manager.ImageExist(name)) { manager.AddImage(name, _imgFlowImg); } #endregion IModelPointSymbol symbol = new ModelPointSymbolClass(); symbol.SetResourceDataSet(iFeatureDataSet); symbol.Color = uint.MaxValue; symbol.EnableColor = true; mp.ModelEnvelope = model.Envelope; rpt = DrawGeometry.Ocx.ObjectManager.CreateRenderModelPoint(mp, symbol, DrawGeometry.Ocx.ProjectTree.RootID); return(true); } catch (Exception exception) { return(false); } }
public bool projectBackward(IFeatureClass pInputFeatureClass, IRasterLayer pDemLayer, string szXmlFilename, ref IFeatureClass pOutputPolylineFeatureClass, ref IFeatureClass pOutputPointFeatureClass) { if (pInputFeatureClass == null || pDemLayer == null || string.IsNullOrEmpty(szXmlFilename) || pOutputPointFeatureClass == null || pOutputPolylineFeatureClass == null) { return(false); } #region 读取DEM文件 IRasterLayer pRasterLayer = pDemLayer;// new RasterLayerClass(); //pRasterLayer.CreateFromFilePath(szDemFilename); IRaster pDemRaster = pRasterLayer.Raster; IRasterProps pDemRasterProps = pDemRaster as IRasterProps; #endregion #region 读取相机姿态参数 ClsCameraPara cameraPara = ParseXmlFileToGetPara(szXmlFilename); if (cameraPara == null) { return(false); } //根据姿态参数获得旋转矩阵 OriAngle oriAngle = new OriAngle(); Matrix pRotateMatrix = new Matrix(3, 3); oriAngle.kap = cameraPara.dKappa; oriAngle.omg = cameraPara.dOmg; oriAngle.phi = cameraPara.dPhi; if (!ClsGetCameraView.OPK2RMat(oriAngle, ref pRotateMatrix)) { return(false); } #endregion #region 得到曲线信息 List <ISegmentCollection> pSegmentCollection = new List <ISegmentCollection>(); List <IFeature> pFeatureList = new List <IFeature>(); IFeatureCursor pFCursor = pInputFeatureClass.Search(null, false); IFeature pFeature = null;// pFCursor.NextFeature(); while ((pFeature = pFCursor.NextFeature()) != null) { IPolyline pPolyline = pFeature.Shape as IPolyline; if (pPolyline == null) { //pFeature = pFCursor.NextFeature(); continue; } IFeature pTmpFeature = pFeature; pFeatureList.Add(pTmpFeature); ISegmentCollection pCurrentSegmentCollection = pPolyline as ISegmentCollection; pSegmentCollection.Add(pCurrentSegmentCollection); } #endregion #region 节点位置反投影 List <List <Pt2d> > ptImageFeaturePoints = new List <List <Pt2d> >(); List <List <Pt2d> > ptImageFeaturePointsForPointShp = new List <List <Pt2d> >(); ClsGetCameraView pGetCameraView = new ClsGetCameraView(); for (int i = 0; i < pSegmentCollection.Count; i++) { List <Pt2d> ptSingleImageFeaturePoints = new List <Pt2d>(); List <Pt2d> ptSingleImageFeaturePointsForPointShp = new List <Pt2d>(); for (int j = 0; j < pSegmentCollection[i].SegmentCount; j++) { ISegment pCurrentSegment = pSegmentCollection[i].get_Segment(j); if (pCurrentSegment == null) { continue; } //直线 if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryLine) { ILine pLine = pCurrentSegment as ILine; //起始点 IPoint ptFrom = pLine.FromPoint; Pt2d ptFrom2d = getProjectBackwardPoint(ptFrom, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara); if (ptFrom2d != null) { ptSingleImageFeaturePoints.Add(ptFrom2d); ptSingleImageFeaturePointsForPointShp.Add(ptFrom2d); } //终止点 IPoint ptTo = pLine.ToPoint; Pt2d ptTo2d = getProjectBackwardPoint(ptTo, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara); if (ptTo2d != null) { if (j == pSegmentCollection[i].SegmentCount - 1) //最后一条直线段 { ptSingleImageFeaturePointsForPointShp.Add(ptTo2d); ptSingleImageFeaturePoints.Add(ptTo2d); } } } else if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryCircularArc) //圆弧 { ICircularArc pCircularArc = pCurrentSegment as ICircularArc; double dbCurveLength = pCircularArc.Length; int nCount = 15; double dbOffset = dbCurveLength / nCount; for (int nCurrent = 0; nCurrent <= nCount; nCurrent++) { IPoint ptCurrent = new Point(); pCircularArc.QueryPoint(esriSegmentExtension.esriNoExtension, nCurrent * dbOffset, false, ptCurrent); Pt2d ptCurrentImagePoint = getProjectBackwardPoint(ptCurrent, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara); if (ptCurrentImagePoint != null) { ptSingleImageFeaturePoints.Add(ptCurrentImagePoint); //只保留端点的信息,用于创建点SHP图层 if (nCurrent == 0 || nCurrent == nCount) { ptSingleImageFeaturePointsForPointShp.Add(ptCurrentImagePoint); } } } } else { continue; } } ptImageFeaturePoints.Add(ptSingleImageFeaturePoints); ptImageFeaturePointsForPointShp.Add(ptSingleImageFeaturePointsForPointShp); } #endregion #region 把节点位置信息写入 IDataset dataset = (IDataset)pOutputPolylineFeatureClass; IWorkspace workspace = dataset.Workspace; //Cast for an IWorkspaceEdit IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); ////////////////////////////////////////////////////////////////////////// //整条路线的添加 IFeatureCursor pOutFCursor = null; for (int i = 0; i < ptImageFeaturePoints.Count; i++) { int nPtsCount = ptImageFeaturePoints[i].Count; IFeatureBuffer pFeatureBuffer = pOutputPolylineFeatureClass.CreateFeatureBuffer(); pOutFCursor = pOutputPolylineFeatureClass.Insert(true); IPolyline pPolyline = new PolylineClass(); IPointCollection pPointCollection = pPolyline as IPointCollection; for (int j = 0; j < nPtsCount; j++) { IPoint pt = new PointClass(); pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y); pPointCollection.AddPoint(pt); } if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature)) { continue; } pFeatureBuffer.Shape = pPolyline as IGeometry; object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer); } if (pOutFCursor != null) { pOutFCursor.Flush(); } //分段路线的添加 for (int i = 0; i < ptImageFeaturePoints.Count; i++) { int nPtsCount = ptImageFeaturePoints[i].Count; for (int j = 0; j < nPtsCount - 1; j++) { IFeatureBuffer pFeatureBuffer = pOutputPolylineFeatureClass.CreateFeatureBuffer(); pOutFCursor = pOutputPolylineFeatureClass.Insert(true); IPolyline pPolyline = new PolylineClass(); IPointCollection pPointCollection = pPolyline as IPointCollection; IPoint pt = new PointClass(); pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y); pPointCollection.AddPoint(pt); pt.PutCoords(ptImageFeaturePoints[i][j + 1].X, ptImageFeaturePoints[i][j + 1].Y); pPointCollection.AddPoint(pt); if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature)) { continue; } pFeatureBuffer.Shape = pPolyline as IGeometry; object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer); } } if (pOutFCursor != null) { pOutFCursor.Flush(); } //featureCursor.Flush(); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); #endregion #region 点SHP文件的添加 IDataset pPointDataset = (IDataset)pOutputPointFeatureClass; IWorkspace pPointWorkspace = pPointDataset.Workspace; //Cast for an IWorkspaceEdit IWorkspaceEdit pPointWorkspaceEdit = pPointWorkspace as IWorkspaceEdit; pPointWorkspaceEdit.StartEditing(true); pPointWorkspaceEdit.StartEditOperation(); IFeatureCursor pOutPointFCursor = null; for (int i = 0; i < ptImageFeaturePointsForPointShp.Count; i++) { //int nSegmentCount = pSegmentCollection[i].SegmentCount; //IMultipoint pMultiPoint = new MultipointClass(); for (int j = 0; j < ptImageFeaturePointsForPointShp[i].Count; j++) { IFeatureBuffer pFeatureBuffer = pOutputPointFeatureClass.CreateFeatureBuffer(); pOutPointFCursor = pOutputPointFeatureClass.Insert(true); IPoint pt = new PointClass(); Pt2d pt2d = ptImageFeaturePointsForPointShp[i][j]; pt.PutCoords(pt2d.X, pt2d.Y); //CopyFeatureField(pFeatureList[i], pFeatureBuffer); pFeatureBuffer.Shape = pt as IGeometry; object featureOID = pOutPointFCursor.InsertFeature(pFeatureBuffer); } } if (pOutPointFCursor != null) { pOutPointFCursor.Flush(); } //featureCursor.Flush(); pPointWorkspaceEdit.StopEditOperation(); pPointWorkspaceEdit.StopEditing(true); #endregion return(true); }
private bool MakeData() { try { //_waitForm.Worker.ReportProgress(0, "状态:正在统计,请稍后..."); bool result; _waitForm.Worker.ReportProgress(0, "状态:创建临时表,请稍候..."); _cursor = _layerInfo.FeatureClass.Search(_spatialFilter, false); IFeature feature = this._cursor.NextFeature(); IFields fields = this._cursor.Fields; int num = 0; this.OidField = 0; bool flag = false; bool isNUsing = false; IMAware mAware = feature.Shape as IMAware; isNUsing = mAware.MAware; if (feature.FeatureType == esriFeatureType.esriFTComplexEdge || feature.FeatureType == esriFeatureType.esriFTSimpleEdge) { if (!this.stable.Columns.Contains("GD管线长度")) { this.stable.Columns.Add("GD管线长度", typeof(double)); } flag = true; this.nGeoType = 1; } else if (feature.FeatureType == esriFeatureType.esriFTSimpleJunction || feature.FeatureType == esriFeatureType.esriFTComplexJunction) { this.nGeoType = 0; } else if (feature.FeatureType == esriFeatureType.esriFTSimple) { if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { this.nGeoType = 0; } if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPath || feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { this.nGeoType = 3; } if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { this.nGeoType = 2; } if (feature.Shape.GeometryType == esriGeometryType.esriGeometryNull) { this.nGeoType = -1; } } if (feature.FeatureType == esriFeatureType.esriFTAnnotation) { this.nGeoType = 4; } if (this.nGeoType == -1) { result = false; } else { if (this.nGeoType > 0) { if (!this.Geotable.Columns.Contains("LINECODE")) { this.Geotable.Columns.Add("LINECODE", typeof(string)); } if (!this.Geotable.Columns.Contains("序号")) { this.Geotable.Columns.Add("序号", typeof(int)); } if (!this.Geotable.Columns.Contains("X")) { this.Geotable.Columns.Add("X", typeof(double)); } if (!this.Geotable.Columns.Contains("Y")) { this.Geotable.Columns.Add("Y", typeof(double)); } if (!this.Geotable.Columns.Contains("Z")) { this.Geotable.Columns.Add("Z", typeof(double)); } if (!this.Geotable.Columns.Contains("M")) { this.Geotable.Columns.Add("M", typeof(double)); } } else { if (!this.Geotable.Columns.Contains("PONTCODE")) { this.Geotable.Columns.Add("PONTCODE", typeof(string)); } if (!this.Geotable.Columns.Contains("X")) { this.Geotable.Columns.Add("X", typeof(double)); } if (!this.Geotable.Columns.Contains("Y")) { this.Geotable.Columns.Add("Y", typeof(double)); } if (!this.Geotable.Columns.Contains("Z")) { this.Geotable.Columns.Add("Z", typeof(double)); } } object[] array; object[] array2; if (this.nGeoType > 0) { if (this.nGeoType == 1) { array = new object[fields.FieldCount + 1]; } else { array = new object[fields.FieldCount]; } array2 = new object[6]; } else { array = new object[fields.FieldCount]; array2 = new object[4]; } string text = feature.FeatureType.ToString(); this._selection.Clear(); _waitForm.Worker.ReportProgress(0, "状态:填充表单,请稍候..."); int qdgcIdx = -1; int qdmsIdx = -1; int zdgcIdx = -1; int zdmsIdx = -1; if (_layerInfo.DataType == enumPipelineDataType.Line) { qdgcIdx = feature.Fields.FindField(_layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDGC)); qdmsIdx = feature.Fields.FindField(_layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDMS)); zdgcIdx = feature.Fields.FindField(_layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDGC)); zdmsIdx = feature.Fields.FindField(_layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS)); } int i = 1; while (feature != null) { if (_waitForm.Worker.CancellationPending) { break; } _waitForm.Worker.ReportProgress(i++, "状态:填充表单,请稍候..."); double num2 = 0.0; string text2 = feature.Value[this.OidField].ToString(); if (feature.Shape == null || feature.Shape.IsEmpty) { feature = this._cursor.NextFeature(); } else { int j; for (j = 0; j < fields.FieldCount; j++) { if (j == this.OidField) { array[0] = text2; } if (j == num) { if (num > this.OidField) { array[j] = text; } else { array[j + 1] = text; } if (this.nGeoType == 1 || this.nGeoType == 3) { IPolyline polyline = (IPolyline)feature.Shape; IPointCollection pointCollection = (IPointCollection)polyline; IPoint point = null; IPoint point2 = null; if (isNUsing) { for (int k = 0; k < pointCollection.PointCount - 1; k++) { point = pointCollection.Point[k]; array2[0] = text2; array2[1] = k + 1; array2[2] = point.X; array2[3] = point.Y; if (this.nGeoType == 3) { array2[4] = point.Z; array2[5] = 0; } else { array2[4] = ((float)(point.Z - point.M)).ToString("f3"); array2[5] = point.M.ToString("f3"); } this.Geotable.Rows.Add(array2); point2 = pointCollection.Point[k + 1]; num2 += Math.Sqrt(Math.Pow(point.X - point2.X, 2.0) + Math.Pow(point.Y - point2.Y, 2.0) + Math.Pow(point.Z - point.M - point2.Z + point2.M, 2.0)); } array2[0] = text2; array2[1] = pointCollection.PointCount; array2[2] = point2.X; array2[3] = point2.Y; if (this.nGeoType == 3) { array2[4] = point2.Z; array2[5] = 0; } else { array2[4] = ((float)(point.Z - point.M)).ToString("f3"); array2[5] = point2.M.ToString("f3"); } this.Geotable.Rows.Add(array2); } else { point = pointCollection.Point[0]; point2 = pointCollection.Point[pointCollection.PointCount - 1]; array2[0] = text2; array2[1] = 1; array2[2] = point.X; array2[3] = point.Y; double height; array2[4] = qdgcIdx >= 0 ? GetDoubleValue(feature, qdgcIdx, out height) : 0; array2[5] = qdmsIdx >= 0 ? GetDoubleValue(feature, qdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); array2[0] = text2; array2[1] = 2; array2[2] = point2.X; array2[3] = point2.Y; array2[4] = zdgcIdx >= 0 ? GetDoubleValue(feature, zdgcIdx, out height) : 0; array2[5] = zdmsIdx >= 0 ? GetDoubleValue(feature, zdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); } } else if (this.nGeoType == 0) { IPoint point3 = (IPoint)feature.Shape; array2[0] = text2; array2[1] = point3.X; array2[2] = point3.Y; array2[3] = point3.Z; this.Geotable.Rows.Add(array2); } else if (this.nGeoType == 2 || this.nGeoType == 4) { IPolygon polygon = (IPolygon)feature.Shape; IPointCollection pointCollection2 = (IPointCollection)polygon; IPoint point4 = null; if (isNUsing) { for (int l = 0; l < pointCollection2.PointCount - 1; l++) { IPoint point5 = pointCollection2.Point[l]; array2[0] = text2; array2[1] = l + 1; array2[2] = point5.X; array2[3] = point5.Y; array2[4] = point5.Z; array2[5] = point5.M; this.Geotable.Rows.Add(array2); point4 = pointCollection2.Point[l + 1]; num2 += Math.Sqrt(Math.Pow(point5.X - point4.X, 2.0) + Math.Pow(point5.Y - point4.Y, 2.0) + Math.Pow(point5.Z - point5.M - point4.Z + point4.M, 2.0)); } array2[0] = text2; array2[1] = pointCollection2.PointCount; array2[2] = point4.X; array2[3] = point4.Y; array2[4] = point4.Z; array2[5] = point4.M; this.Geotable.Rows.Add(array2); } else { IPoint point = pointCollection2.Point[0]; IPoint point2 = pointCollection2.Point[pointCollection2.PointCount - 1]; array2[0] = text2; array2[1] = 1; array2[2] = point.X; array2[3] = point.Y; double height; array2[4] = qdgcIdx >= 0 ? GetDoubleValue(feature, qdgcIdx, out height) : 0; array2[5] = qdmsIdx >= 0 ? GetDoubleValue(feature, qdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); array2[0] = text2; array2[1] = 2; array2[2] = point2.X; array2[3] = point2.Y; array2[4] = zdgcIdx >= 0 ? GetDoubleValue(feature, zdgcIdx, out height) : 0; array2[5] = zdmsIdx >= 0 ? GetDoubleValue(feature, zdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); } } } else { IField field2 = feature.Fields.Field[j]; object obj = feature.Value[j]; if (j < this.OidField) { if (field2.Type == esriFieldType.esriFieldTypeDouble || field2.Type == esriFieldType.esriFieldTypeSingle) { if (obj != DBNull.Value) { array[j + 1] = Math.Round(Convert.ToDouble(obj), 3); } else { array[j + 1] = obj; } } else if (field2.Type == esriFieldType.esriFieldTypeDate) { if (obj != DBNull.Value) { DateTime dateTime = Convert.ToDateTime(obj); array[j + 1] = dateTime.ToShortDateString(); } else { array[j + 1] = ""; } } else { array[j + 1] = obj; } } else if (field2.Type == esriFieldType.esriFieldTypeDouble || field2.Type == esriFieldType.esriFieldTypeSingle) { if (obj != DBNull.Value) { array[j] = Math.Round(Convert.ToDouble(obj), 3); } else { array[j] = obj; } } else if (field2.Type == esriFieldType.esriFieldTypeDate) { if (obj != DBNull.Value) { array[j] = Convert.ToDateTime(obj).ToShortDateString(); } else { array[j] = ""; } } else { array[j] = obj; } } } if (flag) { array[j] = num2.ToString(CultureInfo.InvariantCulture); } this.stable.Rows.Add(array); this._selection.Add(feature); feature = this._cursor.NextFeature(); } } this._selection.SelectionSet.Refresh(); IActiveView activeView = _context.ActiveView; activeView.Refresh(); result = true; } return(result); } catch (Exception exception) { return(false); } }
private void AddCutBackBoundariesConnectLines( IGeometry geometryToReshape, StickyIntersectionConnectLineCalculator connectLineCalculator, IPolyline splitReshapeLine, Dictionary <AdjustedCutSubcurve, IGeometry> toResult) { IPath usablePathOnTarget = null; foreach (IPath pathOnTarget in GeometryUtils.GetPaths(splitReshapeLine)) { if (HasLengthZero(pathOnTarget)) { // duplicate split points result in 0-length parts continue; } TryAddCutBackBoundaryConnectLine(geometryToReshape, pathOnTarget, connectLineCalculator, true, toResult); TryAddCutBackBoundaryConnectLine(geometryToReshape, pathOnTarget, connectLineCalculator, false, toResult); if (usablePathOnTarget == null) { usablePathOnTarget = GeometryFactory.Clone(pathOnTarget); } else { // usablePathOnTarget != null: // the last path on target did not properly connect back to source - add this part plus its end connect line ((ISegmentCollection)usablePathOnTarget).AddSegmentCollection( (ISegmentCollection)pathOnTarget); TryAddCutBackBoundaryConnectLine(geometryToReshape, usablePathOnTarget, connectLineCalculator, true, toResult); TryAddCutBackBoundaryConnectLine(geometryToReshape, usablePathOnTarget, connectLineCalculator, false, toResult); } // always calculate both ends, because it depends on the other end's position on the unreshaped from/to point! //IPath connectLineAtEnd; //connectLineCalculator.FindConnection(polylineToReshape, // usablePathOnTarget, false, // out connectLineAtEnd); IPoint sourcePoint; if (!connectLineCalculator.IsTargetIntersectionPoint(usablePathOnTarget.ToPoint, out sourcePoint)) { // try adding the next part of the sketch to the usable part continue; } //if (connectLineAtStart != null && HasLengthZero(connectLineAtStart) && // HasLengthZero(connectLineAtEnd)) //{ // //consolidatedPathsOnTarget.Add(usablePathOnTarget); // // already reshaped normally, could result in invalid reshape line error! // usablePathOnTarget = null; // continue; //} //if (connectLineAtEnd != null) //{ // AddReshapeConnect(connectLineAtEnd, usablePathOnTarget, toResult, // geometryToReshape); //} usablePathOnTarget = null; } }
public bool projectBackward(string szInputShpFilename, IRasterLayer pDemLayer, string szXmlFilename, string szOutShpFilename) { if (string.IsNullOrEmpty(szInputShpFilename) || pDemLayer == null || string.IsNullOrEmpty(szXmlFilename) || string.IsNullOrEmpty(szOutShpFilename)) { return(false); } ClsGDBDataCommon processDataCommon = new ClsGDBDataCommon(); string strInputPath = System.IO.Path.GetDirectoryName(szInputShpFilename); string strInputName = System.IO.Path.GetFileName(szInputShpFilename); #region 读取SHP文件 IWorkspace pWorkspace = processDataCommon.OpenFromShapefile(strInputPath); IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace; IFeatureClass pInputFC = pFeatureWorkspace.OpenFeatureClass(strInputName); #endregion #region 读取DEM文件 IRasterLayer pRasterLayer = pDemLayer;// new RasterLayerClass(); //pRasterLayer.CreateFromFilePath(szDemFilename); IRaster pDemRaster = pRasterLayer.Raster; IRasterProps pDemRasterProps = pDemRaster as IRasterProps; #endregion #region 得到曲线信息 List <ISegmentCollection> pSegmentCollection = new List <ISegmentCollection>(); List <IFeature> pFeatureList = new List <IFeature>(); IFeatureCursor pFCursor = pInputFC.Search(null, false); IFeature pFeature = null;// pFCursor.NextFeature(); while ((pFeature = pFCursor.NextFeature()) != null) { IPolyline pPolyline = pFeature.Shape as IPolyline; if (pPolyline == null) { //pFeature = pFCursor.NextFeature(); continue; } IFeature pTmpFeature = pFeature; pFeatureList.Add(pTmpFeature); ISegmentCollection pCurrentSegmentCollection = pPolyline as ISegmentCollection; pSegmentCollection.Add(pCurrentSegmentCollection); } #endregion #region 读取相机姿态参数 ClsCameraPara cameraPara = ParseXmlFileToGetPara(szXmlFilename); if (cameraPara == null) { return(false); } //根据姿态参数获得旋转矩阵 OriAngle oriAngle = new OriAngle(); Matrix pRotateMatrix = new Matrix(3, 3); oriAngle.kap = cameraPara.dKappa; oriAngle.omg = cameraPara.dOmg; oriAngle.phi = cameraPara.dPhi; if (!ClsGetCameraView.OPK2RMat(oriAngle, ref pRotateMatrix)) { return(false); } #endregion #region 创建输出SHP文件 string strOutputPath = System.IO.Path.GetDirectoryName(szOutShpFilename); string strOutputName = System.IO.Path.GetFileName(szOutShpFilename); string strPointOutputName = System.IO.Path.GetFileNameWithoutExtension(szOutShpFilename) + "_point" + System.IO.Path.GetExtension(szOutShpFilename); //设置空间参考 ISpatialReference pSpatialRef = new UnknownCoordinateSystemClass(); //没有这一句就报错,说尝试读取或写入受保护的内存。 pSpatialRef.SetDomain(MIN_INT, MAX_INT, MIN_INT, MAX_INT); //没有这句就抛异常来自HRESULT:0x8004120E。 pSpatialRef.SetZDomain(MIN_INT, MAX_INT); //创建POLYLINE文件的字段 IFields pFields = pInputFC.Fields; //创建点SHP文件的字段 IFields pPointFields = new FieldsClass(); IFieldsEdit pFieldsEdit = (IFieldsEdit)pPointFields; //设置字段 IField pField = new FieldClass(); IFieldEdit pFieldEdit = (IFieldEdit)pField; //创建类型为几何类型的字段 pFieldEdit.Name_2 = "shape"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry; IGeometryDef pGeoDef = new GeometryDefClass(); IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef; pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; pGeoDefEdit.HasM_2 = false; pGeoDefEdit.HasZ_2 = false; pGeoDefEdit.SpatialReference_2 = pSpatialRef; //pFieldEdit.Name_2 = "SHAPE"; //pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry; pFieldEdit.GeometryDef_2 = pGeoDef; pFieldEdit.IsNullable_2 = true; pFieldEdit.Required_2 = true; pFieldsEdit.AddField(pField); IFeatureClass pOutputFC = processDataCommon.CreateShapefile(strOutputPath, strOutputName, pFields, pSpatialRef); IFeatureClass pOutputPointFC = processDataCommon.CreateShapefile(strOutputPath, strPointOutputName, pPointFields, pSpatialRef); if (pOutputFC == null || pOutputPointFC == null) { return(false); } #endregion #region 节点位置反投影 List <List <Pt2d> > ptImageFeaturePoints = new List <List <Pt2d> >(); List <List <Pt2d> > ptImageFeaturePointsForPointShp = new List <List <Pt2d> >(); ClsGetCameraView pGetCameraView = new ClsGetCameraView(); for (int i = 0; i < pSegmentCollection.Count; i++) { List <Pt2d> ptSingleImageFeaturePoints = new List <Pt2d>(); List <Pt2d> ptSingleImageFeaturePointsForPointShp = new List <Pt2d>(); for (int j = 0; j < pSegmentCollection[i].SegmentCount; j++) { ISegment pCurrentSegment = pSegmentCollection[i].get_Segment(j); if (pCurrentSegment == null) { continue; } //直线 if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryLine) { ILine pLine = pCurrentSegment as ILine; //起始点 IPoint ptFrom = pLine.FromPoint; Pt2d ptFrom2d = getProjectBackwardPoint(ptFrom, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara); if (ptFrom2d != null) { ptSingleImageFeaturePoints.Add(ptFrom2d); ptSingleImageFeaturePointsForPointShp.Add(ptFrom2d); } //终止点 IPoint ptTo = pLine.ToPoint; Pt2d ptTo2d = getProjectBackwardPoint(ptTo, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara); if (ptTo2d != null) { ptSingleImageFeaturePoints.Add(ptTo2d); if (j == pSegmentCollection[i].SegmentCount - 1) //最后一条直线段 { ptSingleImageFeaturePointsForPointShp.Add(ptTo2d); } } } else if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryCircularArc) //圆弧 { ICircularArc pCircularArc = pCurrentSegment as ICircularArc; double dbCurveLength = pCircularArc.Length; int nCount = 15; double dbOffset = dbCurveLength / nCount; for (int nCurrent = 0; nCurrent < nCount; nCurrent++) { IPoint ptCurrent = new Point(); pCircularArc.QueryPoint(esriSegmentExtension.esriNoExtension, nCurrent * dbOffset, false, ptCurrent); Pt2d ptCurrentImagePoint = getProjectBackwardPoint(ptCurrent, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara); if (ptCurrentImagePoint != null) { ptSingleImageFeaturePoints.Add(ptCurrentImagePoint); //只保留端点的信息,用于创建点SHP图层 if (nCurrent == 0 || nCurrent == nCount - 1) { ptSingleImageFeaturePointsForPointShp.Add(ptCurrentImagePoint); } } } } else { continue; } } ptImageFeaturePoints.Add(ptSingleImageFeaturePoints); ptImageFeaturePointsForPointShp.Add(ptSingleImageFeaturePointsForPointShp); } #endregion #region 写入POLYLINE节点信息 IDataset dataset = (IDataset)pOutputFC; IWorkspace workspace = dataset.Workspace; //Cast for an IWorkspaceEdit IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); ////////////////////////////////////////////////////////////////////////// //整条路线的添加 IFeatureCursor pOutFCursor = null; for (int i = 0; i < ptImageFeaturePoints.Count; i++) { int nPtsCount = ptImageFeaturePoints[i].Count; IFeatureBuffer pFeatureBuffer = pOutputFC.CreateFeatureBuffer(); pOutFCursor = pOutputFC.Insert(true); IPolyline pPolyline = new PolylineClass(); IPointCollection pPointCollection = pPolyline as IPointCollection; for (int j = 0; j < nPtsCount; j++) { IPoint pt = new PointClass(); pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y); pPointCollection.AddPoint(pt); } if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature)) { continue; } pFeatureBuffer.Shape = pPolyline as IGeometry; object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer); } pOutFCursor.Flush(); //分段路线的添加 for (int i = 0; i < ptImageFeaturePoints.Count; i++) { int nPtsCount = ptImageFeaturePoints[i].Count; for (int j = 0; j < nPtsCount - 1; j++) { IFeatureBuffer pFeatureBuffer = pOutputFC.CreateFeatureBuffer(); pOutFCursor = pOutputFC.Insert(true); IPolyline pPolyline = new PolylineClass(); IPointCollection pPointCollection = pPolyline as IPointCollection; IPoint pt = new PointClass(); pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y); pPointCollection.AddPoint(pt); pt.PutCoords(ptImageFeaturePoints[i][j + 1].X, ptImageFeaturePoints[i][j + 1].Y); pPointCollection.AddPoint(pt); if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature)) { continue; } pFeatureBuffer.Shape = pPolyline as IGeometry; object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer); } } pOutFCursor.Flush(); //featureCursor.Flush(); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); #endregion #region 点SHP文件的添加 IDataset pPointDataset = (IDataset)pOutputPointFC; IWorkspace pPointWorkspace = pPointDataset.Workspace; //Cast for an IWorkspaceEdit IWorkspaceEdit pPointWorkspaceEdit = pPointWorkspace as IWorkspaceEdit; pPointWorkspaceEdit.StartEditing(true); pPointWorkspaceEdit.StartEditOperation(); IFeatureCursor pOutPointFCursor = null; for (int i = 0; i < ptImageFeaturePointsForPointShp.Count; i++) { //int nSegmentCount = pSegmentCollection[i].SegmentCount; //IMultipoint pMultiPoint = new MultipointClass(); for (int j = 0; j < ptImageFeaturePointsForPointShp[i].Count; j++) { IFeatureBuffer pFeatureBuffer = pOutputPointFC.CreateFeatureBuffer(); pOutPointFCursor = pOutputPointFC.Insert(true); IPoint pt = new PointClass(); Pt2d pt2d = ptImageFeaturePointsForPointShp[i][j]; pt.PutCoords(pt2d.X, pt2d.Y); //CopyFeatureField(pFeatureList[i], pFeatureBuffer); pFeatureBuffer.Shape = pt as IGeometry; object featureOID = pOutPointFCursor.InsertFeature(pFeatureBuffer); } } pOutPointFCursor.Flush(); //featureCursor.Flush(); pPointWorkspaceEdit.StopEditOperation(); pPointWorkspaceEdit.StopEditing(true); #endregion return(true); }
ReshapeGeometries( [NotNull] IPath reshapePath, [CanBeNull] NotificationCollection notifications) { IList <IGeometry> geometriesToReshape = _reshapeGeometryCloneByOriginal.Values.ToList(); // TODO: out/ref parameter with non-reshapable geometries/notifications dictionary Assert.ArgumentCondition(geometriesToReshape.Count > 0, "No geometries to reshape provided."); IDictionary <IGeometry, NotificationCollection> reshapedGeometries = new Dictionary <IGeometry, NotificationCollection>(); // General idea: // - Additionally to normal reshapes the intersection points of the sources // are connected to the defined target intersections (the pairing is by distance) // and thus additional reshapes are made possible, even if the source polygon // is only cut once or never. Moreover, when a boundary is shortened (cut back) // by the original (individual) reshape, the intersection point is moved to the target // intersection point (similar to multi-reshape for lines when a joining road is cut back) // The cut-back logic is further enhanced for cases at the outer boundary of the // selected polygons to allow 'cutting back' even if no regular reshape happened, // because the first target intersection is inside the polygon. var highLevelReshapePath = (IPolyline)GeometryUtils.GetHighLevelGeometry(reshapePath); IPointCollection sketchOriginalIntersectionPoints = Assert.NotNull( GetSketchIntersectionPointsWithOriginalGeometries(geometriesToReshape, highLevelReshapePath)); IList <KeyValuePair <IPoint, IPoint> > sourceTargetPairs = AddAutomaticSourceTargetPairs ? _stickyIntersections.AddAutomaticSourceTargetPairs(reshapePath, geometriesToReshape, sketchOriginalIntersectionPoints) : _stickyIntersections.SourceTargetPairs; var connectLinesAtCutOffs = new Dictionary <AdjustedCutSubcurve, IGeometry>(); foreach ( KeyValuePair <IGeometry, IGeometry> keyValuePair in _reshapeGeometryCloneByOriginal ) { // Add the source-target connection to the reshape path for each feature that intersects a source point // and the target point is on an open jaw (dangling) part of the sketch, i.e does not re-connect // back to the source. For each usable piece of the split reshape path, create an AdjustCurve. // Work-around: re-snap after each feature - ITopologicalOperator.Intersect seems to change the // topo-op geometry in a way that makes Disjoint() lie except it's snapped to the spatial ref highLevelReshapePath.SnapToSpatialReference(); IGeometry originalGeometry = keyValuePair.Key; IGeometry geometryToReshape = keyValuePair.Value; List <KeyValuePair <IPoint, IPoint> > intersectingSourceTargetPoints = sourceTargetPairs.Where( sourceTargetPair => CanUseSourceTargetPair( sourceTargetPair, highLevelReshapePath, originalGeometry)).ToList(); // Get the reshape line split at all source intersection points and on all intersections with any original geometry IPolyline splitReshapeLine = GetSplitReshapePath(reshapePath, intersectingSourceTargetPoints, sketchOriginalIntersectionPoints); // 1. Calculate the subcurves that reshape in a way that connects the source and the target intersection point // (open-jaw style) StickyIntersectionConnectLineCalculator connectLineCalculator; IEnumerable <AdjustedCutSubcurve> adjustCurves = CalculateSourceTargetPointAdjustSubcurves( geometryToReshape, highLevelReshapePath, splitReshapeLine, intersectingSourceTargetPoints, out connectLineCalculator); // Apply the adjust curves foreach (AdjustedCutSubcurve adjustedCutSubcurve in adjustCurves) { bool reshaped = ApplyReshapePath(geometryToReshape, adjustedCutSubcurve, notifications, reshapedGeometries); if (reshaped) { foreach (IPoint point in adjustedCutSubcurve.GetPotentialTargetInsertPoints()) { AddUsedTargetIntersection(point, sourceTargetPairs); } } } // Add potential connect lines to target points at cut-backs AddCutBackBoundariesConnectLines(geometryToReshape, connectLineCalculator, splitReshapeLine, connectLinesAtCutOffs); connectLineCalculator.Dispose(); } // apply the relevant connect lines at the outer boundary (2-Ländereck) (no shared boundary cut back) ApplySharedBoundaryOuterEndReshape(connectLinesAtCutOffs, reshapedGeometries, notifications); // apply the relevant connect lines at shared boundary cut-backs ApplySharedBoundaryCutBackConnectAtTriangleIntersections( connectLinesAtCutOffs, sourceTargetPairs, reshapedGeometries, notifications); RemoveStitchPoints(geometriesToReshape); return(reshapedGeometries); }
private IEnumerable <AdjustedCutSubcurve> CalculateSourceTargetPointAdjustSubcurves( IGeometry geometryToReshape, IPolyline highLevelReshapePath, IPolyline splitHighLevelReshapePath, List <KeyValuePair <IPoint, IPoint> > intersectingSourceTargetPoints, out StickyIntersectionConnectLineCalculator connectLineCalculator) { var polyToReshapeBoundary = (IPolyline)GeometryUtils.GetBoundary(geometryToReshape); connectLineCalculator = CreateStickyIntersectionsConnectLineCalculator(polyToReshapeBoundary, highLevelReshapePath, intersectingSourceTargetPoints); IPath usablePathOnTarget = null; IPath startConnectLine = null; var adjustCurves = new List <AdjustedCutSubcurve>(); foreach (IPath pathOnTarget in GeometryUtils.GetPaths(splitHighLevelReshapePath)) { if (HasLengthZero(pathOnTarget)) { // duplicate split points result in 0-length parts continue; } if (usablePathOnTarget == null) { startConnectLine = connectLineCalculator.FindConnection(polyToReshapeBoundary, pathOnTarget, true); } IPath endConnectLine = connectLineCalculator.FindConnection(polyToReshapeBoundary, pathOnTarget, false); if (usablePathOnTarget != null) { // the last path on target did not properly connect back to source - add this part plus its end connect line // and add a stitch point between the paths on the target IPoint potentialStitchpoint = usablePathOnTarget.ToPoint; AddPotentialStitchPoint(highLevelReshapePath, potentialStitchpoint); ((ISegmentCollection)usablePathOnTarget).AddSegmentCollection( (ISegmentCollection)pathOnTarget); } else { usablePathOnTarget = GeometryFactory.Clone(pathOnTarget); } if (startConnectLine == null) { // completely useless usablePathOnTarget = null; continue; } if (endConnectLine == null) { // try adding the next part of the sketch to the usable part continue; } if (HasLengthZero(startConnectLine) && HasLengthZero(endConnectLine)) { // already reshaped normally, could result in invalid reshape line error! usablePathOnTarget = null; continue; } if (HasLengthZero(startConnectLine)) { AddPotentialStitchPoint(highLevelReshapePath, usablePathOnTarget.FromPoint); } if (HasLengthZero(endConnectLine)) { AddPotentialStitchPoint(highLevelReshapePath, usablePathOnTarget.ToPoint); } // Theoretically consecutive adjustCurves could be merged to reduce the amount of reshapes // but this results in more frequent cases of reshapes to the wrong side. adjustCurves.Add( new AdjustedCutSubcurve(usablePathOnTarget, startConnectLine, endConnectLine)); usablePathOnTarget = null; } Marshal.ReleaseComObject(polyToReshapeBoundary); return(adjustCurves); }
public void ConstructPointParallelToLine(IPolyline Path) { IWorkspaceEdit WorkspaceEdit = null; try { if (Path != null) { if (Path.GeometryType == esriGeometryType.esriGeometryPolyline) { firstLine = false; widthPointsMain = new List <IPoint>(); heigthPoints = new List <IPoint>(); widthPoints = new List <IPoint>(); IFeatureClass rectsFeatureClass = ((IFeatureLayer)lstLayers[cboLayers.SelectedIndex]).FeatureClass; IWorkspace workspace = ((IDataset)rectsFeatureClass).Workspace; WorkspaceEdit = (IWorkspaceEdit)workspace; if (!WorkspaceEdit.IsBeingEdited()) { WorkspaceEdit.StartEditing(true); } WorkspaceEdit.StartEditOperation(); IConstructPoint constructionPoint = (IConstructPoint) new ESRI.ArcGIS.Geometry.Point(); IGeometryCollection geometryCollection = Path as IGeometryCollection; ISegmentCollection segmentCollection = geometryCollection.get_Geometry(0) as ISegmentCollection; widthSegment = segmentCollection.get_Segment(0); heightSegment = segmentCollection.get_Segment(1); IPoint fromPoint = new ESRI.ArcGIS.Geometry.Point(); heightSegment.QueryFromPoint(fromPoint); widthPointsMain.Add(fromPoint); IRgbColor rgbColor = GetColor(255, 0, 0); //AddGraphicToMap((IMap)GetActiveView, fromPoint, rgbColor, rgbColor); //GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); widthSegment.ReverseOrientation(); double distanceAlongWidthBunderiesPoints = 0; double distanceAlongHeightBunderiesPoints = 0; for (int i = 0; i < NumberOfRectsinWidth; i++) { IPoint qpWidthSegment = GetQPWidthSegment(distanceAlongWidthBunderiesPoints + Widthofrects); if (qpWidthSegment == null) { return; } widthPointsMain.Add(qpWidthSegment); //AddGraphicToMap((IMap)GetActiveView, qpWidthSegment, rgbColor, rgbColor); if (i != NumberOfRectsinWidth - 1) { IPoint qpWidthSegmentWithDistance = GetQPWidthSegment(distanceAlongWidthBunderiesPoints + Widthofrects + distanceAlongWidth); //AddGraphicToMap((IMap)GetActiveView, qpWidthSegmentWithDistance, rgbColor, rgbColor); widthPointsMain.Add(qpWidthSegmentWithDistance); } distanceAlongWidthBunderiesPoints = (Widthofrects + distanceAlongWidth) * (i + 1); } for (int i = 0; i < NumberOfRectsinHeigth; i++) { IPoint qpHeightSegment = GetQPHeightSegment(distanceAlongHeightBunderiesPoints + Heigthofrects); if (qpHeightSegment == null) { return; } heigthPoints.Add(qpHeightSegment); //AddGraphicToMap((IMap)GetActiveView, qpHeightSegment, rgbColor, rgbColor); if (i != NumberOfRectsinHeigth - 1) { IPoint qpHeightSegmentWithDistance = GetQPHeightSegment(distanceAlongHeightBunderiesPoints + Heigthofrects + distanceAlongHeigth); //AddGraphicToMap((IMap)GetActiveView, qpHeightSegmentWithDistance, rgbColor, rgbColor); heigthPoints.Add(qpHeightSegmentWithDistance); } distanceAlongHeightBunderiesPoints = (Heigthofrects + distanceAlongHeigth) * (i + 1); } for (int j = 0; j < heigthPoints.Count; j++) { constructionPoint.ConstructParallel(widthSegment, esriSegmentExtension.esriExtendAtTo, heigthPoints[j], Widthofrects); IPoint outPutPoint = constructionPoint as IPoint; IPath newPath = (IPath) new ESRI.ArcGIS.Geometry.Path(); newPath.FromPoint = heigthPoints[j]; newPath.ToPoint = outPutPoint; if (!firstLine) { widthPoints.Add(heigthPoints[j]); } else { widthPointsMain.Add(heigthPoints[j]); } distanceAlongWidthBunderiesPoints = 0; for (int i = 0; i < NumberOfRectsinWidth; i++) { IPoint qpWidthSegment = GetQPWidthNewSegment(newPath, distanceAlongWidthBunderiesPoints + Widthofrects); if (qpWidthSegment == null) { return; } if (!firstLine) { widthPoints.Add(qpWidthSegment); } else { widthPointsMain.Add(qpWidthSegment); } //AddGraphicToMap((IMap)GetActiveView, qpWidthSegment, rgbColor, rgbColor); if (i != NumberOfRectsinWidth - 1) { IPoint qpWidthSegmentWithDistance = GetQPWidthNewSegment(newPath, distanceAlongWidthBunderiesPoints + Widthofrects + distanceAlongWidth); //AddGraphicToMap((IMap)GetActiveView, qpWidthSegmentWithDistance, rgbColor, rgbColor); if (!firstLine) { widthPoints.Add(qpWidthSegmentWithDistance); } else { widthPointsMain.Add(qpWidthSegmentWithDistance); } } //widthPoints.Add(qpWidthSegment); //widthPoints.Add(qpWidthSegmentWithDistance); distanceAlongWidthBunderiesPoints = (Widthofrects + distanceAlongWidth) * (i + 1); } //IRgbColor rgbColor1 = GetColor(0, 255, 0); if (widthPoints.Count > 0 && widthPointsMain.Count > 0) { //IFeatureClass rectsFeatureClass = getFeatureClass.GetFeatureClassFromShapefileOnDisk(shapefileLocation, out workspace); if (rectsFeatureClass == null) { return; } createRects.FeatureClass = rectsFeatureClass; createRects.SpatialReference = ((IGeoDataset)rectsFeatureClass).SpatialReference; createRects.WidthPoints = widthPoints; createRects.WidthPointsMain = widthPointsMain; createRects.CreateFeatures(); widthPoints.Clear(); widthPointsMain.Clear(); //if(!ShapefileIsAdded()) AddShapefile(GetActiveView, shapefileLocation); } firstLine = !firstLine; //AddGraphicToMap((IMap)GetActiveView, outPutPoint, rgbColor1, rgbColor1); } labelStatus.Text = "It's done."; WorkspaceEdit.StopEditOperation(); WorkspaceEdit.StopEditing(true); GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } } } catch (Exception ex) { Path = null; graphicsContainer.DeleteAllElements(); labelStatus.Text = ex.Message; if (WorkspaceEdit != null) { if (WorkspaceEdit.IsBeingEdited()) { WorkspaceEdit.AbortEditOperation(); WorkspaceEdit.StopEditing(false); } } GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
public static ISegment MakeOneHatch(IPolyline pSubPL, double dist, double m, double numhatch, double dTxtInterval, double dHatchLen, double dHatchOffset) { ILine pL = new LineClass(); int result; ISegmentM pSegM; Math.DivRem((int)numhatch, (int)dTxtInterval, out result); if (!(result == 0)) { if (dHatchOffset == 0) pSubPL.QueryNormal(esriSegmentExtension.esriNoExtension, dist, false, (dHatchLen * 0.5), pL); else if (dHatchOffset > 0) pSubPL.QueryNormal(esriSegmentExtension.esriNoExtension, dist, false, (dHatchLen * 0.5) + dHatchOffset, pL); else if (dHatchOffset < 0) { pSubPL.ReverseOrientation(); pSubPL.QueryNormal(esriSegmentExtension.esriNoExtension, pSubPL.Length - dist, false, dHatchLen + Math.Abs(dHatchOffset), pL); pSubPL.ReverseOrientation(); } } ICurve pCurve; if (dHatchOffset != 0) { pL.GetSubcurve(Math.Abs(dHatchOffset), pL.Length, false, out pCurve); pSegM = pCurve as ISegmentM; } else pSegM = pL as ISegmentM; pSegM.SetMs(m, m); return pSegM as ISegment; }
public List <Result> DepotToDest(IFeatureLayer DepotLayer, IFeatureLayer DestLayer, string pFeatureFID) { InitializationRoadNetwork(DepotLayer, DestLayer, pFeatureFID); IPolyline[] depotlines = new IPolyline[2]; IPolyline[] destlines = new IPolyline[2]; double[] depottime = new double[2]; double[] desttime = new double[2]; string[] DestPointID = new string[DestPoint.PointCount]; for (int j = 0; j < DestPoint.PointCount; j++) { string[] StartdestPoint = new string[DestPoint.PointCount]; string[] EnddestPoint = new string[DestPoint.PointCount]; IFeature pDestpointFeature; IPoint destPoint = DestPoint.get_Point(j); pDestpointFeature = GetNearestFeature(destPoint); StartdestPoint[j] = Convert.ToString(pDestpointFeature.get_Value(pDestpointFeature.Fields.FindField("StartNodeI"))); EnddestPoint[j] = Convert.ToString(pDestpointFeature.get_Value(pDestpointFeature.Fields.FindField("EndNodeID"))); double time = Convert.ToDouble(pDestpointFeature.get_Value(pDestpointFeature.Fields.FindField("Minutes"))); string SpaceFeatureName = Convert.ToString(pDestpointFeature.get_Value(pDestpointFeature.Fields.FindField("Name"))); DestPointID[j] = (NodeList.Count + 1).ToString(); destlines = GetSubLine(destPoint, pDestpointFeature); desttime[0] = time * (destlines[0].Length / (destlines[0].Length + destlines[1].Length)); desttime[1] = time - desttime[0]; //移除应急处置空间位置点最近的路径要素 for (int i = 0; i < 2; i++) { if (i == 0) { Edge pedge = new Edge(); pedge.StartNodeID = StartdestPoint[j]; pedge.EndNodeID = EnddestPoint[j]; pedge.Weight = time; pedge.line = pDestpointFeature.Shape as IPolyline; pedge.name = SpaceFeatureName; NodeList[Convert.ToInt32(StartdestPoint[j]) - 1].EdgeList.Remove(pedge); } if (i == 1) { Edge pedge = new Edge(); pedge.StartNodeID = EnddestPoint[j]; pedge.EndNodeID = StartdestPoint[j]; pedge.Weight = time; pedge.line = pDestpointFeature.Shape as IPolyline; pedge.name = SpaceFeatureName; NodeList[Convert.ToInt32(EnddestPoint[j]) - 1].EdgeList.Remove(pedge); } } Node addNode = new Node((NodeList.Count + 1).ToString()); NodeList.Add(addNode); //添加应急处置空间位置点最近的路径要素从起点到最近点的路径要素 for (int k = 0; k < 2; k++) { if (k == 0) { Edge pedge = new Edge(); pedge.StartNodeID = StartdestPoint[j]; pedge.EndNodeID = NodeList.Count.ToString(); pedge.Weight = desttime[0]; pedge.line = destlines[0]; pedge.name = SpaceFeatureName; NodeList[Convert.ToInt32(StartdestPoint[j]) - 1].EdgeList.Add(pedge); } if (k == 1) { Edge pedge = new Edge(); pedge.StartNodeID = NodeList.Count.ToString(); pedge.EndNodeID = StartdestPoint[j]; pedge.Weight = desttime[0]; pedge.line = destlines[0]; pedge.name = SpaceFeatureName; NodeList[NodeList.Count - 1].EdgeList.Add(pedge); } } //添加应急处置空间位置点最近的路径要素从终点到最近点的路径要素 for (int k = 0; k < 2; k++) { if (k == 0) { Edge pedge = new Edge(); pedge.StartNodeID = EnddestPoint[j]; pedge.EndNodeID = NodeList.Count.ToString(); pedge.Weight = desttime[1]; pedge.line = destlines[1]; pedge.name = SpaceFeatureName; NodeList[Convert.ToInt32(EnddestPoint[j]) - 1].EdgeList.Add(pedge); } if (k == 1) { Edge pedge = new Edge(); pedge.StartNodeID = NodeList.Count.ToString(); pedge.EndNodeID = EnddestPoint[j]; pedge.Weight = desttime[1]; pedge.line = destlines[1]; pedge.name = SpaceFeatureName; NodeList[NodeList.Count - 1].EdgeList.Add(pedge); } } } //应急资源仓库最近路段的管理 for (int i = 0; i < DepotPoint.PointCount; i++) { FindPath(DepotNodeID[i].ToString(), DepotName[i], DestPointID); } return(ResultList); }
public static void drawPolyline(IActiveView pActiveView, IPolyline pGeom) { try { IGraphicsContainer iGC = pActiveView as IGraphicsContainer; ILineSymbol ipLineSymbol = new CartographicLineSymbolClass(); ipLineSymbol.Width = 5; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pRgbColor.Green = 0; pRgbColor.Blue = 0; ipLineSymbol.Color = pRgbColor as IColor; IElement pEle; ILineElement pLE; if (pGeom != null) { pEle = new LineElementClass() as IElement; pLE = pEle as ILineElement; pLE.Symbol = ipLineSymbol; pEle.Geometry = pGeom; iGC.AddElement(pEle, 0); } pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, pActiveView.Extent); } catch (Exception e) { MessageBox.Show(e.Message); } }
public void Run(IFeatureClass inp, IFeatureClass outp, ProgressCallback progress) { IFeatureCursor all_inp = inp.Search(null, true); LineSegOverlay <ArcSegInf> op = new LineSegOverlay <ArcSegInf>(new PMQTree(4, 8), m_atol, m_dtol); double inp_count = inp.FeatureCount(null); int steps = (int)Math.Ceiling((double)inp_count / 20.0); int inp_progress = 0; IFeature infeat = all_inp.NextFeature(); while (infeat != null) { int fid = infeat.OID; IGeometryCollection c = infeat.Shape as IGeometryCollection; for (int shell_num = 0; shell_num < c.GeometryCount; shell_num++) { IPointCollection ps = c.get_Geometry(shell_num) as IPointCollection; IPoint last = null; for (int seg_num = 0; seg_num < ps.PointCount; seg_num++) { IPoint cur = ps.get_Point(seg_num); if (last != null) { LineSeg seg = LineSeg.FromEndpoints(new Vector(last.X, last.Y), new Vector(cur.X, cur.Y)); op.Insert(new ArcSegInf(seg, fid, shell_num, seg_num)); m_seensegs++; } last = cur; } } inp_progress++; if (inp_progress % steps == 0) { progress(0.5 * (inp_progress / inp_count)); } infeat = all_inp.NextFeature(); } int lfid = outp.FindField("left_fid"); int rfid = outp.FindField("right_fid"); // Reassemble line strings SegmentAssembler sa = new SegmentAssembler(); foreach (Pair <LineSeg, IEnumerable <ArcSegInf> > r in op.Segments) { int overlap_count = 0; foreach (Pair <ArcSegInf, ArcSegInf> v in Pair <ArcSegInf, ArcSegInf> .Pairs(r.Second)) { OverlapSegment o = new OverlapSegment(r.First, v.First, v.Second); if (v.First.SrcFid < v.Second.SrcFid) { sa.AddSegment(o); } overlap_count++; } if (overlap_count == 0) { // TODO: add exterior boundaries? ArcSegInf seen = null; foreach (ArcSegInf seg in r.Second) { seen = seg; } sa.AddSegment(new OverlapSegment(r.First, seen, null)); } } double outp_count = sa.OverlapCount; int outp_progress = 0; int outp_steps = (int)Math.Ceiling((double)outp_count / 20.0); IFeatureBuffer outfeat = outp.CreateFeatureBuffer(); IFeatureCursor outcursor = outp.Insert(true); foreach (Pair <Pair <int, int>, Pair <int, int> > ss in sa.SegsAndShells) { int rhs_fid = ss.First.First; int rhs_shellid = ss.First.Second; int lhs_fid = ss.Second.First; int lhs_shellid = ss.Second.Second; foreach (Pair <Pair <int, int>, List <LineSeg> > linestring in sa.GetStrings(ss)) { IPolyline line = assemblePolyLine(linestring.Second); outfeat.set_Value(lfid, lhs_fid); outfeat.set_Value(rfid, rhs_fid); outfeat.Shape = line; outcursor.InsertFeature(outfeat); // Same boundary but swapped! outfeat.set_Value(lfid, rhs_fid); outfeat.set_Value(rfid, lhs_fid); outfeat.Shape = line; outcursor.InsertFeature(outfeat); } // progress outp_progress++; if (outp_progress % outp_steps == 0) { progress(0.5 + (0.5 * outp_progress / outp_count)); } } outcursor.Flush(); System.Runtime.InteropServices.Marshal.ReleaseComObject(outcursor); }
public bool isIntersect(IPolyline line) { //需要做四次相交, 分别是和四个边线. //左边边线. IPolyline boundLine = new PolylineClass(); IPointCollection ptCol = boundLine as IPointCollection; ptCol.AddPoint(upperLeftPt); ptCol.AddPoint(lowerLeftPt); ITopologicalOperator tpOp = boundLine as ITopologicalOperator; IGeometry geom = tpOp.Intersect(line, esriGeometryDimension.esriGeometry0Dimension); if (!geom.IsEmpty) { return true; } //右边边线. boundLine = new PolylineClass(); ptCol = boundLine as IPointCollection; ptCol.AddPoint(upperRightPt); ptCol.AddPoint(lowerRightPt); tpOp = boundLine as ITopologicalOperator; geom = tpOp.Intersect(line, esriGeometryDimension.esriGeometry0Dimension); if (!geom.IsEmpty) { return true; } //上边边线. boundLine = new PolylineClass(); ptCol = boundLine as IPointCollection; ptCol.AddPoint(upperLeftPt); ptCol.AddPoint(upperRightPt); tpOp = boundLine as ITopologicalOperator; geom = tpOp.Intersect(line, esriGeometryDimension.esriGeometry0Dimension); if (!geom.IsEmpty) { return true; } //下边边线. boundLine = new PolylineClass(); ptCol = boundLine as IPointCollection; ptCol.AddPoint(lowerLeftPt); ptCol.AddPoint(lowerRightPt); tpOp = boundLine as ITopologicalOperator; geom = tpOp.Intersect(line, esriGeometryDimension.esriGeometry0Dimension); if (!geom.IsEmpty) { return true; } return false; }
private IList <IGeometry> RemoveOverlaps( [NotNull] IMultiPatch sourceMultipatch, [NotNull] IPolygon overlaps, ChangeAlongZSource zSource, out IList <IGeometry> overlappingMultiPatches) { // NOTE: // Difference / Intersect are useless for multipatches, they can only return polygons // -> Get the relevant boundary segments of the overlap and use the FeatureCutter to cut the multipatch. // Then select the correct (non-intersecting part) IPolyline interiorIntersection = GetCutLine(sourceMultipatch, overlaps); Assert.False(interiorIntersection.IsEmpty, "Cut line is empty."); IDictionary <IPolygon, IMultiPatch> cutResultByFootprintPart = CutGeometryUtils.TryCut(sourceMultipatch, interiorIntersection, zSource); IList <IGeometry> result = new List <IGeometry>(cutResultByFootprintPart.Count); overlappingMultiPatches = _storeOverlapsAsNewFeatures ? new List <IGeometry>( cutResultByFootprintPart.Count) : null; // now select the multipatch of the right side... foreach (KeyValuePair <IPolygon, IMultiPatch> footprintWithMultipatch in cutResultByFootprintPart) { IMultiPatch resultMultipatch = footprintWithMultipatch.Value; if (!GeometryUtils.InteriorIntersects(footprintWithMultipatch.Key, overlaps)) { result.Add(resultMultipatch); } else { overlappingMultiPatches?.Add(resultMultipatch); } } if (!_explodeMultipartResult) { // merge the different parts into one: if (result.Count > 1) { result = new List <IGeometry> { GeometryUtils.Union(result) }; } if (overlappingMultiPatches?.Count > 1) { overlappingMultiPatches = new List <IGeometry> { GeometryUtils.Union(overlappingMultiPatches) }; } } return(result); }
private void CalculateIntersect(IFeatureCursor pFeatureCursor, IGeometry pGeometry) { if (pFeatureCursor == null) { return; } IMultipoint pIntersectionPoints = null; IPointCollection pPointColl = null; List <IFeature> pFeatureList = new List <IFeature>(); ITopologicalOperator pTopoOperator = pGeometry as ITopologicalOperator; //画线的几何体 IPointCollection pSkecthPiontColl = pGeometry as IPointCollection; IPoint pPoint0 = pSkecthPiontColl.get_Point(0); IFeature pFeature = pFeatureCursor.NextFeature(); pFeatureList.Clear(); while ((pFeature != null)) { pFeatureList.Add(pFeature); pFeature = pFeatureCursor.NextFeature(); } IPolyline pPolyline = pGeometry as IPolyline; IPoint pPointF = pPolyline.FromPoint; Dictionary <double, IFeature> pDic = new Dictionary <double, IFeature>(); int pCount = pFeatureList.Count; double[] sortArray = new double[pCount]; for (int i = 0; i <= pCount; i++) { try { pFeature = pFeatureList[i]; pIntersectionPoints = pTopoOperator.Intersect(pFeature.Shape, esriGeometryDimension.esriGeometry0Dimension) as IMultipoint; pPointColl = pIntersectionPoints as IPointCollection; sortArray[i] = GetDistance(pPointF, pPointColl.get_Point(0)); pDic.Add(GetDistance(pPointF, pPointColl.get_Point(0)), pFeatureList[i]); pFeature = pFeatureCursor.NextFeature(); } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } } for (int H = sortArray.Length - 1; H >= 0; H--) { for (int j = 0; j < H; j++) { if (sortArray[j] > sortArray[j + 1]) { double temp = sortArray[j]; sortArray[j] = sortArray[j + 1]; sortArray[j + 1] = temp; } } } int pFieldIndex = pFeatureLayer.FeatureClass.Fields.FindField(pHeightName); Dictionary <IFeature, double> pDicdis = new Dictionary <IFeature, double>(); for (int m = 0; m < sortArray.Length; m++) { foreach (KeyValuePair <double, IFeature> pKey in pDic) { if (sortArray[m] == pKey.Key) { IFeature pFeatureH = pKey.Value; pFeatureH.set_Value(pFieldIndex, pHeight + pInterval * m); pFeatureH.Store(); } } } }
public Range(int id, int low, int high, int fromleft, int toleft, int fromright, int toright, IPolyline shape) { ID = id; Low = low; High = high; FromLeft = fromleft; ToLeft = toleft; FromRight = fromright; ToRight = toright; Shape = shape; Errors = new List <string>(); }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (e.button == 1) { //给m_graphicsContainer赋值 m_graphicsContainer = axMapControl1.Map as IGraphicsContainer; //在添加polygon被选中时 if (miAddPolygon.Checked) { //在鼠标点击的位置生成一个点 IPoint p_Point = new PointClass(); p_Point.PutCoords(e.mapX, e.mapY); IActiveView p_activeview = axMapControl1.Map as IActiveView; IScreenDisplay p_ScreenDisplay = p_activeview.ScreenDisplay; //标记符等于0时 if (m_marker == 0) { //对m_DisplayFeedback重新初始化 m_DisplayFeedback = new NewPolygonFeedbackClass(); //设置m_DisplayFeedback的display m_DisplayFeedback.Display = p_ScreenDisplay; //开始绘制polygon的第一个点 ((INewPolygonFeedback)m_DisplayFeedback).Start(p_Point); //将m_polyline转为pointcollection IPointCollection p_PointCollection = m_polyline as IPointCollection; //将第一个点加入pointcollection中 p_PointCollection.AddPoint(p_Point); //将第一个点记录到m_point中 m_point = p_Point; //对m_polyline重新赋值 m_polyline = p_PointCollection as IPolyline; if (m_marker == 0) { m_marker = 1; } //刷新 axMapControl1.ActiveView.Refresh(); } //如果不是第一次点击,就添加节点 else { //初始化红线和蓝线 if (m_element_red != null) { m_graphicsContainer.DeleteElement(m_element_red); } if (m_element_green != null) { m_graphicsContainer.DeleteElement(m_element_green); } //向m_DisplayFeedback中添加顶点 ((INewPolygonFeedback)m_DisplayFeedback).AddPoint(p_Point); IPointCollection p_PointCollection = m_polyline as IPointCollection; p_PointCollection.AddPoint(p_Point); //生成红线 m_polyline = p_PointCollection as IPolyline; ILineElement p_LineElement_red = new LineElementClass(); m_element_red = p_LineElement_red as IElement; m_element_red.Geometry = m_polyline; ISimpleLineSymbol p_SimpleLineSymbol = new SimpleLineSymbolClass(); IRgbColor p_rgbcolor = new RgbColorClass(); p_rgbcolor.Red = 255; p_rgbcolor.Green = 0; p_rgbcolor.Blue = 0; p_SimpleLineSymbol.Color = p_rgbcolor as IColor; p_LineElement_red.Symbol = p_SimpleLineSymbol as ILineSymbol; //设置蓝线symbol ISimpleLineSymbol p_SimpleLine_green = new SimpleLineSymbolClass(); IRgbColor p_rgbcolor_green = new RgbColorClass(); p_rgbcolor_green.Red = 0; p_rgbcolor_green.Green = 255; p_rgbcolor_green.Blue = 255; p_SimpleLine_green.Color = p_rgbcolor_green as IColor; //生成蓝线 IPolyline p_polyline = new PolylineClass(); IPointCollection p_pointColl_green = p_polyline as IPointCollection; //向蓝线中添加两个顶点 p_pointColl_green.AddPoint(m_point); p_pointColl_green.AddPoint(p_Point); p_polyline = p_pointColl_green as IPolyline; ILineElement p_LineElement_green = new LineElementClass(); m_element_green = p_LineElement_green as IElement; p_LineElement_green.Symbol = p_SimpleLine_green as ILineSymbol; m_element_green.Geometry = p_polyline; //将红线和蓝线加入containner显示 m_graphicsContainer.AddElement(m_element_red, 0); m_graphicsContainer.AddElement(m_element_green, 0); //更新视图 axMapControl1.ActiveView.Refresh(); } } //当选择polygon被选中时 if (miSelectPolygon.Checked) { //如果m_list不为空,则从容器中把其所对应element删除并将m_list清空 if (m_list.Count != 0) { for (int i = 0; i < m_list.Count; i++) { m_graphicsContainer.DeleteElement(m_list[i]); } m_list.Clear(); } //刷新 axMapControl1.ActiveView.Refresh(); IPoint p_point = new PointClass(); //记录点下的点 p_point.PutCoords(e.mapX, e.mapY); //得到选中的element集合 IEnumElement p_EnumElement = m_graphicsContainer.LocateElements(p_point, 5); IGeometry p_geometry; //选中的element集合不为空时 if (p_EnumElement != null) { m_hitElement = p_EnumElement.Next(); p_geometry = m_hitElement.Geometry; //循环找到类型为polygon的element while (p_geometry.GeometryType != esriGeometryType.esriGeometryPolygon && m_hitElement != null) { m_hitElement = p_EnumElement.Next(); if (m_hitElement != null) { p_geometry = m_hitElement.Geometry; } } if (p_geometry.GeometryType == esriGeometryType.esriGeometryPolygon) { m_polygon = (IPolygon)p_geometry; m_PointColl = m_polygon as IPointCollection; //循环将选中的polygon的每个点以element加入容器中 for (int k = 1; k < m_PointColl.PointCount; k++) { IMarkerElement p_MarkerElement = new MarkerElementClass(); ISimpleMarkerSymbol p_simpleMarker = new SimpleMarkerSymbolClass(); p_simpleMarker.Size = 5; IElement p_element = (IElement)p_MarkerElement; p_MarkerElement.Symbol = p_simpleMarker as IMarkerSymbol; if (!(p_element == null)) { p_element.Geometry = m_PointColl.get_Point(k); m_graphicsContainer.AddElement(p_element, 0); } m_list.Add(p_element); } axMapControl1.ActiveView.Refresh(); } } } //当编辑polygon被选中时 if (miEditPolygon.Checked) { if (m_polygon != null) { //在鼠标点击的位置生成一个点 IPoint p_Point = new PointClass(); p_Point.PutCoords(e.mapX, e.mapY); IActiveView p_ActiveView = axMapControl1.Map as IActiveView; IScreenDisplay p_ScreenDisplay = p_ActiveView.ScreenDisplay; //建立新的hittest,设置相关变量,获取点击处polygon的顶点 IHitTest p_HitTest = m_polygon as IHitTest; IPoint p_hitPoint = new PointClass(); double p_distance = 0; bool p_isOnRightSide = true; int p_hitPartIndex = 0; int p_hitSegmentIndex = 0; bool p_isHit = p_HitTest.HitTest(p_Point, this.axMapControl1.ActiveView.Extent.Width / 100, esriGeometryHitPartType.esriGeometryPartVertex, p_hitPoint, ref p_distance, ref p_hitPartIndex, ref p_hitSegmentIndex, ref p_isOnRightSide); //如果有点被选中,开始拖动该点 if (p_isHit) { m_DisplayFeedback = new PolygonMovePointFeedbackClass(); m_marker = 2; m_DisplayFeedback.Display = p_ScreenDisplay; ((IPolygonMovePointFeedback)m_DisplayFeedback).Start(m_polygon, p_hitSegmentIndex, p_Point); } } } } }
// Methods public DrawScanningModel(IMultiPolygon sSection, IMultiPolygon eSection, IPolyline polyline) { this.SetParameter(sSection, eSection, polyline); }
// Shap数据中含各顶点高程数据 private bool GetPipeLineVertexs(IGeometry geo, double sHeight, double eHeight, out IPolyline route) { route = null; try { IPolyline polyline = null; if ((geo == null) || ((polyline = geo as IPolyline) == null)) { return(false); } IPoint pointValue = null; route = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; if (polyline.PointCount == 2) { pointValue = polyline.StartPoint.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint; pointValue.Z = sHeight; route.AppendPoint(pointValue); pointValue = polyline.EndPoint.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint; pointValue.Z = eHeight; route.AppendPoint(pointValue); } else { IPoint point; Stack <int> stack = new Stack <int>(); double num4 = eHeight - sHeight; if (Math.Abs(num4) < 0.0015) { point = null; for (int i = 0; i < polyline.PointCount; i++) { pointValue = polyline.GetPoint(i).Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint; if (i < 1) { pointValue.Z = sHeight; route.AppendPoint(pointValue); point = pointValue; } else if (Math.Sqrt(((pointValue.X - point.X) * (pointValue.X - point.X)) + ((pointValue.Y - point.Y) * (pointValue.Y - point.Y))) < (this._dia1 * 1.5)) { stack.Push(i); } else { pointValue.Z = sHeight; route.AppendPoint(pointValue); point = pointValue; } } } else { double num3 = sHeight; IPolyline o = polyline.Clone2(gviVertexAttribute.gviVertexAttributeNone) as IPolyline; double length = o.Length; Marshal.ReleaseComObject(o); point = null; for (int j = 0; j < polyline.PointCount; j++) { pointValue = polyline.GetPoint(j).Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint; if (j < 1) { pointValue.Z = sHeight; route.AppendPoint(pointValue); point = pointValue; } else { double num2; if ((num2 = Math.Sqrt(((pointValue.X - point.X) * (pointValue.X - point.X)) + ((pointValue.Y - point.Y) * (pointValue.Y - point.Y)))) < (this._dia1 * 1.5)) { stack.Push(j); } else { num3 += (num2 / length) * num4; pointValue.Z = num3; route.AppendPoint(pointValue); point = pointValue; } } } } while (stack.Count > 0) { polyline.RemovePoints(stack.Pop(), 1); } } return(true); } catch (Exception exception) { return(false); } }
//解决路径 public void SolvePath(string WeightName) { try { int intEdgeUserClassID; int intEdgeUserID; int intEdgeUserSubID; int intEdgeID; IPoint ipFoundEdgePoint; double dblEdgePercent; //定义追踪线 ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN; INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver; //ipNetSolver.SelectionSetBarriers INetwork ipNetwork = m_ipGeometricNetwork.Network; ipNetSolver.SourceNetwork = ipNetwork; INetElements ipNetElements = ipNetwork as INetElements; int intCount = m_ipPoints.PointCount; //定义一个边线旗数组,各边线与输入点最近 IEdgeFlag[] pEdgeFlagList = new EdgeFlagClass[intCount]; for (int i = 0; i < intCount; i++) { INetFlag ipNetFlag = new EdgeFlagClass() as INetFlag; IPoint ipEdgePoint = m_ipPoints.get_Point(i); //查找输入点的最近的边线 m_ipPointToEID.GetNearestEdge(ipEdgePoint, out intEdgeID, out ipFoundEdgePoint, out dblEdgePercent); ipNetElements.QueryIDs(intEdgeID, esriElementType.esriETEdge, out intEdgeUserClassID, out intEdgeUserID, out intEdgeUserSubID); ipNetFlag.UserClassID = intEdgeUserClassID; ipNetFlag.UserID = intEdgeUserID; ipNetFlag.UserSubID = intEdgeUserSubID; IEdgeFlag pTemp = (IEdgeFlag)(ipNetFlag as IEdgeFlag); pEdgeFlagList[i] = pTemp; } IFeatureClassContainer ipFeatureClassContainer = m_ipGeometricNetwork as IFeatureClassContainer; IFeatureClass ipFeatureClass; int count = ipFeatureClassContainer.ClassCount; if (barrierflag == 1) { for (int i = 0; i < count; i++) { ipFeatureClass = ipFeatureClassContainer.get_Class(i); INetElementBarriers inetelementbarriers; if (i == 0) { inetelementbarriers = setbarriers(ipFeatureClass, barrierarray1, ipNetwork); if(inetelementbarriers!=null) ipNetSolver.set_ElementBarriers(esriElementType.esriETEdge, inetelementbarriers); } if (i == 1) { inetelementbarriers = setbarriers(ipFeatureClass, barrierarray2, ipNetwork); if(inetelementbarriers!=null) ipNetSolver.set_ElementBarriers(esriElementType.esriETEdge, inetelementbarriers); } } } ipTraceFlowSolver.PutEdgeOrigins(ref pEdgeFlagList); INetSchema ipNetSchema = ipNetwork as INetSchema; INetWeight ipNetWeight = ipNetSchema.get_WeightByName(WeightName); INetSolverWeights ipNetSolverWeights = ipTraceFlowSolver as INetSolverWeights; ipNetSolverWeights.FromToEdgeWeight = ipNetWeight;//开始边线的权重 ipNetSolverWeights.ToFromEdgeWeight = ipNetWeight;//终止边线的权重 object[] vaRes = new object[intCount - 1]; //通过findpath得到边线和交汇点的集合 ipTraceFlowSolver.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinSum, out m_ipEnumNetEID_Junctions, out m_ipEnumNetEID_Edges, intCount - 1, ref vaRes); //计算成本 m_dblPathCost = 0; for (int i = 0; i < vaRes.Length; i++) { double m_Va = (double)vaRes[i]; m_dblPathCost = m_dblPathCost + m_Va; } m_ipPolyline = null; } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary>Gets the end point of a turn edge</summary> /// <remarks> /// - The Via node of a turn is assumed to be at the From or To point of the edge /// </remarks> private static IPoint GetTurnEndpoint(IPolyline line, IPoint ptVia, out bool edgeEndAtToPoint, out double position) { IPoint point = null; edgeEndAtToPoint = false; position = 0.0; if ((ptVia.X == line.FromPoint.X) && (ptVia.Y == line.FromPoint.Y)) { point = ((IPointCollection)line).get_Point(1); ISegment segment = ((ISegmentCollection)line).get_Segment(0); position = segment.Length / line.Length; } else { edgeEndAtToPoint = true; IPointCollection pc = (IPointCollection)line; point = pc.get_Point(pc.PointCount - 2); ISegmentCollection sc = line as ISegmentCollection; ISegment segment = sc.get_Segment(sc.SegmentCount - 1); position = (line.Length - segment.Length) / line.Length; } return point; }
public bool GetPipeLineParameter(double thick, out List <Vector> vtxs, out IPipeSection section) { vtxs = null; section = null; IPolyline polyline = null; if ((base._geoGroup[1] == null) || ((polyline = base._geoGroup[1] as IPolyline) == null)) { return(false); } if (polyline.PointCount < 2) { return(false); } IPoint p = null; Vector vector = null; Vector vector2 = null; Vector item = null; vtxs = new List <Vector>(); section = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, thick, 0); for (int i = 0; i < polyline.PointCount; i++) { p = polyline.GetPoint(i); if (p != null) { vector = new Vector(p); if ((this._dia1 > 1.5) || (this._dia2 > 1.5)) { item = vector; } else if (i == 0) { // 增加起点退让判断,并对较短管线做处理 FX 2014.04.08 vector2 = new Vector(polyline.GetSegment(i)); double length = vector2.Length; vector2 = vector2.UnitVector(); if (this._isSBackhind) { if (length > (section.Diameter / 1.8)) { item = vector + ((Vector)((vector2 * section.Diameter) / 1.8)); } else { item = vector + ((Vector)((vector2 * length) / 1.8)); } } else { item = vector; } } else if (i == (polyline.PointCount - 1)) { // 增加终点退让判断,并对较短管线做处理 FX 2014.04.08 vector2 = new Vector(polyline.GetSegment(i - 1)); double length = vector2.Length; vector2 = -vector2.UnitVector(); if (this._isEBackhind) { if (length > (section.Diameter / 1.8)) { item = vector + ((Vector)((vector2 * section.Diameter) / 1.8)); } else { item = vector + ((Vector)((vector2 * length) / 1.8)); } } else { item = vector; } } else { item = vector; } item.Z += this.OffsetZ; vtxs.Add(item); } } return(true); }
public static bool CreatePoints(IApplication app, List<ConstructLineWithPointsDetails> linesWithPointsDetails, IPolyline line, IFeatureLayer SourceLayer, bool bUseTemplate, out List<IFeature> pLstFeat) { pLstFeat = null; IFeatureLayer pStartPointLayer = null; IFeatureLayer pAlongPointLayer = null; IFeatureLayer pEndPointLayer = null; IEditor editor = null; ICurve pCur = null;// as ICurve; //List<string> strTemplateNames = null; IEditTemplate pEditTempStart = null; IEditTemplate pEditTempAlong = null; IEditTemplate pEditTempEnd = null; IFeature pPntFeat = null; IEnumVertex pEnumVx = null; IPoint ppnt = null; try { editor = Globals.getEditor(app); if (linesWithPointsDetails == null) return false; if (linesWithPointsDetails.Count == 0) return false; // MessageBox.Show(Control.ModifierKeys.ToString()); pLstFeat = new List<IFeature>(); foreach (ConstructLineWithPointsDetails pDet in linesWithPointsDetails) { if (pDet.Line_LayerName != SourceLayer.Name) continue; bool FCorLayerStart = true; bool FCorLayerAlong = true; bool FCorLayerEnd = true; pStartPointLayer = Globals.FindLayer(app, pDet.Point_Start_LayerName, ref FCorLayerStart) as IFeatureLayer; pAlongPointLayer = Globals.FindLayer(app, pDet.Point_Along_LayerName, ref FCorLayerAlong) as IFeatureLayer; pEndPointLayer = Globals.FindLayer(app, pDet.Point_End_LayerName, ref FCorLayerEnd) as IFeatureLayer; if (pStartPointLayer == null) continue; else if (pStartPointLayer.FeatureClass == null) continue; //if (pAlongPointLayer == null) // continue; //else if (pAlongPointLayer.FeatureClass == null) // continue; if (pEndPointLayer == null) continue; else if (pEndPointLayer.FeatureClass == null) continue; //if (pDet.lineLayerName == SourceLayer.Name) if (!Globals.IsEditable(ref pStartPointLayer, ref editor)) return false; if (pAlongPointLayer != null) { if (!Globals.IsEditable(ref pAlongPointLayer, ref editor)) return false; } if (!Globals.IsEditable(ref pEndPointLayer, ref editor)) return false; //IFeatureLayer pPointLay = Globals.FindLayer(app, pDet.pointLayerName) as IFeatureLayer; pCur = line;// as ICurve; if (bUseTemplate) { //pEditTempStart = Globals.PromptAndGetEditTemplate(app, pStartPointLayer, pDet.Point_Start_EditTemplate, "Template for Start Layer: " + pStartPointLayer.Name); //pEditTempAlong = Globals.PromptAndGetEditTemplate(app, pAlongPointLayer, pDet.Point_Along_EditTemplate, "Template for Point Along Layer: " + pAlongPointLayer.Name); //pEditTempEnd = Globals.PromptAndGetEditTemplate(app, pEndPointLayer, pDet.Point_End_EditTemplate, "Template for End Layer: " + pEndPointLayer.Name); pEditTempStart = Globals.PromptAndGetEditTemplateGraphic(pStartPointLayer, pDet.Point_Start_EditTemplate); if (pAlongPointLayer != null) { pEditTempAlong = Globals.PromptAndGetEditTemplateGraphic(pAlongPointLayer, pDet.Point_Along_EditTemplate); } pEditTempEnd = Globals.PromptAndGetEditTemplateGraphic(pEndPointLayer, pDet.Point_End_EditTemplate); } else { //pEditTempStart = Globals.PromptAndGetEditTemplate(app, pStartPointLayer, "", "Template for Start Layer: " + pStartPointLayer.Name); //pEditTempAlong = Globals.PromptAndGetEditTemplate(app, pAlongPointLayer, "", "Template for Point Along Layer: " + pAlongPointLayer.Name); //pEditTempEnd = Globals.PromptAndGetEditTemplate(app, pEndPointLayer, "", "Template for End Layer: " + pEndPointLayer.Name); pEditTempStart = Globals.PromptAndGetEditTemplateGraphic(pStartPointLayer, ""); if (pAlongPointLayer != null) { pEditTempAlong = Globals.PromptAndGetEditTemplateGraphic(pAlongPointLayer, ""); } pEditTempEnd = Globals.PromptAndGetEditTemplateGraphic(pEndPointLayer, ""); } if (pDet.PointAtVertices.ToUpper() == "TRUE") { ESRI.ArcGIS.Geometry.IPointCollection4 pPointColl; pPointColl = (IPointCollection4)line; pEnumVx = pPointColl.EnumVertices; pEnumVx.Reset(); int partIdx; int verIdx; pEnumVx.Next(out ppnt, out partIdx, out verIdx); int pntIdx = 0; while (ppnt != null) { if (pntIdx == 0) { if (pEditTempStart == null) { pPntFeat = Globals.CreateFeature(pCur.FromPoint, pStartPointLayer, editor, app, true, false, true); //editor.Map.SelectFeature(pStartPointLayer, pPntFeat); // pPntFeat.Store(); } else { pPntFeat = Globals.CreateFeature(pCur.FromPoint, pEditTempStart, editor, app, true, false, true); //editor.Map.SelectFeature(pEditTempStart.Layer, pPntFeat); //pPntFeat.Store(); } } else if (pntIdx == pPointColl.PointCount - 1) { if (pEditTempEnd == null) { pPntFeat = Globals.CreateFeature(pCur.ToPoint, pEndPointLayer, editor, app, true, false, true); //editor.Map.SelectFeature(pEndPointLayer, pPntFeat); // pPntFeat.Store(); } else { pPntFeat = Globals.CreateFeature(pCur.ToPoint, pEditTempEnd, editor, app, true, false, true); //editor.Map.SelectFeature(pEditTempEnd.Layer, pPntFeat); // pPntFeat.Store(); } } else { if (pAlongPointLayer != null) { if (pEditTempAlong != null) { pPntFeat = Globals.CreateFeature(ppnt, pEditTempAlong, editor, app, true, false, true); //editor.Map.SelectFeature(pEditTempStart.Layer, pPntFeat); } else { pPntFeat = Globals.CreateFeature(ppnt, pAlongPointLayer, editor, app, true, false, true); //editor.Map.SelectFeature(pEditTempStart.Layer, pPntFeat); } } } if (pPntFeat != null) { pLstFeat.Add(pPntFeat); //pPntFeat.Store(); } pntIdx = pntIdx + 1; pEnumVx.Next(out ppnt, out partIdx, out verIdx); } } else { if (pEditTempStart == null) { pPntFeat = Globals.CreateFeature(pCur.FromPoint, pStartPointLayer, editor, app, true, false, true); if (pPntFeat != null) { pLstFeat.Add(pPntFeat); // pPntFeat.Store(); } } else { pPntFeat = Globals.CreateFeature(pCur.FromPoint, pEditTempStart, editor, app, true, false, true); if (pPntFeat != null) { pLstFeat.Add(pPntFeat); // pPntFeat.Store(); } } if (pEditTempEnd == null) { pPntFeat = Globals.CreateFeature(pCur.ToPoint, pEndPointLayer, editor, app, true, false, true); if (pPntFeat != null) { pLstFeat.Add(pPntFeat); // pPntFeat.Store(); } } else { pPntFeat = Globals.CreateFeature(pCur.ToPoint, pEditTempEnd, editor, app, true, false, true); if (pPntFeat != null) { pLstFeat.Add(pPntFeat); // pPntFeat.Store(); } } } return Convert.ToBoolean(pDet.TwoPointLines); } return false; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("Error") + ex.Message); return false; } finally { pStartPointLayer = null; pAlongPointLayer = null; pEndPointLayer = null; editor = null; pCur = null;// as ICurve; pEditTempStart = null; pEditTempAlong = null; pEditTempEnd = null; pPntFeat = null; pEnumVx = null; ppnt = null; } }
public void InsertPointAtIntersection(ref IPolyline pPolyline, IGeometry pOther, double hmgetal) { bool SplitHappened = false; int newPartIndex = 0; int newSegmentIndex = 0; int index = 0; List<int> indices; IPoint Point = null; IClone pClone = pPolyline.SpatialReference as IClone; if (pClone.IsEqual(pOther.SpatialReference as IClone) == false) { pOther.Project(pPolyline.SpatialReference); } ITopologicalOperator pTopoOp = pOther as ITopologicalOperator; pTopoOp.Simplify(); pTopoOp = pPolyline as ITopologicalOperator; IGeometry pGeomResult = pTopoOp.Intersect(pOther, esriGeometryDimension.esriGeometry0Dimension); indices = new List<int>(); if ((pGeomResult is IPointCollection) && ((pGeomResult as IPointCollection).PointCount > 0)) { for (int i = 0; i < (pGeomResult as IPointCollection).PointCount; i++) { (pPolyline as IPolycurve2).SplitAtPoint((pGeomResult as IPointCollection).get_Point(i), true, false, out SplitHappened, out newPartIndex, out newSegmentIndex); //TODO Zet de measure op het ingevoegde punt, houdt rekening met partindex en segmentindex for (int j = 0; j < newPartIndex; j++) { index += ((pPolyline as IGeometryCollection).get_Geometry(j) as IPointCollection).PointCount; } index += newSegmentIndex; Point = (pPolyline as IPointCollection).get_Point(index); Point.M = hmgetal; (pPolyline as IPointCollection).UpdatePoint(index, Point); } } (pPolyline as ITopologicalOperator2).IsKnownSimple_2 = false; (pPolyline as IPolyline4).SimplifyEx(true); }
public bool SetDynamicValues(IObject inObject, string mode, out List<IObject> ChangeFeatureList, out List<IObject> NewFeatureList, out List<IObject> ChangeFeatureGeoList) { NumberFormatInfo nfi = new CultureInfo(A4LGSharedFunctions.Localizer.GetString("AA_CultureInfo"), false).NumberFormat; nfi.NumberGroupSeparator = ""; ChangeFeatureList = null; NewFeatureList = null; ChangeFeatureGeoList = null; IMSegmentation mseg = null; INetworkFeature netFeat = null; IJunctionFeature iJuncFeat = null; IEdgeFeature iEdgeFeat = null; //ProgressBar //ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = null; //ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = null; //ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog = null; //// Create a CancelTracker //ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass(); //trackCancel.CancelOnKeyPress = true; // trackCancel.CancelOnClick = true; try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14d")); if (AAState.PerformUpdates == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14a")); } if (AAState.PerformUpdates && AAState._dv == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14b") + AAState._defaultsTableName); AAState.PerformUpdates = false; return false; } if (AAState.PerformUpdates && AAState._dv != null) { if (AAState._dv.Table == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14c")); return false; } if (inObject == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14e")); return false; } if (inObject.Table == AAState._tab) { if (inObject.get_Value(inObject.Fields.FindField("VALUEMETHOD")).ToString().ToUpper() == "LAST_VALUE") { if (inObject.get_Value(inObject.Fields.FindField("FIELDNAME")) != null) { if (inObject.get_Value(inObject.Fields.FindField("FIELDNAME")) != DBNull.Value) { try { LastValueEntry lstVal = AAState.lastValueProperties.GetProperty(inObject.get_Value(inObject.Fields.FindField("FIELDNAME")).ToString()) as LastValueEntry; if (lstVal != null) { lstVal.On_Manual = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_MANUAL")).ToString()); lstVal.On_Create = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_CREATE")).ToString()); lstVal.On_ChangeAtt = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_CHANGE")).ToString()); if (inObject.Fields.FindField("ON_CHANGEGEO") >= 0) { lstVal.On_ChangeGeo = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_CHANGEGEO")).ToString()); } } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14f")); } catch { //property does not exist } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14g")); } return false; } string modeVal; if (AAState._dv.Table.Columns[mode] == null) { AAState.WriteLine(mode + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14h")); mode = mode.Replace("GEO", ""); } if (AAState._dv.Table.Columns[mode].DataType == System.Type.GetType("System.String")) { modeVal = "(" + mode + " = '1' or " + mode + " = 'Yes' or " + mode + " = 'YES' or " + mode + " = 'True' or " + mode + " = 'TRUE')"; } else { modeVal = mode + " = 1"; } //System.Int32 int32_hWnd = ArcMap.Application.hWnd; //progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass(); //stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd); //stepProgressor.MinRange = 0; //stepProgressor.MaxRange = inObject.Fields.FieldCount; //stepProgressor.StepValue = 1; //stepProgressor.Message = "Attribute Assistant Progress"; //// Create the ProgressDialog. This automatically displays the dialog //progressDialog = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast //// Set the properties of the ProgressDialog //progressDialog.CancelEnabled = true; ArcMap.Application.StatusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14i") + inObject.Class.AliasName); //progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14i") + inObject.Class.AliasName; //progressDialog.Title = "Attribute Assistant Progress"; //progressDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressGlobe; //progressDialog.ShowDialog(); //Optional skip junctions feature class //if (Globals.isOrpanJunction(inFeature)) // return false; //Get table name for this feature _currentDataset = inObject.Class as IDataset; _currentDatasetNameItems = _currentDataset.Name.Split('.'); tableName = _currentDatasetNameItems[_currentDatasetNameItems.GetLength(0) - 1]; ArcMap.Application.StatusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain10") + inObject.Class.AliasName); //stepProgressor.Message = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain10") + inObject.Class.AliasName; // progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain10") + inObject.Class.AliasName; AAState.WriteLine("***********************************************************"); AAState.WriteLine("############ " + DateTime.Now + " ################"); AAState.WriteLine(""); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain11")); if (AAState._dv.Table.Columns.Contains("RUN_WEIGHT")) AAState._dv.Sort = "RUN_WEIGHT DESC"; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14j") + inObject.Class.AliasName); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14k") + "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND VALUEMETHOD = 'Last_Value'"); AAState._dv.RowFilter = "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND VALUEMETHOD = 'Last_Value'"; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14l") + AAState._dv.Count.ToString()); if (AAState._dv.Count > 0) { IRowChanges pRowChLast = inObject as IRowChanges; for (int retRows = 0; retRows < AAState._dv.Count; retRows++) { DataRowView drv = AAState._dv[retRows]; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14m") + drv["FIELDNAME"].ToString()); int fldLoc = inObject.Fields.FindField(drv["FIELDNAME"].ToString()); if (fldLoc > 0) { AAState.WriteLine(" " + drv["FIELDNAME"].ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14n") + fldLoc); if (pRowChLast.get_ValueChanged(fldLoc)) { AAState.WriteLine(" " + drv["FIELDNAME"].ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14o") ); try { LastValueEntry lstVal = (AAState.lastValueProperties.GetProperty(drv["FIELDNAME"].ToString()) as LastValueEntry); if (lstVal != null) { if (inObject.get_Value(fldLoc) != null) { if (inObject.get_Value(fldLoc) != DBNull.Value) { if (lstVal.Value != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") ); AAState.WriteLine(" " + drv["FIELDNAME"].ToString() + ": " + inObject.get_Value(fldLoc).ToString()); lstVal.Value = inObject.get_Value(fldLoc); AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") ); AAState.WriteLine(" " + drv["FIELDNAME"].ToString() + ": " + inObject.get_Value(fldLoc)); lstVal.Value = inObject.get_Value(fldLoc); AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal); } } else { if (mode == "ON_CREATE") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14q") ); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") ); AAState.WriteLine(" " + drv["FIELDNAME"].ToString() + ": NULL"); lstVal.Value = null; AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal); } } } else { if (mode == "ON_CREATE") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14q") ); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") ); AAState.WriteLine(" " + drv["FIELDNAME"].ToString() + ": NULL"); lstVal.Value = null; AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal); } } } else { lstVal = new LastValueEntry(); lstVal.Value = inObject.get_Value(fldLoc); lstVal.On_Manual = Globals.toBoolean(drv["ON_MANUAL"].ToString()); lstVal.On_Create = Globals.toBoolean(drv["ON_CREATE"].ToString()); lstVal.On_ChangeAtt = Globals.toBoolean(drv["ON_CHANGE"].ToString()); if (drv["ON_CHANGEGEO"] != null) { lstVal.On_ChangeGeo = Globals.toBoolean(drv["ON_CHANGEGEO"].ToString()); } AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal); } } catch { } } else { AAState.WriteLine(" " + drv["FIELDNAME"].ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14r") ); } } } pRowChLast = null; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14s") + inObject.Class.AliasName); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14k") + "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND " + modeVal); AAState._dv.RowFilter = "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND " + modeVal; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14l") + AAState._dv.Count.ToString()); if (AAState._processCount > 2) { System.Threading.Thread.Sleep(400); } if (AAState._processCount > 15) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14t") ); return false; } if (AAState._dv.Count > 0) { bool proc = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14u") ); for (int retRows = 0; retRows < AAState._dv.Count; retRows++) { DataRowView drv = AAState._dv[retRows]; AAState.WriteLine(" ------------------------------------------------"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14v") ); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14w") + (retRows + 1).ToString()); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14x") + drv["TABLENAME"].ToString()); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14y") + drv["FIELDNAME"].ToString()); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14z") + drv["VALUEINFO"].ToString()); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aa") + drv["VALUEMETHOD"].ToString()); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ab") + drv["ON_CREATE"].ToString()); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ac") + drv["ON_CHANGE"].ToString()); if (AAState._dv.Table.Columns.Contains("RUNORDER")) AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ad") + drv["RUNORDER"].ToString()); AAState.WriteLine(""); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ae") ); valFC = drv["TABLENAME"].ToString().Trim(); if (valFC.Contains("|")) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14af") ); string[] spliVal = valFC.Split('|'); List<string> validSubtypes = new List<string>(spliVal[1].Split(',')); List<string> inValidSubtypes; if (spliVal.GetLength(0) == 3) { inValidSubtypes = new List<string>(spliVal[2].Split(',')); } else { inValidSubtypes = new List<string>(); } int obSubVal; ISubtypes pSub = inObject.Class as ISubtypes; if (pSub != null) { if (pSub.HasSubtype) { if (inObject.get_Value(pSub.SubtypeFieldIndex).ToString() != "") { obSubVal = Convert.ToInt32(inObject.get_Value(pSub.SubtypeFieldIndex).ToString()); if (validSubtypes.Contains("*")) { if (inValidSubtypes.Contains(obSubVal.ToString())) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ag") ); proc = false; continue; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ah") ); } } else if (validSubtypes.Contains(obSubVal.ToString())) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ah") ); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ag") ); proc = false; continue; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ai") ); proc = false; continue; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aj") ); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aj") ); } } valMethod = drv["VALUEMETHOD"].ToString().ToUpper().Trim(); valData = drv["VALUEINFO"].ToString().Trim(); if (valData.Contains(Environment.NewLine)) { valData = valData.Substring(0, valData.IndexOf(Environment.NewLine)); } List<string> strFldNames = new List<string>(); List<string> strFldAlias = new List<string>(); List<int> intFldIdxs = new List<int>(); fieldObj = null; if (drv["FIELDNAME"] != null && drv["FIELDNAME"].ToString().Trim() != "" && drv["FIELDNAME"].ToString().Trim() != "*" && drv["FIELDNAME"].ToString().Trim() != "#") { strFldNames = new List<string>(drv["FIELDNAME"].ToString().Trim().Split(',')); foreach (string strFldName in strFldNames) { if (inObject.Fields.FindField(strFldName) >= 0) { strFldAlias.Add(inObject.Fields.get_Field(inObject.Fields.FindField(strFldName)).AliasName); int tem = inObject.Fields.FindField(strFldName); intFldIdxs.Add(tem); fieldObj = inObject.Fields.get_Field(tem); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ak") + inObject.Fields.get_Field(inObject.Fields.FindField(strFldName)).AliasName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14al") + tem); proc = true; } else if (inObject.Fields.FindFieldByAliasName(strFldName) >= 0) { int tem = inObject.Fields.FindFieldByAliasName(strFldName); intFldIdxs.Add(tem); strFldAlias.Add(inObject.Fields.get_Field(tem).AliasName); fieldObj = inObject.Fields.get_Field(tem); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ak") + strFldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14al") + tem); proc = true; } else { intFldIdxs.Add(-1); strFldAlias.Add("{Not Found}"); AAState.WriteLine(" " + strFldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") ); fieldObj = null; proc = false; } } } else if (drv["FIELDNAME"].ToString() == "#") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14an") ); IRowChanges pRowCh = null; IField pTmpFld = null; pRowCh = inObject as IRowChanges; for (int i = 0; i < inObject.Fields.FieldCount; i++) { pTmpFld = inObject.Fields.get_Field(i); if (pTmpFld.Type != esriFieldType.esriFieldTypeGlobalID && pTmpFld.Type != esriFieldType.esriFieldTypeOID && pTmpFld.Type != esriFieldType.esriFieldTypeGeometry && pTmpFld.Name.ToUpper() != "SHAPE_LENGTH" && pTmpFld.Name.ToUpper() != "SHAPE.LEN" && pTmpFld.Name.ToUpper() != "SHAPE_AREA" && pTmpFld.Name.ToUpper() != "SHAPE.AREA") { if (pRowCh.get_ValueChanged(i) == true) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ao") + pTmpFld.Name + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ap") ); strFldNames.Add(pTmpFld.Name); intFldIdxs.Add(i); proc = true; } } } pRowCh = null; pTmpFld = null; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aq") ); fieldObj = null; proc = true; } if (proc) { try { switch (valMethod) { case "FIELD_TRIGGER"://Value|FieldToChange|Value try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FIELD_TRIGGER" ); if (inFeature != null & valData != null) { // Parse arguments args = valData.Split('|'); string valToCheck = ""; string fldToChange = ""; string valToSet = ""; if (args.GetLength(0) == 3) { valToCheck = args[0]; fldToChange = args[1]; valToSet = args[2]; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14av")); continue; } IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (intFldIdxs.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aw")); continue; } if (intFldIdxs[0] == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am")); continue; } if (pRowCh.get_ValueChanged(intFldIdxs[0])) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ax")); if (inObject.get_Value(intFldIdxs[0]).ToString() == valToCheck) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); int chngFldIdx = Globals.GetFieldIndex(inObject.Fields, fldToChange); if (chngFldIdx == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am")); continue; } try { inObject.set_Value(chngFldIdx, valToSet); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14c") + valToSet); } } } pRowCh = null; } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FIELD_TRIGGER: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FIELD_TRIGGER"); } break; case "VALIDATE_ATTRIBUTE_LOOKUP": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "VALIDATE_ATTRIBUTE_LOOKUP"); IRowChanges pRowCh = null; ISQLSyntax sqlSyntax = null; IQueryFilter pQFilt = null; try { if ((valData != null) && (inObject != null)) { pRowCh = inObject as IRowChanges; bool valueChanged = false; for (int i = 0; i < intFldIdxs.Count; i++) { if (pRowCh.get_ValueChanged(intFldIdxs[i]) == true) { valueChanged = true; break; } } if (valueChanged == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain12")); continue; } sourceLayerName = ""; string[] sourceFieldNames = null; // Parse arguments args = valData.Split('|'); if (args.Length == 2) { sourceLayerName = args[0].ToString().Trim(); sourceFieldNames = args[1].ToString().Split(','); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d")); continue; } if ((sourceFieldNames != null) && (sourceFieldNames.Length > 0)) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain13") + sourceLayerName); boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer; if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer; } IFields pFlds = null; IDataset pDs = null; string layNameFnd = ""; bool matchingLayFnd = false; IStandaloneTable pTbl = null; if (sourceLayer != null) { if (sourceLayer.FeatureClass != null) { pFlds = sourceLayer.FeatureClass.Fields; pDs = sourceLayer.FeatureClass as IDataset; layNameFnd = sourceLayer.Name; matchingLayFnd = true; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayerName + " data source is not set"); continue; } } else { pTbl = Globals.FindStandAloneTable(AAState._editor.Map, sourceLayerName) as IStandaloneTable; if (pTbl != null) { if (pTbl.Table != null) { pFlds = pTbl.Table.Fields; pDs = pTbl.Table as IDataset; layNameFnd = pTbl.Name; matchingLayFnd = true; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayerName + " data source is not set"); continue; } } if (matchingLayFnd == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); continue; } sqlSyntax = (ISQLSyntax)(pDs.Workspace); string specChar = sqlSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_WildcardManyMatch); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain14") + layNameFnd + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain15") + sourceLayerName); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain16")); if (sourceFieldNames.Length != intFldIdxs.Count) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain17")); continue; } int[] sourceFieldNums = new int[sourceFieldNames.Length]; pQFilt = new QueryFilterClass(); string sqlString = ""; string sqlStringUpper = ""; string sqlUpp = ""; if (sqlSyntax.GetStringComparisonCase()) { sqlUpp = "UPPER"; } for (int i = 0; i < sourceFieldNames.Length; i++) { sourceFieldNums[i] = Globals.GetFieldIndex(pFlds, sourceFieldNames[i].Trim()); if (sourceFieldNums[i] < 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain18") + sourceFieldName[i]); break; } if (pFlds.get_Field(sourceFieldNums[i]).Type == esriFieldType.esriFieldTypeString) { if (sqlString == "") { sqlString = pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString() + "'"; sqlStringUpper = sqlUpp + "(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar) + specChar + "'"; } else { sqlString = sqlString + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString() + "'"; sqlStringUpper = sqlStringUpper + " AND " + sqlUpp + "(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar) + specChar + "'"; } } else { if (sqlString == "") { sqlString = pFlds.get_Field(sourceFieldNums[i]).Name + " = " + inObject.get_Value(intFldIdxs[i]); sqlStringUpper = pFlds.get_Field(sourceFieldNums[i]).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[i]) + specChar; } else { sqlString = sqlString + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + " = " + inObject.get_Value(intFldIdxs[i]); sqlStringUpper = sqlStringUpper + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[i]) + specChar; } } } pQFilt.WhereClause = sqlString; AAState.WriteLine(" " + pQFilt.WhereClause + " used to search for matching record"); int intRecFound = 0; if (sourceLayer == null) { intRecFound = pTbl.Table.RowCount(pQFilt); } else { intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt); } AAState.WriteLine(" " + intRecFound + " rows found using " + sqlString); if (intRecFound != 1) { pQFilt.WhereClause = sqlStringUpper; AAState.WriteLine(" " + pQFilt.WhereClause + " used to search for matching record"); if (sourceLayer == null) { intRecFound = pTbl.Table.RowCount(pQFilt); } else { intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt); } AAState.WriteLine(" " + intRecFound + " rows found"); if (intRecFound == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain20")); ICursor pCurs = null; if (sourceLayer == null) { pCurs = pTbl.Table.Search(pQFilt, true); } else { pCurs = sourceLayer.FeatureClass.Search(pQFilt, true) as ICursor; } pQFilt = null; List<string> pLst = Globals.CursorToList(ref pCurs, sourceFieldNums); if (pCurs != null) Marshal.ReleaseComObject(pCurs); pCurs = null; string disFld = ""; for (int j = 0; j < sourceFieldNames.Length - 1; j++) { disFld = disFld == "" ? sourceFieldNames[j] : disFld + "|" + sourceFieldNames[j]; } string selectVal = Globals.showOptionsForm(pLst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain21") + disFld, ComboBoxStyle.DropDownList); if (selectVal == "||Cancelled||") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain22") + selectVal); string[] strVals = selectVal.Split('|'); for (int i = 0; i < sourceFieldNums.Length; i++) { inObject.set_Value(intFldIdxs[i], (strVals[i].Trim())); } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain23")); } pQFilt = null; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14e") + valData); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14f")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "VALIDATE_ATTRIBUTE_LOOKUP" + Environment.NewLine + ex.Message); } finally { pQFilt = null; sqlSyntax = null; pRowCh = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "VALIDATE_ATTRIBUTE_LOOKUP"); } break; } case "PREVIOUS_VALUE": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "PREVIOUS_VALUE"); IRowChanges pRowCh = null; try { if ((valData != null) && (inObject != null)) { pRowCh = inObject as IRowChanges; bool valueChanged = false; for (int i = 0; i < intFldIdxs.Count; i++) { if (pRowCh.get_ValueChanged(intFldIdxs[i]) == true) { valueChanged = true; break; } } if (valueChanged == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain24")); continue; } string[] sourceFieldNames = null; // Parse arguments args = valData.Split('|'); if (args.Length == 1) { sourceFieldNames = args[0].ToString().Split(','); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d")); continue; } if ((sourceFieldNames != null) && (sourceFieldNames.Length > 0)) { int flx = inObject.Fields.FindField(sourceFieldNames[0]); if (flx > 0) { inObject.set_Value(flx, pRowCh.get_OriginalValue(intFldIdxs[0])); inObject.Store(); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14e") + valData); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14f")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "PREVIOUS_VALUE" + Environment.NewLine + ex.Message); } finally { pRowCh = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "PREVIOUS_VALUE"); } break; } case "ANGLE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "ANGLE"); if (inFeature != null) { if (intFldIdxs.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain25")); continue; } if ((inFeature.Class as IFeatureClass).ShapeType != esriGeometryType.esriGeometryPolyline) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain26")); continue; } bool boolGeo = true; if (valData.Trim() != "") { if (valData.ToUpper() == "A") { boolGeo = false; } } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain27")); IPolyline pLyLine = inFeature.Shape as IPolyline; ILine pLine = new LineClass(); pLine.ToPoint = pLyLine.FromPoint; pLine.FromPoint = pLyLine.ToPoint; double angArth = pLine.Angle * 180 / Math.PI; if (angArth < 0) { angArth = 360 + angArth; } double angGeo = 270 - angArth; if (angGeo < 0) { angGeo = 360 + angGeo; } double ang; if (boolGeo) { ang = angGeo; } else { ang = angArth; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain28") + ang); try { inObject.set_Value(intFldIdxs[0], ang); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain29")); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain30")); } pLine = null; pLyLine = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain31")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "ANGLE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "ANGLE"); } break; case "CREATE_PERP_LINE"://Layer to Search For|Offset Distante or Field|Search distance to look for a line|UseSnapPoint|TargetLayer|TargetLayerTemplate try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CREATE_PERP_LINE"); if (inFeature != null & valData != null) { sourceLayerName = ""; double offsetVal = 5; bool useSnapPnt = false; string targetLayerName = ""; IFeatureLayer targetLayer = null; string targetLayerTemp = ""; // Parse arguments args = valData.Split('|'); int fldOff = -1; if (args.GetLength(0) == 6) { sourceLayerNames = args[0].ToString().Split(','); if (Globals.IsNumeric(args[1])) Double.TryParse(args[1], out offsetVal); else { fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]); } Double.TryParse(args[2], out searchDistance); Boolean.TryParse(args[3], out useSnapPnt); targetLayerName = args[4]; targetLayerTemp = args[5]; } else if (args.GetLength(0) == 5) { sourceLayerNames = args[0].ToString().Split(','); if (Globals.IsNumeric(args[1])) Double.TryParse(args[1], out offsetVal); else { fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]); } Double.TryParse(args[2], out searchDistance); Boolean.TryParse(args[3], out useSnapPnt); targetLayerName = args[4]; targetLayerTemp = ""; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14av")); continue; } if (intFldIdxs.Count > 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain32")); continue; } targetLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref boolLayerOrFC); if (targetLayer == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14g") + targetLayerName); continue; } if (targetLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14h") + targetLayerName); continue; } if (targetLayer is ICadastralFabricSubLayer2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14i") + targetLayerName); continue; } for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString(); if (sourceLayerName != "") sourceLayerName = args[i].ToString(); if (i == 0) i++; boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14b") + sourceLayer + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); continue; } if (fldOff != -1) { try { string temp = inObject.get_Value(fldOff).ToString(); if (Globals.IsNumeric(temp)) { Double.TryParse(temp, out offsetVal); } } catch { } } IPolyline pTempLine = new PolylineClass(); pTempLine = Globals.CreateAngledLineFromLocationOnLine((IPoint)inFeature.Shape, sourceLayer, boolLayerOrFC, Globals.ConvertDegToRads(90), offsetVal, "true", true, false); IEditTemplate pTemp = null; IFeature pFeat = null; if (targetLayerTemp != "") pTemp = Globals.GetEditTemplate(targetLayerTemp, targetLayer); if (pTemp != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain33")); pFeat = Globals.CreateFeature(pTempLine, pTemp, AAState._editor, ArcMap.Application, false, false, false); } else { pFeat = Globals.CreateFeature(pTempLine, targetLayer, AAState._editor, ArcMap.Application, false, false, false); } if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain34")); NewFeatureList.Add(pFeat); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CREATE_PERP_LINE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "CREATE_PERP_LINE"); } break; case "AUTONUMBER"://Layer to Search For|Offset Distante or Field|Search distance to look for a line try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "AUTONUMBER"); if (inObject != null) { if (intFldIdxs.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain25")); continue; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain35") + strFldNames[0]); string res = Globals.GetFieldStats(inObject.Class as IFeatureClass, strFldNames[0], Globals.statsType.Max); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain36") + res); if (res == "External component has thrown an exception.") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain37")); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cm")); long val = 1; try { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14co")); inObject.set_Value(intFldIdxs[0], val); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString()); } } else { if (Globals.IsNumeric(res)) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cs")); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cr") + res); try { long val = (Convert.ToInt64(res) + 1); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cq") + res); try { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14co") + res); inObject.set_Value(intFldIdxs[0], val); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az") + res); } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString()); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString()); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cp")); long val = 1; inObject.set_Value(intFldIdxs[0], val); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cn") + res); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cm")); long val = 1; try { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14co") + res); inObject.set_Value(intFldIdxs[0], val); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az") + res); } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString()); } } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "AUTONUMBER: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "AUTONUMBER"); } break; case "COPY_LINKED_RECORD"://Feature Layer|Field To Copy|Primary Key Field|Foreign Key Field { try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "COPY_LINKED_RECORD"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length != 4) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } if (inObject == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak")); break; } string[] targetLayerNames; string targetFieldName = ""; found = false; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs")); targetLayerNames = args[0].ToString().Split(','); targetFieldName = args[1].ToString(); string targetLayerName = ""; string sourceIDFieldName = args[2].ToString(); string targetIDFieldName = args[3].ToString(); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt")); if (targetFieldName != null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cj")); int fldIDSourecIdx = Globals.GetFieldIndex(inObject.Fields, sourceIDFieldName); if (fldIDSourecIdx > -1 && intFldIdxs.Count > 0) { if (inObject.get_Value(fldIDSourecIdx) != null && inObject.get_Value(fldIDSourecIdx) != DBNull.Value) { if (inObject.get_Value(fldIDSourecIdx).ToString() != "") { for (int i = 0; i < targetLayerNames.Length; i++) { targetLayerName = targetLayerNames[i].ToString().Trim(); if (targetLayerName != "") { // Get layer AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cl")); bool FCorLayerSource = true; sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref FCorLayerSource); if (sourceLayer != null) { int fldValToCopyIdx = sourceLayer.FeatureClass.Fields.FindField(targetFieldName); int fldIDTargetIdx = sourceLayer.FeatureClass.Fields.FindField(targetIDFieldName); if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1) { IQueryFilter pQFilt = Globals.createQueryFilter(); if (sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString) { pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'"; } else { pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx); } IFeatureCursor pCurs; pCurs = sourceLayer.FeatureClass.Search(pQFilt, true); IFeature pRow; while ((pRow = pCurs.NextFeature()) != null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf")); try { inObject.set_Value(intFldIdxs[0], pRow.get_Value(fldValToCopyIdx)); break; } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]); } pRow = null; } pRow = null; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd")); if (pCurs != null) Marshal.ReleaseComObject(pCurs); pCurs = null; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k")); } } else { ITable pTable = Globals.FindTable(AAState._editor.Map, targetLayerName); if (pTable != null) { int fldValToCopyIdx = Globals.GetFieldIndex(pTable.Fields, targetFieldName); int fldIDTargetIdx = Globals.GetFieldIndex(pTable.Fields, targetIDFieldName); if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1) { IQueryFilter pQFilt = Globals.createQueryFilter(); if (pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString) { pQFilt.WhereClause = "" + pTable.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'"; } else { pQFilt.WhereClause = pTable.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx); } ICursor pCurs; pCurs = pTable.Search(pQFilt, true); IRow pRow; bool valSet = false; pRow = pCurs.NextRow(); while (pRow != null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf")); try { inObject.set_Value(intFldIdxs[0], pRow.get_Value(fldValToCopyIdx)); AAState.WriteLine(" " + pRow.get_Value(fldValToCopyIdx).ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ch")); valSet = true; break; } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]); } pRow = pCurs.NextRow(); } pRow = null; if (valSet) AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd")); else AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ce")); if (pCurs != null) Marshal.ReleaseComObject(pCurs); pCurs = null; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ax") + sourceLayerName); } pTable = null; } } } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ck")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_LINKED_RECORD" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "COPY_LINKED_RECORD"); } break; } case "UPDATE_LINKED_RECORD"://Feature Layer|Field To Copy|Primary Key Field|Foreign Key Field { try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_LINKED_RECORD"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length != 4) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } if (inObject == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak")); break; } IRowChanges pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false && mode != "ON_CREATE") { AAState.WriteLine(" PROMPT: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ck")); pRowCh = null; continue; } else { pRowCh = null; string[] targetLayerNames; string targetFieldName = ""; found = false; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs")); targetLayerNames = args[0].ToString().Split(','); targetFieldName = args[1].ToString(); string targetLayerName = ""; string sourceIDFieldName = args[2].ToString(); string targetIDFieldName = args[3].ToString(); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt")); if (targetFieldName != null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cj")); int fldIDSourecIdx = Globals.GetFieldIndex(inObject.Fields, sourceIDFieldName); if (fldIDSourecIdx > -1 && intFldIdxs.Count > 0) { if (inObject.get_Value(fldIDSourecIdx) != null && inObject.get_Value(fldIDSourecIdx) != DBNull.Value) { if (inObject.get_Value(fldIDSourecIdx).ToString() != "") { for (int i = 0; i < targetLayerNames.Length; i++) { targetLayerName = targetLayerNames[i].ToString().Trim(); if (targetLayerName != "") { // Get layer AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ci")); bool FCorLayerSource = true; sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref FCorLayerSource); if (sourceLayer != null) { int fldValToCopyIdx = sourceLayer.FeatureClass.Fields.FindField(targetFieldName); int fldIDTargetIdx = sourceLayer.FeatureClass.Fields.FindField(targetIDFieldName); if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1) { IQueryFilter pQFilt = Globals.createQueryFilter(); if (sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString) { pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'"; } else { pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx); } IFeatureCursor pCurs; pCurs = sourceLayer.FeatureClass.Search(pQFilt, true); IFeature pRow; bool valSet = false; while ((pRow = pCurs.NextFeature()) != null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cg")); try { pRow.set_Value(fldValToCopyIdx, inObject.get_Value(intFldIdxs[0])); pRow.Store(); AAState.WriteLine(" " + inObject.get_Value(intFldIdxs[0]).ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ch")); valSet = true; } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(intFldIdxs[0]).ToString() + " to field: " + targetFieldName); } pRow = null; } pRow = null; if (valSet) AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd")); else AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ce")); if (pCurs != null) Marshal.ReleaseComObject(pCurs); pCurs = null; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k")); } } else { ITable pTable = Globals.FindTable(AAState._editor.Map, targetLayerName); if (pTable != null) { int fldValToCopyIdx = Globals.GetFieldIndex(pTable.Fields, targetFieldName); int fldIDTargetIdx = Globals.GetFieldIndex(pTable.Fields, targetIDFieldName); if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1) { IQueryFilter pQFilt = Globals.createQueryFilter(); if (pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString) { pQFilt.WhereClause = "" + pTable.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'"; } else { pQFilt.WhereClause = pTable.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx); } ICursor pCurs; pCurs = pTable.Search(pQFilt, false); IRow pRow; bool valSet = false; pRow = pCurs.NextRow(); while (pRow != null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf")); try { pRow.set_Value(fldValToCopyIdx, inObject.get_Value(intFldIdxs[0])); pRow.Store(); AAState.WriteLine(" " + inObject.get_Value(intFldIdxs[0]).ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ch")); valSet = true; } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]); } pRow = pCurs.NextRow(); } pRow = null; if (valSet) AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd")); else AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ce")); if (pCurs != null) Marshal.ReleaseComObject(pCurs); pCurs = null; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ax") + sourceLayerName); } pTable = null; } } } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ay")); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_LINKED_RECORD" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_LINKED_RECORD"); } break; } case "OFFSET"://Layer to Search For|Offset Distante or Field|Search distance to look for a line try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "OFFSET"); if (inFeature != null & valData != null) { sourceLayerName = ""; double offsetVal = 5; // Parse arguments args = valData.Split('|'); int fldOff = -1; if (args.GetLength(0) >= 3) { sourceLayerNames = args[0].ToString().Split(','); if (Globals.IsNumeric(args[1])) Double.TryParse(args[1], out offsetVal); else { fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]); } Double.TryParse(args[2], out searchDistance); } else if (args.GetLength(0) >= 2) { sourceLayerNames = args[0].ToString().Split(','); if (Globals.IsNumeric(args[1])) Double.TryParse(args[1], out offsetVal); else { fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]); } Double.TryParse("1", out searchDistance); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14av")); continue; } if (intFldIdxs.Count != 2) { AAState.WriteLine( A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bn")); continue; } // Get layer for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString(); if (sourceLayerName != "") sourceLayerName = args[i].ToString(); if (i == 0) i++; boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14b") + sourceLayer + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); continue; } IFeatureClass iFC = inFeature.Class as IFeatureClass; if (sourceLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayer + " is a polygon layer"); break; } if (sourceLayer != null) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, true); } } else { fCursor = sourceLayer.FeatureClass.Search(sFilter, true); } while ((sourceFeature = fCursor.NextFeature()) != null) { double dAlong = 0; if (sourceFeature.Class != inFeature.Class) { IPoint pIntPnt; if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint; } else pIntPnt = inFeature.ShapeCopy as IPoint; IPoint snapPnt = null; dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt); snapPnt = null; pIntPnt = null; } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { IPoint pIntPnt; if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint; } else pIntPnt = inFeature.ShapeCopy as IPoint; IPoint snapPnt = null; dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt); snapPnt = null; pIntPnt = null; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cc") + dAlong); IPoint pNewPt = new PointClass(); IConstructPoint2 pConsPoint = pNewPt as IConstructPoint2; if (fldOff != -1) { string temp = inObject.get_Value(fldOff).ToString(); if (Globals.IsNumeric(temp)) { Double.TryParse(temp, out offsetVal); } } pConsPoint.ConstructOffset (sourceFeature.Shape as ICurve, esriSegmentExtension.esriNoExtension, dAlong, false, offsetVal); inObject.set_Value(intFldIdxs[0], pNewPt.X); inObject.set_Value(intFldIdxs[1], pNewPt.Y); pNewPt = null; pConsPoint = null; } } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "OFFSET: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "OFFSET"); } break; case "SIDE": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "SIDE"); try { //Layer|IDField|IDField source if ((valData != null) && (inFeature != null)) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb")); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData); sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; string inputFieldName = ""; args = valData.Split('|'); if (args.Length < 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SIDE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bm")); continue; } switch (args.Length) { case 3: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString(); inputFieldName = args[2].ToString(); break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SIDE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bm")); continue; } int fldValToCopyIdx = inObject.Fields.FindField(inputFieldName); if (fldValToCopyIdx > -1) { for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString(); if (sourceLayerName != "") { boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer != null) { // Get layer AAState.WriteLine(" " + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bz")); int fldValTargetJoinIdx = Globals.GetFieldIndex(sourceLayer, sourceFieldName); if (fldValTargetJoinIdx > -1) { IQueryFilter pQFilt = Globals.createQueryFilter(); if (sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Type == esriFieldType.esriFieldTypeString) { pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Name + "" + " = '" + inObject.get_Value(fldValToCopyIdx).ToString() + "'"; } else { pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Name + " = " + inObject.get_Value(fldValToCopyIdx); } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bx") + pQFilt.WhereClause); int cnt = sourceLayer.FeatureClass.FeatureCount(pQFilt); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14by") + cnt); if (cnt > 0) { fCursor = sourceLayer.FeatureClass.Search(pQFilt, true); while ((sourceFeature = fCursor.NextFeature()) != null) { bool side = false; if (Globals.GetPointOnLine(inFeature.Shape, sourceFeature.Shape, 450, out side) != null) { if (side) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain38")); inFeature.set_Value(intFldIdxs[0], "Right"); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain39")); inFeature.set_Value(intFldIdxs[0], "Left"); } if (fCursor != null) Marshal.ReleaseComObject(fCursor); fCursor = null; continue; } } if (fCursor != null) Marshal.ReleaseComObject(fCursor); fCursor = null; } pQFilt = null; } } } } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SIDE" + Environment.NewLine + ex.Message); } finally { if (fCursor != null) Marshal.ReleaseComObject(fCursor); fCursor = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "SIDE"); } break; } case "PROMPT": { //Loop through all fields list in the fieldname //If blank or null, prompt user for value //Store Value IDomain pDom = default(IDomain); ISubtypes pSubType = null; List<Globals.DomSubList> lst = null; Globals.DomSubList dmRetVal = null; try { if ((inObject != null)) { pSubType = (ISubtypes)inObject.Class; if (pSubType.HasSubtype) { int intSub; if (intFldIdxs.Contains(pSubType.SubtypeFieldIndex)) { lst = Globals.SubtypeToList(pSubType); if (inObject.get_Value(pSubType.SubtypeFieldIndex) == null || inObject.get_Value(pSubType.SubtypeFieldIndex) == "" || inObject.get_Value(pSubType.SubtypeFieldIndex) == DBNull.Value) { dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + pSubType.SubtypeFieldName, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + pSubType.SubtypeFieldName, ComboBoxStyle.DropDownList); inObject.set_Value(pSubType.SubtypeFieldIndex, dmRetVal.Value); intSub = Convert.ToInt32(dmRetVal.Value); } else { intSub = Convert.ToInt32(inObject.get_Value(pSubType.SubtypeFieldIndex)); } for (int l = 0; l < strFldNames.Count; l++) { if (intFldIdxs[l] == pSubType.SubtypeFieldIndex) continue; if (intFldIdxs[l] != -1) { pDom = pSubType.get_Domain(intSub, inObject.Fields.get_Field(intFldIdxs[l]).Name); if (pDom == null) { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { IList<string> pVals = new List<string>(); string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + strFldAlias[l], ComboBoxStyle.DropDown); try { inObject.set_Value(intFldIdxs[l], strRetVal); } catch { } pVals = null; } } else { if (pDom is CodedValueDomain) { lst = Globals.DomainToList(pDom); if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDownList); try { inObject.set_Value(intFldIdxs[l], dmRetVal.Value); } catch { } lst = null; } } else { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { IList<string> pVals = new List<string>(); string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown); try { inObject.set_Value(intFldIdxs[l], strRetVal); } catch { } pVals = null; } } } } else { AAState.WriteLine(" PROMPT: " + strFldNames[l] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } } else { if (inObject.get_Value(pSubType.SubtypeFieldIndex) == null) intSub = pSubType.DefaultSubtypeCode; else intSub = Convert.ToInt32(inObject.get_Value(pSubType.SubtypeFieldIndex)); for (int l = 0; l < strFldNames.Count; l++) { if (intFldIdxs[l] != -1) { pDom = pSubType.get_Domain(intSub, inObject.Fields.get_Field(intFldIdxs[l]).Name); if (pDom == null) { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { IList<string> pVals = new List<string>(); string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown); try { inObject.set_Value(intFldIdxs[l], strRetVal); } catch { } pVals = null; } } else { if (pDom is CodedValueDomain) { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { lst = Globals.DomainToList(pDom); dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDownList); try { inObject.set_Value(intFldIdxs[l], dmRetVal.Value); } catch { } lst = null; } } else { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { IList<string> pVals = new List<string>(); string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown); try { inObject.set_Value(intFldIdxs[l], strRetVal); } catch { } pVals = null; } } } } else { AAState.WriteLine(" PROMPT: " + strFldNames[l] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } } } else { for (int l = 0; l < strFldNames.Count; l++) { if (intFldIdxs[l] != -1) { pDom = inObject.Fields.get_Field(intFldIdxs[l]).Domain; if (pDom == null) { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { IList<string> pVals = new List<string>(); string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown); try { inObject.set_Value(intFldIdxs[l], strRetVal); } catch { } pVals = null; } } else { if (pDom is CodedValueDomain) { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { lst = Globals.DomainToList(pDom); dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDownList); try { inObject.set_Value(intFldIdxs[l], dmRetVal.Value); } catch { } lst = null; } } else { if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value) { IList<string> pVals = new List<string>(); string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown); try { inObject.set_Value(intFldIdxs[l], strRetVal); } catch { } pVals = null; } } } } else { AAState.WriteLine(" PROMPT: " + strFldNames[l] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "PROMPT" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "PROMPT"); pDom = null; pSubType = null; lst = null; dmRetVal = null; } break; } case "CASCADE_ATTRIBUTE": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CASCADE_ATTRIBUTE"); string flds; string targetLayer; IRowChanges pRowCh = null; try { if ((valData != null) && (inObject != null)) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb")); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData); //field name is the field to Check //value|Layer|tempalte|Cut or Copy|field-toField args = valData.Split('|'); if (args.Length < 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bl")); continue; } targetLayer = args[0]; flds = args[1]; bool bPrompt; if (args.Length == 3) { if (args[2].ToUpper() == "T" || args[2].ToUpper() == "TRUE" || args[2].ToUpper() == "YES") { bPrompt = true; } else { bPrompt = false; } } else { bPrompt = true; } pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bk")); continue; } bool boolFoundAsLayer = true; sourceLayer = Globals.FindLayer(ArcMap.Application, args[0].ToString(), ref boolFoundAsLayer) as IFeatureLayer; if (sourceLayer == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bj")); continue; } int intTargFld = -1; intTargFld = sourceLayer.FeatureClass.Fields.FindField(flds); if (intTargFld == -1) { intTargFld = sourceLayer.FeatureClass.Fields.FindFieldByAliasName(flds); if (intTargFld != -1) { flds = sourceLayer.FeatureClass.Fields.get_Field(intTargFld).Name; } } if (intTargFld > -1) { bool proceed = true; if (pRowCh.get_OriginalValue(intFldIdxs[0]).ToString().Trim() == "") continue; IQueryFilter pQFilt = new QueryFilterClass(); if (sourceLayer.FeatureClass.Fields.get_Field(intTargFld).Type == esriFieldType.esriFieldTypeString) { pQFilt.WhereClause = flds + " = '" + pRowCh.get_OriginalValue(intFldIdxs[0]) + "'"; } else { pQFilt.WhereClause = flds + " = " + pRowCh.get_OriginalValue(intFldIdxs[0]) + ""; } int featCnt = sourceLayer.FeatureClass.FeatureCount(pQFilt); if (featCnt == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain40")); } else { string promptLayname; promptLayname = Globals.getClassName(sourceLayer); if (bPrompt) { if (MessageBox.Show("You are about to change " + featCnt + " rows in the " + promptLayname + " Feature Class, proceed?", "Cascade", MessageBoxButtons.YesNo) == DialogResult.Yes) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain41")); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain42")); proceed = false; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain43")); } if (proceed) { IFeatureCursor pCalcCursor = sourceLayer.FeatureClass.Update(pQFilt, false); IFeature updateFeat; if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } while ((updateFeat = pCalcCursor.NextFeature()) != null) { updateFeat.set_Value(intTargFld, inObject.get_Value(intFldIdxs[0])); ChangeFeatureList.Add(updateFeat); //if (!trackCancel.Continue()) //{ // AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); // AAState._editor.AbortOperation(); // return false; //} } updateFeat = null; if (pCalcCursor != null) { Marshal.ReleaseComObject(pCalcCursor); } pCalcCursor = null; pQFilt = null; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bi")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE" + Environment.NewLine + ex.Message); } finally { sourceLayer = null; pRowCh = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "CASCADE_ATTRIBUTE"); } break; } case "COPY_FEATURE": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "COPY_FEATURE"); IFeatureLayer pTargetFL; string[] FldPairs; string targetValue; IRowChanges pRowCh = null; IFeature pNewFeat = null; try { if ((valData != null) && (inFeature != null)) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb")); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData); //field name is the field to Check //value|Layer|tempalte|Cut or Copy|field-toField args = valData.Split('|'); if (args.Length < 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bh")); continue; } targetValue = args[0]; pRowCh = inObject as IRowChanges; if (intFldIdxs.Count > 0) { if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false && mode != "ON_CREATE") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain44")); continue; } if (inFeature.get_Value(intFldIdxs[0]).ToString() != targetValue.ToString()) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain45")); continue; } } bool FCorLayerTarget = true; pTargetFL = Globals.FindLayer(ArcMap.Application, args[1].ToString(), ref FCorLayerTarget) as IFeatureLayer; if (pTargetFL == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bg")); continue; } if (Globals.IsEditable(ref pTargetFL, ref AAState._editor) == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14be")); continue; } if (pTargetFL.FeatureClass.ShapeType != (inFeature.Class as IFeatureClass).ShapeType) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bf")); continue; } FldPairs = null; //value|Layer|tempalte|Cut or Copy|field-toField IEditTemplate pEditTemp = null; string sourceAction = "COPY"; string fldMatching = null; switch (args.Length) { //case 2: // break; case 3: if (args[2].Trim() != "") { pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim()); } else { pEditTemp = null; } break; case 4: if (args[2].Trim() != "") { pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim()); } else { pEditTemp = null; } sourceAction = args[3].ToUpper().Trim(); break; case 5: if (args[2].Trim() != "") { pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim()); } else { pEditTemp = null; } sourceAction = args[3].ToUpper().Trim(); fldMatching = args[4].Trim(); break; } if (pEditTemp != null) { pNewFeat = Globals.CreateFeature(inFeature.ShapeCopy, pEditTemp, AAState._editor, ArcMap.Application, false, false, false); } else { pNewFeat = Globals.CreateFeature(inFeature.ShapeCopy, pTargetFL, AAState._editor, ArcMap.Application, false, false, false); } pEditTemp = null; if (fldMatching != null) { if (fldMatching == "") { FldPairs = new string[] { }; } else { FldPairs = fldMatching.Split(','); } } else { FldPairs = new string[] { }; } List<string> targFilds = new List<string>(); foreach (string strFlpPair in FldPairs) { string[] fldMatch = strFlpPair.Split('-'); if (fldMatch.Length != 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bd")); } else { string strSrcFldName = fldMatch[0]; string strTarFldName = fldMatch[1]; int intSrcFldIdx = Globals.GetFieldIndex((inFeature.Class as IFeatureClass).Fields, (strSrcFldName)); int intTarFldIdx = Globals.GetFieldIndex(pTargetFL.FeatureClass.Fields, strTarFldName); if (intSrcFldIdx == -1 || intTarFldIdx == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bc")); } else { targFilds.Add(strTarFldName.ToUpper()); try { pNewFeat.set_Value(intTarFldIdx, inFeature.get_Value(intSrcFldIdx)); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bb") + strFlpPair); } } } } IFields pTarFields = pTargetFL.FeatureClass.Fields; IField pTarField = null; for (int i = 0; i < pTarFields.FieldCount; i++) { pTarField = pTarFields.get_Field(i); if (pTarField.Type != esriFieldType.esriFieldTypeGlobalID && pTarField.Type != esriFieldType.esriFieldTypeOID && pTarField.Type != esriFieldType.esriFieldTypeGeometry && pTarField.Name.ToUpper() != "SHAPE_LENGTH" && pTarField.Name.ToUpper() != "SHAPE.LEN" && pTarField.Name.ToUpper() != "SHAPE_AREA" && pTarField.Name.ToUpper() != "SHAPE.AREA") { if (targFilds.Contains(pTarField.Name.ToUpper()) == false) { int fldIdx = inFeature.Fields.FindField(pTarField.Name); if (fldIdx > 0) { try { pNewFeat.set_Value(i, inFeature.get_Value(fldIdx)); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain46") + pTarField.Name); } } } } } pTarFields = null; pTarField = null; if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } NewFeatureList.Add(pNewFeat); if (sourceAction == "CUT") { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain47")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain48")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE" + Environment.NewLine + ex.Message); } finally { pTargetFL = null; pRowCh = null; pNewFeat = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "COPY_FEATURE"); } break; } case "VALIDATE_CONNECTIVITY": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "VALIDATE_CONNECTIVITY"); try { if ((valData != null) && (inFeature != null)) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain49")); bool validFeat = false; if (inFeature is INetworkFeature) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain50")); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData); args = valData.Split('|'); int connectionCnt = Globals.getConnectionCount(inFeature); foreach (string fldConPair in args) { string[] fldCon = fldConPair.Split(','); if (fldCon.Length == 1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain51")); if (Globals.IsNumeric(fldCon[0])) { if (connectionCnt == Convert.ToInt32(fldCon[0])) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain53")); } } else { if (intFldIdxs.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain51")); if (fldCon.Length == 2) { if (connectionCnt == Convert.ToInt32(fldCon[1])) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } if (fldCon.Length > 2) { if (connectionCnt >= Convert.ToInt32(fldCon[1]) && connectionCnt <= Convert.ToInt32(fldCon[2])) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } } else if (inFeature.get_Value(intFldIdxs[0]).ToString() == fldCon[0]) { if (fldCon.Length == 2) { if (connectionCnt == Convert.ToInt32(fldCon[1])) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } if (fldCon.Length > 2) { if (connectionCnt >= Convert.ToInt32(fldCon[1]) && connectionCnt <= Convert.ToInt32(fldCon[2])) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } } } } if (validFeat == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain54")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain48")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "VALIDATE_CONNECTIVITY" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "VALIDATE_CONNECTIVITY"); } break; } case "VALIDATE_ATTRIBUTES": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "VALIDATE_ATTRIBUTES"); try { if ((valData != null) && (inFeature != null)) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb")); IRowChanges pRowCh = inObject as IRowChanges; changed = true; if (intFldIdxs != null && intFldIdxs.Count > 0 && mode != "ON_CREATE") { for (int fldIdx = 0; fldIdx < intFldIdxs.Count; fldIdx++) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain55")); changed = pRowCh.get_ValueChanged(intFldIdxs[fldIdx]); AAState.WriteLine(" " + strFldNames[fldIdx] + " changed value was " + changed); if (changed) break; } } if (changed) { args = valData.Split('|'); args = args[0].Split(','); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain56") + args); if (args.Length > 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain57")); IList<ILayer> pLayList = Globals.FindLayersByClassID(((IMxDocument)ArcMap.Application.Document).FocusMap, inObject.Class.ObjectClassID); if (pLayList != null) { if (pLayList.Count > 0) { AAState.WriteLine(" " + pLayList.Count + " Layers found"); bool ValidComb = false; foreach (ILayer pLay in pLayList) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain58") + pLay.Name); if (pLay is IFeatureLayer) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain59")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain60")); IEditTemplateManager pEdTmpManager = Globals.GetEditTemplateManager((IFeatureLayer)pLay); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain61")); ValidComb = Globals.FeatureIsValidTemplate(pEdTmpManager, inFeature, args); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain62") + ValidComb.ToString()); if (ValidComb == true) break; } } if (ValidComb == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain63")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain63")); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain64")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "VALIDATE_ATTRIBUTES" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "VALIDATE_ATTRIBUTES"); } break; } case "SPLIT_INTERSECTING_FEATURE": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "SPLIT_INTERSECTING_FEATURE"); try { if ((valData != null) && (inFeature != null)) { intersectLayerName = ""; intersectLayer = null; args = valData.Split('|'); if (args.Length > 0) { AAState.WriteLine(" " + args.Length + " Layers listed "); for (int i = 0; i < args.Length; i++) { intersectLayerName = args[i].Trim(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain65") + intersectLayerName); boolLayerOrFC = true; if (intersectLayerName.Contains("(")) { string[] tempSplt = intersectLayerName.Split('('); intersectLayerName = tempSplt[0]; intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer; if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer; } if (intersectLayer != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain66") + intersectLayerName); if (intersectLayer.FeatureClass != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain67") + intersectLayerName); double snapTol = Globals.GetXYTolerance(intersectLayer); sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain68")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain69") + intersectLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain70")); pFS = (IFeatureSelection)intersectLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = intersectLayer.Search(sFilter, true); } } else { fCursor = intersectLayer.FeatureClass.Search(sFilter, true); } IFeature intsersectFeature; int idx = 1; while ((intsersectFeature = fCursor.NextFeature()) != null) { if (intsersectFeature.Class != inFeature.Class) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain71") + idx); idx++; if (intsersectFeature is INetworkFeature) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain72")); } else { ISet featset = Globals.splitLineWithPoint(intsersectFeature, inFeature.ShapeCopy as IPoint, snapTol, null, "{0:0.00}", ArcMap.Application); if (featset != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain73")); if (featset.Count > 0) { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } object featobj; while ((featobj = featset.Next()) != null) { IFeature feature = featobj as IFeature; if (feature != null) { NewFeatureList.Add(feature as IObject); } feature = null; } } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain74") + intersectLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain75") + featset.Count); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain76")); } featset = null; } } if (intsersectFeature != null) { Marshal.ReleaseComObject(intsersectFeature); } else if (intsersectFeature.Class == inFeature.Class && intsersectFeature.OID != inFeature.OID) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain71") + idx); idx++; if (intsersectFeature is INetworkFeature) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain72")); } else { ISet featset = Globals.splitLineWithPoint(intsersectFeature, inFeature.ShapeCopy as IPoint, snapTol, null, "{0:0.00}", ArcMap.Application); if (featset == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain77")); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain73")); if (featset.Count > 0) { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } object featobj; while ((featobj = featset.Next()) != null) { IFeature feature = featobj as IFeature; if (feature != null) { NewFeatureList.Add(feature as IObject); } feature = null; } } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain74") + intersectLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain75") + featset.Count); } featset = null; } if (intsersectFeature != null) { Marshal.ReleaseComObject(intsersectFeature); } } } intsersectFeature = null; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain78") + intersectLayerName); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14l") + valData); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14m")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SPLIT_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "SPLIT_INTERSECTING_FEATURE"); } break; } case "NEAREST_FEATURE_ATTRIBUTES": { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "NEAREST_FEATURE_ATTRIBUTES"); try { if ((valData != null) && (inFeature != null)) { sourceLayerName = ""; string[] sourceFieldNames = null; string[] destFieldNames = null; searchDistance = 0; // Parse arguments args = valData.Split('|'); if (args.Length == 3) { sourceLayerName = args[0].ToString().Trim(); sourceFieldNames = args[1].ToString().Split(','); destFieldNames = args[2].ToString().Split(','); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain79")); } else if (args.Length == 4) { sourceLayerName = args[0].ToString().Trim(); sourceFieldNames = args[1].ToString().Split(','); destFieldNames = args[2].ToString().Split(','); Double.TryParse(args[3], out searchDistance); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d")); continue; } if ((sourceFieldNames != null) && (destFieldNames != null) && (sourceFieldNames.Length > 0) && (destFieldNames.Length > 0) && (sourceFieldNames.Length == destFieldNames.Length)) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain13") + sourceLayerName); boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer; if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer; } if (sourceLayer != null) { if (sourceLayer.FeatureClass != null) { AAState.WriteLine(" " + sourceLayer.Name + " layer Found: " + sourceLayerName); string missingFieldMess = null; int[] sourceFieldNums = new int[sourceFieldNames.Length]; int[] destFieldNums = new int[destFieldNames.Length]; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain80")); for (int i = 0; i < sourceFieldNums.Length; i++) { int fnum = sourceLayer.FeatureClass.FindField(sourceFieldNames[i].Trim()); if (fnum < 0) { missingFieldMess = sourceFieldNames[i].Trim() + " in table " + sourceLayerName; break; } sourceFieldNums[i] = fnum; } if (missingFieldMess == null) { for (int i = 0; i < destFieldNums.Length; i++) { int fnum = inFeature.Fields.FindField(destFieldNames[i].Trim()); if (fnum < 0) { missingFieldMess = destFieldNames[i].Trim() + " in table " + tableName; break; } destFieldNums[i] = fnum; } } if (missingFieldMess == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain81")); // found source and destination fields. if (searchDistance > 0) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false); } else { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain82")); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, false, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, false); } } else { fCursor = sourceLayer.FeatureClass.Search(sFilter, false); } sourceFeature = fCursor.NextFeature(); nearestFeature = null; proxOp = (IProximityOperator)inFeature.Shape; lastDistance = searchDistance; if (sourceFeature != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain83")); while (sourceFeature != null) { if (sourceFeature.Class != inFeature.Class) { IGeometry pTempGeo = sourceFeature.ShapeCopy; pTempGeo.Project(inFeature.Shape.SpatialReference); distance = proxOp.ReturnDistance(pTempGeo); pTempGeo = null; if (distance <= lastDistance) { nearestFeature = sourceFeature; lastDistance = distance; } } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { IGeometry pTempGeo = sourceFeature.ShapeCopy; pTempGeo.Project(inFeature.Shape.SpatialReference); distance = proxOp.ReturnDistance(pTempGeo); pTempGeo = null; if (distance <= lastDistance) { nearestFeature = sourceFeature; lastDistance = distance; } } sourceFeature = fCursor.NextFeature(); } } if (nearestFeature != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain84") + lastDistance + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain85") + nearestFeature.OID); for (int i = 0; i < sourceFieldNums.Length; i++) { try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain86") + sourceFieldNames[i] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain87") + destFieldNames[i]); inObject.set_Value(destFieldNums[i], nearestFeature.get_Value(sourceFieldNums[i])); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14n") + sourceFieldNames[i] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain87") + destFieldNames[i]); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain88")); for (int i = 0; i < destFieldNums.Length; i++) { IField field = inObject.Fields.get_Field(destFieldNums[i]); object newval = field.DefaultValue; if (newval == null) { if (field.IsNullable) { inObject.set_Value(destFieldNums[i], null); } } else { inObject.set_Value(destFieldNums[i], newval); } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14o") + missingFieldMess); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayerName + " data source is not set"); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14e") + valData); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14f")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "NEAREST_FEATURE_ATTRIBUTES" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "NEAREST_FEATURE_ATTRIBUTES"); } break; } case "MINIMUM_LENGTH": { try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "MINIMUM_LENGTH"); double minlength; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain89")); if (Double.TryParse(valData, out minlength)) { if (inFeature != null) { ICurve curve = inFeature.Shape as ICurve; if (curve != null) { if (curve.Length < minlength) { String mess = "Line is shorter than " + String.Format("{0:0.00}", minlength) + " " + Globals.GetSpatRefUnitName(inFeature.Shape.SpatialReference, true) + ", aborting edit."; AAState.WriteLine(" " + mess); MessageBox.Show(mess, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain90")); AAState._editor.AbortOperation(); return false; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14p")); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "MINIMUM_LENGTH \n" + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "MINIMUM_LENGTH"); } break; } case "LINK_TABLE_ASSET": try { intersectLayerName = ""; intersectTable = null; intersectLayer = null; List<string> intersectLayerFieldNameList = new List<string>(); List<int> intersectFieldPosList = new List<int>(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LINK_TABLE_ASSET"); args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // Feature Layer only intersectLayerName = args[0].ToString(); break; case 2: // Feature Layer| Field to copy intersectLayerName = args[0].ToString(); intersectLayerFieldNameList = new List<string>(args[1].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); break; case 3: // Feature Layer| Field to copy | for future intersectLayerName = args[0].ToString(); intersectLayerFieldNameList = new List<string>(args[1].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14q") + valData); continue; } bool FCorLayerIntersect = true; intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref FCorLayerIntersect); intersectTable = Globals.FindStandAloneTable(AAState._editor.Map, intersectLayerName); if (intersectLayer != null) { //Find Area Field foreach (string intersectLayerFieldName in intersectLayerFieldNameList) { intersectFieldPos = intersectLayer.FeatureClass.Fields.FindField(intersectLayerFieldName); if (intersectFieldPos < 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14r") +"(" + intersectLayerFieldName + ") not found"); break; } else { intersectFieldPosList.Add(intersectFieldPos); } } intersectLayerSelection = (IFeatureSelection)intersectLayer; if (intersectLayerSelection.SelectionSet.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14s") + intersectLayerName); break; } if (intersectLayerSelection.SelectionSet.Count > 1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14t") + intersectLayerName); break; } intersectLayerSelection.SelectionSet.Search(null, true, out cCurs); } else if (intersectTable != null) { if (intersectTable.Table == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14u") + "(" + intersectLayerName + ") not found"); break; } foreach (string intersectLayerFieldName in intersectLayerFieldNameList) { intersectFieldPos = intersectTable.Table.Fields.FindField(intersectLayerFieldName); if (intersectFieldPos < 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14v") + "(" + intersectLayerFieldName + ") not found"); break; } else { intersectFieldPosList.Add(intersectFieldPos); } } intersectTableSelection = (ITableSelection)intersectTable; if (intersectTableSelection.SelectionSet.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14s") + intersectLayerName); break; } if (intersectTableSelection.SelectionSet.Count > 1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14t") + intersectLayerName); break; } intersectTableSelection.SelectionSet.Search(null, true, out cCurs); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14u") + "(" + intersectLayerName + ") not found"); break; } IRow row; while ((row = cCurs.NextRow()) != null) { int idx = 0; foreach (int fldIdxInt in intersectFieldPosList) { if (idx >= intFldIdxs.Count) continue; string val = row.get_Value(fldIdxInt).ToString(); if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeString) inObject.set_Value(intFldIdxs[idx], val); else if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeSmallInteger || inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeInteger) { if (Globals.IsNumeric(val)) { inObject.set_Value(intFldIdxs[idx], Convert.ToInt32(val)); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14w") + val); } } else if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeSingle || inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeDouble) { if (Globals.IsNumeric(val)) { inObject.set_Value(intFldIdxs[idx], Convert.ToDouble(val)); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14x") + val); } } else { inObject.set_Value(intFldIdxs[idx], val); } idx++; } } if (row != null) Marshal.ReleaseComObject(cCurs); row = null; } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LINK_TABLE_ASSET" + Environment.NewLine + ex.Message); } finally { if (cCurs != null) { Marshal.ReleaseComObject(cCurs); GC.Collect(300); GC.WaitForFullGCComplete(); cCurs = null; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LINK_TABLE_ASSET"); } break; case "GET_ADDRESS_FROM_CENTERLINE": AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GET_ADDRESS_FROM_CENTERLINE"); List<IPoint> pPnts = null; try { if ((valData != null) && (inFeature != null)) { sourceLayerName = ""; string[] sourceFieldNames = null; searchDistance = 0; // Parse arguments args = valData.Split('|'); if (args.Length == 2) { sourceLayerName = args[0].ToString().Trim(); sourceFieldNames = args[1].ToString().Split(','); searchDistance = 2; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain79")); } else if (args.Length == 3) { sourceLayerName = args[0].ToString().Trim(); sourceFieldNames = args[1].ToString().Split(','); Double.TryParse(args[2], out searchDistance); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d")); continue; } if (sourceFieldNames.Length != 5) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14y")); continue; } boolLayerOrFC = false; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } pPnts = Globals.GetGeomCenter(inObject as IFeature); if (pPnts.Count != 0) { AddressInfo pRetValu = Globals.GetAddressInfo(ArcMap.Application, pPnts[0] as IPoint, sourceLayerName, sourceFieldNames[0].Trim(), sourceFieldNames[1].Trim(), sourceFieldNames[2].Trim(), sourceFieldNames[3].Trim(), sourceFieldNames[4].Trim(), false, searchDistance); if (pRetValu != null) { if (pRetValu.Messages == "") { bool rightSide = true; IPoint pPnt = Globals.GetPointOnLine((inObject as IFeature).Shape as IPoint, pRetValu.StreetGeometry as IPolyline, 400, out rightSide); try { if (strFldNames.Count == 2) { if (intFldIdxs[0] != -1) { if (rightSide) { inObject.set_Value(intFldIdxs[0], pRetValu.RightAddress); } else { inObject.set_Value(intFldIdxs[0], pRetValu.LeftAddress); } } if (intFldIdxs[1] != -1) inObject.set_Value(intFldIdxs[1], pRetValu.StreetName); } else { if (intFldIdxs[0] != -1) { if (rightSide) { inObject.set_Value(intFldIdxs[0], pRetValu.RightAddress + " " + pRetValu.StreetName); } else { inObject.set_Value(intFldIdxs[0], pRetValu.LeftAddress + " " + pRetValu.StreetName); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14z") + Environment.NewLine + ex.Message); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aa") + pRetValu.Messages); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ab")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ac")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GET_ADDRESS_FROM_CENTERLINE" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GET_ADDRESS_FROM_CENTERLINE"); pPnts = null; } break; case "GET_ADDRESS_USING_GEOCODER": { IReverseGeocoding reverseGeocoding = null; IAddressGeocoding addressGeocoding = null; IPoint revGCLoc = null; IFields matchFields = null; IField shapeField = null; IReverseGeocodingProperties reverseGeocodingProperties = null; IPropertySet addressProperties = null; IAddressInputs addressInputs = null; IFields addressFields = null; object key = null; object value = null; try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GET_ADDRESS_USING_GEOCODER"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length != 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain91")); reverseGeocoding = Globals.OpenLocator(args[0], args[1]); if (reverseGeocoding == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ae")); break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain92")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain93")); revGCLoc = Globals.GetGeomCenter(inFeature)[0]; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain94")); // Create a Point at which to find the address. addressGeocoding = (IAddressGeocoding)reverseGeocoding; matchFields = addressGeocoding.MatchFields; int shpFld = matchFields.FindField("Shape"); shapeField = matchFields.get_Field(shpFld); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain95")); // Set the search tolerance for reverse geocoding. reverseGeocodingProperties = (IReverseGeocodingProperties)reverseGeocoding; reverseGeocodingProperties.SearchDistance = 100; reverseGeocodingProperties.SearchDistanceUnits = esriUnits.esriFeet; reverseGeocoding.InitDefaults(); // Find the address nearest the Point. addressProperties = reverseGeocoding.ReverseGeocode(revGCLoc, false); // Print the address properties. addressInputs = (IAddressInputs)reverseGeocoding; addressFields = addressInputs.AddressFields; addressProperties.GetAllProperties(out key, out value); string tempVal = ""; for (int i = 0; i < addressFields.FieldCount; i++) { IField addressField = addressFields.get_Field(i); if (tempVal == "") { tempVal = addressProperties.GetProperty(addressField.Name).ToString(); } else { tempVal = tempVal + ", " + addressProperties.GetProperty(addressField.Name).ToString(); } } inFeature.set_Value(intFldIdxs[0], tempVal); } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GET_ADDRESS_USING_GEOCODER" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GET_ADDRESS_USING_GEOCODER"); reverseGeocoding = null; addressGeocoding = null; revGCLoc = null; matchFields = null; shapeField = null; reverseGeocodingProperties = null; addressProperties = null; addressInputs = null; addressFields = null; key = null; value = null; } break; } case "GET_ADDRESS_USING_ARCGIS_SERVICE": //ARGS: url try { IPoint revGCLoc = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GET_ADDRESS_USING_ARCGIS_SERVICE"); if (fieldObj.Type == esriFieldType.esriFieldTypeString) { if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty)) { args = valData.Split('|'); revGCLoc = Globals.GetGeomCenter(inFeature)[0]; int wkid = inFeature.Shape.SpatialReference.FactoryCode; if (revGCLoc != null) { //Test for user specified URL if (valData.Trim() != "") { if (args.Length == 2) { wkid = Convert.ToInt32(args[1]); } if (Globals.IsUrl(args[0])) { locatorURL = args[0]; if (!(locatorURL.EndsWith(reverseGeocodeStr))) { if (!(locatorURL.EndsWith(GeocodeStr))) { if (!(locatorURL.EndsWith("/"))) { locatorURL += "/" + GeocodeStr + "/" + reverseGeocodeStr; } else { locatorURL += GeocodeStr + "/" + reverseGeocodeStr; } } else { if (!(locatorURL.EndsWith("/"))) { locatorURL += "/" + reverseGeocodeStr; } else { locatorURL += reverseGeocodeStr; } } } } //else if (args[0] == "TA_Streets_US_10") //{ // locatorURL = _agsOnlineLocators + args[0] + GeocodeStr + "/" + reverseGeocodeStr; // // wkid = 102100; //} //else if (args[0] == "TA_Address_NA_10" || args[0] == "TA_Address_EU") //{ // locatorURL = _agsOnlineLocators + args[0] + GeocodeStr + "/" + reverseGeocodeStr; // // wkid = 4326; //} ////Default to AGS Online USA geocode service //else if (_agsOnlineLocators.Substring(_agsOnlineLocators.LastIndexOf('/', _agsOnlineLocators.Length - 2)).Contains("Locator")) //{ // locatorURL = _agsOnlineLocators + "TA_Address_NA_10" + GeocodeStr + "/" + reverseGeocodeStr; // // wkid = 4326; //} else { locatorURL = _agsOnlineLocators + GeocodeStr + "/" + reverseGeocodeStr; ; // wkid = 4326; } } else { if (_agsOnlineLocators.Substring(_agsOnlineLocators.LastIndexOf('/', _agsOnlineLocators.Length - 2)).Contains(GeocodeStr)) { locatorURL = _agsOnlineLocators + "/" + reverseGeocodeStr; // wkid = 4326; } else { _agsOnlineLocators = _agsOnlineLocators + "/" + GeocodeStr; locatorURL = _agsOnlineLocators + "/" + reverseGeocodeStr; // wkid = 4326; } } if (!locatorURL.ToUpper().Contains("/REST/")) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14af")); } else { //Copy point from this current feature _copyPoint = revGCLoc;//inFeature.ShapeCopy as IPoint; StreamReader reader = null; HttpWebRequest request = null; try { // Create the web request request = WebRequest.Create(_agsOnlineLocators) as HttpWebRequest; // Get response using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { // Get the response stream reader = new StreamReader(response.GetResponseStream()); string resp = reader.ReadToEnd(); resp = resp.Substring(resp.IndexOf("Spatial Reference:")); resp = resp.Substring(0, resp.IndexOf("<br/>")); resp = resp.Substring(resp.IndexOf("</b>") + 4); wkid = Convert.ToInt32(resp.Split(' ')[0]); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain96")); wkid = 4326; } finally { reader = null; request = null; } _copyPoint.Project(Globals.CreateSpatRef(wkid)); //Include location parameters in URL string results = Globals.FormatLocationRequest(locatorURL, _copyPoint.X, _copyPoint.Y, 100); //Send and receieve the request WebRequest req = null; WebResponse res = null; XmlDictionaryReader xr = null; XmlDocument doc = null; try { req = WebRequest.Create(results); res = req.GetResponse(); //Convert response from JSON to XML doc = new XmlDocument(); using (Stream s = res.GetResponseStream()) { xr = JsonReaderWriterFactory.CreateJsonReader(s, XmlDictionaryReaderQuotas.Max); doc.Load(xr); xr.Close(); s.Close(); string val = ""; for (int h = 0; h < doc.DocumentElement.FirstChild.ChildNodes.Count - 1; h++) { if (doc.DocumentElement.FirstChild.ChildNodes[h].Name.Contains("Match") == false) { if (val == "") { val = doc.DocumentElement.FirstChild.ChildNodes[h].InnerText; } else { if (val.EndsWith(",")) val = val + " " + doc.DocumentElement.FirstChild.ChildNodes[h].InnerText; else val = val + ", " + doc.DocumentElement.FirstChild.ChildNodes[h].InnerText; } } val = val.Trim(); } inFeature.set_Value(intFldIdxs[0], val); } } catch { } finally { req = null; res = null; xr = null; doc = null; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain97")); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GET_ADDRESS_USING_ARCGIS_SERVICE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GET_ADDRESS_USING_ARCGIS_SERVICE"); } break; case "TIMESTAMP": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TIMESTAMP"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length > 0) { try { if (fieldObj.Type == esriFieldType.esriFieldTypeDate) { if (args[0].ToString().ToUpper() == "DATE") { inObject.set_Value(intFldIdxs[0], DateTime.Now.Date); } else if (args[0].ToString().Trim() != "") { try { inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString(args[0])); } catch { inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString()); } } else { inObject.set_Value(intFldIdxs[0], DateTime.Now); } } else if (fieldObj.Type == esriFieldType.esriFieldTypeString) { if (args[0].ToString().ToUpper() == "DATE") { inObject.set_Value(intFldIdxs[0], DateTime.Now.Date); } else if (args[0].ToString().ToUpper() == "TIME") { inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString("hh:mm:ss tt")); } else if (args[0].ToString().ToUpper() == "TIME24") { // ReadOnlyCollection<System.TimeZoneInfo> timeZones = System.TimeZoneInfo.GetSystemTimeZones(); // string s = System.TimeZoneInfo.ConvertTime(DateTime.Now, timeZones[0]).ToString("HH:mm:ss"); inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString("HH:mm:ss")); } else if (args[0].ToString().ToUpper() == "YEAR") { inObject.set_Value(intFldIdxs[0], DateTime.Now.Year.ToString()); } else if (args[0].ToString().ToUpper() == "MONTH") { inObject.set_Value(intFldIdxs[0], DateTime.Now.Month.ToString()); } else if (args[0].ToString().ToUpper() == "DAY") { inObject.set_Value(intFldIdxs[0], DateTime.Now.DayOfWeek.ToString()); } else if (args[0].ToString().Trim() != "") { try { inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString(args[0])); } catch { inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString()); } } else { inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString()); } } } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ag")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain98")); if (fieldObj.Type == esriFieldType.esriFieldTypeDate) inObject.set_Value(intFldIdxs[0], DateTime.Now); else if (fieldObj.Type == esriFieldType.esriFieldTypeString) inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString()); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain98")); if (fieldObj.Type == esriFieldType.esriFieldTypeDate) inObject.set_Value(intFldIdxs[0], DateTime.Now); else if (fieldObj.Type == esriFieldType.esriFieldTypeString) inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString()); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TIMESTAMP: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TIMESTAMP"); } break; case "LAST_VALUE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LAST_VALUE"); bool CheckForValue = false; if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length > 0) { if (args[0].ToString().ToUpper() == "TRUE") { CheckForValue = true; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain98")); } if (CheckForValue && (inObject.get_Value(intFldIdxs[0]) != null && inObject.get_Value(intFldIdxs[0]) != DBNull.Value)) { } else { if (mode == "ON_CREATE") { lastValue = AAState.lastValueProperties.GetProperty(strFldNames[0]) as LastValueEntry; if (lastValue == null) { if (inObject.get_Value(intFldIdxs[0]) != null) { if (inObject.get_Value(intFldIdxs[0]) != DBNull.Value) { AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0])); } } } else if (lastValue.Value != null) { if (lastValue.Value != DBNull.Value) { inObject.set_Value(intFldIdxs[0], lastValue.Value); AAState.WriteLine(" " + strFldNames[0] + ": " + lastValue.Value); } } else { if (inObject.get_Value(intFldIdxs[0]) != null) { if (inObject.get_Value(intFldIdxs[0]) != DBNull.Value) { AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0])); } } } } else if (mode == "ON_CHANGE") { IRowChanges pRowCh = inObject as IRowChanges; changed = pRowCh.get_ValueChanged(intFldIdxs[0]); if (!changed) { lastValue = AAState.lastValueProperties.GetProperty(strFldNames[0]) as LastValueEntry; if (lastValue != null) { if (lastValue.Value != null) { inObject.set_Value(intFldIdxs[0], lastValue.Value); AAState.WriteLine(" " + strFldNames[0] + ": " + lastValue.Value); } } } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LAST_VALUE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LAST_VALUE"); } break; case "X_COORDINATE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "X_COORDINATE"); if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty)) { if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { _copyPoint = inFeature.Shape as IPoint; inFeature.set_Value(intFldIdxs[0], _copyPoint.X); } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { _copyPolyline = inFeature.Shape as IPolyline; if (valData.Trim() == "") { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.X); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.X); } else { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X); } } } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { _copyPolygon = inFeature.ShapeCopy as IPolygon; if (valData.Trim() == "") { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].X); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], _copyPolygon.FromPoint.X); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], _copyPolygon.ToPoint.X); } else { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].X); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "X_COORDINATE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "X_COORDINATE"); } break; case "Y_COORDINATE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "Y_COORDINATE"); if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty)) { if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { _copyPoint = inFeature.Shape as IPoint; inFeature.set_Value(intFldIdxs[0], _copyPoint.Y); } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { _copyPolyline = inFeature.Shape as IPolyline; if (valData == "") { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.Y); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.Y); } else { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y); } } } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { _copyPolygon = inFeature.ShapeCopy as IPolygon; if (valData.Trim() == "") { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].Y); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], _copyPolygon.FromPoint.Y); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], _copyPolygon.ToPoint.Y); } else { inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].Y); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "Y_COORDINATE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "Y_COORDINATE"); } break; case "LATITUDE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LATITUDE"); if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty)) { if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { _copyPoint = inFeature.ShapeCopy as IPoint; _copyPoint.Project(AAState._sr1); inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPoint.Y.ToString())); } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { _copyPolyline = inFeature.ShapeCopy as IPolyline; _copyPolyline.Project(AAState._sr1); if (valData == "") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].Y.ToString())); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.FromPoint.Y.ToString())); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.ToPoint.Y.ToString())); } else { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].Y.ToString())); } } } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { _copyPolygon = inFeature.ShapeCopy as IPolygon; _copyPolygon.Project(AAState._sr1); if (valData.Trim() == "") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].Y.ToString())); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.FromPoint.Y.ToString())); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.ToPoint.Y.ToString())); } else { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].Y.ToString())); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LATITUDE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LATITUDE"); } break; case "LONGITUDE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LONGITUDE"); if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty)) { if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { _copyPoint = inFeature.ShapeCopy as IPoint; _copyPoint.Project(AAState._sr1); inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPoint.X.ToString())); } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { _copyPolyline = inFeature.Shape as IPolyline; _copyPolyline.Project(AAState._sr1); if (valData == "") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].X.ToString())); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.FromPoint.X.ToString())); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.ToPoint.X.ToString())); } else { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].X.ToString())); } } } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { _copyPolygon = inFeature.ShapeCopy as IPolygon; _copyPolygon.Project(AAState._sr1); if (valData.Trim() == "") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].X.ToString())); } else { args = valData.Split('|'); if (args[0].ToUpper() == "S") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.FromPoint.X.ToString())); } else if (args[0].ToUpper() == "E") { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.ToPoint.X.ToString())); } else { inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].X.ToString())); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LONGITUDE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LONGITUDE"); } break; case "FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "Field"); // verify that field to copy exists if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); fieldCopy = inObject.Fields.FindField(args[0] as string); if (fieldCopy > -1) { bool useDisplayValue = true; if (args.Length == 2) { if (args[1].ToUpper() == "CODE") useDisplayValue = false; } try { if (useDisplayValue) { inObject.set_Value(intFldIdxs[0], Globals.GetDomainDisplay(inObject.get_Value(fieldCopy), inObject as IFeature, inObject.Fields.get_Field(fieldCopy))); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } else { inObject.set_Value(intFldIdxs[0], inObject.get_Value(fieldCopy)); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + ex.Message); } } else { AAState.WriteLine(" " + valData + " is not found"); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "Field: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "Field"); } break; //CURRENT_USER //Value Data options: //U - windows username only //W or (blank) - full username including domain i.e. domain\username //D - database user if available and not dbo case "CURRENT_USER": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CURRENT_USER"); lastEditorName = AAState._currentUserInfo.GetCurrentUser(valData, fieldObj.Length); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain99") + lastEditorName); if (!String.IsNullOrEmpty(lastEditorName)) { inObject.set_Value(intFldIdxs[0], lastEditorName); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CURRENT_USER: "******"AttributeAssistantEditorMess_14as") + "CURRENT_USER"); } break; case "JUNCTION_ROTATION": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "JUNCTION_ROTATION"); if ((inFeature != null)) { AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic; args = null; AAState.rCalc.UseDiameter = false; AAState.rCalc.DiameterFieldName = ""; AAState.rCalc.SpinAngle = 0; if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length == 0) { AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic; } else if (args.Length == 1) { if (args[0].Substring(0, 1).ToLower() == "a") AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic; } else if (args.Length == 2) { if (args[0].Substring(0, 1).ToLower() == "a") AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic; if (Globals.IsNumeric(args[1].ToString())) AAState.rCalc.SpinAngle = Convert.ToDouble(args[1]); } else if (args.Length == 3) { if (args[0].Substring(0, 1).ToLower() == "a") AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic; if (Globals.IsNumeric(args[1].ToString())) AAState.rCalc.SpinAngle = Convert.ToDouble(args[1]); AAState.rCalc.UseDiameter = true; AAState.rCalc.DiameterFieldName = args[2].ToString(); } else { AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic; } } AAState.WriteLine(" " + AAState.rCalc.RotationType.ToString() + " is being used"); rotationAngle = AAState.rCalc.GetRotationUsingConnectedEdges(inFeature); if (rotationAngle == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain100")); continue; } //Accept optional second argument to provide extra rotation if (rotationAngle != -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain101") + rotationAngle.ToString()); inObject.set_Value(intFldIdxs[0], rotationAngle); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain102")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "JUNCTION_ROTATION \r\n" + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "JUNCTION_ROTATION"); } break; //For Release: 1.2 //New Dynamic Value Method: Length - stores calculated length of line feature case "LENGTH": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LENGTH"); if (inFeature != null) { curve = (ICurve)inFeature.Shape; if (curve != null) { inObject.set_Value(intFldIdxs[0], curve.Length); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LENGTH: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LENGTH"); } break; //Release: 1.2 //New Dynamic Value Method: SET_MEASURES - stores calculated M values (from 0 to length of line) for line feature //Value Data options: //P = Percent - Ms will be zero to 100 //default - Ms will be zero to length of line case "SET_MEASURES": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "SET_MEASURES"); if (inFeature != null) { curve = inFeature.Shape as ICurve; mseg = inFeature.Shape as IMSegmentation; if (curve != null && mseg != null) if (valData != null && valData != "" && valData.Substring(0, 1).ToUpper() == "P") mseg.SetAndInterpolateMsBetween(0, 100); else mseg.SetAndInterpolateMsBetween(0, curve.Length); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SET_MEASURES: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "SET_MEASURES"); } break; //case "EDGE_INTERSECT_SECOND": // try // { // if (inFeature != null) // { // netFeat = inFeature as INetworkFeature; // if (netFeat != null) // { // if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) // { // iJuncFeat = (IJunctionFeature)netFeat; // // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; // ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; // if (iSJunc == null) // break; // if (iSJunc.EdgeFeatureCount <= 1) // break; // iEdgeFeat = iSJunc.get_EdgeFeature(1); // // verify that field (in junction) to copy exists // IRow pRow = iEdgeFeat as IRow; // juncField = pRow.Fields.FindField(valData as string); // if (juncField > -1) // { // inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField)); // } // } // } // } // } // catch // { // } // break; //case "EDGE_INTERSECT_FIRST": // try // { // if (inFeature != null) // { // netFeat = inFeature as INetworkFeature; // if (netFeat != null) // { // if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) // { // iJuncFeat = (IJunctionFeature)netFeat; // // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; // ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; // if (iSJunc == null) // break; // if (iSJunc.EdgeFeatureCount <= 0) // break; // iEdgeFeat = iSJunc.get_EdgeFeature(0); // IRow pRow = iEdgeFeat as IRow; // juncField = pRow.Fields.FindField(valData as string); // if (juncField > -1) // { // inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField)); // } // } // } // } // } // catch // { // } // break; //Release: 2.0 //New Dynamic Value Method: TO_EDGE_FIELD transfers a field value from a connected egde feature to a junction feature //Takes value from the frist edge whose "TO" point connects with this junction case "TO_EDGE_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_EDGE_FIELD"); if (inFeature != null) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { iEdgeFeat = iSJunc.get_EdgeFeature(i); try { if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); continue; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField); if (intTmpFld > -1) { //IFeature pTest = ((IFeature)iEdgeFeat); if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); continue; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(pRow.Fields, netField); if (juncField > -1) { inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField)); } else { AAState.WriteLine(" " + netField + " field not found in edge"); } pRow = null; break; } } catch { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an")); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } iSJunc = null; } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_FIELD"); } break; //Release: 2.0 //New Dynamic Value Method: FROM_EDGE_FIELD transfers a field value from a connected egde feature to a junction feature //Takes value from the frist edge whose "FROM" point connects with this junction case "FROM_EDGE_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_EDGE_FIELD"); if (inFeature != null) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { iEdgeFeat = iSJunc.get_EdgeFeature(i); try { if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); continue; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField); if (intTmpFld > -1) { //IFeature pTest = ((IFeature)iEdgeFeat); if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); continue; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } iJuncFeat = iEdgeFeat.ToJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(pRow.Fields, netField); if (juncField > -1) { inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField)); } else { AAState.WriteLine(" " + iSJunc + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") ); } pRow = null; break; } } catch { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an")); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } iSJunc = null; } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FROM_EDGE_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FROM_EDGE_FIELD"); } break; case "TO_EDGE_STATS": try { if (valData == null) break; args = valData.Split('|'); string statType = "MAX"; switch (args.GetLength(0)) { case 1: sourceFieldName = args[0].ToString(); break; case 2: sourceFieldName = args[0].ToString(); statType = args[1].ToString(); break; default: break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_EDGE_STATS"); int AverageCount = 0; double result = -999999.1; string textRes = ""; if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103")); if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104")); iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); iEdgeFeat = iSJunc.get_EdgeFeature(i); try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106")); iJuncFeat = iEdgeFeat.FromJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain107")); IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain108")); juncField = pRow.Fields.FindField(sourceFieldName); string test = pRow.get_Value(juncField).ToString(); if (Globals.IsNumeric(test)) { double valToTest = Convert.ToDouble(test); if (result == -999999.1) { result = valToTest; } else { switch (statType.ToUpper()) { case "MAX": if (result < valToTest) { result = valToTest; } break; case "MIN": if (result > valToTest) { result = valToTest; } break; case "SUM": result += valToTest; break; case "AVERAGE": result += valToTest; AverageCount++; break; case "MEAN": result += valToTest; AverageCount++; break; case "CONCAT": if (textRes.Contains(valToTest.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + valToTest.ToString())) { } else { if (textRes == "") { textRes += valToTest.ToString(); } else { textRes += ConcatDelim + valToTest.ToString(); } } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": if (textRes.Contains(test.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + test.ToString())) { } else { if (textRes == "") { textRes += test; } else { textRes += ConcatDelim + test; } } break; default: AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain109")); } } catch { } }//end loop try { if (textRes != "") { inObject.set_Value(intFldIdxs[0], textRes); } else if (result != -999999.1) { if (AverageCount != 0) { result = result / AverageCount; } inObject.set_Value(intFldIdxs[0], result); } else { IField field = inObject.Fields.get_Field(intFldIdxs[0]); object newval = field.DefaultValue; if (newval == null) { if (field.IsNullable) { inObject.set_Value(intFldIdxs[0], null); } } else { inObject.set_Value(intFldIdxs[0], newval); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS"); } break; case "FROM_EDGE_STATS": try { if (valData == null) break; args = valData.Split('|'); string statType = "MAX"; switch (args.GetLength(0)) { case 1: sourceFieldName = args[0].ToString(); break; case 2: sourceFieldName = args[0].ToString(); statType = args[1].ToString(); break; default: break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_EDGE_STATS"); int AverageCount = 0; double result = -999999.1; string textRes = ""; if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103")); if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104")); iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); iEdgeFeat = iSJunc.get_EdgeFeature(i); try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106")); iJuncFeat = iEdgeFeat.ToJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain110")); IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain111")); juncField = pRow.Fields.FindField(sourceFieldName); string test = pRow.get_Value(juncField).ToString(); if (Globals.IsNumeric(test)) { double valToTest = Convert.ToDouble(test); if (result == -999999.1) { result = valToTest; } else { switch (statType.ToUpper()) { case "MAX": if (result < valToTest) { result = valToTest; } break; case "MIN": if (result > valToTest) { result = valToTest; } break; case "SUM": result += valToTest; break; case "AVERAGE": result += valToTest; AverageCount++; break; case "MEAN": result += valToTest; AverageCount++; break; case "CONCAT": if (textRes.Contains(valToTest.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + valToTest.ToString())) { } else { if (textRes == "") { textRes += valToTest.ToString(); } else { textRes += ConcatDelim + valToTest.ToString(); } } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": if (textRes.Contains(test.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + test.ToString())) { } else { if (textRes == "") { textRes += test; } else { textRes += ConcatDelim + test; } } break; default: AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain112")); } } catch { } }//end loop try { if (textRes != "") { inObject.set_Value(intFldIdxs[0], textRes); } else if (result != -999999.1) { if (AverageCount != 0) { result = result / AverageCount; } inObject.set_Value(intFldIdxs[0], result); } else { IField field = inObject.Fields.get_Field(intFldIdxs[0]); object newval = field.DefaultValue; if (newval == null) { if (field.IsNullable) { inObject.set_Value(intFldIdxs[0], null); } } else { inObject.set_Value(intFldIdxs[0], newval); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS"); } break; case "EDGE_STATS": try { if (valData == null) break; args = valData.Split('|'); string statType = "MAX"; switch (args.GetLength(0)) { case 1: sourceFieldName = args[0].ToString(); break; case 2: sourceFieldName = args[0].ToString(); statType = args[1].ToString(); break; default: break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "EDGE_STATS"); int AverageCount = 0; double result = -999999.1; string textRes = ""; if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103")); if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104")); iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); iEdgeFeat = iSJunc.get_EdgeFeature(i); try { IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain113")); juncField = pRow.Fields.FindField(sourceFieldName); string test = pRow.get_Value(juncField).ToString(); if (Globals.IsNumeric(test)) { double valToTest = Convert.ToDouble(test); if (result == -999999.1) { result = valToTest; } else { switch (statType.ToUpper()) { case "MAX": if (result < valToTest) { result = valToTest; } break; case "MIN": if (result > valToTest) { result = valToTest; } break; case "SUM": result += valToTest; break; case "AVERAGE": result += valToTest; AverageCount++; break; case "MEAN": result += valToTest; AverageCount++; break; case "CONCAT": if (textRes.Contains(valToTest.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + valToTest.ToString())) { } else { if (textRes == "") { textRes += valToTest.ToString(); } else { textRes += ConcatDelim + valToTest.ToString(); } } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": if (textRes.Contains(test.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + test.ToString())) { } else { if (textRes == "") { textRes += test; } else { textRes += ConcatDelim + test; } } break; default: AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } catch { } }//end loop try { if (textRes != "") { inObject.set_Value(intFldIdxs[0], textRes); } else if (result != -999999.1) { if (AverageCount != 0) { result = result / AverageCount; } inObject.set_Value(intFldIdxs[0], result); } else { IField field = inObject.Fields.get_Field(intFldIdxs[0]); object newval = field.DefaultValue; if (newval == null) { if (field.IsNullable) { inObject.set_Value(intFldIdxs[0], null); } } else { inObject.set_Value(intFldIdxs[0], newval); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS"); } break; case "TO_EDGE_MULTI_FIELD_INTERSECT": try { if (valData == null) break; sourceFieldName = ""; sourceField = -1; found = false; //LayerToIntersect|Field To Elevate // Parse arguments args = valData.Split('|'); int popFldIdx = 0; if (args.GetLength(0) >= 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114")); sourceFieldName = args[0].ToString(); string[] fieldsToPop = args[1].ToString().Split(','); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_EDGE_MULTI_FIELD_INTERSECT"); if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103")); if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104")); iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); iEdgeFeat = iSJunc.get_EdgeFeature(i); try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106")); iJuncFeat = iEdgeFeat.FromJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain107")); IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain108")); juncField = pRow.Fields.FindField(sourceFieldName); string test = pRow.get_Value(juncField).ToString(); if (fieldsToPop.Length == popFldIdx) break; int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]); if (tempFieldNum > -1) { inObject.set_Value(tempFieldNum, test); popFldIdx++; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain109")); } } catch { } }//end loop } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS"); } break; case "FROM_EDGE_MULTI_FIELD_INTERSECT": try { if (valData == null) break; sourceFieldName = ""; sourceField = -1; found = false; //LayerToIntersect|Field To Elevate // Parse arguments args = valData.Split('|'); int popFldIdx = 0; if (args.GetLength(0) >= 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114")); sourceFieldName = args[0].ToString(); string[] fieldsToPop = args[1].ToString().Split(','); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_EDGE_MULTI_FIELD_INTERSECT"); if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103")); if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104")); iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); iEdgeFeat = iSJunc.get_EdgeFeature(i); try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106")); iJuncFeat = iEdgeFeat.ToJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain110")); IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain111")); juncField = pRow.Fields.FindField(sourceFieldName); string test = pRow.get_Value(juncField).ToString(); if (fieldsToPop.Length == popFldIdx) break; int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]); if (tempFieldNum > -1) { inObject.set_Value(tempFieldNum, test); popFldIdx++; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain112")); } } catch { } }//end loop } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS"); } break; case "FROM_JUNCTION_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_JUNCTION_FIELD"); if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.FromJunctionFeature; if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); break; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField); if (intTmpFld > -1) { if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); break; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField); if (juncField > -1) { inObject.set_Value(intFldIdxs[0], ((IFeature)iJuncFeat).get_Value(juncField)); } else AAState.WriteLine(" " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") ); } else AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc")); } else AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain115")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FROM_JUNCTION_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FROM_JUNCTION_FIELD"); } break; //Release: 1.2 //New Dynamic Value Method: TO_JUNCTION_FIELD transfers a field value from a junction connected at terminal end of a line feature case "TO_JUNCTION_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_JUNCTION_FIELD"); if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.ToJunctionFeature; if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); break; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField); if (intTmpFld > -1) { if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); break; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField); //juncField = ((IFeature)iJuncFeat).Fields.FindField(valData as string); if (juncField > -1) { inObject.set_Value(intFldIdxs[0], ((IFeature)iJuncFeat).get_Value(juncField)); } else { AAState.WriteLine(" " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") ); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_JUNCTION_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_JUNCTION_FIELD"); } break; case "UPDATE_TO_JUNCTION_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_TO_JUNCTION_FIELD"); IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.ToJunctionFeature; if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); break; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField); if (intTmpFld > -1) { if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); break; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField); //juncField = ((IFeature)iJuncFeat).Fields.FindField(valData as string); if (juncField > -1) { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ((IFeature)iJuncFeat).set_Value(juncField, inObject.get_Value(intFldIdxs[0])); ChangeFeatureList.Add(((IFeature)iJuncFeat)); } else { AAState.WriteLine(" " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") ); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_TO_JUNCTION_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_TO_JUNCTION_FIELD"); } break; case "UPDATE_FROM_JUNCTION_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_FROM_JUNCTION_FIELD"); IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: netField = args[0].ToString().Trim(); break; case 2: netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.FromJunctionFeature; if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); break; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField); if (intTmpFld > -1) { if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); break; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField); //juncField = ((IFeature)iJuncFeat).Fields.FindField(valData as string); if (juncField > -1) { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ((IFeature)iJuncFeat).set_Value(juncField, inObject.get_Value(intFldIdxs[0])); ChangeFeatureList.Add(((IFeature)iJuncFeat)); } else { AAState.WriteLine(" " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") ); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_FROM_JUNCTION_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_FROM_JUNCTION_FIELD"); } break; case "UPDATE_FROM_EDGE_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_FROM_EDGE_FIELD"); if (inFeature != null) { IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { iEdgeFeat = iSJunc.get_EdgeFeature(i); try { if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); continue; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField); if (intTmpFld > -1) { //IFeature pTest = ((IFeature)iEdgeFeat); if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); continue; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } iJuncFeat = iEdgeFeat.ToJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { IFeature pRow = iEdgeFeat as IFeature; // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(pRow.Fields, netField); if (juncField > -1) { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } pRow.set_Value(juncField, inObject.get_Value(intFldIdxs[0])); ChangeFeatureList.Add(((IFeature)pRow)); } else { AAState.WriteLine(" " + iSJunc + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") ); } pRow = null; break; } } catch { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an")); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } iSJunc = null; } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_FROM_EDGE_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_FROM_EDGE_FIELD"); } break; case "UPDATE_TO_EDGE_FIELD": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_TO_EDGE_FIELD"); if (inFeature != null) { IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { iEdgeFeat = iSJunc.get_EdgeFeature(i); try { if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); continue; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField); if (intTmpFld > -1) { //IFeature pTest = ((IFeature)iEdgeFeat); if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); continue; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { IFeature pRow = iEdgeFeat as IFeature; // verify that field (in junction) to copy exists juncField = Globals.GetFieldIndex(pRow.Fields, netField); if (juncField > -1) { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } pRow.set_Value(juncField, inObject.get_Value(intFldIdxs[0])); ChangeFeatureList.Add(((IFeature)pRow)); } else { AAState.WriteLine(" " + netField + " field not found in edge"); } pRow = null; break; } } catch { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an")); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } iSJunc = null; } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_TO_EDGE_FIELD: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_TO_EDGE_FIELD"); } break; //***************8 case "TRIGGER_UPDATE_INTERSECTING_FEATURE"://Intersected Feature|FieldIntersectingFeatureToChange|FromFieldinModifiedFeature { try { IFeatureCursor fLocalCursor = null; IFeature sourceFeatureLocal = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_INTERSECTING_FEATURE"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length != 3) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } if (inFeature == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak")); break; } bool cont = true; if (intFldIdxs.Count > 1) { IRowChanges inChanges = inObject as IRowChanges; if (inChanges.get_ValueChanged(intFldIdxs[0])) { cont = true; } else { cont = false; } inChanges = null; } if (cont) { sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; found = false; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs")); sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); string targetFieldName = args[2].ToString().Trim(); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt")); if (sourceFieldName != null) { for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); if (sourceLayerName != "") { boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0].Trim(); sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer != null) { if (Globals.IsEditable(ref sourceLayer, ref AAState._editor)) { if (inObject.Class.ObjectClassID != sourceLayer.FeatureClass.ObjectClassID) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, false, out cCurs); fLocalCursor = cCurs as IFeatureCursor; } else { fLocalCursor = sourceLayer.Search(sFilter, false); } } else { fLocalCursor = sourceLayer.FeatureClass.Search(sFilter, false); } while ((sourceFeatureLocal = fLocalCursor.NextFeature()) != null) { try { if (sourceFeatureLocal.Class.ObjectClassID != inFeature.Class.ObjectClassID) { if (sourceFieldName == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } NewFeatureList.Add(((IFeature)sourceFeatureLocal)); } else if (sourceFieldName == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List<IObject>(); } ChangeFeatureGeoList.Add(((IFeature)sourceFeatureLocal)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(((IFeature)sourceFeatureLocal)); } } else if (sourceFeatureLocal.Class == inFeature.Class && sourceFeatureLocal.OID != inFeature.OID) { if (sourceFieldName == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } NewFeatureList.Add(((IFeature)sourceFeatureLocal)); } else if (sourceFieldName == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List<IObject>(); } ChangeFeatureGeoList.Add(((IFeature)sourceFeatureLocal)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(((IFeature)sourceFeatureLocal)); } } } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14al")); } finally { } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14b") + sourceLayerName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName); } } } if (found) { break; } } fLocalCursor = null; sourceFeatureLocal = null; } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_INTERSECTING_FEATURE"); } break; } case "TRIGGER_UPDATE_TO_JUNCTION": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_TO_JUNCTION"); IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.ToJunctionFeature; if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); break; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField); if (intTmpFld > -1) { if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); break; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } // verify that field (in junction) to copy exists if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } NewFeatureList.Add(((IFeature)iJuncFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List<IObject>(); } ChangeFeatureGeoList.Add(((IFeature)iJuncFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(((IFeature)iJuncFeat)); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_TO_JUNCTION: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_TO_JUNCTION"); } break; case "TRIGGER_UPDATE_FROM_JUNCTION": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_FROM_JUNCTION"); IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } if (inFeature != null) { netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: netField = args[0].ToString().Trim(); break; case 2: netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.FromJunctionFeature; if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); break; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField); if (intTmpFld > -1) { if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); break; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } NewFeatureList.Add(((IFeature)iJuncFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List<IObject>(); } ChangeFeatureGeoList.Add(((IFeature)iJuncFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(((IFeature)iJuncFeat)); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_FROM_JUNCTION: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_FROM_JUNCTION"); } break; case "TRIGGER_UPDATE_FROM_EDGE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_FROM_EDGE"); if (inFeature != null) { IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { iEdgeFeat = iSJunc.get_EdgeFeature(i); try { if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); continue; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField); if (intTmpFld > -1) { //IFeature pTest = ((IFeature)iEdgeFeat); if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); continue; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } iJuncFeat = iEdgeFeat.ToJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } NewFeatureList.Add(((IFeature)iEdgeFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List<IObject>(); } ChangeFeatureGeoList.Add(((IFeature)iEdgeFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(((IFeature)iEdgeFeat)); } break; } } catch { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an")); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } iSJunc = null; } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_FROM_EDGE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_FROM_EDGE"); } break; case "TRIGGER_UPDATE_TO_EDGE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_TO_EDGE"); if (inFeature != null) { IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true) { if (valData == null) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba")); break; } netFeat = inFeature as INetworkFeature; if (netFeat != null) { if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { string netField = ""; string netRestrictFC = ""; string netRestrictField = ""; string netRestrictValue = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); break; default: break; } iJuncFeat = (IJunctionFeature)netFeat; // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { iEdgeFeat = iSJunc.get_EdgeFeature(i); try { if (netRestrictFC != "") { string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class)); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName); if (strClsName != netRestrictFC) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg")); continue; } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh")); if (netRestrictField != "" && netRestrictValue != "") { int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField); if (intTmpFld > -1) { //IFeature pTest = ((IFeature)iEdgeFeat); if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl")); continue; } } else { AAState.WriteLine(" " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm")); } } iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } NewFeatureList.Add(((IFeature)iEdgeFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List<IObject>(); } ChangeFeatureGeoList.Add(((IFeature)iEdgeFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(((IFeature)iEdgeFeat)); } break; break; } } catch { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an")); } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } iSJunc = null; } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_TO_EDGE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_TO_EDGE"); } break; //***********8 //Release: 1.2 //New Dynamic Value Method: GENERATE_ID - uses value in specificed table and increments it as specified case "GENERATE_ID": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GENERATE_ID"); if (AAState._gentab != null) { sequenceColumnName = ""; sequenceColumnNum = -1; sequenceValue = -1; sequenceFixedWidth = ""; sequencePadding = 0; formatString = ""; // Parse arguments if (valData == null) break; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only sequenceColumnName = args[0].ToString(); break; case 2: // sequenceColumnName|sequenceFixedWidth sequenceColumnName = args[0].ToString(); sequenceFixedWidth = args[1].ToString(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString sequenceColumnName = args[0].ToString(); sequenceFixedWidth = args[1].ToString(); formatString = args[2].ToString(); break; default: break; } //Check for requested zero padding of sequence number if (sequenceFixedWidth != "") int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding); if (sequencePadding > 25) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain116")); AAState.WriteLine(" WARNING: " + sequencePadding + " 0's is what you have"); } else if (sequencePadding > 50) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain117")); } qFilter = new QueryFilterClass(); qFilter.WhereClause = "SEQNAME = '" + sequenceColumnName + "'"; cCurs = AAState._gentab.Update(qFilter, false); sequenceColumnNum = AAState._gentab.Fields.FindField("SEQCOUNTER"); //get value of first row, increment it, and return incremented value for (int j = 0; j < 51; j++) { row = cCurs.NextRow(); if (row == null) { break; } if (row.get_Value(sequenceColumnNum) == null) { sequenceValue = 0; } else if (row.get_Value(sequenceColumnNum).ToString() == "") { sequenceValue = 0; } else sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum)); // _editEvents.OnChangeFeature -= OnChangeFeature; // _editEvents.OnCreateFeature -= OnCreateFeature; int sequenceInt = 1; if (AAState._gentab.Fields.FindField("SEQINTERV") > 0) { if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != null) { if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != DBNull.Value) sequenceInt = Convert.ToInt32(row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV"))); } } sequenceValue = sequenceValue + sequenceInt; row.set_Value(sequenceColumnNum, sequenceValue); AAState.WriteLine(" " + row.Fields.get_Field(sequenceColumnNum).AliasName + " changed to " + sequenceValue); //AAState.changeFeature -= OnChangeFeature; //AAState.createFeature -= OnCreateFeature; row.Store(); //AAState.changeFeature += OnChangeFeature; //AAState.createFeature += OnCreateFeature; // _editEvents.OnChangeFeature += OnChangeFeature; // _editEvents.OnCreateFeature += OnCreateFeature; if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue) break; } if (sequenceValue == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ao")); } else { if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString) if (formatString == null || formatString == "" || formatString.ToLower().IndexOf("[seq]") == -1) { string setVal = (sequenceValue.ToString("D" + sequencePadding) + sequencePostfix).ToString(); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < setVal.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sequenceValue + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName); } else { inObject.set_Value(intFldIdxs[0], (sequenceValue.ToString("D" + sequencePadding) + sequencePostfix).Trim()); AAState.WriteLine(" " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix); } } else { int locIdx = formatString.ToUpper().IndexOf("[SEQ]"); if (locIdx >= 0) { formatString = formatString.Remove(locIdx, 5); formatString = formatString.Insert(locIdx, sequenceValue.ToString("D" + sequencePadding)); } //formatString = formatString.Replace("[seq]", sequenceValue.ToString("D" + sequencePadding)); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < formatString.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + formatString + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName); } else { inObject.set_Value(intFldIdxs[0], formatString.Trim()); AAState.WriteLine(" " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + formatString); } } else { inObject.set_Value(intFldIdxs[0], sequenceValue); AAState.WriteLine(" " + sequenceColumnNum + " changed to " + sequenceValue); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ap")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + ex.Message); } finally { if (cCurs != null) { Marshal.ReleaseComObject(cCurs); GC.Collect(300); GC.WaitForFullGCComplete(); cCurs = null; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GENERATE_ID"); } break; case "GENERATE_ID_BY_INTERSECT": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GENERATE_ID_BY_INTERSECT"); if (AAState._gentab != null && inFeature != null && !(inFeature.Shape.IsEmpty)) { sequenceColumnName = ""; sequenceColumnNum = -1; sequenceValue = -1; sequenceFixedWidth = ""; sequencePadding = 0; //genIdAreaFieldName = ""; intersectLayerName = ""; intersectLayerFieldName = ""; formatString = ""; intersectFieldPos = -1; // Parse arguments if (valData == null) break; args = valData.Split('|'); if (args.GetLength(0) < 3) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ap")); break; } switch (args.GetLength(0)) { case 3: //columnName intersectLayerName = args[0].ToString(); intersectLayerFieldName = args[1].ToString(); // genIdAreaFieldName = args[2].ToString(); sequenceColumnName = args[2].ToString(); break; case 4: // columnName|sequenceFixedWidth //sequenceFixedWidth formats the sequence with leading zeros to create specified width intersectLayerName = args[0].ToString(); intersectLayerFieldName = args[1].ToString(); //genIdAreaFieldName = args[2].ToString(); sequenceColumnName = args[2].ToString(); sequenceFixedWidth = Convert.ToString(0); formatString = args[3].ToString(); break; case 5: // columnName|sequenceFixedWidth|formatString //formatString must contain [seq] and [id] and may contain [area] plus any desired text intersectLayerName = args[0].ToString(); intersectLayerFieldName = args[1].ToString(); //genIdAreaFieldName = args[2].ToString(); sequenceColumnName = args[2].ToString(); sequenceFixedWidth = args[3].ToString(); formatString = args[4].ToString(); break; default: break; } //Find Area Layer // FindLayerByName(areaLayerName, out areaLayer); boolLayerOrFC = true; if (intersectLayerName.Contains("(")) { string[] tempSplt = intersectLayerName.Split('('); intersectLayerName = tempSplt[0]; intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC); } if (intersectLayer == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aq") +"(" + intersectLayerName + ") not found"); break; } //Find Area Field intersectFieldPos = intersectLayer.FeatureClass.FindField(intersectLayerFieldName); if (intersectFieldPos < 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14as") +"(" + intersectLayerFieldName + ") not found"); break; } //Perform spatial search IGeometry pSearchGeo = Globals.GetGeomCenter((IGeometry)inFeature.ShapeCopy)[0]; pSearchGeo.SpatialReference = (inFeature.Class as IGeoDataset).SpatialReference; pSearchGeo.Project((intersectLayer as IGeoDataset).SpatialReference); sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false); pFS = (IFeatureSelection)intersectLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = intersectLayer.Search(sFilter, true); } } else { fCursor = intersectLayer.FeatureClass.Search(sFilter, true); } sourceFeature = fCursor.NextFeature(); intersectValue = "-9999.1"; if (sourceFeature == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14at")); break; } else { while (sourceFeature != null) { if (sourceFeature.Class != inFeature.Class) { intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString(); break; } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString(); break; } sourceFeature = fCursor.NextFeature(); } } if (intersectValue == "-9999.1") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14at")); break; } //Check for requested zero padding of sequence number if (sequenceFixedWidth != "") int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding); if (sequencePadding > 25) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain116")); AAState.WriteLine(" WARNING: " + sequencePadding + " 0's is what you have"); } sequenceColumnName = sequenceColumnName + intersectValue; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bn") + sequenceColumnName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bo")); qFilter = new QueryFilterClass(); qFilter.WhereClause = "SEQNAME = '" + sequenceColumnName + "'"; cCurs = AAState._gentab.Update(qFilter, false); sequenceColumnNum = AAState._gentab.Fields.FindField("SEQCOUNTER"); //get value of first row, increment it, and return incremented value for (int j = 0; j < 51; j++) { row = cCurs.NextRow(); if (row == null) { break; } if (row.get_Value(sequenceColumnNum) == null) { sequenceValue = 0; } else if (row.get_Value(sequenceColumnNum).ToString() == "") { sequenceValue = 0; } else sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum)); int sequenceInt = 1; if (AAState._gentab.Fields.FindField("SEQINTERV") > 0) { if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != null) { if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != DBNull.Value) sequenceInt = Convert.ToInt32(row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV"))); } } sequenceValue = sequenceValue + sequenceInt; row.set_Value(sequenceColumnNum, sequenceValue); row.Store(); if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue) break; } if (sequenceValue == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14au")); } else { if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString) if (formatString == null || formatString == "" || (formatString.ToUpper().IndexOf("[SEQ]") == -1 && formatString.ToUpper().IndexOf("[ID]") == -1)) inObject.set_Value(intFldIdxs[0], intersectValue + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix); else { int locIdx = formatString.ToUpper().IndexOf("[ID]"); if (locIdx >= 0) { formatString = formatString.Remove(locIdx, 4); formatString = formatString.Insert(locIdx, intersectValue); } locIdx = formatString.ToUpper().IndexOf("[SEQ]"); if (locIdx >= 0) { string sequenceValuePad = sequenceValue.ToString("D" + sequencePadding); formatString = formatString.Remove(locIdx, 5); formatString = formatString.Insert(locIdx, sequenceValuePad.ToString()); } // inObject.set_Value(intFldIdxs[0], formatString); } else inObject.set_Value(intFldIdxs[0], sequenceValue); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ap")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID_BY_INTERSECT: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GENERATE_ID_BY_INTERSECT"); } break; //Modified for Release 1.2 (No longer uses ICalculator) //Requires valid VBScript expression //Can include string, numeric, and date fields by name in square brackets [] //Example: DateDiff("yyyy",[INSTALLDATE],Now()) case "EXPRESSION": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "EXPRESSION"); if (inObject != null & valData != null) { int intTargetFld = -1; if (intFldIdxs.Count == 0) { } else { intTargetFld = intFldIdxs[0]; } newValue = valData; for (int i = 0; i <= inObject.Fields.FieldCount; i++) { string strTmpFldName; int intTmpIdx; if (i == inObject.Fields.FieldCount) { testField = inObject.Fields.get_Field(intFldIdxs[0]); strTmpFldName = "#"; intTmpIdx = intFldIdxs[0]; } else { testField = inObject.Fields.get_Field(i); strTmpFldName = testField.Name; intTmpIdx = i; } int indFld = newValue.ToUpper().IndexOf("[" + strTmpFldName.ToUpper() + "]"); while (indFld >= 0) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bp") + testField.Name + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bq")); int fldLen = strTmpFldName.Length; string tmpStr1 = newValue.Substring(0, indFld + 1); string tmpStr2 = newValue.Substring(indFld + fldLen + 1); newValue = tmpStr1 + "_REPLACE_VAL_" + tmpStr2; switch (testField.Type) { case esriFieldType.esriFieldTypeString: if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "") { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("isNull")) { newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("ISNULL")) { newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True"); } else if (inObject.get_Value(intTmpIdx) == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (inObject.get_Value(intTmpIdx) == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (inObject.get_Value(intTmpIdx).ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\""); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\""); } } break; case esriFieldType.esriFieldTypeDate: if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "" || inObject.get_Value(intTmpIdx) == DBNull.Value) { if (newValue.Contains("IsNull([" + "_REPLACE_VAL_" + "])")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("isNull([" + "_REPLACE_VAL_" + "])")) { newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("ISNULL([" + "_REPLACE_VAL_" + "])")) { newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True"); } else if (inObject.get_Value(intTmpIdx) == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\""); } else if (inObject.get_Value(intTmpIdx) == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");//"\"" + inObject.get_Value(intTmpIdx).ToString() + "\""); } else if (inObject.get_Value(intTmpIdx).ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + inObject.get_Value(intTmpIdx).ToString() + "\")"); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + inObject.get_Value(intTmpIdx).ToString() + "\")"); } } break; case esriFieldType.esriFieldTypeDouble: if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "") { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("isNull")) { newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("ISNULL")) { newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True"); } else if (inObject.get_Value(intTmpIdx) == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (inObject.get_Value(intTmpIdx) == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (inObject.get_Value(intTmpIdx).ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "" + inObject.get_Value(intTmpIdx).ToString() + ""); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } else { double val; Double.TryParse(inObject.get_Value(intTmpIdx).ToString(), out val); // ' string test2 = test.ToString("N",nfi); newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", val.ToString("N", nfi)); } } break; default: if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "") { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("isNull")) { newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True"); } else if (newValue.Contains("ISNULL")) { newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True"); } else if (inObject.get_Value(intTmpIdx) == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (inObject.get_Value(intTmpIdx) == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (inObject.get_Value(intTmpIdx).ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "" + inObject.get_Value(intTmpIdx).ToString() + ""); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", inObject.get_Value(intTmpIdx).ToString()); } } break; } indFld = newValue.ToUpper().IndexOf("[" + testField.Name.ToUpper() + "]"); } } try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain118")); if (intTargetFld > -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14br") + newValue); newValue = script.Eval(newValue).ToString(); if (newValue.ToUpper() == "<Null>".ToUpper()) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain119")); inObject.set_Value(intTargetFld, DBNull.Value); } else if (inObject.get_Value(intTargetFld).ToString() != newValue) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain120") + newValue.Trim()); inObject.set_Value(intTargetFld, newValue.Trim()); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14av") + inObject.Class.AliasName + " with OID of " + inObject.OID); AAState.WriteLine(" " + ex.Message); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "EXPRESSION: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "EXPRESSION"); } break; // GUID values are calculated into text fields or into native GUID field types // When using text field you have an optional argument (valdata) to specify the format // N-none 32 chars, D-dash 36, B-braces 38, P-Parenthesis 38 case "GUID": try { if (inObject != null) { if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeGUID) inObject.set_Value(intFldIdxs[0], System.Guid.NewGuid().ToString("B")); else if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString && inObject.Fields.get_Field(intFldIdxs[0]).Length >= 32) { valData = valData.Trim(); if (valData != "N" && valData != "D" && valData != "B" && valData != "P") if (inObject.Fields.get_Field(intFldIdxs[0]).Length >= 38) valData = "B"; //Default to braces else if (inObject.Fields.get_Field(intFldIdxs[0]).Length < 36) valData = "N"; else valData = "D"; inObject.set_Value(intFldIdxs[0], System.Guid.NewGuid().ToString(valData)); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "EXPRESSION: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "EXPRESSION"); } break; case "CREATE_LINKED_RECORD"://Feature Layer|Field To Copy|Field To Populate|Primary Key Field|Foreign Key Field { try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CREATE_LINKED_RECORD"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length < 5) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } if (inObject == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak")); break; } sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; found = false; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs")); sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); string targetFieldName = args[2].ToString().Trim(); string sourceIDFieldName = args[3].ToString().Trim(); string targetIDFieldName = args[4].ToString().Trim(); int countFld = 1; if (args.Length == 6) { if (!Globals.IsNumeric(args[5].ToString().Trim())) { int fldx = Globals.GetFieldIndex(inObject.Fields, args[5].ToString().Trim()); if (fldx > 0) { string tempVal = inObject.get_Value(fldx).ToString(); if (Globals.IsNumeric(tempVal)) countFld = Convert.ToInt32(tempVal); } } else { countFld = Convert.ToInt32(args[5].ToString().Trim()); } } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt")); if (sourceFieldName != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain121")); int fldValToCopyIdx = Globals.GetFieldIndex(inObject.Fields, sourceFieldName); int fldIDToCopyIdx = Globals.GetFieldIndex(inObject.Fields, sourceIDFieldName); if (fldValToCopyIdx > -1 && fldIDToCopyIdx > -1) { for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); if (sourceLayerName != "") { // Get layer AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain122")); bool FCorLayerSource = true; sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerSource); if (sourceLayer != null) { AAState.WriteLine(" " + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } else { ITable pTable = Globals.FindTable(AAState._editor.Map, sourceLayerName); if (pTable != null) { int fldValToPopIdx = Globals.GetFieldIndex(pTable.Fields, targetFieldName); int fldIDToPopIdx = Globals.GetFieldIndex(pTable.Fields, targetIDFieldName); if (fldValToPopIdx > -1 && fldIDToPopIdx > -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain123")); IRow pNewRow; for (int j = 0; j < countFld; j++) { pNewRow = pTable.CreateRow(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain124")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain125")); try { pNewRow.set_Value(fldIDToPopIdx, inObject.get_Value(fldIDToCopyIdx)); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldIDToCopyIdx) + " to field: " + targetIDFieldName); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain126")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain127")); try { pNewRow.set_Value(fldValToPopIdx, inObject.get_Value(fldValToCopyIdx)); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + targetFieldName); } if (NewFeatureList == null) { NewFeatureList = new List<IObject>(); } IObject featobj = pNewRow as IObject; if (featobj != null) { NewFeatureList.Add(featobj); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain128")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ax") + sourceLayerName); } } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ay")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CREATE_LINKED_RECORD" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "CREATE_LINKED_RECORD"); } break; } case "UPDATE_INTERSECTING_FEATURE"://Intersected Feature|FieldIntersectingFeatureToChange|FromFieldinModifiedFeature { try { IFeatureCursor fLocalCursor = null; IFeature sourceFeatureLocal = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_INTERSECTING_FEATURE"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length != 3) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad")); break; } if (inFeature == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak")); break; } bool cont = true; if (intFldIdxs.Count > 1) { IRowChanges inChanges = inObject as IRowChanges; if (inChanges.get_ValueChanged(intFldIdxs[0])) { cont = true; } else { cont = false; } inChanges = null; } if (cont) { sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; found = false; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs")); sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); string targetFieldName = args[2].ToString().Trim(); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt")); if (sourceFieldName != null) { for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); if (sourceLayerName != "") { boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0].Trim(); sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer != null) { if (Globals.IsEditable(ref sourceLayer, ref AAState._editor)) { if (inObject.Class.ObjectClassID != sourceLayer.FeatureClass.ObjectClassID) { sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName); if (sourceField > -1) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false); int fldIdx = Globals.GetFieldIndex(inFeature.Fields, targetFieldName); AAState.WriteLine(" " + targetFieldName + " at index " + fldIdx); string test = targetFieldName; if (fldIdx > -1) { test = inFeature.get_Value(fldIdx).ToString().Trim(); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bu") + test); } AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bv") + test); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, false, out cCurs); fLocalCursor = cCurs as IFeatureCursor; } else { fLocalCursor = sourceLayer.Search(sFilter, false); } } else { fLocalCursor = sourceLayer.FeatureClass.Search(sFilter, false); } while ((sourceFeatureLocal = fLocalCursor.NextFeature()) != null) { try { if (sourceFeatureLocal.Class.ObjectClassID != inFeature.Class.ObjectClassID) { if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeString) { sourceFeatureLocal.set_Value(sourceField, test); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } else { if (Globals.IsNumeric(test)) { if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSmallInteger || sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeInteger) { sourceFeatureLocal.set_Value(sourceField, Convert.ToInt32(test)); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; //break; } else if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeDouble || sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSingle) { sourceFeatureLocal.set_Value(sourceField, Convert.ToDouble(test)); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } } } else if (sourceFeatureLocal.Class == inFeature.Class && sourceFeatureLocal.OID != inFeature.OID) { if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeString) { sourceFeatureLocal.set_Value(sourceField, test); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } else { if (Globals.IsNumeric(test)) { if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSmallInteger || sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeInteger) { sourceFeatureLocal.set_Value(sourceField, Convert.ToInt32(test)); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } else if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeDouble || sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSingle) { sourceFeatureLocal.set_Value(sourceField, Convert.ToDouble(test)); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List<IObject>(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } } } } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14al")); } finally { } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14b") + sourceLayerName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName); } } } if (found) { break; } } } fLocalCursor = null; sourceFeatureLocal = null; } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_INTERSECTING_FEATURE"); } break; } case "MULTI_FIELD_INTERSECT": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "MULTI_FIELD_INTERSECT"); if (inFeature != null & valData != null) { sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; found = false; // Parse arguments args = valData.Split('|'); int popFldIdx = 0; if (args.GetLength(0) > 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114")); sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); string[] fieldsToPop = args[2].ToString().Split(','); if (args.GetLength(0) == 4) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain129")); if (Globals.IsDouble(args[3])) { searchDistance = Convert.ToDouble(args[3]); } else { searchDistance = 0.0; } } else { searchDistance = 0.0; } if (sourceFieldName != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain130")); for (int i = 0; i < sourceLayerNames.Length; i++) { if (fieldsToPop.Length == popFldIdx) break; sourceLayerName = sourceLayerNames[i].ToString().Trim(); if (sourceLayerName != "") { boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0].Trim(); sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer != null) { if (sourceLayer.FeatureClass != null) { sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName); if (sourceField > -1) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, true); } } else { fCursor = sourceLayer.FeatureClass.Search(sFilter, true); } while ((sourceFeature = fCursor.NextFeature()) != null) { if (sourceFeature.Class != inFeature.Class) { if (fieldsToPop.Length == popFldIdx) break; string test = sourceFeature.get_Value(sourceField).ToString().Trim(); int tempFieldNum = Globals.GetFieldIndex(inObject.Fields, fieldsToPop[popFldIdx]); popFldIdx++; if (tempFieldNum > -1) { inObject.set_Value(tempFieldNum, sourceFeature.get_Value(sourceField)); } } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { if (fieldsToPop.Length == popFldIdx) break; string test = sourceFeature.get_Value(sourceField).ToString().Trim(); int tempFieldNum = Globals.GetFieldIndex(inObject.Fields, fieldsToPop[popFldIdx]); popFldIdx++; if (tempFieldNum > -1) { inObject.set_Value(tempFieldNum, sourceFeature.get_Value(sourceField)); } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14f") + sourceLayerName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14e")); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14az")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ba")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "MULTI_FIELD_INTERSECT: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "MULTI_FIELD_INTERSECT"); } break; case "INTERSECT_STATS": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECT_STATS"); if (inFeature != null & valData != null) { sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; found = false; //LayerToIntersect|Field To Elevate // Parse arguments args = valData.Split('|'); int AverageCount = 0; if (args.GetLength(0) > 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114")); sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); string statType = args[2].ToString().Trim(); if (args.GetLength(0) == 4) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain129")); if (Globals.IsDouble(args[3])) searchDistance = Convert.ToDouble(args[3]); else searchDistance = 0.0; } else { searchDistance = 0.0; } double result = -999999.1; string textRes = ""; if (sourceFieldName != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain130")); for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); if (sourceLayerName != "") { boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0].Trim(); sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer != null) { if (sourceLayer.FeatureClass != null) { sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName); if (sourceField > -1) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, true); } } else { fCursor = sourceLayer.FeatureClass.Search(sFilter, true); } sourceFeature = fCursor.NextFeature(); while (sourceFeature != null) { if (sourceFeature.Class != inFeature.Class) { string test = sourceFeature.get_Value(sourceField).ToString().Trim(); if (Globals.IsNumeric(test)) { double valToTest = Convert.ToDouble(test); if (result == -999999.1) { result = valToTest; } else { switch (statType.ToUpper()) { case "MAX": if (result < valToTest) { result = valToTest; } break; case "MIN": if (result > valToTest) { result = valToTest; } break; case "SUM": result += valToTest; break; case "AVERAGE": result += valToTest; AverageCount++; break; case "MEAN": result += valToTest; AverageCount++; break; case "CONCAT": if (textRes.Contains(valToTest.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + valToTest.ToString())) { } else { if (textRes == "") { textRes += valToTest.ToString(); } else { textRes += ConcatDelim + valToTest.ToString(); } } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": if (textRes.Contains(test.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + test.ToString())) { } else { if (textRes == "") { textRes += test; } else { textRes += ConcatDelim + test; } } break; default: AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { string test = sourceFeature.get_Value(sourceField).ToString(); if (Globals.IsNumeric(test)) { double valToTest = Convert.ToDouble(test); if (result == -999999.1) { result = valToTest; } else { switch (statType.ToUpper()) { case "MAX": if (result < valToTest) { result = valToTest; } break; case "MIN": if (result > valToTest) { result = valToTest; } break; case "SUM": result += valToTest; break; case "AVERAGE": result += valToTest; AverageCount++; break; case "MEAN": result += valToTest; AverageCount++; break; case "CONCAT": if (textRes.Contains(valToTest.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + valToTest.ToString())) { } else { if (textRes == "") { textRes += valToTest.ToString(); } else { textRes += ConcatDelim + valToTest.ToString(); } } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": if (textRes.Contains(test.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + test.ToString())) { } else { if (textRes == "") { textRes += test; } else { textRes += ConcatDelim + test; } } break; default: AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } sourceFeature = fCursor.NextFeature(); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14f") + sourceLayerName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14e")); } } try { if (textRes != "") { inObject.set_Value(intFldIdxs[0], textRes); } else if (result != -999999.1) { if (AverageCount != 0) { result = result / AverageCount; } inObject.set_Value(intFldIdxs[0], result); } else { IField field = inObject.Fields.get_Field(intFldIdxs[0]); object newval = field.DefaultValue; if (newval == null) { if (field.IsNullable) { inObject.set_Value(intFldIdxs[0], null); } } else { inObject.set_Value(intFldIdxs[0], newval); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14az")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ba")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECT_STATS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECT_STATS"); } break; case "FEATURE_STATS": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FEATURE_STATS"); if (inFeature != null & valData != null) { sourceFieldName = ""; sourceField = -1; found = false; //LayerToIntersect|Field To Elevate // Parse arguments args = valData.Split('|'); int AverageCount = 0; if (args.GetLength(0) > 1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114")); string[] sourceFieldNames = args[0].ToString().Split(','); string statType = args[1].ToString(); double result = -999999.1; string textRes = ""; if (sourceFieldNames != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain131")); for (int i = 0; i < sourceFieldNames.Length; i++) { sourceFieldName = sourceFieldNames[i].ToString(); if (sourceFieldName != "") { sourceField = Globals.GetFieldIndex(inObject.Fields, sourceFieldName); if (sourceField > -1) { string test = inObject.get_Value(sourceField).ToString(); if (Globals.IsNumeric(test)) { double valToTest = Convert.ToDouble(test); if (result == -999999.1) { result = valToTest; } else { switch (statType.ToUpper()) { case "MAX": if (result < valToTest) { result = valToTest; } break; case "MIN": if (result > valToTest) { result = valToTest; } break; case "SUM": result += valToTest; break; case "AVERAGE": result += valToTest; AverageCount++; break; case "MEAN": result += valToTest; AverageCount++; break; case "CONCAT": if (textRes.Contains(valToTest.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + valToTest.ToString())) { } else { if (textRes == "") { textRes += valToTest.ToString(); } else { textRes += ConcatDelim + valToTest.ToString(); } } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": if (textRes.Contains(test.ToString() + ConcatDelim)) { } else if (textRes.Contains(ConcatDelim + test.ToString())) { } else { if (textRes == "") { textRes += test; } else { textRes += ConcatDelim + test; } } break; default: AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } } } try { if (textRes != "") { inObject.set_Value(intFldIdxs[0], textRes); } else if (result != -999999.1) { if (AverageCount != 0) { result = result / AverageCount; } inObject.set_Value(intFldIdxs[0], result); } else { IField field = inObject.Fields.get_Field(intFldIdxs[0]); object newval = field.DefaultValue; if (newval == null) { if (field.IsNullable) { inObject.set_Value(intFldIdxs[0], null); } } else { inObject.set_Value(intFldIdxs[0], newval); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14az")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ba")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FEATURE_STATS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FEATURE_STATS"); } break; case "INTERSECTING_EDGE": try { if (valData == null) break; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: sourceFieldName = args[0].ToString(); break; case 2: sourceFieldName = args[1].ToString(); break; default: break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_EDGE"); if (inFeature != null) { netFeat = inFeature as INetworkFeature; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain132")); if (netFeat != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103")); if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104")); iJuncFeat = (IJunctionFeature)netFeat; ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature; if (iSJunc == null) break; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount); if (iSJunc.EdgeFeatureCount <= 0) break; if (iSJunc.EdgeFeatureCount > 0) { for (int i = 0; i < iSJunc.EdgeFeatureCount; i++) { iEdgeFeat = iSJunc.get_EdgeFeature(i); try { IRow pRow = iEdgeFeat as IRow; // verify that field (in junction) to copy exists AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain113")); juncField = Globals.GetFieldIndex(pRow.Fields, sourceFieldName); string test = pRow.get_Value(juncField).ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain133") + test); inObject.set_Value(intFldIdxs[0], test); continue; } catch { } }//end loop try { } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj")); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_EDGE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_EDGE"); } break; case "INTERSECTING_FEATURE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_FEATURE"); if (inFeature != null & valData != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain134")); sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; found = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain135") + valData); // Parse arguments args = valData.Split('|'); //if (args.GetLength(0) >= 2) if (args.Length >= 2) { AAState.intersectOptions strOpt = AAState.intersectOptions.First; switch (args.Length) { case 2: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString(); break; case 3: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString(); switch (args[2].ToString().ToUpper()) { case "PROMPT": strOpt = AAState.intersectOptions.PromptMulti; break; case "P": strOpt = AAState.intersectOptions.PromptMulti; break; case "CENTROID": strOpt = AAState.intersectOptions.Centroid; break; case "C": strOpt = AAState.intersectOptions.Centroid; break; case "F": strOpt = AAState.intersectOptions.First; break; case "L": strOpt = AAState.intersectOptions.Last; break; case "FIRST": strOpt = AAState.intersectOptions.First; break; } break; default: break; } if (sourceFieldName != null) { List<Globals.OptionsToPresent> pFoundFeat = new List<Globals.OptionsToPresent>(); for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); if (sourceLayerName != "") { boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0].Trim(); sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } // Get layer if (sourceLayer != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain136") + sourceLayer.Name); sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName); AAState.WriteLine(" " + sourceFieldName + ": at " + sourceField); if (sourceField > -1) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, strOpt == AAState.intersectOptions.Centroid); if (sFilter == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain137")); continue; } pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain138")); if (pFS.SelectionSet.Count > 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain139")); pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140")); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain141")); fCursor = sourceLayer.Search(sFilter, true); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain142")); fCursor = sourceLayer.FeatureClass.Search(sFilter, true); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140")); } if (fCursor == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain143")); continue; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain144")); while ((sourceFeature = fCursor.NextFeature()) != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain145")); if (sourceFeature.Class != inFeature.Class) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain146")); if (strOpt == AAState.intersectOptions.PromptMulti) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString(); pOp.Value = sourceFeature.get_Value(sourceField); if (pOp.Display.Trim() != "") { pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } pOp.OID = sourceFeature.OID; pOp.LayerName = sourceLayer.Name; pFoundFeat.Add(pOp); } else if (strOpt == AAState.intersectOptions.Last) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString(); pOp.Value = sourceFeature.get_Value(sourceField); if (pOp.Display.Trim() != "") { pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } pOp.OID = sourceFeature.OID; pOp.LayerName = sourceLayer.Name; pFoundFeat.Add(pOp); } else { string test = sourceFeature.get_Value(sourceField).ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test); inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField)); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); found = true; } } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain148")); if (strOpt == AAState.intersectOptions.PromptMulti) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString(); pOp.Value = sourceFeature.get_Value(sourceField); if (pOp.Display.Trim() != "") { pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } pOp.OID = sourceFeature.OID; pOp.LayerName = sourceLayer.Name; pFoundFeat.Add(pOp); } else if (strOpt == AAState.intersectOptions.Last) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString(); pOp.Value = sourceFeature.get_Value(sourceField); if (pOp.Display.Trim() != "") { pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } pOp.OID = sourceFeature.OID; pOp.LayerName = sourceLayer.Name; pFoundFeat.Add(pOp); } else { string test = sourceFeature.get_Value(sourceField).ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test); inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField)); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); found = true; } } if (found == true) break; } if (found == false && AAState._CheckEnvelope && pFoundFeat.Count == 0) { sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects; pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, true); } } else { fCursor = sourceLayer.FeatureClass.Search(sFilter, true); } sourceFeature = fCursor.NextFeature(); while (sourceFeature != null) { if (strOpt == AAState.intersectOptions.PromptMulti) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString(); pOp.Value = sourceFeature.get_Value(sourceField); if (pOp.Display.Trim() != "") { pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } pOp.OID = sourceFeature.OID; pOp.LayerName = sourceLayer.Name; pFoundFeat.Add(pOp); } else if (strOpt == AAState.intersectOptions.Last) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString(); pOp.Value = sourceFeature.get_Value(sourceField); if (pOp.Display.Trim() != "") { pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } pOp.OID = sourceFeature.OID; pOp.LayerName = sourceLayer.Name; pFoundFeat.Add(pOp); } else { if (found) { break; } string test = sourceFeature.get_Value(sourceField).ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test); inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField)); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); found = true; } sourceFeature = fCursor.NextFeature(); } } if (found) { break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName); } } } if (pFoundFeat.Count > 0 && strOpt == AAState.intersectOptions.PromptMulti) { Globals.OptionsToPresent strRetVal = Globals.showOptionsForm(pFoundFeat, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, ComboBoxStyle.DropDownList); if (strRetVal != null) { //sourceFeature = sourceLayer.FeatureClass.GetFeature(strRetVal.OID); string test = strRetVal.Value.ToString();//sourceFeature.get_Value(sourceField).ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test); inObject.set_Value(intFldIdxs[0], strRetVal.Value); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); found = true; } } else if (pFoundFeat.Count > 0 && strOpt == AAState.intersectOptions.Last) { //sourceFeature = sourceLayer.FeatureClass.GetFeature(pFoundFeat[pFoundFeat.Count - 1].OID); string test = pFoundFeat[pFoundFeat.Count - 1].Value.ToString(); //sourceFeature.get_Value(sourceField).ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test); inObject.set_Value(intFldIdxs[0], pFoundFeat[pFoundFeat.Count - 1].Value); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); found = true; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain150")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain151")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain152")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_FEATURE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_FEATURE"); } break; case "INTERSECTING_BOOLEAN": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_BOOLEAN"); if (inFeature != null & valData != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain134")); sourceLayerName = ""; string valTrue = ""; string valFalse = ""; found = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain135") + valData); // Parse arguments args = valData.Split('|'); //if (args.GetLength(0) >= 2) if (args.Length == 3) { AAState.intersectOptions strOpt = AAState.intersectOptions.First; switch (args.Length) { case 3: sourceLayerNames = args[0].ToString().Split(','); valTrue = args[1].ToString(); valFalse = args[2].ToString(); break; default: break; } for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); if (sourceLayerName != "") { boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0].Trim(); sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } // Get layer if (sourceLayer != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain136") + sourceLayer.Name); sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, strOpt == AAState.intersectOptions.Centroid); if (sFilter == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain137")); continue; } pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain138")); if (pFS.SelectionSet.Count > 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain139")); pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140")); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain141")); fCursor = sourceLayer.Search(sFilter, true); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain142")); fCursor = sourceLayer.FeatureClass.Search(sFilter, true); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140")); } if (fCursor == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain143")); continue; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain144")); while ((sourceFeature = fCursor.NextFeature()) != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain145")); if (sourceFeature.Class != inFeature.Class) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain146")); found = true; } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain148")); found = true; } if (found == true) break; } if (found == false && AAState._CheckEnvelope) { sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects; pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, true); } } else { fCursor = sourceLayer.FeatureClass.Search(sFilter, true); } sourceFeature = fCursor.NextFeature(); while (sourceFeature != null) { found = true; break; } } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName); } if (found) { break; } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName); } } if (found) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + valTrue); inObject.set_Value(intFldIdxs[0], valTrue); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + valFalse); inObject.set_Value(intFldIdxs[0], valFalse); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain153")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain154")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_BOOLEAN: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_BOOLEAN"); } break; case "INTERSECTING_RASTER": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_RASTER"); if (inFeature != null & valData != null) { sourceLayerName = ""; formatString = ""; found = false; // Parse arguments args = valData.Split('|'); if (args.Length < 1) break; switch (args.Length) { case 1: sourceLayerNames = args[0].ToString().Split(','); break; case 2: sourceLayerNames = args[0].ToString().Split(','); formatString = args[1].ToString(); break; default: break; } // Get layer for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); IPoint pLoc = Globals.GetGeomCenter(inFeature)[0]; if (pLoc != null) { string cellVal = Globals.GetCellValue(sourceLayerName, pLoc, AAState._editor.Map); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain155") + sourceLayerName); if (cellVal != null && cellVal != "" && cellVal != "No Raster") { if (formatString == null || formatString == "" || (inObject.Fields.get_Field(intFldIdxs[0]).Type != esriFieldType.esriFieldTypeString)) { inObject.set_Value(intFldIdxs[0], cellVal); found = true; break; } else { formatString = formatString + cellVal; inObject.set_Value(intFldIdxs[0], formatString); found = true; break; } } } } if (!(found) && inObject.Fields.get_Field(intFldIdxs[0]).IsNullable) inObject.set_Value(intFldIdxs[0], null); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_RASTER: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_RASTER"); } break; case "INTERSECTING_LAYER_DETAILS": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_LAYER_DETAILS"); if (inFeature != null & valData != null) { sourceLayerName = ""; formatString = ""; found = false; List<string> matchPattern = null; // Parse arguments args = valData.Split('|'); if (args.Length >= 1) { AAState.intersectOptions strOpt = AAState.intersectOptions.First; switch (args.Length) { case 1: sourceLayerNames = args[0].ToString().Split(','); formatString = "P"; break; case 2: sourceLayerNames = args[0].ToString().Split(','); formatString = args[1].ToString(); break; case 3: sourceLayerNames = args[0].ToString().Split(','); formatString = args[1].ToString(); switch (args[2].ToString().ToUpper()) { case "PROMPT": strOpt = AAState.intersectOptions.PromptMulti; break; case "P": strOpt = AAState.intersectOptions.PromptMulti; break; case "CENTROID": strOpt = AAState.intersectOptions.Centroid; break; case "C": strOpt = AAState.intersectOptions.Centroid; break; case "F": strOpt = AAState.intersectOptions.First; break; case "FIRST": strOpt = AAState.intersectOptions.First; break; } break; case 4: sourceLayerNames = args[0].ToString().Split(','); formatString = args[1].ToString(); switch (args[2].ToString().ToUpper()) { case "PROMPT": strOpt = AAState.intersectOptions.PromptMulti; break; case "P": strOpt = AAState.intersectOptions.PromptMulti; break; case "CENTROID": strOpt = AAState.intersectOptions.Centroid; break; case "C": strOpt = AAState.intersectOptions.Centroid; break; case "F": strOpt = AAState.intersectOptions.First; break; case "FIRST": strOpt = AAState.intersectOptions.First; break; } matchPattern = new List<string>(args[3].ToString().Split(',')); break; default: break; } List<Globals.OptionsToPresent> strFiles = new List<Globals.OptionsToPresent>(); // Get layer for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); IGeometry pGeo = inFeature.ShapeCopy; List<IGeometry> pGeos = new List<IGeometry>(); if (pGeo != null) { if (strOpt == AAState.intersectOptions.Centroid) { List<IPoint> pGeoPnts = Globals.GetGeomCenter(pGeo); pGeos = pGeoPnts.ConvertAll(new Converter<IPoint, IGeometry>(Globals.PointToGeometry)); } else { pGeos.Add(pGeo); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain156") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain157")); IEnumLayer pEnum = Globals.GetLayers(AAState._editor.Map, sourceLayerName); if (pEnum != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain158") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain157")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain159")); ILayer pLay = pEnum.Next(); while (pLay != null) { intersectLayerDetailsFunctions(pLay, pGeos, strOpt, ref found, ref strFiles, ref inObject, intFldIdxs[0], matchPattern); if (found) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain160")); break; } pLay = pEnum.Next(); } pLay = null; pEnum = null; } else { bool FCorLayerTemp = true; ILayer pLay = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerTemp); if (pLay != null) { intersectLayerDetailsFunctions(pLay, pGeos, strOpt, ref found, ref strFiles, ref inObject, intFldIdxs[0], matchPattern); } pLay = null; } if (pEnum != null) Marshal.ReleaseComObject(pEnum); pEnum = null; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain161")); } if (found) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain160")); break; } pGeo = null; pGeos = null; } if (strOpt == AAState.intersectOptions.PromptMulti && strFiles.Count > 0) { Globals.OptionsToPresent strRetVal = Globals.showOptionsForm(strFiles, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain162") + strFldNames[0], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain163") + strFldNames[0], ComboBoxStyle.DropDownList); if (strRetVal != null) { try { inObject.set_Value(intFldIdxs[0], strRetVal.Display); } catch { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain164")); } found = true; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain165")); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_LAYER_DETAILS: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_LAYER_DETAILS"); } break; case "INTERSECTING_FEATURE_DISTANCE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_FEATURE_DISTANCE"); if (inFeature != null & valData != null) { sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; // Parse arguments args = valData.Split('|'); if (args.GetLength(0) >= 2) { sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); } // Get layer if (sourceFieldName != null) { for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString(); if (sourceLayerName != "") sourceLayerName = args[i].ToString(); if (i == 0) i++; boolLayerOrFC = true; if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); if (tempSplt[1].ToUpper().Contains("LAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)")) { boolLayerOrFC = true; } else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("CLASS)")) { boolLayerOrFC = false; } else if (tempSplt[1].ToUpper().Contains("FEATURE)")) { boolLayerOrFC = false; } else { boolLayerOrFC = true; } } else { sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC); } if (sourceLayer == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14b") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); continue; } IFeatureClass iFC = inFeature.Class as IFeatureClass; if (sourceLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayer + " is a polygon layer"); break; } if (sourceLayer != null) { sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName); if (sourceField > -1) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { if (pFS.SelectionSet.Count > 0) { pFS.SelectionSet.Search(sFilter, true, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, true); } } else { fCursor = sourceLayer.FeatureClass.Search(sFilter, true); } while ((sourceFeature = fCursor.NextFeature()) != null) { if (sourceFeature.Class != inFeature.Class) { IPoint pIntPnt; if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint; } else pIntPnt = inFeature.ShapeCopy as IPoint; IPoint snapPnt = null; double dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt); snapPnt = null; string strUnit = Globals.GetSpatRefUnitName(Globals.GetLayersCoordinateSystem(sourceLayer.FeatureClass), true); if (strUnit == "Foot" && dAlong != 1) { strUnit = "Feet"; } else if (strUnit == "Meter" && dAlong != 1) { strUnit = "Meters"; } string strDis = dAlong + " " + strUnit + " along " + sourceLayer.Name + " with " + sourceLayer.FeatureClass.Fields.get_Field(sourceField).AliasName + A4LGSharedFunctions.Localizer.GetString("Of") + sourceFeature.get_Value(sourceField); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { strDis = dAlong + " " + strUnit + ": " + sourceFeature.get_Value(sourceField); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { strDis = dAlong.ToString(); inObject.set_Value(intFldIdxs[0], strDis); break; } else { inObject.set_Value(intFldIdxs[0], strDis); break; } } else { strDis = dAlong.ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { strDis = dAlong.ToString(); inObject.set_Value(intFldIdxs[0], strDis); break; } else { inObject.set_Value(intFldIdxs[0], strDis); break; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain167") + strDis); inObject.set_Value(intFldIdxs[0], strDis); break; } } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { IPoint pIntPnt; if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint; } else pIntPnt = inFeature.ShapeCopy as IPoint; IPoint snapPnt = null; double dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt); snapPnt = null; string strUnit = Globals.GetSpatRefUnitName(Globals.GetLayersCoordinateSystem(sourceLayer.FeatureClass), true); if (strUnit == "Foot" && dAlong != 1) { strUnit = "Feet"; } else if (strUnit == "Meter" && dAlong != 1) { strUnit = "Meters"; } string strDis = dAlong + " " + strUnit + " along " + sourceLayer.Name + " with " + sourceLayer.FeatureClass.Fields.get_Field(sourceField).AliasName + A4LGSharedFunctions.Localizer.GetString("Of") + sourceFeature.get_Value(sourceField); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { strDis = dAlong + " " + strUnit + ": " + sourceFeature.get_Value(sourceField); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { strDis = dAlong.ToString(); inObject.set_Value(intFldIdxs[0], strDis); break; } else { inObject.set_Value(intFldIdxs[0], strDis); break; } } else { strDis = dAlong.ToString(); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis); if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1) { strDis = dAlong.ToString(); inObject.set_Value(intFldIdxs[0], strDis); break; } else { inObject.set_Value(intFldIdxs[0], strDis); break; } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain167") + strDis); inObject.set_Value(intFldIdxs[0], strDis); break; } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayer + ": field: " + sourceFieldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { } } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_FEATURE_DISTANCE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_FEATURE_DISTANCE"); } break; //Release: 1.2 //New Dynamic Value Method: NEARSET_FEATURE - similiar to INTERSECTING_FEATURE but requires a search distance. case "NEAREST_FEATURE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "NEAREST_FEATURE"); if (inFeature != null & valData != null) { string sourceMatField = ""; string targetMatField = ""; sourceLayerName = ""; sourceFieldName = ""; searchDistance = 0; found = false; // Parse arguments args = valData.Split('|'); switch (args.Length) { case 2: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString(); break; case 3: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString(); Double.TryParse(args[2], out searchDistance); break; case 4: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain168")); break; case 5: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString(); Double.TryParse(args[2], out searchDistance); sourceMatField = args[3].ToString(); targetMatField = args[4].ToString(); break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain168")); break; } if (sourceLayerNames.Length > 0 & sourceFieldName != null) { for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString(); if (sourceLayerName != "") { bool FCorLayerSource = true; sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerSource) as IFeatureLayer; if (sourceLayer != null) { sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName); if (sourceField > -1) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false); pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain169")); if (pFS.SelectionSet.Count > 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain170")); pFS.SelectionSet.Search(sFilter, false, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = sourceLayer.Search(sFilter, false); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain171")); fCursor = sourceLayer.FeatureClass.Search(sFilter, false); } nearestFeature = null; proxOp = (IProximityOperator)inFeature.ShapeCopy; lastDistance = searchDistance; while ((sourceFeature = fCursor.NextFeature()) != null) { if (sourceFeature.Class != inFeature.Class) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain172")); if (targetMatField == "" && sourceMatField == "") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain173")); try { IGeometry pTempGeo = sourceFeature.ShapeCopy; pTempGeo.Project(inFeature.Shape.SpatialReference); distance = proxOp.ReturnDistance(pTempGeo); pTempGeo = null; if (distance <= lastDistance) { nearestFeature = sourceFeature; lastDistance = distance; } pTempGeo = null; } catch { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain174")); return false; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain175")); int idxTargetFld = Globals.GetFieldIndex(sourceLayer, targetMatField); int idxSourceFld = Globals.GetFieldIndex(inObject.Fields, sourceMatField); if (idxSourceFld >= 0 && idxTargetFld >= 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain176")); if (inObject.get_Value(idxSourceFld).ToString() == sourceFeature.get_Value(idxTargetFld).ToString()) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); IGeometry pTempGeo = sourceFeature.ShapeCopy; pTempGeo.Project(inFeature.Shape.SpatialReference); distance = proxOp.ReturnDistance(pTempGeo); pTempGeo = null; if (distance <= lastDistance) { nearestFeature = sourceFeature; lastDistance = distance; } pTempGeo = null; } else { AAState.WriteLine(" Values does not Match: " + inObject.get_Value(idxSourceFld).ToString() + " - " + sourceFeature.get_Value(idxTargetFld).ToString()); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain177")); IGeometry pTempGeo = sourceFeature.ShapeCopy; pTempGeo.Project(inFeature.Shape.SpatialReference); distance = proxOp.ReturnDistance(pTempGeo); pTempGeo = null; if (distance <= lastDistance) { nearestFeature = sourceFeature; lastDistance = distance; } pTempGeo = null; } } } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain175")); int idxTargetFld = Globals.GetFieldIndex(sourceLayer, targetMatField); int idxSourceFld = Globals.GetFieldIndex(inObject.Fields, sourceMatField); if (idxSourceFld >= 0 && idxTargetFld >= 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain176")); if (inObject.get_Value(idxSourceFld).ToString() == sourceFeature.get_Value(idxTargetFld).ToString()) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay")); IGeometry pTempGeo = sourceFeature.ShapeCopy; pTempGeo.Project(inFeature.Shape.SpatialReference); distance = proxOp.ReturnDistance(pTempGeo); pTempGeo = null; if (distance <= lastDistance) { nearestFeature = sourceFeature; lastDistance = distance; } pTempGeo = null; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain177")); IGeometry pTempGeo = sourceFeature.ShapeCopy; pTempGeo.Project(inFeature.Shape.SpatialReference); distance = proxOp.ReturnDistance(pTempGeo); pTempGeo = null; if (distance <= lastDistance) { nearestFeature = sourceFeature; lastDistance = distance; } pTempGeo = null; } } } if (nearestFeature != null) { AAState.WriteLine(" Feature found: " + nearestFeature.Class.AliasName + ":" + nearestFeature.OID); inObject.set_Value(intFldIdxs[0], nearestFeature.get_Value(sourceField)); found = true; break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayer + ": field: " + sourceFieldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + sourceLayer + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain178")); } } if (!found) { } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "NEAREST_FEATURE: " + ex.Message); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "NEAREST_FEATURE"); } break; default: AAState.WriteLine("ERROR: " + valMethod + " for layer " + tableName + " is not a valid method, check the dynamic value table"); break; } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain179") + tableName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain180") + strFldNames[0] + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain181") + valMethod + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain182") + valData + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain183") + ex.Message, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain184")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain185") + tableName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain180") + strFldNames[0] + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain181") + valMethod + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain182") + valData + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain183") + ex.Message); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain186")); } try { if (intFldIdxs.Count > 0 && strFldNames.Count > 0) { for (int p = 0; p < strFldNames.Count; p++) { IRowChanges inChanges = inObject as IRowChanges; bool changed = inChanges.get_ValueChanged(intFldIdxs[p]); if (changed) try { if (AAState.lastValueProperties.GetProperty(strFldNames[p]) != null) { LastValueEntry lstVal = AAState.lastValueProperties.GetProperty(strFldNames[p]) as LastValueEntry; if (lstVal != null) { if (mode == "ON_CREATE" && lstVal.On_Create == false) { string test = ""; } else if (mode == "ON_MANUAL" && lstVal.On_Manual == false) { string test = ""; } else if (mode == "ON_CHANGE" && lstVal.On_ChangeAtt == false) { string test = ""; } else if (mode == "ON_CHANGEGEO" && lstVal.On_ChangeGeo == false) { string test = ""; } else { if (lstVal.Value != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") ); if (mode == "ON_CREATE" && (inObject.get_Value(intFldIdxs[p]) == null || inObject.get_Value(intFldIdxs[p]).ToString() == "")) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain187")); } else { AAState.WriteLine(" " + strFldNames[p] + ": " + inObject.get_Value(intFldIdxs[p]).ToString()); lstVal.Value = inObject.get_Value(intFldIdxs[p]); AAState.lastValueProperties.SetProperty(strFldNames[p], lstVal); } } else { if (mode == "ON_CREATE" && (inObject.get_Value(intFldIdxs[p]) == null || inObject.get_Value(intFldIdxs[p]).ToString() == "")) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain187")); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") ); AAState.WriteLine(" " + strFldNames[p] + ": " + inObject.get_Value(intFldIdxs[p]).ToString()); lstVal.Value = inObject.get_Value(intFldIdxs[p]); AAState.lastValueProperties.SetProperty(strFldNames[p], lstVal); } } } } } } catch { } } } } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain188")); } AAState.WriteLine(" ------------------------------------------------"); } } } return true; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain189") + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain190") + ex.Message, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain184")); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain189")); return false; } finally { if (AAState._tab == inObject.Class || AAState._gentab == inObject.Class) { AAState.reInitExt(); } //if (progressDialog != null) //{ // progressDialog.HideDialog(); //} AAState.WriteLine("DONE"); AAState.WriteLine("---------------------------------------"); if (fCursor != null) { Marshal.ReleaseComObject(fCursor); GC.Collect(300); GC.WaitForFullGCComplete(); } inFeature = null; mseg = null; netFeat = null; iEdgeFeat = null; iJuncFeat = null; //progressDialogFactory = null; //stepProgressor = null; //progressDialog = null; //trackCancel = null; ArcMap.Application.StatusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain191")); } }
public void ScalePolyline(IPolyline Raai, double scale) { ITransform2D TransForm2D = Raai as ITransform2D; // Get the center point of the envelope. IEnvelope envelope = Raai.Envelope; IPoint centerPoint = new PointClass(); centerPoint.X = ((envelope.XMax - envelope.XMin) / 2) + envelope.XMin; centerPoint.Y = ((envelope.YMax - envelope.YMin) / 2) + envelope.YMin; TransForm2D.Scale(centerPoint, scale, scale); }
//���ݶ���ߺͷ������鴴���߳����� public static void ProfileCreateGraph(AxMapControl ppAxMapControl, IPolyline pPolyline, IArray pSewerElevArray) { IZ pPolylineZ = pPolyline as IZ; IRasterLayer pRasterLyr = FindRasterLayer("Elevation", ppAxMapControl); //��ñ�����в�ֵ ISurface pSurface = GetSurface(pRasterLyr); //����Polyline z-ware; IZAware pZAwareLineZ = pPolyline as IZAware; pZAwareLineZ.ZAware = true; //'* work around for InterpolateFromSurface sometimes flipping polyline IPoint pPtOrigFrom = pPolyline.FromPoint; IPoint pPtOrigTo = pPolyline.ToPoint; //���Zֵ��������� pPolylineZ.InterpolateFromSurface(pSurface); if (pPolyline.FromPoint.X != pPtOrigFrom.X || pPolyline.FromPoint.Y != pPtOrigFrom.Y) pPolyline.ReverseOrientation(); //���Mֵ������ IMSegmentation pMSegmentation = pPolyline as IMSegmentation; IMAware pMAware = pPolyline as IMAware; pMAware.MAware = true; pMSegmentation.SetMsAsDistance(false); //������� ITable pTable = ProfileCreateTable(); int i = 0; if (pTable != null) { //��ͼ���б�ؼ���Ҫȷ���ñ�����ڣ����������ɾ���� IStandaloneTableCollection pStandAloneTabColl = ppAxMapControl.ActiveView.FocusMap as IStandaloneTableCollection; for (i = 0; i <= pStandAloneTabColl.StandaloneTableCount - 1; i++) { if (pStandAloneTabColl.get_StandaloneTable(i).Name == "xxprofiletable") pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.get_StandaloneTable(i)); } //����һ���µĶ��������������ӵ���ͼ������ IStandaloneTable pStandAloneTab = new StandaloneTableClass(); pStandAloneTab.Table = pTable; pStandAloneTabColl = ppAxMapControl.ActiveView.FocusMap as IStandaloneTableCollection; pStandAloneTabColl.AddStandaloneTable(pStandAloneTab); pTable = pStandAloneTab as ITable; //Ϊ�����ֶ����ñ��� ITableFields pTableFields = pStandAloneTab as ITableFields; IFieldInfo pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("Z")); pFieldInfo.Alias = "Ground Elevation"; pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("SewerElev")); pFieldInfo.Alias = "Sewer Line Elevation"; //Ϊ�����һ�������� ICursor pCursor = pTable.Insert(true); IRowBuffer pRowBuff; // IPointCollection pPtCollection = pPolyline as IPointCollection; IEnumVertex pEnumVertex = pPtCollection.EnumVertices; pEnumVertex.Reset(); IPoint pPT; int iPartIndex; int iVertexIndex; i = 0; //��ӽڵ�XYZ���±���� pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex); while (pPT != null) { pRowBuff = pTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("X"), pPT.X); pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"), pPT.Y); pRowBuff.set_Value(pRowBuff.Fields.FindField("Z"), pPT.Z); pRowBuff.set_Value(pRowBuff.Fields.FindField("M"), pPT.M); pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), Convert.ToDouble(pSewerElevArray.get_Element(i))); pCursor.InsertRow(pRowBuff); pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex); i = i + 1; } pCursor.Flush(); pCursor = null; pCursor = pTable.Search(null, false); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = "SewerElev <> -99"; ICursor pCursorSewerElev = pTable.Search(pQueryFilter, false); pCursor = null; pCursor = pTable.Update(null, false); pRowBuff = pCursor.NextRow(); double m = 0; double Mmin = 0; double Mmax = 0; double deltaM = 0; double deltaSewerElev = 0; double sewerelev = 0; double newZ = 0; int j = 0; double minSewerElev = 0; double maxSewerElev = 0; IRow pRowSewerElev; while (pRowBuff != null) { if (Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("SewerElev"))) == -99) { m = Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("M"))); newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev; pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), newZ); pCursor.UpdateRow(pRowBuff as IRow); } else { if (j == 0) { pRowSewerElev = pCursorSewerElev.NextRow(); minSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmin = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); pRowSewerElev = pCursorSewerElev.NextRow(); maxSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); } else { pRowSewerElev = pCursorSewerElev.NextRow(); if (pRowSewerElev != null) { minSewerElev = maxSewerElev; Mmin = Mmax; maxSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); } } deltaSewerElev = maxSewerElev - minSewerElev; deltaM = Mmax - Mmin; sewerelev = minSewerElev; j = j + 1; } pRowBuff = pCursor.NextRow() as IRowBuffer; } pCursor.Flush(); //�ӱ���д���ͼ�� m_SewerElevStructArray = new ArrayClass(); pCursor = null; pCursor = pTable.Search(null, false); pRowSewerElev = null; pRowSewerElev = pCursor.NextRow(); //ma //while (pRowSewerElev != null) //{ // clsProfileStruct pProfileDataStruct = new clsProfileStruct(); // pProfileDataStruct.M = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); // pProfileDataStruct.Z = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Z"))); // pProfileDataStruct.dSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Sewerelev"))); // m_SewerElevStructArray.Add(pProfileDataStruct); // pRowSewerElev = pCursor.NextRow(); //} //frmDrawProfile frmDrawProfile1 = new frmDrawProfile(m_SewerElevStructArray); //frmDrawProfile1.Show(); } }
// 地下—针对管线较短情况 public bool GetPipeNodeParameterUnder(int flag, out Vector[] vtxs, out Vector dir, out IPipeSection section) { vtxs = null; dir = null; section = null; IPolyline polyline = null; if ((base._geoGroup[1] == null) || ((polyline = base._geoGroup[1] as IPolyline) == null)) { return(false); } if (polyline.PointCount < 2) { return(false); } ISegment seg = null; Vector vector = null; Vector vector2 = null; vtxs = new Vector[2]; section = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, 0.02, 0); if (flag == 0) { vector = new Vector(polyline.GetPoint(0)); vtxs[0] = new Vector(vector.X, vector.Y, vector.Z + this.OffsetZ); seg = polyline.GetSegment(0); dir = new Vector(seg); dir = dir.UnitVector(); double length = dir.Length; // 针对管线较短情况 if (length > (section.Diameter / 2)) { vector2 = vector + ((Vector)((dir * section.Diameter) / 2.0)); } else { vector2 = vector + ((Vector)((dir * length) / 2.0)); } vtxs[1] = new Vector(vector2.X, vector2.Y, vector2.Z + this.OffsetZ); } else { vector = new Vector(polyline.GetPoint(polyline.PointCount - 1)); vtxs[0] = new Vector(vector.X, vector.Y, vector.Z + this.OffsetZ); seg = polyline.GetSegment(polyline.PointCount - 2); dir = new Vector(seg); double length = dir.Length; dir = -dir.UnitVector(); // 针对管线较短情况 if (length > (section.Diameter / 2)) { vector2 = vector + ((Vector)((dir * section.Diameter) / 2.0)); } else { vector2 = vector + ((Vector)((dir * length) / 2.0)); } vtxs[1] = new Vector(vector2.X, vector2.Y, vector2.Z + this.OffsetZ); } return(true); }
public static void MakeHatchesEndsOnly(IPolyline pPL, bool Ends, IPolyline pMajor, IPolyline pMinor, double dHatchLen, double dTxtInterval, double dHatchOffset) { //��������� ITopologicalOperator pTopo = pPL as ITopologicalOperator; pTopo.Simplify(); //���ǽ��ڶμ����д洢HATCH ISegmentCollection pSCMajor = pMajor as ISegmentCollection; ISegmentCollection pSCMinor = pMinor as ISegmentCollection; //Break the polyline into parts here ... Ideally, there should be one part //per route. In cases where there is mSEETARD than one part, and there is no physical // separation in the parts, the results can look like they are wrong (i.e. there //appears to be text where there should not be). IGeometryCollection pGC = pPL as IGeometryCollection; int cnt = pGC.GeometryCount - 1; object missing = Type.Missing; object distances; double dist; for (int i = 0; i <= pGC.GeometryCount - 1; i++) { IPath pPath = pGC.get_Geometry(i) as IPath; IGeometryCollection pSubPL = new PolylineClass(); pSubPL.AddGeometry(pPath, ref missing, ref missing); IMAware pMAware = pSubPL as IMAware; pMAware.MAware = true; IMSegmentation pPLM = pSubPL as IMSegmentation; double Mmin = pPLM.MMin; double Mmax = pPLM.MMax; ISegment pSeg = MakeOneHatch(pSubPL as IPolyline, Mmin, Mmin, 1, dTxtInterval, dHatchLen, dHatchOffset); if (pSeg.Length >= ((Math.Abs(dHatchLen) * 0.5) + 0.001)) pSCMajor.AddSegment(pSeg, ref missing, ref missing); else pSCMinor.AddSegment(pSeg, ref missing, ref missing); distances = pPLM.GetDistancesAtM(false, Mmax); IArray pArray = (IArray)distances; for (int j = 0; j <= pArray.Count - 1; j++) { dist = (double)pArray.get_Element(j); pSeg = MakeOneHatch(pSubPL as IPolyline, dist, Mmax, 1, dTxtInterval, dHatchLen, dHatchOffset); if (pSeg.Length >= (Math.Abs(dHatchLen) * 0.5) + 0.001) { pSCMajor.AddSegment(pSeg, ref missing, ref missing); } else { pSCMinor.AddSegment(pSeg, ref missing, ref missing); } } } pMajor.SimplifyNetwork(); pMinor.SimplifyNetwork(); }
private void ValidateFeature(IFeature feature) { if (feature.FeatureType != esriFeatureType.esriFTSimpleJunction) { MessageService.Current.Warn("请选择管线点"); return; } if (!_pipelineConfig.IsPipelineLayer(feature.Class.AliasName, enumPipelineDataType.Point)) { MessageService.Current.Warn("请选择管线点"); return; } double snapDist = CommonUtils.ConvertPixelsToMapUnits(_context.ActiveView, _context.Config.SnapTolerance); if (this._startPoint == null && _startEid == 0) { //开始记录起始点 IPipelineLayer oldLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName, enumPipelineDataType.Point); if (oldLayer == null) { MessageService.Current.Warn("你选择的图层不是合法的管线图层!"); return; } List <IBasicLayerInfo> basicInfos = oldLayer.GetLayers(enumPipelineDataType.Junction); IFeatureClass featureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null; if (featureClass == null) { MessageService.Current.Warn("管线图层没有构建网络图层!"); return; } INetworkClass networkClass = featureClass as INetworkClass; _geometricNetwork = networkClass.GeometricNetwork; IPointToEID pnToEid = new PointToEIDClass(); pnToEid.GeometricNetwork = _geometricNetwork; pnToEid.SnapTolerance = snapDist; pnToEid.SourceMap = _context.FocusMap; pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint); return; } IPipelineLayer newLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName, enumPipelineDataType.Point); if (newLayer == null) { MessageService.Current.Warn("你选择的图层不是合法的管线图层!"); return; } List <IBasicLayerInfo> basicInfos1 = newLayer.GetLayers(enumPipelineDataType.Junction); IFeatureClass featureClass2 = basicInfos1.Count > 0 ? basicInfos1[0].FeatureClass : null; if (featureClass2 == null) { MessageService.Current.Warn("第二个管线图层没有构建网络图层!"); return; } INetworkClass networkClass2 = featureClass2 as INetworkClass; if (networkClass2.GeometricNetwork != _geometricNetwork) { if (MessageService.Current.Ask("两个点位属于不同的网络图层,使用第二个网络图层作为分析图层吗?") == false) { return; } _geometricNetwork = networkClass2.GeometricNetwork; IPointToEID pnToEid = new PointToEIDClass(); pnToEid.GeometricNetwork = _geometricNetwork; pnToEid.SnapTolerance = snapDist; pnToEid.SourceMap = _context.FocusMap; pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint); return; } try { IPointToEID pntEid = new PointToEIDClass(); pntEid.GeometricNetwork = _geometricNetwork; pntEid.SourceMap = _context.FocusMap; pntEid.SnapTolerance = snapDist; pntEid.GetNearestJunction(feature.Shape as IPoint, out _endEid, out _endPoint); if (_endEid < 1) { MessageService.Current.Warn("未能找到第二个分析点!"); return; } if (_startEid == _endEid) { MessageService.Current.Warn("起点终点为同一个点!"); return; } INetElements netElements = _geometricNetwork.Network as INetElements; IJunctionFlag[] array = new JunctionFlag[2]; INetFlag netFlag = new JunctionFlag() as INetFlag; int userClassID; int userID; int userSubID; netElements.QueryIDs(_endEid, esriElementType.esriETJunction, out userClassID, out userID, out userSubID); netFlag.UserClassID = (userClassID); netFlag.UserID = (userID); netFlag.UserSubID = (userSubID); IJunctionFlag value = netFlag as IJunctionFlag; array.SetValue(value, 0); INetFlag netFlag2 = new JunctionFlag() as INetFlag; netElements.QueryIDs(_startEid, esriElementType.esriETJunction, out userClassID, out userID, out userSubID); netFlag2.UserClassID = (userClassID); netFlag2.UserID = (userID); netFlag2.UserSubID = (userSubID); value = (netFlag2 as IJunctionFlag); array.SetValue(value, 1); ITraceFlowSolverGEN traceFlowSolverGEN = new TraceFlowSolver() as ITraceFlowSolverGEN; INetSolver netSolver = traceFlowSolverGEN as INetSolver; netSolver.SourceNetwork = _geometricNetwork.Network; traceFlowSolverGEN.PutJunctionOrigins(ref array); object[] array2 = new object[1]; IEnumNetEID enumNetEID; IEnumNetEID enumNetEID2; traceFlowSolverGEN.FindPath(esriFlowMethod.esriFMConnected, (esriShortestPathObjFn.esriSPObjFnMinMax), out enumNetEID, out enumNetEID2, 1, ref array2); if (this.ipolyline_0 == null) { this.ipolyline_0 = new Polyline() as IPolyline; } IGeometryCollection geometryCollection = this.ipolyline_0 as IGeometryCollection; geometryCollection.RemoveGeometries(0, geometryCollection.GeometryCount); if (enumNetEID2.Count <= 0) { this._iFeature = null; MessageService.Current.Warn("两点之间不存在路径可以连通!"); return; } else { ISpatialReference spatialReference = _context.FocusMap.SpatialReference; IEIDHelper eIDHelperClass = new EIDHelper(); eIDHelperClass.GeometricNetwork = _geometricNetwork; eIDHelperClass.OutputSpatialReference = (spatialReference); eIDHelperClass.ReturnGeometries = (true); IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID2); int count = enumEIDInfo.Count; enumEIDInfo.Reset(); double num2 = 0.0; for (int i = 0; i < count; i++) { IEIDInfo iEIDInfo = enumEIDInfo.Next(); IGeometry geometry = iEIDInfo.Geometry; IPolyline polyline = geometry as IPolyline; num2 += polyline.Length; geometryCollection.AddGeometryCollection(geometry as IGeometryCollection); } EsriUtils.ZoomToGeometry(this.ipolyline_0, _context.MapControl.Map, 1.3); FlashUtility.FlashGeometry(this.ipolyline_0, _context.MapControl); //_context.ActiveView.Refresh(); //CMapOperator.ShowFeatureWithWink(_context.ActiveView.ScreenDisplay, this.ipolyline_0); this._iFeature = null; _startEid = 0; _startPoint = null; _geometricNetwork = null; string text3 = string.Format("两个管线点之间连通,最短路径为{0}米", num2.ToString("f2")); MessageService.Current.Info(text3); } } catch (Exception ex) { this._iFeature = null; _startEid = 0; _startPoint = null; _geometricNetwork = null; MessageService.Current.Warn(ex.Message); } }
internal bool WriteShape(IFeature feature) { if (feature == null) { return(false); } StreamWriter sw_shx = null; StreamWriter sw_shp = null; BinaryWriter bw_shp = null; BinaryWriter bw_shx = null; FileStream fs_shx = null, fs_shp = null; try { //this.Close(); sw_shx = new StreamWriter(_file_SHX, true); sw_shp = new StreamWriter(_file_SHP, true); bw_shx = new BinaryWriter(sw_shx.BaseStream); bw_shp = new BinaryWriter(sw_shp.BaseStream); //sw_shx.BaseStream.Position = fi_shp.Length; //sw_shx.BaseStream.Position = fi_shx.Length; long pos1 = sw_shp.BaseStream.Position; uint recNumber = (uint)(sw_shx.BaseStream.Length - 100) / 8 + 1; HeaderEnvelope he = new HeaderEnvelope(); long contentsLenthPos = 0; switch (_header.ShapeType) { case ShapeType.NullShape: break; case ShapeType.PointM: case ShapeType.PointZ: case ShapeType.Point: if (!(feature.Shape is IPoint)) { return(false); } IPoint p = (IPoint)feature.Shape; he.minx = he.maxx = p.X; he.miny = he.maxy = p.Y; if (_header.ShapeType == ShapeType.PointZ) { he.minz = he.maxz = p.Z; } contentsLenthPos = WriteFeatureHeader(bw_shp, recNumber); WritePoint(bw_shp, (IPoint)feature.Shape); if (_header.ShapeType == ShapeType.PointZ) { bw_shp.Write(((IPoint)feature.Shape).Z); } if (_header.ShapeType == ShapeType.PointM || _header.ShapeType == ShapeType.PointZ) { //bw_shp.Write(((IPoint)feature.Shape).M); bw_shp.Write((double)0.0); } break; case ShapeType.MultiPointM: case ShapeType.MultiPointZ: case ShapeType.MultiPoint: if (feature.Shape is IPoint) { contentsLenthPos = WriteFeatureHeader(bw_shp, recNumber); WriteEnvelope(bw_shp, feature.Shape.Envelope, he); bw_shp.Write((int)1); WritePoint(bw_shp, (IPoint)feature.Shape); if (_header.ShapeType == ShapeType.MultiPointZ) { bw_shp.Write(((IPoint)feature.Shape).Z); } if (_header.ShapeType == ShapeType.MultiPointM || _header.ShapeType == ShapeType.MultiPointZ) { //bw_shp.Write(((IPoint)feature.Shape).M); bw_shp.Write((double)0.0); } } else if (feature.Shape is IPointCollection) { contentsLenthPos = WriteFeatureHeader(bw_shp, recNumber); WriteEnvelope(bw_shp, feature.Shape.Envelope, he); bw_shp.Write((int)((IPointCollection)feature.Shape).PointCount); WritePoints(bw_shp, (IPointCollection)feature.Shape); if (_header.ShapeType == ShapeType.MultiPointZ) { WritePointsZRange(bw_shp, (IPointCollection)feature.Shape); WritePointsZ(bw_shp, (IPointCollection)feature.Shape); } if (_header.ShapeType == ShapeType.MultiPointM || _header.ShapeType == ShapeType.MultiPointZ) { //bw_shp.Write(((IPoint)feature.Shape).M); WritePointsMRange(bw_shp, (IPointCollection)feature.Shape); WritePointsM(bw_shp, (IPointCollection)feature.Shape); } } else { return(false); } break; case ShapeType.PolyLineM: case ShapeType.PolyLineZ: case ShapeType.PolyLine: if (!(feature.Shape is IPolyline)) { return(false); } IPolyline pline = (IPolyline)feature.Shape; contentsLenthPos = WriteFeatureHeader(bw_shp, recNumber); WriteEnvelope(bw_shp, feature.Shape.Envelope, he); bw_shp.Write((int)pline.PathCount); WritePointCount(bw_shp, pline); WriteParts(bw_shp, pline); for (int i = 0; i < pline.PathCount; i++) { WritePoints(bw_shp, pline[i]); } if (_header.ShapeType == ShapeType.PolyLineM || _header.ShapeType == ShapeType.PolyLineZ) { IPointCollection pColl = gView.Framework.SpatialAlgorithms.Algorithm.GeometryPoints(pline, false); if (_header.ShapeType == ShapeType.PolyLineZ) { WritePointsZRange(bw_shp, pColl); WritePointsZ(bw_shp, pColl); } //bw_shp.Write(((IPoint)feature.Shape).M); WritePointsMRange(bw_shp, pColl); WritePointsM(bw_shp, pColl); } break; case ShapeType.PolygonM: case ShapeType.PolygonZ: case ShapeType.Polygon: if (!(feature.Shape is IPolygon)) { return(false); } IPolygon poly = (IPolygon)feature.Shape; contentsLenthPos = WriteFeatureHeader(bw_shp, recNumber); WriteEnvelope(bw_shp, feature.Shape.Envelope, he); bw_shp.Write((int)poly.RingCount); WritePointCount(bw_shp, poly); WriteParts(bw_shp, poly); for (int i = 0; i < poly.RingCount; i++) { WritePoints(bw_shp, poly[i]); } if (_header.ShapeType == ShapeType.PolygonM || _header.ShapeType == ShapeType.PolygonZ) { IPointCollection pColl = gView.Framework.SpatialAlgorithms.Algorithm.GeometryPoints(poly, false); if (_header.ShapeType == ShapeType.PolygonZ) { WritePointsZRange(bw_shp, pColl); WritePointsZ(bw_shp, pColl); } //bw_shp.Write(((IPoint)feature.Shape).M); WritePointsMRange(bw_shp, pColl); WritePointsM(bw_shp, pColl); } break; default: return(false); } sw_shp.Flush(); uint contentsSize = (uint)(sw_shp.BaseStream.Position - pos1 - 8) / 2; // -8 weil recnumber und nullword nicht mitzählen. Erst Shapetype und coordinaten,... bw_shx.Write((int)SwapWord((uint)(pos1 / 2))); // 16 bit Words bw_shx.Write((int)SwapWord(contentsSize)); sw_shx.Flush(); sw_shx.Close(); sw_shx = null; sw_shp.Close(); sw_shp = null; fs_shp = new FileStream(_file_SHP, FileMode.Open); fs_shx = new FileStream(_file_SHX, FileMode.Open); bw_shp = new BinaryWriter(fs_shp); bw_shx = new BinaryWriter(fs_shx); if (contentsLenthPos != 0) { bw_shp.BaseStream.Position = contentsLenthPos; bw_shp.Write((int)SwapWord((uint)contentsSize)); } UpdateHeaderEnvelope(bw_shp, he); UpdateHeaderEnvelope(bw_shx, he); fs_shp.Flush(); fs_shx.Flush(); //this.Open(); _dbfFile.WriteRecord(recNumber, feature); return(true); } catch (Exception ex) { string err = ex.Message; return(false); } finally { if (sw_shx != null) { sw_shx.Close(); } if (sw_shp != null) { sw_shp.Close(); } if (fs_shp != null) { fs_shp.Close(); } if (fs_shx != null) { fs_shx.Close(); } } }
static void Main(string[] args) { //ESRI License Initializer generated code. m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced }, new esriLicenseExtensionCode[] { }); Dictionary <string, Vertex> nodeDict = new Dictionary <string, Vertex>(); Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); IWorkspace workspace = workspaceFactory.OpenFromFile(@"C:\Users\hellocomrade\NHDPlusV21_GL_04.gdb", 0); IFeatureWorkspace iFtrWs = workspace as IFeatureWorkspace; if (null != iFtrWs) { IFeatureClass fcLine = iFtrWs.OpenFeatureClass("NHD_Flowline"); IFeatureClass fcPoint = iFtrWs.OpenFeatureClass("Hydro_Net_Junctions"); System.Diagnostics.Debug.Assert(null != fcLine && null != fcPoint); var fldLst = new List <string> { "OBJECTID", "FlowDir", "FTYPE", "V0001E_MA", "V0001E_MM", "V0001E_01", "V0001E_02", "V0001E_03", "V0001E_04", "V0001E_05", "V0001E_06", "V0001E_07", "V0001E_08", "V0001E_09", "V0001E_10", "V0001E_11", "V0001E_12" }; Dictionary <string, int> fldDict = new Dictionary <string, int>(); fldLst.ForEach(fldName => fldDict.Add(fldName, fcLine.FindField(fldName))); int lineFtrId = -1; //Find field index for oid in Hydro_Net_Junctions feature class int pntFtrIdIdx = fcPoint.FindField("OBJECTID"); string pntFtrId = null; /* * It has been observed that the most time consuming part of this script is on spatial query. * We could take the same approach we had on Arcpy through fcLine.Search() with a spatial filter. * However, it will make us have the same granularity as using arcpy. * Instead, we took a different route here by using IFeatureIndex and IIndexQuery2 */ IGeoDataset geoLineDS = (IGeoDataset)fcLine; ISpatialReference srLine = geoLineDS.SpatialReference; IFeatureIndex lineIdx = new FeatureIndexClass(); lineIdx.FeatureClass = fcLine; lineIdx.Index(null, geoLineDS.Extent); IIndexQuery2 queryLineByIdx = lineIdx as IIndexQuery2; IFeatureIndex pointIdx = new FeatureIndexClass(); pointIdx.FeatureClass = fcPoint; pointIdx.Index(null, ((IGeoDataset)fcPoint).Extent); IIndexQuery2 queryPointByIdx = pointIdx as IIndexQuery2; //Get a cursor on Hydro_Net_Junctions as the iterator IFeatureCursor pntCur = fcPoint.Search(null, false); IFeature pnt = pntCur.NextFeature(); IFeature line = null; IFeature otherPnt = null; List <string> requiredTypes = new List <string> { "StreamRiver", "ArtificialPath" }; /* * ITopologicalOpeartor is good for two geometries comparing with each other. It doesn't fit * very well for our situation, which check the geometric relationships between a geometry * against a feature class that may have more than 100K geometries. */ //ITopologicalOperator optor = null; /* * It's a shame that we have to reference to a Server API in order to calcuate Geodesic * distances for a polyline with lon/lat as coordinates. * * We could do Haversine ourselves, but we have to believe ESRI could definitely does a * better job there, well, hard to figure out how to get this simple task done in an intutive * way though... */ IGeometryServer2 geoOperator = new GeometryServerClass(); IPolyline polyLine = null; List <DownstreamNode> dsLst = null; int[] lineIds = null; int[] pntIds = null; object idobjs; object idobjs1; PolylineArray tmpArr = null; IDoubleArray lengths = null; double lineLen = 0.0; double v = 0.0; ILinearUnit unit = new LinearUnitClass(); var range = Enumerable.Range(3, 14); int count = 0; int incoming = 0; while (null != pnt) { //get ftr id of the current vertex pntFtrId = pnt.get_Value(pntFtrIdIdx).ToString(); //optor = pnt.Shape as ITopologicalOperator; /* * This should return feature ids that interects with the given geometry in the feature * class having the index built. */ queryLineByIdx.IntersectedFeatures(pnt.Shape, out idobjs); lineIds = idobjs as int[]; if (null != lineIds && lineIds.Length > 0) { foreach (int id in lineIds) { line = fcLine.GetFeature(id); lineFtrId = int.Parse(line.get_Value(fldDict["OBJECTID"]).ToString()); if ("1" == line.get_Value(fldDict["FlowDir"]).ToString() && true == requiredTypes.Contains(line.get_Value(fldDict["FTYPE"]).ToString())) { polyLine = line.Shape as IPolyline; if (isSamePoint(polyLine.FromPoint, pnt.Shape as IPoint)) { queryPointByIdx.IntersectedFeatures(line.Shape, out idobjs1); pntIds = idobjs1 as int[]; if (null != pntIds && 2 == pntIds.Length) { foreach (int pid in pntIds) { otherPnt = fcPoint.GetFeature(pid); if (false == isSamePoint(otherPnt.Shape as IPoint, pnt.Shape as IPoint)) { tmpArr = new PolylineArrayClass(); tmpArr.Add(polyLine); lengths = geoOperator.GetLengthsGeodesic(srLine, tmpArr as IPolylineArray, unit); if (0 == lengths.Count) { continue; } lineLen = lengths.get_Element(0) * 3.28084; //var velos = from idx in range select double.Parse(line.get_Value(fldDict[fldLst[idx]]).ToString()); List <double> velos = new List <double>(); foreach (int idx in range) { v = double.Parse(line.get_Value(fldDict[fldLst[idx]]).ToString()); velos.Add(v == 0 ? 0 : lineLen / v); } if (null == dsLst) { dsLst = new List <DownstreamNode>(); } dsLst.Add(new DownstreamNode(pid, id, velos)); } } } } else // pnt at the end of the polyline { ++incoming; } } } } if (null != dsLst || incoming > 0) { nodeDict.Add(pntFtrId, new Vertex(int.Parse(pntFtrId), incoming, dsLst)); } pnt = pntCur.NextFeature(); if (++count % 1000 == 0) { Console.WriteLine("Processing Count: " + count); } incoming = 0; dsLst = null; }//end of while(null != pnt) ReleaseCOMObj(pntCur); } ReleaseCOMObj(workspaceFactory); //ESRI License Initializer generated code. //Do not make any call to ArcObjects after ShutDownApplication() m_AOLicenseInitializer.ShutdownApplication(); }
public static bool ConvertBuildingParam(IPolygon footprint, double startZ, double height, out IMultiPolygon segPolygon, out IPolyline route) { segPolygon = null; route = null; IPoint point = null; IPoint pointValue = null; IEnvelope envelope = null; IPolygon polygon = null; if (footprint == null) { return(false); } try { envelope = footprint.Envelope; segPolygon = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; route = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; point = DrawGeometry.geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); point.SetCoords(envelope.Center.X, envelope.Center.Y, 0.0, 0.0, 0); pointValue = point.Clone() as IPoint; pointValue.Z = startZ; route.AppendPoint(pointValue); pointValue = point.Clone() as IPoint; pointValue.Z = startZ + height; route.AppendPoint(pointValue); int pointCount = footprint.ExteriorRing.PointCount; polygon = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; for (int i = 0; i < pointCount; i++) { pointValue = footprint.ExteriorRing.GetPoint(i).Clone() as IPoint; pointValue.X -= point.X; pointValue.Y -= point.Y; polygon.ExteriorRing.AppendPoint(pointValue); } segPolygon.AddPolygon(polygon); return(true); } catch (Exception exception) { DrawGeometry.WriteLog(exception.StackTrace); return(false); } }
public override void Init() { try { base.Init(); FacilityClass fac = this._facClassReg.FacilityType; if (fac == null) { return; } #region 设置管径 bool bHaveDia1 = false; bool bHaveDia2 = false; bool bHaveDia = false; DFDataConfig.Class.FieldInfo fiDiameter1 = fac.GetFieldInfoBySystemName("Diameter1"); if (fiDiameter1 != null) { int indexDiameter1 = this._rowInfo.FieldIndex(fiDiameter1.Name); if (indexDiameter1 != -1) { string diaInfo1 = ""; if (!this._rowInfo.IsNull(indexDiameter1) && !string.IsNullOrEmpty(diaInfo1 = this._rowInfo.GetValue(indexDiameter1).ToString())) { this._dia1 = double.Parse(diaInfo1) * 0.001; bHaveDia1 = true; } } } DFDataConfig.Class.FieldInfo fiDiameter2 = fac.GetFieldInfoBySystemName("Diameter2"); if (fiDiameter2 != null) { int indexDiameter2 = this._rowInfo.FieldIndex(fiDiameter2.Name); if (indexDiameter2 != -1) { string diaInfo2 = ""; if (!this._rowInfo.IsNull(indexDiameter2) && !string.IsNullOrEmpty(diaInfo2 = this._rowInfo.GetValue(indexDiameter2).ToString())) { this._dia2 = double.Parse(diaInfo2) * 0.001; bHaveDia2 = true; } } } if (bHaveDia1 && bHaveDia2) { bHaveDia = true; } else { DFDataConfig.Class.FieldInfo fiDiameter = fac.GetFieldInfoBySystemName("Diameter"); if (fiDiameter != null) { int indexDiameter = this._rowInfo.FieldIndex(fiDiameter.Name); if (indexDiameter != -1) { string diaInfo = ""; string coverstyle = ""; if (!this._rowInfo.IsNull(indexDiameter) && !string.IsNullOrEmpty(diaInfo = this._rowInfo.GetValue(indexDiameter).ToString())) { DFDataConfig.Class.FieldInfo fiCoverStyle = fac.GetFieldInfoBySystemName("CoverStyle"); if (fiCoverStyle != null) { int indexCoverStyle = this._rowInfo.FieldIndex(fiCoverStyle.Name); if (indexCoverStyle != -1 && !this._rowInfo.IsNull(indexCoverStyle)) { coverstyle = this._rowInfo.GetValue(indexCoverStyle).ToString(); } } SplitDiameter(diaInfo, coverstyle, out this._dia1, out this._dia2); if (this._rowInfo.FieldIndex(fiDiameter.Name + "1") != -1) { this._rowInfo.SetValue(this._rowInfo.FieldIndex(fiDiameter.Name + "1"), this._dia1); } if (this._rowInfo.FieldIndex(fiDiameter.Name + "2") != -1) { this._rowInfo.SetValue(this._rowInfo.FieldIndex(fiDiameter.Name + "2"), this._dia1); } bHaveDia = true; this._dia1 *= 0.001; this._dia2 *= 0.001; } } } } if (!bHaveDia || (this._dia1 < 0.000001 && this._dia2 < 0.000001)) { this._dia1 = 0.05; this._dia2 = 0.0; } this._segtype = GetSegType(this._dia1, this._dia2); #endregion // 设置管线对象二维Shape数据-顶点坐标\高程信息 IPolyline route = null; if ((this._style != null) && (this._style is PipeLineStyleClass)) { PipeLineStyleClass style = this._style as PipeLineStyleClass; switch (style.HeightParam) { case HeightParam.PipeHeight: DFDataConfig.Class.FieldInfo fiStartHeight = fac.GetFieldInfoBySystemName("StartHeight"); if (fiStartHeight != null) { int indexStartHeight = this._rowInfo.FieldIndex(fiStartHeight.Name); if (indexStartHeight != -1) { this._sheight = Fac.GetDouble(base._rowInfo, indexStartHeight); if (double.IsNaN(this._sheight)) { this._sheight = 0.0; } } } DFDataConfig.Class.FieldInfo fiEndHeight = fac.GetFieldInfoBySystemName("EndHeight"); if (fiEndHeight != null) { int indexEndHeight = this._rowInfo.FieldIndex(fiEndHeight.Name); if (indexEndHeight != -1) { this._eheight = Fac.GetDouble(base._rowInfo, indexEndHeight); } if (double.IsNaN(this._eheight)) { this._eheight = 0.0; } } // 根据管线起始点高程计算中间点高程,并替换设施对象中Shape二维数据 if (this.GetPipeLineVertexs(base._geoGroup[2], this._sheight, this._eheight, out route)) { base._geoGroup[1] = route; base.SetValue("Shape", base._geoGroup[1]); } break; case HeightParam.LineSurfH2Deep: DFDataConfig.Class.FieldInfo fiStartSurfHeight = fac.GetFieldInfoBySystemName("StartSurfHeight"); if (fiStartSurfHeight != null) { int indexStartSurfHeight = this._rowInfo.FieldIndex(fiStartSurfHeight.Name); if (indexStartSurfHeight != -1) { this._ssurfh = Fac.GetDouble(base._rowInfo, indexStartSurfHeight); if (double.IsNaN(this._ssurfh)) { this._ssurfh = 0.0; } } } DFDataConfig.Class.FieldInfo fiStartDepth = fac.GetFieldInfoBySystemName("StartDepth"); if (fiStartDepth != null) { int indexStartDepth = this._rowInfo.FieldIndex(fiStartDepth.Name); if (indexStartDepth != -1) { this._sdeep = Fac.GetDouble(base._rowInfo, indexStartDepth); if (double.IsNaN(this._sdeep)) { this._sdeep = 0.0; } } } DFDataConfig.Class.FieldInfo fiEndSurfHeight = fac.GetFieldInfoBySystemName("EndSurfHeight"); if (fiEndSurfHeight != null) { int indexEndSurfHeight = this._rowInfo.FieldIndex(fiEndSurfHeight.Name); if (indexEndSurfHeight != -1) { this._esurfh = Fac.GetDouble(base._rowInfo, indexEndSurfHeight); if (double.IsNaN(this._esurfh)) { this._esurfh = 0.0; } } } DFDataConfig.Class.FieldInfo fiEndDepth = fac.GetFieldInfoBySystemName("EndDepth"); if (fiEndDepth != null) { int indexEndDepth = this._rowInfo.FieldIndex(fiEndDepth.Name); if (indexEndDepth != -1) { this._edeep = Fac.GetDouble(base._rowInfo, indexEndDepth); if (double.IsNaN(this._edeep)) { this._edeep = 0.0; } } } this._sheight = this._ssurfh - this._sdeep; this._eheight = this._esurfh - this._edeep; // 根据管线起始点高程计算中间点高程,并替换设施对象中Shape二维数据 if (this.GetPipeLineVertexs(base._geoGroup[2], this._sheight, this._eheight, out route)) { base._geoGroup[1] = route; base.SetValue("Shape", base._geoGroup[1]); } break; case HeightParam.PipeVertexHeight: this.GetPipeLineVertexs(base._geoGroup[1], out route); this._sheight = double.IsNaN(route.StartPoint.Z) ? 0.0 : route.StartPoint.Z; this._eheight = double.IsNaN(route.EndPoint.Z) ? 0.0 : route.EndPoint.Z; // 替换设施对象中缓存行\Shape二维数据 base._geoGroup[1] = route; base.SetValue("Shape", route); break; case HeightParam.Unkown: this._sheight = double.IsNaN(route.StartPoint.Z) ? 0.0 : route.StartPoint.Z; this._eheight = double.IsNaN(route.EndPoint.Z) ? 0.0 : route.EndPoint.Z; this.SimplifyPolyline(base._geoGroup[1], out route); // 替换设施对象中缓存行\Shape二维数据 base._geoGroup[1] = route; base.SetValue("Shape", route); break; } switch (style.HeightMode) { case HeightMode.Top: this._vPos = VerticalPos.Top; break; case HeightMode.Bottom: this._vPos = VerticalPos.Bottom; break; default: this._vPos = VerticalPos.Center; break; } // 重新设置高程选项,针对同类管线中高程设置不一致的情况 DFDataConfig.Class.FieldInfo fiHLB = fac.GetFieldInfoBySystemName("HLB"); if (fiHLB != null) { int indexHLB = this._rowInfo.FieldIndex(fiHLB.Name); if (indexHLB != -1) { string hlb = base._rowInfo.GetValue(indexHLB).ToString(); if (hlb.Contains("内")) { this._vPos = VerticalPos.Bottom; } else if (hlb.Contains("外")) { this._vPos = VerticalPos.Top; } else { this._vPos = VerticalPos.Center; } } } } } catch (Exception exception) { } }
private void CloseWorkspace() { m_ipGeometricNetwork = null; m_ipPoints = null; m_ipPointToEID = null; m_ipEnumNetEID_Junctions = null; m_ipEnumNetEID_Edges = null; m_ipPolyline = null; }
public void CanGetSegmentIndexMultipartPolyline() { const double xyTolerance = 0.0125; IPolyline polyline = GeometryFactory.CreatePolyline(1000, 2000, 1500, 2500); ISpatialReference lv95 = CreateSpatialReference(0.0125, 0.0125); polyline.SpatialReference = lv95; object missing = Type.Missing; ((IPointCollection)polyline).AddPoint( GeometryFactory.CreatePoint(2000, 3000), ref missing, ref missing); IGeometry secondLine = GeometryFactory.CreatePolyline(5000, 8000, 5500, 8500); ((IPointCollection)secondLine).AddPoint( GeometryFactory.CreatePoint(6000, 9000), ref missing, ref missing); ((IGeometryCollection)polyline).AddGeometryCollection( (IGeometryCollection)secondLine); GeometryUtils.Simplify(polyline); IPoint searchPoint = new PointClass(); searchPoint.PutCoords(234, 34675); int partIndex; int?resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, true, true); Assert.IsNull(resultIndex, "Point is not on geometry but non-null segment index returned."); // 1. point, segment from-point searchPoint.PutCoords(1000, 2000); resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, true, true); Assert.IsNotNull(resultIndex, "Point is on geometry but segment index not found."); Assert.AreEqual(0, resultIndex); Assert.AreEqual(0, partIndex); // 1. point, segment to-point (actually incorrect parameter combination) resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, false, true); Assert.AreEqual(0, resultIndex); Assert.AreEqual(0, partIndex); // 2. point, segment from-point searchPoint.PutCoords(1500, 2500); resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, true, true); Assert.AreEqual(1, resultIndex); Assert.AreEqual(0, partIndex); // 2. point, segment to-point resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, false, true); Assert.AreEqual(0, resultIndex); Assert.AreEqual(0, partIndex); // 3. point, segment from-point (actually incorrect parameter combination) searchPoint.PutCoords(2000, 3000); resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, true, true); Assert.AreEqual(1, resultIndex); Assert.AreEqual(0, partIndex); // 3. point, segment to-point resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, false, true); Assert.AreEqual(1, resultIndex); Assert.AreEqual(0, partIndex); // 1. point of second, segment from-point searchPoint.PutCoords(5000, 8000); resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, true, true); Assert.AreEqual(0, resultIndex); Assert.AreEqual(1, partIndex); // 1. point of inner ring, segment to-point (incorrect parameter combination) resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, false, true); Assert.AreEqual(0, resultIndex); Assert.AreEqual(1, partIndex); // 2. point of inner ring, segment from-point searchPoint.PutCoords(5500, 8500); resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, true, true); Assert.AreEqual(1, resultIndex); Assert.AreEqual(1, partIndex); // 2. point of inner ring, segment to-point resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, false, true); Assert.AreEqual(0, resultIndex); Assert.AreEqual(1, partIndex); // 3. point of inner ring, segment from-point (actually incorrect parameter combination) searchPoint.PutCoords(6000, 9000); resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, true, true); Assert.AreEqual(1, resultIndex); Assert.AreEqual(1, partIndex); // 3. point of inner ring, segment to-point resultIndex = SegmentReplacementUtils.GetSegmentIndex( polyline, searchPoint, xyTolerance, out partIndex, false, true); Assert.AreEqual(1, resultIndex); Assert.AreEqual(1, partIndex); }
public string NewGeologicLine(string Type, double LocationConfidenceMeters, string ExistenceConfidence, string IdentityConfidence, string Symbol, string Label, string Notes, string DataSourceID, string RuleID, IPolyline Shape) { GeologicLine newGeologicLine = new GeologicLine(); sysInfo SysInfoTable = new sysInfo(m_theWorkspace); newGeologicLine.GeologicLines_ID = SysInfoTable.ProjAbbr + ".GeologicLines." + SysInfoTable.GetNextIdValue("GeologicLines"); newGeologicLine.Type = Type; newGeologicLine.LocationConfidenceMeters = LocationConfidenceMeters; newGeologicLine.ExistenceConfidence = ExistenceConfidence; newGeologicLine.IdentityConfidence = IdentityConfidence; newGeologicLine.Symbol = Symbol; newGeologicLine.Label = Label; newGeologicLine.Notes = Notes; newGeologicLine.DataSourceID = DataSourceID; newGeologicLine.RuleID = RuleID; newGeologicLine.Shape = Shape; newGeologicLine.RequiresUpdate = false; m_GeologicLinesDictionary.Add(newGeologicLine.GeologicLines_ID, newGeologicLine); return newGeologicLine.GeologicLines_ID; }
private bool LDJC() { try { if (_pointFeatureLayer == null || _lineFeatureLayer == null) { return(false); } _featureItems = new List <FeatureItem>(); IFeatureCursor pFeatureCursor = _lineFeatureLayer.Search(null, false); IFeature pFeature; ISpatialFilter spatialFilter; IFeatureCursor featureCursor; while ((pFeature = pFeatureCursor.NextFeature()) != null) { string msg = ""; IPolyline polyline = pFeature.Shape as IPolyline; if (polyline == null || polyline.IsEmpty) { continue; } spatialFilter = new SpatialFilterClass(); spatialFilter.Geometry = polyline.FromPoint; spatialFilter.GeometryField = _pointFeatureLayer.FeatureClass.ShapeFieldName; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; spatialFilter.OutputSpatialReference[_pointFeatureLayer.FeatureClass.ShapeFieldName] = _context.FocusMap.SpatialReference; featureCursor = _pointFeatureLayer.Search(spatialFilter, false); if (featureCursor.NextFeature() == null) { // 缺少起点 msg += "管线漏点,漏点为起点"; } featureCursor = null; spatialFilter.Geometry = polyline.ToPoint; featureCursor = _pointFeatureLayer.Search(spatialFilter, false); if (featureCursor.NextFeature() == null) { // 缺少终点 if (msg.Length <= 0) { msg += "管线漏点,漏点为终点"; } else { msg += "及终点"; } } featureCursor = null; if (msg.Length > 0) { _featureItems.Add(new FeatureItem(pFeature) { Name = msg }); } } Marshal.ReleaseComObject(pFeatureCursor); if (_featureItems.Any()) { MessageBox.Show(@"检查完毕", @"提示"); return(true); } else { MessageBox.Show(@"检查完毕,未发现任何问题", @"提示"); return(false); } } catch (Exception exception) { MessageBox.Show(exception.Message); return(false); } }
public void InsertPointAtIntersection2(ref IPolyline pPolyline, IGeometry pOther, double hmgetal) { bool SplitHappened = false; int newPartIndex = 0; int newSegmentIndex = 0; int index = 0; IPoint Point = null; IPoint HitPoint = new ESRI.ArcGIS.Geometry.Point(); double hitDistance = 0; int hitPartIndex = 0; int hitSegmentIndex = 0; bool bRightSide = false; ITopologicalOperator5 pTopoOpOther = pOther as ITopologicalOperator5; pTopoOpOther.Simplify(); ITopologicalOperator6 pTopoOpPolyline = pPolyline as ITopologicalOperator6; IGeometry pGeomResult = pTopoOpPolyline.IntersectEx(pOther,false, esriGeometryDimension.esriGeometry0Dimension); if ((pGeomResult is IPointCollection) && ((pGeomResult as IPointCollection).PointCount > 0)) { for (int i = 0; i < (pGeomResult as IPointCollection).PointCount; i++) { (pPolyline as IHitTest).HitTest( (pGeomResult as IPointCollection).get_Point(i), 10, esriGeometryHitPartType.esriGeometryPartBoundary, HitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide); index = 0; for (int j = 0; j < hitPartIndex; j++) { index += ((pPolyline as IGeometryCollection).get_Geometry(j) as IPointCollection).PointCount; } index += hitSegmentIndex; HitPoint.M = hmgetal; (pPolyline as IPointCollection).AddPoint(HitPoint, after: index); } } (pPolyline as ITopologicalOperator2).IsKnownSimple_2 = false; (pPolyline as IPolyline4).SimplifyEx(true); }
private int ValidateVerticalFaces( [NotNull] IFeature feature, [NotNull] IEnumerable <SegmentProxy> verticalFaceSegments, [CanBeNull] IPolygon footPrint) { int errorCount = 0; IGeometryCollection errorParts = null; foreach (SegmentProxy segment in verticalFaceSegments) { const bool forceCreation = true; IPolyline line = segment.GetPolyline(forceCreation); if (Math.Abs(line.Length) < double.Epsilon) { continue; } if (footPrint == null || !((IRelationalOperator2)footPrint).ContainsEx( line, esriSpatialRelationExEnum.esriSpatialRelationExBoundary)) { if (errorParts == null) { errorParts = new PolylineClass(); } errorParts.AddGeometryCollection((IGeometryCollection)line); } } if (errorParts != null) { ((ITopologicalOperator)errorParts).Simplify(); if (footPrint == null) { if (GeometryUtils.IsSelfIntersecting((IGeometry)errorParts) || ((IPolyline)errorParts).IsClosed) { errorCount += ReportError( "Multipatch has only vertical patches forming a ring", (IPolyline)errorParts, Codes[Code.MultiPatchHasOnlyVerticalPatchesFormingARing], _shapeFieldName, feature); } } else { if (ReportVerticalPatchesNotCompletelyWithinFootprint) { errorCount += ReportError( "Segments of vertical patch is not (completely) within footprint", (IPolyline)errorParts, Codes[Code.VerticalPatchNotCompletelyWithinFootprint], _shapeFieldName, feature); } } } return(errorCount); }
public IPolyline ScaleRaai(ref IPolyline Raai) { ISegmentCollection Segments = Raai as ISegmentCollection; IEnumSegment enumSegment = Segments.EnumSegments; ISegment Segment = null; ISegment LangsteSegment = null; int outPartIndex = 0; int SegmentIndex = 0; enumSegment.Next(out Segment, ref outPartIndex, ref SegmentIndex); LangsteSegment = Segment; while (Segment != null) { if (Segment.Length >= LangsteSegment.Length) { LangsteSegment = (Segment as IClone).Clone() as ISegment; } enumSegment.Next(out Segment, ref outPartIndex, ref SegmentIndex); } IConstructLine line = new Line() as IConstructLine; line.ConstructExtended(LangsteSegment as ILine, esriSegmentExtension.esriExtendEmbedded); Raai = new Polyline() as IPolyline; (Raai as IPointCollection).AddPoint((line as ILine).FromPoint); (Raai as IPointCollection).AddPoint((line as ILine).ToPoint); return Raai; }
public override void OnMouseDown(int button, int shift, int x, int y) { if (button != 1) { return; } if (_context.Config.EngineSnapEnvironment.SnapToleranceUnits == esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels) { _tolerance = ArcGIS.Common.Helpers.CommonHelper.ConvertPixelsToMapUnits(_context.ActiveView, _tolerance); } this.SelectByClick(x, y); IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature; IFeature feature = enumFeature.Next(); if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { _pointFeature = feature; } if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { _lineFeature = feature; } if (_pointFeature == null || _lineFeature == null) { return; } this.SelectByShape(_pointFeature.Shape); enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature; enumFeature.Reset(); List <IFeature> linkFeatures = new List <IFeature>(); IFeature lineFeature; while ((lineFeature = enumFeature.Next()) != null) { IPolyline polyline = lineFeature.Shape as IPolyline; if (polyline == null) { continue; } linkFeatures.Add(lineFeature); } if (linkFeatures.Count <= 0) { return; } _linkFeature = linkFeatures[0]; if (_linkFeature == null || _linkFeature.Shape.GeometryType != esriGeometryType.esriGeometryPolyline) { return; } IPoint intersectPoint = GeometryHelper.GetIntersectPoint(_lineFeature.Shape as IPolyline, _linkFeature.Shape as IPolyline); this.SelectByShape(intersectPoint, true); enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature; IFeature moveFeature = enumFeature.Next(); if (moveFeature == null || moveFeature.Shape.GeometryType != esriGeometryType.esriGeometryPoint) { return; } _context.FocusMap.SelectFeature(_pointFeatureLayer, moveFeature); _context.FocusMap.SelectFeature(_pointFeatureLayer, _pointFeature); _context.FocusMap.SelectFeature(_lineFeatureLayer, _lineFeature); _context.FocusMap.SelectFeature(_lineFeatureLayer, _linkFeature); try { if (GeometryHelper.IsFromOrToPoint(intersectPoint, _linkFeature.Shape as IPolyline) && GeometryHelper.IsFromOrToPoint(intersectPoint, _lineFeature.Shape as IPolyline)) { IPoint targetPoint = GeometryHelper.GetNearPoint(_lineFeature.Shape as IPolyline, _pointFeature.Shape as IPoint); double distance = GeometryHelper.GetDistance(targetPoint, moveFeature.Shape as IPoint); if (MessageBox.Show($@"要素:{_linkFeature.OID},将移动{distance:0.0000}米,是否继续?", @"提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { linkFeatures = new List <IFeature>(); this.SelectByShape(moveFeature.Shape); enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature; enumFeature.Reset(); while ((lineFeature = enumFeature.Next()) != null) { IPolyline polyline = lineFeature.Shape as IPolyline; if (polyline == null) { continue; } linkFeatures.Add(lineFeature); } if (linkFeatures.Count <= 0) { return; } CommonHelper.MovePointWithLine(moveFeature, linkFeatures, targetPoint, _tolerance); _context.ActiveView.Refresh(); _linkFeature = null; _lineFeature = null; _pointFeature = null; } } } catch (Exception exception) { MessageBox.Show(exception.Message); } }