private void DoTestFile(string file) { if (!File.Exists(file)) Assert.Inconclusive("File {0} does not exist", file); var r = new WKTFileReader(file, new WKTReader(factory)); var geoms = r.Read(); var ls = new LineSequencer(); ls.Add(geoms); if (!ls.IsSequenceable()) Assert.Inconclusive("Linework not sequencable"); var seq = ls.GetSequencedLineStrings(); Assert.Less(seq.NumGeometries, geoms.Count); }
public static IGeometry SequenceLines(IGeometry g) { LineSequencer ls = new LineSequencer(); ls.Add(g); return ls.GetSequencedLineStrings(); }
/// <summary> /// Takes the path returned from QuickGraph library and uses the /// list of coordinates to reconstruct the path into a geometric /// "shape" /// </summary> /// <param name="paths">Shortest path from the QucikGraph Library</param> /// <returns> /// A <see cref="ILineString"/> or a <see cref="IMultiLineString"/> /// with all the elements of the graph that composes the shortest path, /// sequenced using a <see cref="LineSequencer"/>. /// </returns> private IGeometry BuildString(ICollection<IEdge<Coordinate>> paths) { // if the path has no links then return a null reference if (paths.Count < 1) return null; var collector = new LineSequencer(); foreach (var path in paths) { var src = path.Source; var dst = path.Target; foreach (var str in strings) { if (IsBound(str, src) && IsBound(str, dst)) collector.Add(str); } } var sequence = collector.GetSequencedLineStrings(); return sequence; }
private static void RunLineSequencer(String[] inputWKT, String expectedWKT) { try { IEnumerable<IGeometry> inputGeoms = FromWKT(inputWKT); LineSequencer sequencer = new LineSequencer(); sequencer.Add(inputGeoms); if (!sequencer.IsSequenceable()) Assert.IsNull(expectedWKT); else { IGeometry expected = rdr.Read(expectedWKT); IGeometry result = sequencer.GetSequencedLineStrings(); bool isTrue = expected.EqualsExact(result); Assert.IsTrue(isTrue, "Expected " + expected + " but was " + result); bool isSequenced = LineSequencer.IsSequenced(result); Assert.IsTrue(isSequenced, "result is not sequenced"); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); throw; } }
//========================================================== private static void RunLineSequencer(String[] inputWKT, String expectedWKT) { var inputGeoms = FromWKT(inputWKT); var sequencer = new LineSequencer(); sequencer.Add(inputGeoms); var isCorrect = false; if (!sequencer.IsSequenceable()) { Assert.IsTrue(expectedWKT == null); } else { var expected = Rdr.Read(expectedWKT); var result = sequencer.GetSequencedLineStrings(); var isOK = expected.EqualsNormalized(result); if (! isOK) { Console.WriteLine("ERROR - Expected: " + expected); Console.WriteLine(" Actual: " + result); } var isSequenced = LineSequencer.IsSequenced(result); Assert.IsTrue(isOK, "Result does not match expected (using EqualsNormalized)!"); Assert.IsTrue(isSequenced, "Result geometry is not sequenced!"); } }