Exemple #1
0
        public FileResult GetPolygonOSM(string address, int frequency, string fileName)
        {
            OSM    osm       = new OSM();
            Root   root      = new Root();
            string result    = osm.GetUrl("\"" + address + "\"");
            var    webClient = new WebClient();
            var    json      = webClient.DownloadString(result);

            root = JsonConvert.DeserializeObject <Root>(json);
            byte[] coordinatesBytes = osm.GetCoordinates(root, frequency).SelectMany(s => Encoding.Default.GetBytes(s)).ToArray();
            return(File(coordinatesBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
        public RoadMaker2(OSM.OSMInterface osm)
        {
            this.osm = osm;
            this.rand = new Randomizer(0u);

            var roadTypes = Enum.GetNames(typeof(RoadTypes));
            for (var i = 0; i < PrefabCollection<NetInfo>.PrefabCount(); i += 1)
            {
                var pp = PrefabCollection<NetInfo>.GetPrefab((uint)i);
                if (pp != null)
                {
                    if (roadTypes.Contains(pp.name.Replace(" ", "")))
                    {
                        netInfos.Add((RoadTypes)Enum.Parse(typeof(RoadTypes), pp.name.Replace(" ", "")), pp);
                    }
                }

            }
        }
Exemple #3
0
        private static void HandleNewStop(Member way, OSM osm, List <Element> stops)
        {
            var bothStops = osm.Elements.Where(e => e.Id == way.Ref).ToList();
            var stop      = bothStops.FirstOrDefault(s => s.Lat.HasValue);

            if (stop == null)
            {
                return;
            }
            bothStops.Remove(stop);
            var currentName = "";

            if (stop.Tags == null)
            {
                stop.Tags = new Dictionary <string, string>();
            }
            if (stop.Tags.ContainsKey("name"))
            {
                currentName = stop.Tags["name"];
            }
            var cityElement = bothStops.Where(s => s.Tags.ContainsKey("is_in")).FirstOrDefault();

            if (cityElement != null)
            {
                var city = cityElement.Tags["is_in"];
                if (!currentName.Contains(city))
                {
                    currentName = city + ", " + currentName;
                }
            }
            if (stop.Tags.ContainsKey("friendlyName"))
            {
                stop.Tags["friendlyName"] = currentName;
            }
            else
            {
                stop.Tags.Add("friendlyName", currentName);
            }
            if (stop != null && stop.Lon != null && stop.Lat != null)
            {
                AddRelevantStops(stops, stop);
            }
        }