/// <summary> /// Creates any circle that's required for arcs that sit on this leg. This method must /// be called before making any calls to <see cref="CreateLine"/>. /// </summary> /// <param name="ff">The factory for creating new spatial features</param> /// <param name="itemName">The name for the item that represents the point at the center of the circle</param> /// <returns>The created circle (with an undefined radius)</returns> internal Circle CreateCircle(FeatureFactory ff, string itemName) { // Create a center point, and cross-reference to a new circle (with undefined radius) PointFeature center = ff.CreatePointFeature(itemName); m_Circle = new Circle(center, 0.0); m_Circle.AddReferences(); return(m_Circle); }
/// <summary> /// Creates a line feature that corresponds to one of the spans on this leg. /// Before calling this override, the circle object associated with this leg must /// be defined, via a call to <see cref="CreateCircle"/>. /// </summary> /// <param name="ff">The factory for creating new spatial features</param> /// <param name="itemName">The name for the item involved</param> /// <param name="from">The point at the start of the line (not null).</param> /// <param name="to">The point at the end of the line (not null).</param> /// <returns>The created line (never null)</returns> /// <exception cref="InvalidOperationException">If the underlying circle for this leg has not /// been created via a prior call to <see cref="CreateCircle"/>.</exception> internal override LineFeature CreateLine(FeatureFactory ff, string itemName, PointFeature from, PointFeature to) { if (m_Circle == null) { throw new InvalidOperationException("Circle for circular arc has not been defined"); } ArcFeature result = ff.CreateArcFeature(itemName, from, to); // We have to create a geometry object at this stage, so that the circle can be // cross-referenced to created arcs. However, it's not fully defined because the // circle radius will likely be zero at this stage. result.Geometry = new ArcGeometry(m_Circle, from, to, m_Metrics.IsClockwise); return(result); }
/// <summary> /// Executes a brand new editing operation that is part of the working session /// (as opposed to a historical session that is being deserialized from the database). /// </summary> /// <param name="op">The edit to execute</param> /// <param name="ff">The factory for creating new spatial features (specify null if /// the edit is not expected to create anything).</param> internal void Execute(FeatureFactory ff) { Debug.Assert(m_Session == CadastralMapModel.Current.WorkingSession); CadastralMapModel mapModel = this.MapModel; // Create the spatial features ProcessFeatures(ff); // Calculate any geometry for spatial features CalculateGeometry(null); // Index features that were created (and ensure the map extent has been // expanded to include the new features) Feature[] feats = ff.CreatedFeatures; if (feats.Length > 0) { // Attempt to associate new features with database attributes AttributeData.Load(feats); mapModel.AddToIndex(feats); // Define user-perceived IDs if necessary CreateIds(feats); // Ensure user-perceived ID objects have been indexed too mapModel.AddFeatureIds(feats); } // Point referenced features to this editing operation AddReferences(); // Mark any new topological lines as "moved" so that they will be // intersected with the map PrepareForIntersect(feats); // Ensure the map structure has been updated to account for the new data. mapModel.CleanEdit(); // Save the edit to the database m_Session.SaveOperation(this); }
/// <summary> /// Creates spatial features (points and lines) for this leg. The created /// features don't have any geometry. /// </summary> /// <param name="ff">The factory for creating new spatial features</param> /// <param name="startPoint">The point (if any) at the start of this leg. May be /// null in a situation where the preceding leg ended with an "omit point" directive.</param> /// <param name="lastPoint">The point that should be used for the very end /// of the leg (specify null if a point should be created at the end of the leg).</param> internal void CreateFeatures(FeatureFactory ff, PointFeature startPoint, PointFeature lastPoint) { // If we're dealing with a circular arc, create the underlying circle (and a // center point). The radius of the circle is undefined at this stage, but the // circle must be present so that created arcs can be cross-referenced to it. // Note that it is conceivable that the center point will end up coinciding with // another point in the map (it could even coincide with another circular leg in // the same connection path). CircularLeg cLeg = (this as CircularLeg); if (cLeg != null) { cLeg.CreateCircle(ff, this.ItemSequence.ToString()); } m_FirstSide.CreateFeatures(ff, startPoint, lastPoint); // Should the end of an alternate face share the end point of the primary face?? if (m_OtherSide != null) { // If the leg is right at the end of a connection path, the alternate face needs to // end at the specified point. Otherwise use the point that was created at the end // of the primary face (in unusual cases, it's possible that no point was created // there - in that case, the alternate face will create the end point). PointFeature endLegPoint = lastPoint; if (endLegPoint == null) { endLegPoint = m_FirstSide.GetEndPoint(ff.Creator); } m_OtherSide.CreateFeatures(ff, startPoint, endLegPoint); } }
/// <summary> /// Performs data processing that involves creating or retiring spatial features. /// Newly created features will not have any definition for their geometry - a /// subsequent call to <see cref="CalculateGeometry"/> is needed to to that. /// </summary> /// <param name="ff">The factory class for generating any spatial features</param> /// <remarks>This implementation does nothing. Derived classes that need to are /// expected to provide a suitable override.</remarks> internal virtual void ProcessFeatures(FeatureFactory ff) { // Do nothing }
/// <summary> /// Creates a line feature that corresponds to one of the spans on this leg. /// </summary> /// <param name="ff">The factory for creating new spatial features</param> /// <param name="itemName">The name for the item involved</param> /// <param name="from">The point at the start of the line (not null).</param> /// <param name="to">The point at the end of the line (not null).</param> /// <returns>The created line (never null)</returns> abstract internal LineFeature CreateLine(FeatureFactory ff, string itemName, PointFeature from, PointFeature to);
/* * /// <summary> * /// Draws a previously saved leg. * /// </summary> * /// <param name="preview">True if the path should be drawn in preview * /// mode (i.e. in the normal construction colour, with miss-connects * /// shown as dotted lines).</param> * internal override void Draw(bool preview) * { * EditingController ec = EditingController.Current; * ISpatialDisplay display = ec.ActiveDisplay; * IDrawStyle style = ec.DrawStyle; * * int nfeat = this.Count; * * for (int i = 0; i < nfeat; i++) * { * Feature feat = GetFeature(i); * if (feat != null) * { * if (preview) * feat.Draw(display, Color.Magenta); * else * feat.Render(display, style); * } * } * } */ //internal override void Save(FeatureFactory ff, List<PointFeature> createdPoints, // ref IPosition terminal, ref double bearing, double sfac) //{ // // Add on any initial angle (it may be a deflection). // if (Math.Abs(m_StartAngle) > MathConstants.TINY) // { // if (m_IsDeflection) // bearing += m_StartAngle; // else // bearing += (m_StartAngle-Math.PI); // } // // Create a straight span // StraightSpan span = new StraightSpan(this, terminal, bearing, sfac); // int nspan = this.Count; // for (int i = 0; i < nspan; i++) // { // // Get info for the current span (this defines the // // adjusted start and end positions, among other things). // span.Get(i); // // Save the span // Feature feat = SaveSpan(span, ff, createdPoints, null, null, null, null); // SetFeature(i, feat); // } // // Return the end position of the last span. // terminal = span.End; //} /// <summary> /// Creates a line feature that corresponds to one of the spans on this leg. /// </summary> /// <param name="ff">The factory for creating new spatial features</param> /// <param name="itemName">The name for the item involved</param> /// <param name="from">The point at the start of the line (not null).</param> /// <param name="to">The point at the end of the line (not null).</param> /// <returns>The created line (never null)</returns> internal override LineFeature CreateLine(FeatureFactory ff, string itemName, PointFeature from, PointFeature to) { return(ff.CreateSegmentLineFeature(itemName, from, to)); }
/// <summary> /// Creates spatial features (points and lines) for this face. The created /// features don't have any geometry. /// </summary> /// <param name="ff">The factory for creating new spatial features</param> /// <param name="startPoint">The point (if any) at the start of this leg. May be /// null in a situation where the preceding leg ended with an "omit point" directive.</param> /// <param name="lastPoint">The point that should be used for the very end /// of the leg (specify null if a point should be created at the end of the leg).</param> internal void CreateFeatures(FeatureFactory ff, PointFeature startPoint, PointFeature lastPoint) { PointFeature from = startPoint; PointFeature to = null; // The initial item sequence relates to the face itself. The first feature along the face will // have a sequence number one higher. uint maxSequence = this.Sequence.ItemSequence; int nSpan = m_Spans.Length; for (int i = 0; i < nSpan; i++, from = to) { SpanInfo span = GetSpanData(i); // If we have an end point, add it (so long as this span is not // at the very end of the connection path). to = null; maxSequence++; if (span.HasEndPoint) { if (i == (nSpan - 1)) { to = lastPoint; } if (to == null) { to = ff.CreatePointFeature(maxSequence.ToString()); } Debug.Assert(to != null); } // A line can only exist if both end points are defined (the "omit point" // directive may well be used to finish a leg without a point, so the first // span in the next leg can't have a line). maxSequence++; if (span.HasLine && from != null) { LineFeature line = this.Leg.CreateLine(ff, maxSequence.ToString(), from, to); line.ObservedLength = span.ObservedDistance; // Alternate faces should by non-topological. And mark as "void" so that it can be // skipped on export to AutoCad. if (FaceNumber == 2) { line.SetTopology(false); // should probably be false already line.IsVoid = true; } span.CreatedFeature = line; } else { span.CreatedFeature = to; } } }