/// <summary> /// Create a child node /// </summary> /// <param name="type">The node type</param> /// <returns>The child node</returns> internal SpatialBuilderNode CreateChildren(SpatialType type) { var node = new SpatialBuilderNode { Parent = this, Type = type }; this.Children.Add(node); return(node); }
internal override void BeginGeo(SpatialType type) { if (this.currentNode == null) { SpatialBuilderNode node = new SpatialBuilderNode { Type = type }; this.currentNode = node; this.lastConstructedNode = null; } else { this.currentNode = this.currentNode.CreateChildren(type); } }
/// <summary> /// Begin a new spatial type /// </summary> /// <param name="type">The spatial type</param> internal override void BeginGeo(SpatialType type) { Debug.Assert(type != SpatialType.Unknown, "cannot build unknown type - should have validated this call"); // traverse down the tree); if (this.currentNode == null) { this.currentNode = new SpatialBuilderNode { Type = type }; // we are just getting started, clear the last built this.lastConstructedNode = null; } else { this.currentNode = this.currentNode.CreateChildren(type); } }
/// <summary> /// Ends the figure set on the current node /// </summary> internal override void EndFigure() { Debug.Assert(this.currentFigure != null, "current figure is null - call AddPointToNode before ending a figure"); // Attach the figure to the current node if (this.currentFigure.Count == 1) { // point SpatialBuilderNode pointNode = this.currentNode.CreateChildren(SpatialType.Point); pointNode.Instance = this.currentFigure[0]; } else { SpatialBuilderNode lineStringNode = this.currentNode.CreateChildren(SpatialType.LineString); lineStringNode.Instance = this.CreateShapeInstance(SpatialType.LineString, this.currentFigure); } // need to clear current figure, since next geography may not contain a figure this.currentFigure = null; }
/// <summary> /// Traverses up the tree. /// </summary> private void TraverseUpTheTree() { this.lastConstructedNode = this.currentNode; this.currentNode = this.currentNode.Parent; }
/// <summary> /// Setup the pipeline for reuse /// </summary> internal override void Reset() { this.currentNode = null; this.currentFigure = null; }