/// <summary>
        /// Produce an output that records ways that got kept.
        /// </summary>
        public void OutputGraph(Graph <Node> graph, DirectedEdgeMetadata <Node, Way> wayMap, string filename)
        {
            var fullPath = Path.Combine(_outputLocation, filename);

            var converter = new GeoJsonConverter();
            var ways      = new Dictionary <Way, int>();

            foreach (var neighbor1 in graph.Neighbors)
            {
                foreach (var neighbor2 in neighbor1.Value.Where(x => x.PrimaryCopy))
                {
                    var way = wayMap[neighbor1.Key, neighbor2.Vertex];
                    if (ways.ContainsKey(way))
                    {
                        ways[way]++;
                    }
                    else
                    {
                        ways.Add(way, 1);
                    }
                }
            }

            var polygonOut = converter.Convert(ways.Keys);
            var serialized = JsonConvert.SerializeObject(polygonOut);

            File.WriteAllLines(fullPath, new[] { serialized });
        }
Exemple #2
0
        /// <summary>
        /// Produce an output that records ways that got kept.
        /// </summary>
        public void OutputGraph(LinkedList <WeightedAdjacencyNode <Node> > route, DirectedEdgeMetadata <Node, Way> wayMap,
                                string filename)
        {
            var fullPath  = Path.Combine(_outputLocation, filename);
            var converter = new GeoJsonConverter();

//            var prevIt = route.First;
//            for (var it = prevIt.Next; it != null;)
//            {
//                if (prevIt.Value.Vertex != it.Value.Vertex)
//                {
//                    if (wayMap.ContainsKey(prevIt.Value.Vertex, it.Value.Vertex))
//                    {
//                        var way = wayMap[prevIt.Value.Vertex, it.Value.Vertex];
//                        Console.WriteLine(way.Tags["name"]);
//                    }
//                    else
//                    {
//                        Console.WriteLine("Missing");
//                    }
//                }
//
//                it = it.Next;
//            }

            var polygonOut = converter.Convert(route.Select(x => x.Vertex));
            var serialized = JsonConvert.SerializeObject(polygonOut);

            File.WriteAllLines(fullPath, new[] { serialized });
        }
Exemple #3
0
        public void OutputWays(IEnumerable <Way> ways, string filename)
        {
            var fullPath   = Path.Combine(_path, filename);
            var converter  = new GeoJsonConverter();
            var polygonOut = converter.Convert(ways);
            var serialized = JsonConvert.SerializeObject(polygonOut);

            File.WriteAllLines(fullPath, new[] { serialized });
        }
Exemple #4
0
        public static void DebugOut(List <Way> ways, string filename)
        {
            var fullPath   = Path.Combine(outputLocation, filename);
            var converter  = new GeoJsonConverter();
            var polygonOut = converter.Convert(ways);
            var serialized = JsonConvert.SerializeObject(polygonOut);

            File.WriteAllLines(fullPath, new[] { serialized });
        }
        private void BuildGraph(LinkedList <WayStep> waySteps)
        {
            var fullPath  = Path.Combine(_outputLocation, _graphFilename);
            var converter = new GeoJsonConverter();

            var ways = waySteps.GroupBy(x => x.Path).ToDictionary(x => x.Key, x => x.Count());

            foreach (var way in ways)
            {
                way.Key.Tags.Add("EdgeWeight", way.Value.ToString());
            }
            var polygonOut = converter.Convert(ways.Keys);
            var serialized = JsonConvert.SerializeObject(polygonOut);

            File.WriteAllLines(fullPath, new[] { serialized });
        }