Ejemplo n.º 1
0
        private static string drawSVG(List <Station> stations, Dictionary <ushort, MapTransportLine> transportLines, string mapName, float minX, float minY, float maxX, float maxY)
        {
            float maxRadius = Math.Max(stations.Max(x => x.getAllStationOffsetPoints().Count) * 2 + 2, 10);

            SVGTemplate svg = new SVGTemplate((int)((maxY - minY + 16)), (int)((maxX - minX + 16)), maxRadius, minX - maxRadius, minY - maxRadius);

            var linesOrdened = transportLines.OrderBy(x => getLineUID(x.Key)).ToList();

            //ordena pela quantidade de linhas passando
            stations = stations.OrderBy(x => x.linesPassingCount).ToList();

            //calcula as posições de todas as estações no mapa
            foreach (var line in linesOrdened)
            {
                var station0 = line.Value[0];
                var prevPos  = station0.getPositionForLine(line.Key, line.Value[1].centralPos);
                for (int i = 1; i < line.Value.stationsCount(); i++)
                {
                    prevPos = line.Value[i].getPositionForLine(line.Key, prevPos);
                }
            }
            //adiciona as exceções
            svg.addStationsToExceptionMap(stations);
            //pinta as linhas
            foreach (var line in linesOrdened)
            {
                svg.addTransportLine(line.Value, line.Key);
            }
            svg.drawAllLines();
            foreach (var station in stations)
            {
                svg.addStation(station, transportLines);
            }
            String folder = "Transport Lines Manager";

            if (File.Exists(folder) && (File.GetAttributes(folder) & FileAttributes.Directory) != FileAttributes.Directory)
            {
                File.Delete(folder);
            }
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            String filename = folder + Path.DirectorySeparatorChar + "TLM_MAP_" + mapName + ".html";

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            var sr = File.CreateText(filename);

            sr.WriteLine(svg.getResult());
            sr.Close();
            return(filename);
        }
Ejemplo n.º 2
0
        private static string drawSVG(List <Station> stations, Dictionary <ushort, MapTransportLine> transportLines, string cityName, string cityId, DateTime currentTime, float minX, float minY, float maxX, float maxY)
        {
            float maxRadius = Math.Max(stations.Max(x => x.getAllStationOffsetPoints().Count) * 2 + 2, 10);

            var svg = new SVGTemplate((int)((maxY - minY + 16)), (int)((maxX - minX + 16)), maxRadius, minX - maxRadius, minY - maxRadius);

            var linesOrdened = transportLines.OrderBy(x => getLineUID(x.Key)).ToList();

            //ordena pela quantidade de linhas passando
            stations = stations.OrderBy(x => x.linesPassingCount).ToList();

            //calcula as posições de todas as estações no mapa
            foreach (KeyValuePair <ushort, MapTransportLine> line in linesOrdened)
            {
                Station station0 = line.Value[0];
                Vector2 prevPos  = station0.getPositionForLine(line.Key, line.Value[1].centralPos);
                for (int i = 1; i < line.Value.stationsCount(); i++)
                {
                    prevPos = line.Value[i].getPositionForLine(line.Key, prevPos);
                }
            }
            //adiciona as exceções
            svg.addStationsToExceptionMap(stations);
            //pinta as linhas
            foreach (KeyValuePair <ushort, MapTransportLine> line in linesOrdened)
            {
                svg.addTransportLine(line.Value, line.Key);
            }
            svg.drawAllLines();
            foreach (Station station in stations)
            {
                svg.addStation(station, transportLines);
            }
            string   cityMapsFolder = TLMController.exportedMapsFolder + Path.DirectorySeparatorChar + $"{cityName} ({cityId})";
            FileInfo fipalette      = FileUtils.EnsureFolderCreation(cityMapsFolder);
            string   filename       = cityMapsFolder + Path.DirectorySeparatorChar + currentTime.ToString("yyyy-MM-dd-HH-mm-ss") + ".html";

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            StreamWriter sr  = File.CreateText(filename);
            var          cto = new CityTransportObject
            {
                transportLines = transportLines
            };

            sr.WriteLine(svg.getResult(cto, cityName, currentTime));
            sr.Close();
            return(filename);
        }