void OnBeforeStopParcelEditing() { if (m_ParcelEditHelperExt.RecordToField) { return; } IParcelConstruction4 pTrav = (IParcelConstruction4)m_pParcEditorMan.ParcelConstruction; IEnumGSLines pGSLines = pTrav.GetLines(false, false); pGSLines.Reset(); IGSLine pGSLine = null; IGSParcel pGSParcel = null; pGSLines.Next(ref pGSParcel, ref pGSLine); while (pGSLine != null) { IGSAttributes pLineAtts = (IGSAttributes)pGSLine; double brgRecord = Convert.ToDouble(pGSLine.Bearing); brgRecord = brgRecord * 180 / Math.PI; pLineAtts.SetProperty(m_ParcelEditHelperExt.FieldName, brgRecord); //pGSParcel.Modified(); pGSLines.Next(ref pGSParcel, ref pGSLine); } pTrav.UpdateGridFromGSLines(true, false); }
private void AssignExtendedAttributes(IGSAttributes pSourceAttributes, IGSAttributes pTargetAttributes) { if (pSourceAttributes == null || pTargetAttributes == null) { return; } IEnumBSTR pAttributeNames; pAttributeNames = pSourceAttributes.AttributeNames; if (pAttributeNames == null) { return; } string name = pAttributeNames.Next(); while (name != null) { try { object valu = pSourceAttributes.GetProperty(name); pTargetAttributes.SetProperty(name, valu); } catch { ; } name = pAttributeNames.Next(); } }
object OnGridCellEdit(ref int row, ref int col, ref object inValue) { string m_sFieldName = m_ParcelEditHelperExt.FieldName; bool m_bRecordFieldName = m_ParcelEditHelperExt.RecordToField; object OutValue = inValue; if (col == 2 && m_bRecordFieldName)//this is the bearing field { IParcelConstruction pTrav = (IParcelConstruction)m_pParcEditorMan.ParcelConstruction; IGSLine pGSLine = null; bool IsCompleteLine = (pTrav.GetLine(row, ref pGSLine)); //true means it's a complete line //false means it's a partial line //note that the type of the inValue must be honoured when returning the value from this function, in this case we are rebuilding the string for the same value, unaltered. //however the other relevant work done is to set the record field to the same value to capture what was entered prior to resequencing and potential bearing changes. //this happens either for a complete line or a partial one //The logic could be changed to be more conservative and only capture the record for a partial line (IsCompleteLine==false), since that would only record the first time it's cogo'd, //compared to this code that records edits of completed lines *as well as* partial lines IAngularConverter pAngConv = new AngularConverterClass(); string sBear = Convert.ToString(inValue); sBear = sBear.Replace("°", "-"); sBear = sBear.Replace("'", "-"); sBear = sBear.Replace("\"", ""); if (!pAngConv.SetString(sBear, esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds)) //TODO: base this on Plan properties { return(OutValue); } double brgRecord = pAngConv.GetAngle(esriDirectionType.esriDTNorthAzimuth, esriDirectionUnits.esriDUDecimalDegrees); sBear = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); IParcelConstruction4 pTrav4 = pTrav as IParcelConstruction4; pTrav4.UpdateGridFromGSLines(true, false); sBear = sBear.Replace(" ", ""); sBear = sBear.Insert(sBear.Length - 1, "\""); int i = sBear.LastIndexOf('-'); sBear = sBear.Insert(i, "'"); i = sBear.IndexOf('-'); sBear = sBear.Insert(i, "°"); sBear = sBear.Replace("-", ""); IGSAttributes pLineAtts = (IGSAttributes)pGSLine; pLineAtts.SetProperty(m_sFieldName, sBear); return(sBear); //note that the type of the inValue must be honoured when returning the value from this function. } return(OutValue); }
protected override void OnClick() { IEditor pEd = (IEditor)ArcMap.Application.FindExtensionByName("esriEditor.Editor"); if (pEd.EditState == esriEditState.esriStateNotEditing) { MessageBox.Show("Please start editing and try again."); return; } ICadastralEditor pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension"); IParcelEditManager pParcEditorMan = (IParcelEditManager)pCadEd; ICadastralSelection pCadaSel = (ICadastralSelection)pCadEd; try { ICadastralPacketManager pCadPacketMan = (ICadastralPacketManager)pCadEd; bool bStartedWithPacketOpen = pCadPacketMan.PacketOpen; if (!bStartedWithPacketOpen) { pEd.StartOperation(); } //1. Start map edit session ICadastralMapEdit pCadMapEdit = (ICadastralMapEdit)pCadEd; pCadMapEdit.StartMapEdit(esriMapEditType.esriMEParcelSelection, "Merge Parcel", false); //2. Get job packet ICadastralPacket pCadaPacket = pCadPacketMan.JobPacket; //3. Create Plan (new) string sPlanName = "My New Plan"; //first check to ensure plan is not already in the database. IGSPlan pGSPlan = FindFabricPlanByName(sPlanName, pCadEd); ICadastralPlan pCadaPlan = (ICadastralPlan)pCadaPacket; if (pGSPlan == null) { //if plan is null, it was not found and can be created pGSPlan = new GSPlanClass(); // 3.a set values pGSPlan.Accuracy = 4; pGSPlan.Name = sPlanName; pGSPlan.DirectionFormat = esriDirectionType.esriDTQuadrantBearing; pGSPlan.AngleUnits = esriDirectionUnits.esriDUDegreesMinutesSeconds; pGSPlan.AreaUnits = esriCadastralAreaUnits.esriCAUAcre; pGSPlan.Description = "My Test Plan for Merge"; pGSPlan.DistanceUnits = esriCadastralDistanceUnits.esriCDUFoot; } //3.b Add the plan to the job packet pCadaPlan.AddPlan(pGSPlan); ICadastralPoints pCadaPoints = (ICadastralPoints)pCadaPacket; IConstructParcelFunctions3 constrParcelFunctions = new ParcelFunctions() as IConstructParcelFunctions3; IEnumGSParcels selectedParcels = pCadaSel.SelectedParcels; //get selected parcels AFTER calling ::StartMapEdit to get the in-mem packet representation. IGSParcel gsParcel = constrParcelFunctions.MergeParcels(pGSPlan, pCadaPoints, selectedParcels, pCadaPacket); gsParcel.Type = 7; //7 = Tax parcel in the Local Government Information Model gsParcel.Lot = "My Merged Tax Parcel"; ICadastralObjectSetup pCadaObjSetup = (ICadastralObjectSetup)pParcEditorMan; //Make sure that any extended attributes on the new merged parcel have their default values set IGSAttributes pGSAttributes = (IGSAttributes)gsParcel; pCadaObjSetup.AddExtendedAttributes(pGSAttributes); pCadaObjSetup.SetDefaultValues(pGSAttributes); ICadastralParcel pCadaParcel = (ICadastralParcel)pCadaPacket; pCadaParcel.AddParcel(gsParcel); //set the original parcels to historic selectedParcels.Reset(); IGSParcel selParcel = selectedParcels.Next(); while (selParcel != null) { selParcel.Historical = true; //set SystemEndDate pGSAttributes = (IGSAttributes)selParcel; if (pGSAttributes != null) { pGSAttributes.SetProperty("systemenddate", DateTime.Now); } selParcel = selectedParcels.Next(); } try { pCadMapEdit.StopMapEdit(true); } catch { if (!bStartedWithPacketOpen) { pEd.AbortOperation(); } return; } if (!bStartedWithPacketOpen) { pEd.StopOperation("Merge Parcel"); } pCadPacketMan.PartialRefresh(); } catch (Exception ex) { pEd.AbortOperation(); MessageBox.Show(ex.Message); } }