/// <summary> /// Initializes a new instance of the <see cref="FeatureStub"/> class /// </summary> /// <param name="creator">The editing operation that created the feature.</param> /// <param name="id">The internal ID of the feature within /// the project that created it.</param> /// <param name="ent">The entity type for the feature (not null)</param> /// <param name="fid">The (optional) user-perceived ID for the feature.</param> /// <exception cref="ArgumentNullException">If either <paramref name="ent"/> or /// <paramref name="creator"/> is null.</exception> internal FeatureStub(Operation creator, InternalIdValue id, IEntity ent, FeatureId fid) { if (creator == null || ent == null) throw new ArgumentNullException(); m_Creator = creator; m_InternalId = id; m_What = ent; m_Id = fid; }
/// <summary> /// Initializes a new instance of the <see cref="LineSubdivisionOperation"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal LineSubdivisionOperation(EditDeserializer editDeserializer) : base(editDeserializer) { m_Line = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line); m_Face = editDeserializer.ReadPersistent <LineSubdivisionFace>(DataField.Face); //FeatureStub[] sections = editDeserializer.ReadFeatureStubArray(DataField.Result); if (editDeserializer.IsNextField(DataField.OtherSide)) { InternalIdValue id = editDeserializer.ReadInternalId(DataField.OtherSide); OtherSide = (LineSubdivisionOperation)editDeserializer.MapModel.FindOperation(id); Debug.Assert(OtherSide != null); OtherSide.OtherSide = this; } Project p = editDeserializer.Project; IEntity pointType = editDeserializer.ReadEntity(DataField.PointType); FeatureStub[] sections = CreateStubs(p, pointType, m_Line.EntityType); DeserializationFactory result = new DeserializationFactory(this, sections); ProcessFeatures(result); // Apply any IDs if (editDeserializer.IsNextField(DataField.Ids)) { editDeserializer.ReadIdMappings(DataField.Ids); } }
/// <summary> /// Creates stubs for all items that might be created by executing this edit. /// </summary> /// <param name="p">The project the stubs relate to.</param> /// <param name="pointType">The entity type for created points</param> /// <param name="lineType">The entity type for created lines</param> /// <returns></returns> /// <remarks>The main reason for doing so is to express any miss-connects or omit-points /// that may have been specified via the data entry string (the lack of a stub means the /// feature won't be created). User-perceived IDs are not recorded as part of the stubs, /// they need to be handled separately after the features have been created.</remarks> FeatureStub[] CreateStubs(Project p, IEntity pointType, IEntity lineType) { List <FeatureStub> stubList = new List <FeatureStub>(); foreach (Leg leg in m_Legs) { // Reserve item for point at center of circular arc (if it is one) var iid = new InternalIdValue(leg.ItemSequence); stubList.Add(new FeatureStub(this, iid, pointType, null)); // Reserve two items for each span along the leg FeatureStub[] faceStubs = leg.PrimaryFace.CreateStubs(this, pointType, lineType); stubList.AddRange(faceStubs); if (leg.AlternateFace != null) { // When we create features for alternate faces, we don't actually create // a point at the end of the leg (instead, we use the end point that was // created via the primary face). So here we'll be creating a stub that // doesn't usually get used. One special case is that the end point // may have been explicitly omitted from the primary face. faceStubs = leg.AlternateFace.CreateStubs(this, pointType, lineType); stubList.AddRange(faceStubs); } } return(stubList.ToArray()); }
/// <summary> /// Initializes a new instance of the <see cref="RevisedEdit"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal RevisedEdit(EditDeserializer editDeserializer) { InternalIdValue id = editDeserializer.ReadInternalId(DataField.RevisedEdit); m_Edit = editDeserializer.MapModel.FindOperation(id); m_Changes = (m_Edit as IRevisable).ReadUpdateItems(editDeserializer); }
/// <summary> /// Creates a new <c>PointFeature</c> with geometry that isn't shared /// with any other point. /// </summary> /// <param name="creator">The operation that created the feature (not null)</param> /// <param name="id">The internal ID of this feature within the project that created it.</param> /// <param name="e">The entity type for the feature (not null)</param> /// <param name="g">The geometry for the point (may be null)</param> internal PointFeature(Operation creator, InternalIdValue id, IEntity e, PointGeometry g) : base(creator, id, e, null) { if (g == null) m_Geom = null; else m_Geom = new Node(this, g); }
/// <summary> /// Creates a section for this subdivision op. /// </summary> /// <param name="id">The internal of this feature within the project that created it.</param> /// <param name="start">The point at the start of the section</param> /// <param name="end">The point at the end of the section</param> /// <returns>The created section</returns> internal LineFeature MakeSection(InternalIdValue id, PointFeature start, PointFeature end) { SectionGeometry section = new SectionGeometry(m_Line, start, end); LineFeature newLine = m_Line.MakeSubSection(this, id, section); //MapModel.EditingIndex.Add(newLine); return(newLine); }
/// <summary> /// Initializes a new instance of the <see cref="ForwardFeatureRef"/> class. /// </summary> /// <param name="referenceFrom">The object that makes the forward-reference (not null).</param> /// <param name="field">The ID of the persistent field.</param> /// <param name="iid">The internal ID that has been persisted for the field (relating to a feature /// that has not been created yet).</param> /// <exception cref="ArgumentNullException">If <paramref name="referenceFrom"/> is not defined.</exception> internal ForwardFeatureRef(IFeatureRef referenceFrom, DataField field, InternalIdValue iid) : base(field) { if (referenceFrom == null) throw new ArgumentNullException(); ReferenceFrom = referenceFrom; InternalId = iid; }
/// <summary> /// Records information for a line split /// </summary> /// <param name="parentLine">The line that may be getting split</param> /// <param name="field">The tag of the item that should be attached to the line split info</param> /// <param name="dataId">The ID for the section (null if there is no split)</param> /// <returns>True if a line split was recorded, false if the <paramref name="splitSection"/> is null.</returns> internal bool AddLineSplit(LineFeature parentLine, DataField field, string dataId) { if (dataId == null) return false; InternalIdValue id = new InternalIdValue(dataId); AddFeatureDescription(field, new FeatureStub(Creator, id, parentLine.EntityType, null)); return true; }
int GetFaceIndex(InternalIdValue sequence) { for (int i = 0; i < m_Faces.Count; i++) { if (m_Faces[i].Sequence.Equals(sequence)) { return(i); } } return(-1); }
/// <summary> /// Attempts to locate the face with a specific ID. /// </summary> /// <param name="faceId">The ID of the face to look for.</param> /// <returns>The corresponding face (null if not found)</returns> internal LegFace FindFace(InternalIdValue faceId) { foreach (Leg leg in m_Legs) { if (leg.PrimaryFace.Sequence.Equals(faceId)) { return(leg.PrimaryFace); } if (leg.AlternateFace != null && leg.AlternateFace.Sequence.Equals(faceId)) { return(leg.AlternateFace); } } return(null); }
/// <summary> /// Creates line sections along this face. /// </summary> /// <param name="parentLine">The line that is being subdivided</param> /// <param name="ff">Factory for producing new features (the important thing /// is the editing operation that's involved).</param> /// <param name="isTopological">Should the sections be tagged as polygon boundaries?</param> internal void CreateSections(LineFeature parentLine, FeatureFactory ff, bool isTopological) { // Must have at least two distances if (m_Distances == null) { throw new ArgumentNullException(); } if (m_Distances.Length < 2) { throw new ArgumentException(); } m_Sections = new List <LineFeature>(m_Distances.Length); PointFeature start = parentLine.StartPoint; InternalIdValue item = new InternalIdValue(ff.Creator.EditSequence); for (int i = 0; i < m_Distances.Length; i++) { PointFeature end; if (i == m_Distances.Length - 1) { end = parentLine.EndPoint; } else { item.ItemSequence++; end = ff.CreatePointFeature(item.ToString()); } item.ItemSequence++; LineFeature line = ff.CreateSection(item.ToString(), parentLine, start, end); line.ObservedLength = m_Distances[i]; if (!isTopological) { line.SetTopology(false); } m_Sections.Add(line); start = end; } }
/// <summary> /// Creates a new <c>ArcFeature</c> /// </summary> /// <param name="creator">The operation that created the feature (not null)</param> /// <param name="id">The internal ID of this feature within the project that created it.</param> /// <param name="e">The entity type for the feature.</param> /// <param name="c">The circle the arc coincides with</param> /// <param name="bc">The point at the start of the arc</param> /// <param name="ec">The point at the end of the arc</param> /// <param name="isClockwise">True if the arc is directed clockwise from start to end</param> internal ArcFeature(Operation creator, InternalIdValue id, IEntity e, Circle c, PointFeature bc, PointFeature ec, bool isClockwise) : base(creator, id, e, bc, ec, new ArcGeometry(c, bc, ec, isClockwise)) { }
/// <summary> /// Reads data that was previously written using <see cref="WriteData"/> /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> /// <param name="id">The internal of the feature within the project that created it.</param> /// <param name="entity">The type of real-world object that the feature corresponds to.</param> /// <param name="fid">The ID of the feature (may be null).</param> static void ReadData(EditDeserializer editDeserializer, out InternalIdValue id, out IEntity entity, out FeatureId fid) { id = editDeserializer.ReadInternalId(DataField.Id); entity = editDeserializer.ReadEntity(DataField.Entity); fid = editDeserializer.ReadFeatureId(); }
/// <summary> /// Initializes a new instance of the <see cref="FeatureStub"/> class /// that contains a copy of the properties of a feature. /// </summary> /// <param name="f">The feature containing the properties to copy (not null).</param> /// <exception cref="ArgumentNullException">If the supplied feature is null.</exception> internal FeatureStub(IFeature f) { if (f == null) throw new ArgumentNullException(); m_Creator = f.Creator; m_InternalId = f.InternalId; m_What = f.EntityType; m_Id = f.FeatureId; }
/// <summary> /// Mark this line as inactive. /// </summary> /// <param name="op">The operation that is doing this</param> /* internal void SetInactive(Operation op) { throw new NotImplementedException(); } */ /* // @mfunc Mark this arc as inactive. When you do this, any // system-defined split sections will be eliminated. // // @parm The operation that is doing this. This operation will // hold any sub-features that get created as a result of // de-activating this arc. Only SetDeleted is expected to // pass in a null value. // @parm Is the arc being de-activated in order to trim a // dangling system-generated arc section? If so, DON'T // undo any splits that are incident on this arc. A // TRUE value should be specified ONLY by <mf CeSplit:: // Trim>. Default=FALSE. // // @rdesc Any sub-feature that was created to represent the // layers that this feature was NOT de-activated on. CeFeature* CeArc::SetInactive ( CeOperation* pop , const LOGICAL isTrim ) { // Return if this arc is already inactive (or marked for deletion). if ( this->IsInactive() ) return 0; // De-activate the base class. CeFeature* pSub = CeFeature::SetInactive(pop); // Ensure polygons on the left and right have been marked // for deletion. SetPolDeleted(); // Get any split operation listing arc sections (only returns // something if FFL_SYSTOPOL is set). CeSplit* pSplit = GetpSplit(); if ( pSplit ) { // Return if the splits have been revealed. if ( pSplit->IsRevealed() ) return pSub; // Mark all splits for deletion. RemoveSplits(); // If we created a sub-arc to represent layers that are // not being de-activated, mark it as moved, to force // re-intersection. if ( pSub ) pSub->SetMoved(); } // Check for overlaps with the line's end locations. if ( !isTrim ) m_pLine->UndoEndOverlaps(*this); return pSub; } // end of SetInactive */ /// <summary> /// Make a new line that corresponds to a sub-section of this line. /// </summary> /// <param name="creator">The operation that should be noted as the creator of the new line.</param> /// <param name="id">The internal ID to assign to the sub-section.</param> /// <param name="section">The geometry for the new line.</param> /// <returns>The new line</returns> internal LineFeature MakeSubSection(Operation creator, InternalIdValue id, SectionGeometry section) { LineFeature result = new LineFeature(creator, id, section); //PointFeature start = (PointFeature)section.Start; //PointFeature end = (PointFeature)section.End; //LineFeature result = new LineFeature(this.EntityType, op, start, end, section); DefineFeature(result); // The resultant sub-section should always have the same topological status //if (result.IsTopological) // result.m_Topology = Topology.CreateTopology(result); result.SetTopology(this.IsTopological); return result; }
/// <summary> /// Creates a section for this subdivision op. /// </summary> /// <param name="id">The internal of this feature within the project that created it.</param> /// <param name="start">The point at the start of the section</param> /// <param name="end">The point at the end of the section</param> /// <returns>The created section</returns> internal LineFeature MakeSection(InternalIdValue id, PointFeature start, PointFeature end) { SectionGeometry section = new SectionGeometry(m_Line, start, end); LineFeature newLine = m_Line.MakeSubSection(this, id, section); //MapModel.EditingIndex.Add(newLine); return newLine; }
internal ForwardRefArrayItem(InternalIdValue id, int arrayIndex) { InternalId = id; ArrayIndex = arrayIndex; Feature = null; }
/// <summary> /// Creates a new text feature /// </summary> /// <param name="creator">The operation creating the text</param> /// <param name="id">The internal ID of this feature within the /// project that created it.</param> /// <param name="ent">The entity type for the string.</param> /// <param name="text">The text geometry (including the text string itself)</param> /// </param> internal TextFeature(Operation creator, InternalIdValue id, IEntity ent, TextGeometry text) : base(creator, id, ent, null) { m_Geom = text; m_Container = null; }
/// <summary> /// Creates a stub for an item in this path. /// </summary> /// <param name="itemSequence">The sequence number to assign to the stub</param> /// <param name="ent">The entity type for the stub</param> /// <returns>The created stub</returns> FeatureStub CreateStub(uint itemSequence, IEntity ent) { InternalIdValue iid = new InternalIdValue(itemSequence); return new FeatureStub(this, iid, ent, null); }
/// <summary> /// Creates stubs for all items that might be created by executing this edit. /// </summary> /// <param name="p">The project the stubs relate to.</param> /// <param name="pointType">The entity type for created points</param> /// <param name="lineType">The entity type for created lines</param> /// <returns></returns> /// <remarks>The main reason for doing so is to express any miss-connects or omit-points /// that may have been specified via the data entry string (the lack of a stub means the /// feature won't be created). User-perceived IDs are not recorded as part of the stubs, /// they need to be handled separately after the features have been created.</remarks> FeatureStub[] CreateStubs(Project p, IEntity pointType, IEntity lineType) { List<FeatureStub> stubList = new List<FeatureStub>(); foreach (Leg leg in m_Legs) { // Reserve item for point at center of circular arc (if it is one) var iid = new InternalIdValue(leg.ItemSequence); stubList.Add(new FeatureStub(this, iid, pointType, null)); // Reserve two items for each span along the leg FeatureStub[] faceStubs = leg.PrimaryFace.CreateStubs(this, pointType, lineType); stubList.AddRange(faceStubs); if (leg.AlternateFace != null) { // When we create features for alternate faces, we don't actually create // a point at the end of the leg (instead, we use the end point that was // created via the primary face). So here we'll be creating a stub that // doesn't usually get used. One special case is that the end point // may have been explicitly omitted from the primary face. faceStubs = leg.AlternateFace.CreateStubs(this, pointType, lineType); stubList.AddRange(faceStubs); } } return stubList.ToArray(); }
/// <summary> /// Creates a stub for an item in this path. /// </summary> /// <param name="itemSequence">The sequence number to assign to the stub</param> /// <param name="ent">The entity type for the stub</param> /// <returns>The created stub</returns> FeatureStub CreateStub(uint itemSequence, IEntity ent) { InternalIdValue iid = new InternalIdValue(itemSequence); return(new FeatureStub(this, iid, ent, null)); }
int GetFaceIndex(InternalIdValue sequence) { for (int i=0; i<m_Faces.Count; i++) { if (m_Faces[i].Sequence.Equals(sequence)) return i; } return -1; }
/// <summary> /// Initializes a new instance of the <see cref="IdMapping"/> class. /// </summary> /// <param name="internalId">The internal id.</param> /// <param name="rawId">The raw value for an associated instance of <see cref="NativeId"/>.</param> internal IdMapping(InternalIdValue internalId, uint rawId) { m_InternalId = internalId; m_RawId = rawId; }
/// <summary> /// Initializes a new instance of the <see cref="IdMapping"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal IdMapping(EditDeserializer editDeserializer) { m_InternalId = editDeserializer.ReadInternalId(DataField.Id); m_RawId = editDeserializer.ReadUInt32(DataField.Key); }
/// <summary> /// Creates a new <c>LineFeature</c> /// </summary> /// <param name="creator">The operation that created the feature (not null)</param> /// <param name="id">The internal ID of this feature within the /// project that created it.</param> /// <param name="e">The entity type for the feature (not null)</param> /// <param name="g">The geometry defining the shape of the line (not null)</param> /// <note>To ensure that the start and end of all lines are instances of <see cref="PointFeature"/>, /// this constructor should always remain private.</note> protected LineFeature(Operation creator, InternalIdValue id, IEntity e, PointFeature start, PointFeature end, LineGeometry g) : base(creator, id, e, null) { if (g==null) throw new ArgumentNullException(); m_From = start; m_To = end; m_Geom = g; m_Topology = null; AddReferences(); // If the entity type denotes a topological boundary, initialize the topology. if (e.IsPolygonBoundaryValid) SetTopology(true); }
/// <summary> /// Creates a <c>LineFeature</c> consisting of a simple line segment. /// </summary> /// <param name="creator">The operation that created the feature (not null)</param> /// <param name="id">The internal ID of this feature within the project that created it.</param> /// <param name="e">The entity type for the feature.</param> /// <param name="start">The point at the start of the line</param> /// <param name="end">The point at the end of the line</param> internal LineFeature(Operation creator, InternalIdValue id, IEntity e, PointFeature start, PointFeature end) : this(creator, id, e, start, end, new SegmentGeometry(start, end)) { }
/// <summary> /// Creates line sections along this face. /// </summary> /// <param name="parentLine">The line that is being subdivided</param> /// <param name="ff">Factory for producing new features (the important thing /// is the editing operation that's involved).</param> /// <param name="isTopological">Should the sections be tagged as polygon boundaries?</param> internal void CreateSections(LineFeature parentLine, FeatureFactory ff, bool isTopological) { // Must have at least two distances if (m_Distances == null) throw new ArgumentNullException(); if (m_Distances.Length < 2) throw new ArgumentException(); m_Sections = new List<LineFeature>(m_Distances.Length); PointFeature start = parentLine.StartPoint; InternalIdValue item = new InternalIdValue(ff.Creator.EditSequence); for (int i = 0; i < m_Distances.Length; i++) { PointFeature end; if (i == m_Distances.Length - 1) end = parentLine.EndPoint; else { item.ItemSequence++; end = ff.CreatePointFeature(item.ToString()); } item.ItemSequence++; LineFeature line = ff.CreateSection(item.ToString(), parentLine, start, end); line.ObservedLength = m_Distances[i]; if (!isTopological) line.SetTopology(false); m_Sections.Add(line); start = end; } }
/// <summary> /// Attempts to locate the face with a specific ID. /// </summary> /// <param name="faceId">The ID of the face to look for.</param> /// <returns>The corresponding face (null if not found)</returns> internal LegFace FindFace(InternalIdValue faceId) { foreach (Leg leg in m_Legs) { if (leg.PrimaryFace.Sequence.Equals(faceId)) return leg.PrimaryFace; if (leg.AlternateFace != null && leg.AlternateFace.Sequence.Equals(faceId)) return leg.AlternateFace; } return null; }
/// <summary> /// Creates a <c>LineFeature</c> consisting of a series of connected line segments. /// </summary> /// <param name="creator">The operation that created the feature (not null)</param> /// <param name="id">The internal ID of this feature within the project that created it.</param> /// <param name="e">The entity type for the feature.</param> /// <param name="start">The point at the start of the line</param> /// <param name="end">The point at the end of the line</param> /// <param name="data">The positions defining the shape of the line. The first position must /// coincide precisely with the supplied <paramref name="start"/>, and the last position /// must coincide precisely with <paramref name="end"/>. Expected to be more than two positions.</param> internal LineFeature(Operation creator, InternalIdValue id, IEntity e, PointFeature start, PointFeature end, PointGeometry[] data) : this(creator, id, e, start, end, new MultiSegmentGeometry(start, end, data)) { Debug.Assert(data.Length>2); Debug.Assert(start.Geometry.IsCoincident(data[0])); Debug.Assert(end.Geometry.IsCoincident(data[data.Length-1])); }
/// <summary> /// Creates a stub for an item on this face. /// </summary> /// <param name="itemSequence">The sequence number to assign to the stub</param> /// <param name="ent">The entity type for the stub</param> /// <returns>The created stub</returns> FeatureStub CreateStub(Operation creator, uint itemSequence, IEntity ent) { InternalIdValue iid = new InternalIdValue(itemSequence); return new FeatureStub(creator, iid, ent, null); }
internal LineFeature(Operation creator, InternalIdValue id, SectionGeometry section) : this(creator, id, section.BaseLine.EntityType, (PointFeature)section.Start, (PointFeature)section.End, section) { }