private Graphic GenerateGraphic(CitynamesEntityItem item, Color color) { MapPoint point = new MapPoint(item.Longitude, item.Latitude, SpatialReferences.Wgs84); var graphic = new Graphic(point); var symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = color, Size = 4 }; graphic.Symbol = symbol; graphic.Attributes["Name"] = item.Name; return(graphic); }
public CitynamesEntity RetrieveEntity() { if (!File.Exists(this.filePath)) { throw new FileNotFoundException(this.filePath); } var result = new CitynamesEntity(); using (var reader = new StreamReader(this.filePath)) { string pattern = @"\s+"; string line = reader.ReadLine()?.Trim(); if (string.IsNullOrEmpty(line)) { throw new InvalidDataException(this.filePath); } var array = Regex.Split(line, pattern); result.Description = array[0]; var count = 0; while ((line = reader.ReadLine()?.Trim()) != null) { count++; array = Regex.Split(line, pattern); if (array.Length != 3) { throw new InvalidDataException(this.filePath); } var item = new CitynamesEntityItem(); item.Longitude = Convert.ToSingle(array[0]); item.Latitude = Convert.ToSingle(array[1]); item.Name = array[2]; result.Items.Add(item); } } return(result); }