/// <summary> /// /// </summary> /// <param name="deletedFeature"></param> /// <param name="testFeatureClass"></param> /// <param name="searchPointFilter"></param> private void TestRelationMembership(IFeature deletedFeature, IFeatureClass testFeatureClass, ISpatialFilter searchPointFilter) { using (ESRI.ArcGIS.OSM.OSMClassExtension.ComReleaser comReleaser = new ESRI.ArcGIS.OSM.OSMClassExtension.ComReleaser()) { int testMemberOfFieldIndex = testFeatureClass.Fields.FindField("osmMemberOf"); int testMembersFieldIndex = testFeatureClass.Fields.FindField("osmMembers"); int testOsmIDFieldIndex = testFeatureClass.Fields.FindField("OSMID"); IFeatureCursor searchCursor = testFeatureClass.Search(searchPointFilter, false); comReleaser.ManageLifetime(searchCursor); IFeature touchedFeature = searchCursor.NextFeature(); while (touchedFeature != null) { long osmID = 0; if (testOsmIDFieldIndex > -1) { object osmIDValue = touchedFeature.get_Value(testOsmIDFieldIndex); if (osmIDValue != DBNull.Value) { osmID = Convert.ToInt64(osmIDValue); } } if (testMembersFieldIndex > -1) { ESRI.ArcGIS.OSM.OSMClassExtension.member[] relationMembers = _osmUtility.retrieveMembers(touchedFeature, testMembersFieldIndex); if (relationMembers != null) { if (relationMembers.Length > 0) { string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_pointmemberofrelation"), osmID); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); return; } } } if (testMemberOfFieldIndex > -1) { List<string> isMemberOfList = _osmUtility.retrieveIsMemberOf(touchedFeature, testMemberOfFieldIndex); Dictionary<string, string> dictofParentsAndTypes = _osmUtility.parseIsMemberOfList(isMemberOfList); StringBuilder typeAndIDString = new StringBuilder(); foreach (var item in dictofParentsAndTypes) { switch (item.Value) { case "rel": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_relationidtext") + item.Key + ","); break; case "ply": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polygonidtext") + item.Key + ","); break; case "ln": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polylineidtext") + item.Key + ","); break; case "pt": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_pointidtext") + item.Key + ","); break; default: break; } } if (typeAndIDString.Length > 0) { string parentsString = typeAndIDString.ToString(0, typeAndIDString.Length - 1); string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_pointmemberofrelation"), parentsString); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); return; } } touchedFeature = searchCursor.NextFeature(); } } }
/// <summary> /// /// </summary> /// <param name="deletedFeature"></param> /// <param name="testFeatureClass"></param> /// <param name="searchPointFilter"></param> private void TestRelationMembership(IFeature deletedFeature, IFeatureClass testFeatureClass, ISpatialFilter searchPointFilter) { using (ESRI.ArcGIS.OSM.OSMClassExtension.ComReleaser comReleaser = new ESRI.ArcGIS.OSM.OSMClassExtension.ComReleaser()) { int testMemberOfFieldIndex = testFeatureClass.Fields.FindField("osmMemberOf"); int testMembersFieldIndex = testFeatureClass.Fields.FindField("osmMembers"); int testOsmIDFieldIndex = testFeatureClass.Fields.FindField("OSMID"); IFeatureCursor searchCursor = testFeatureClass.Search(searchPointFilter, false); comReleaser.ManageLifetime(searchCursor); IFeature touchedFeature = searchCursor.NextFeature(); while (touchedFeature != null) { long osmID = 0; if (testOsmIDFieldIndex > -1) { object osmIDValue = touchedFeature.get_Value(testOsmIDFieldIndex); if (osmIDValue != DBNull.Value) { osmID = Convert.ToInt64(osmIDValue); } } if (testMembersFieldIndex > -1) { ESRI.ArcGIS.OSM.OSMClassExtension.member[] relationMembers = _osmUtility.retrieveMembers(touchedFeature, testMembersFieldIndex); if (relationMembers != null) { if (relationMembers.Length > 0) { string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_pointmemberofrelation"), osmID); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); return; } } } if (testMemberOfFieldIndex > -1) { List <string> isMemberOfList = _osmUtility.retrieveIsMemberOf(touchedFeature, testMemberOfFieldIndex); Dictionary <string, string> dictofParentsAndTypes = _osmUtility.parseIsMemberOfList(isMemberOfList); StringBuilder typeAndIDString = new StringBuilder(); foreach (var item in dictofParentsAndTypes) { switch (item.Value) { case "rel": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_relationidtext") + item.Key + ","); break; case "ply": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polygonidtext") + item.Key + ","); break; case "ln": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polylineidtext") + item.Key + ","); break; case "pt": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_pointidtext") + item.Key + ","); break; default: break; } } if (typeAndIDString.Length > 0) { string parentsString = typeAndIDString.ToString(0, typeAndIDString.Length - 1); string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_pointmemberofrelation"), parentsString); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); return; } } touchedFeature = searchCursor.NextFeature(); } } }