/// <summary> /// Obtains the position ratio for a position that is coincident with a line. /// </summary> /// <param name="line">The line the position is coincident with</param> /// <param name="posn">The position on the line</param> /// <returns>The position ratio of the position, expressed in the numeric range /// expected by this editing operation.</returns> /// <exception cref="ArgumentException">If the position does not appear to coincide /// with the supplied line.</exception> static internal uint GetPositionRatio(LineFeature line, IPosition posn) { // Get the distance to the supplied position (confirming that it does fall on the line) LineGeometry g = line.LineGeometry; double lineLen = g.Length.Meters; double posnLen = g.GetLength(posn).Meters; if (posnLen < 0.0) { throw new ArgumentException("Position does not appear to coincide with line."); } // Express the position as a position ratio in the range [0,1 billion] double prat = posnLen / lineLen; uint result = (uint)(prat * (double)MAX_POSITION_RATIO); Debug.Assert(result <= MAX_POSITION_RATIO); return(result); }