示例#1
0
        public static Geometry SequenceLines(Geometry g)
        {
            var 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);
        }
示例#3
0
        private static void RunIsSequenced(string inputWKT, bool expected)
        {
            var  g           = Rdr.Read(inputWKT);
            bool isSequenced = LineSequencer.IsSequenced(g);

            Assert.IsTrue(isSequenced == expected);
        }
示例#4
0
        //==========================================================

        private static void RunLineSequencer(string[] inputWKT, string expectedWKT)
        {
            var inputGeoms = FromWKT(inputWKT);
            var sequencer  = new LineSequencer();

            sequencer.Add(inputGeoms);

            bool isCorrect = false;

            if (!sequencer.IsSequenceable())
            {
                Assert.IsTrue(expectedWKT == null);
            }
            else
            {
                var  expected = Rdr.Read(expectedWKT);
                var  result   = sequencer.GetSequencedLineStrings();
                bool isOK     = expected.EqualsNormalized(result);
                if (!isOK)
                {
                    Console.WriteLine("ERROR - Expected: " + expected);
                    Console.WriteLine("          Actual: " + result);
                }

                bool isSequenced = LineSequencer.IsSequenced(result);
                Assert.IsTrue(isOK, "Result does not match expected (using EqualsNormalized)!");
                Assert.IsTrue(isSequenced, "Result geometry is not sequenced!");
            }
        }
示例#5
0
        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; }
        }
示例#6
0
 private static void RunIsSequenced(String inputWKT, bool expected)
 {
     try
     {
         IGeometry g           = rdr.Read(inputWKT);
         bool      isSequenced = LineSequencer.IsSequenced(g);
         Assert.IsTrue(isSequenced == expected);
     }
     catch (Exception ex) { Debug.WriteLine(ex.ToString()); throw ex; }
 }
        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);
        }