Example #1
0
 private void UpdateGeometry()
 {
     if (Branch == null|| Branch.Geometry == null)
         return;
     
     var lengthIndexedLine = new LengthIndexedLine(Branch.Geometry);
     // thousand bombs and granates: ExtractPoint will give either a new coordinate or 
     // a reference to an existing object
     Geometry = new Point((ICoordinate)lengthIndexedLine.ExtractPoint(Offset).Clone());
 }
 /// <summary>
 /// return the coordinates along the gridProfile at stepSize intervals.
 /// </summary>
 /// <param name="gridProfile"></param>
 /// <param name="stepSize"></param>
 /// <returns></returns>
 public static IEnumerable<ICoordinate> GetGridProfileCoordinates(ILineString gridProfile, double stepSize)
 {
     var lengthIndexedLine = new LengthIndexedLine(gridProfile);
     if (0 == stepSize)
         throw new ArgumentException("Stepsize too small", "stepSize");
     int count = (int)((gridProfile.Length / stepSize) + 1);
     for (int i=0; i<count; i++)
     {
         yield return (ICoordinate)lengthIndexedLine.ExtractPoint(i * stepSize).Clone();
     }
 }
Example #3
0
        private void UpdateGeometry()
        {
            if (Branch == null || Branch.Geometry == null)
                return;

            var lengthIndexedLine = new LengthIndexedLine(Branch.Geometry);

            var offset = Branch.IsLengthCustom ? SnapChainage(Branch.Geometry.Length, (Branch.Geometry.Length / Branch.Length) * Chainage) : Chainage;
            // always clone: ExtractPoint will give either a new coordinate or a reference to an existing object
            Geometry = new Point((ICoordinate)lengthIndexedLine.ExtractPoint(offset).Clone());
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="wkt"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        public void RunExtractedLine(string wkt, double start, double end)    
        {
            Console.WriteLine("=========================");
            IGeometry g1 = rdr.Read(wkt);
            Console.WriteLine("Input Geometry: " + g1);
            Console.WriteLine("Indices to extract: " + start + " " + end);
            
            LengthIndexedLine indexedLine = new LengthIndexedLine(g1);

            IGeometry subLine = indexedLine.ExtractLine(start, end);
            Console.WriteLine("Extracted Line: " + subLine);

            double[] index = indexedLine.IndicesOf(subLine);
            Console.WriteLine("Indices of extracted line: " + index[0] + " " + index[1]);

            ICoordinate midpt = indexedLine.ExtractPoint((index[0] + index[1]) / 2);
            Console.WriteLine("Midpoint of extracted line: " + midpt);
        }