/// <summary> /// Reads back an array of ID mappings, associating the user-perceived IDs with the /// corresponding spatial features. /// </summary> /// <param name="field">A tag associated with the array</param> internal void ReadIdMappings(DataField field) { if (!IsNextField(field)) { return; } IdMapping[] mapping = ReadPersistentArray <IdMapping>(field); for (int i = 0; i < mapping.Length; i++) { IdMapping m = mapping[i]; NativeId nid = MapModel.FindNativeId(m.RawId); if (nid == null) { nid = MapModel.AddNativeId(m.RawId); } Feature f = MapModel.Find <Feature>(m.InternalId); // Ignore null ref if we are dealing with the very last mapping of a connection path // (covers CEdit bug that produced spurious point at the end of the path). if (f == null) { //if (m_CurrentEdit is PathOperation && i == (mapping.Length - 1)) // break; throw new ApplicationException("Cannot locate feature for ID mapping: " + m); } f.SetId(nid); } }
/// <summary> /// Reads a user-perceived feature ID using the specified naming tags. /// </summary> /// <param name="nativeField">The tag to use for a native ID.</param> /// <param name="foreignField">The tag to use for a foreign ID.</param> /// <returns>The user-perceived ID that was read (may be null)</returns> internal FeatureId ReadFeatureId(DataField nativeField, DataField foreignField) { if (IsNextField(nativeField)) { uint nativeKey = m_Reader.ReadUInt32(nativeField.ToString()); NativeId nid = MapModel.FindNativeId(nativeKey); if (nid == null) { return(MapModel.AddNativeId(nativeKey)); } else { return(nid); } } if (IsNextField(foreignField)) { string key = m_Reader.ReadString(foreignField.ToString()); ForeignId fid = MapModel.FindForeignId(key); if (fid == null) { return(MapModel.AddForeignId(key)); } else { return(fid); } } return(null); }