private void BuildStreetAddress(StringBuilder builder, bool includeSiteName = true) { // street_address = name_part number_part street_part // name_part = (address_site_name SP / building_part) // building_part = ( / building_name SP) // street_part = street_name ( / SP street_type) ( / SP street_suffix) // name_part if (includeSiteName && SiteName.HasValue()) { builder.Append(SiteName); builder.Append(Sp); // need building_name from datasets } number_part(builder); // street_part builder.Append(StreetName); if (StreetType.HasValue()) { builder.Append(Sp); builder.Append(StreetType); } if (StreetSuffix.HasValue()) { builder.Append(Sp); builder.Append(StreetSuffix); } }
private static NormalStreetTypeFinder GetFinder(AddressParseContainer container) { var streetTypes = StreetType.From( new string[] { "ALLEY", "AVENUE", "BOULEVARD", "CIRCLE", "CONNECTOR", "COURT", "DRIVE", "HIGHWAY", "KEY", "LANE", "LOOP", "MALL", "PARKWAY", "PLACE", "ROAD", "STREET", "SQUARE", "TERRACE", "WAY" }); var splitter = new AddressSplitter(container); var finder = new NormalStreetTypeFinder(container, streetTypes); splitter.SplitAndClean(); return(finder); }
public async Task SaveAsync(StreetType entity) { try { if (entity == null) { return; } using (var timeLineContext = _contextFactory.GetTimeLineContext()) { var entityModel = await timeLineContext .StreetTypes .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id)); if (entityModel == null) { entityModel = new DA.StreetType(); MapForUpdateentity(entity, entityModel); await timeLineContext.StreetTypes.AddAsync(entityModel); } else { MapForUpdateentity(entity, entityModel); } timeLineContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { StreetType streetType = (StreetType)value; return(streetType.NAME); //throw new NotImplementedException(); }
private StreetType AssignStreetType()//Assigns StreetType { var random = new Random(); var position = random.Next(0, 12); String streetType = Enum.GetName(typeof(StreetType), position); return(this.streetType = (StreetType)Enum.Parse(typeof(StreetType), streetType)); }
static void NormalizeAddresses(List <string> args) { Console.WriteLine("Normalize Addresses"); if (args.Count < 3) { throw new NormalException("Not enough arguments! Usage: alba normalize-addresses <alba-tsv-input-file> <alba-tsv-output-file>"); } string inputPath = args[1]; string outputPath = args[2]; Console.WriteLine($"Input File Path: {inputPath}"); Console.WriteLine($"Output File Path: {outputPath}"); var addresses = LoadTsvAlbaAddresses.LoadFrom(inputPath); var streetTypes = StreetType.Parse(StreetTypes); var parser = new CompleteAddressParser(streetTypes); var errors = new List <AlbaAddressExport>(); var normalized = new List <AlbaAddressExport>(); foreach (var a in addresses) { try { //string before = $"{a.Address}, {a.Suite}, {a.City}, {a.Province}, {a.Postal_code}"; var address = parser.Normalize($"{a.Address}, {a.Suite}", a.City, a.Province, a.Postal_code); a.Address = address.CombineStreet(); a.Suite = address.CombineUnit(); a.City = address.City; a.Province = address.State; a.Postal_code = address.PostalCode; normalized.Add(a); //Console.WriteLine($"{before} :: {a.Address}, {a.Suite}, {a.City}, {a.Province}, {a.Postal_code}"); } catch (Exception e) { errors.Add(a); Console.WriteLine(e.Message); } } if (errors.Count > 0) { Console.WriteLine(); Console.WriteLine("Errors:"); foreach (var a in errors) { Console.WriteLine(a.Address); } Console.WriteLine($"Count: {errors.Count}"); } LoadTsvAlbaAddresses.SaveTo(normalized, outputPath); LoadTsvAlbaAddresses.SaveTo(errors, $"{outputPath}.errors.txt"); }
} //streetType property private StreetType GetStreetType() //the setup and return of streetType { var someStreet = new List <StreetType>(); foreach (StreetType street in Enum.GetValues //Looping through the enums of streetType (typeof(StreetType))) { someStreet.Add(street); //adding the enums to list } streetType = someStreet[rand.Next(someStreet.Count)]; //Get random StreetType from someStreet list for StreetType return(streetType); //return streetType }
public Address() { //Constructor, creates an object var random = new Random(); houseNumber = (uint)random.Next(1, 5000); AddToDictionary(ref stateDictionary); AddZipCode(ref zipCodeDictionary); state = AssignStateName(); zipCode = AssignZipCode(); city = AssignCity(); streetName = AssignStreet(); streetType = AssignStreetType(); }
public async Task <IActionResult> Put([FromBody] StreetType value) { try { var entity = _mapper.Map <BL.StreetType>(value); var id = _service.SaveAsync(entity); return(Ok(id)); } catch (Exception) { return(BadRequest()); } }
public static bool TryParseStreet(string part, out StreetType street) { street = StreetType.None; if (string.IsNullOrEmpty(part)) { return(false); } if (part.Length > 1) { if (Enum.TryParse(part, true, out street)) { return(true); } } else { switch (part.ToLower()) { case "aly": street = StreetType.Alley; return(true); case "ave": street = StreetType.Avenue; return(true); case "blvd": street = StreetType.Boulevard; return(true); case "cir": street = StreetType.Circle; return(true); case "ct": street = StreetType.Court; return(true); case "cv": street = StreetType.Cove; return(true); default: return(false); } } return(false); }
protected AddressBase(string inputAddress, int? houseNumber, double milepost, int poBox, Direction prefixDirection, string streetName, StreetType streetType, Direction suffixDirection, int zip4, int? zip5, bool isHighway, bool isPoBox) { InputAddress = inputAddress; HouseNumber = houseNumber; Milepost = milepost; PoBox = poBox; PrefixDirection = prefixDirection; StreetName = streetName; StreetType = streetType; SuffixDirection = suffixDirection; Zip4 = zip4; Zip5 = zip5; IsHighway = isHighway; IsPoBox = isPoBox; }
public CleansedAddress(string inputAddress, int?houseNumber, double milepost, int poBox, Direction prefixDirection, string streetName, StreetType streetType, Direction suffixDirection, int zip4, int?zip5, bool isHighway, bool isPobox) : base(inputAddress, houseNumber, milepost, poBox, prefixDirection, streetName, streetType, suffixDirection, zip4, zip5, isHighway, isPobox) { }
protected AddressBase(string inputAddress, int?houseNumber, double milepost, int poBox, Direction prefixDirection, string streetName, StreetType streetType, Direction suffixDirection, int zip4, int?zip5, bool isHighway, bool isPoBox) { InputAddress = inputAddress; HouseNumber = houseNumber; Milepost = milepost; PoBox = poBox; PrefixDirection = prefixDirection; StreetName = streetName; StreetType = streetType; SuffixDirection = suffixDirection; Zip4 = zip4; Zip5 = zip5; IsHighway = isHighway; IsPoBox = isPoBox; }
private static StreetTypeStreetNameFinder GetFinder(AddressParseContainer container) { var streetTypes = StreetType.From( new string[] { "ALLEY", "AVENUE", "CIRCLE", "WAY" }); var splitter = new AddressSplitter(container); var finder = new StreetTypeStreetNameFinder(container, streetTypes); splitter.SplitAndClean(); return(finder); }
protected void FreeSpace(StreetType last) { if (last is StreetSegment) { StreetSegment segment = (StreetSegment)last; int direction = segment.EP1.Connector == currentConnector ? 2 : 1; segment.FreeSpace(direction, size); } else if (last is StreetHub) { StreetHub hub = (StreetHub)last; hub.FreeSpace(size); } else { throw new StreetMapException("Unknown StreetType"); } }
public CleansedAddress(string inputAddress, int? houseNumber, double milepost, int poBox, Direction prefixDirection, string streetName, StreetType streetType, Direction suffixDirection, int zip4, int? zip5, bool isHighway, bool isPobox) : base(inputAddress, houseNumber, milepost, poBox, prefixDirection, streetName, streetType, suffixDirection, zip4, zip5, isHighway, isPobox) { }
public static List <StreetType> SelectAllStreetTypes() { MySqlCommand cmd = new MySqlCommand("SELECT street_types.ID, street_types.NAME FROM street_types"); DataTable result = DBConnect.Instance.Select(cmd); if (result == null) { return(null); } var streetTypesList = new List <StreetType>(); for (int i = 0; i < result.Rows.Count; i++) { int streetTypeID = Int32.Parse(result.Rows[i].ItemArray[0].ToString()); string streetTypeName = result.Rows[i].ItemArray[1].ToString(); StreetType streetType = new StreetType(streetTypeID, streetTypeName); streetTypesList.Add(streetType); } return(streetTypesList); }
public static string getStreetPath(StreetType street_type) { return(getStreetPath((int)street_type)); }
private List <StreetType> StreetTypes() { return(StreetType.From(streetTypes.Select(t => t.Full).ToArray())); }
public static int[] pickStreet(StreetType street_ype) { int[] result = new int[2]; // 1st index = class, 2nd = direction int street = 1; int street_direction = 1; // if pedestrian pathway if (street_ype == StreetType.PedestrianPathway) { street = (int)StreetType.PedestrianPathway; street_direction = (int)StreetDirection.OneWay; } // if dirt road else if (street_ype == StreetType.DirtRoad) { street = (int)StreetType.DirtRoad; street_direction = (int)StreetDirection.OneWay; } // if 2 lane street else if (street_ype == StreetType.TwoLaneStreet) { street = (int)StreetType.TwoLaneStreet; street_direction = (int)StreetDirection.TwoWay; } // if 4 lane street else if (street_ype == StreetType.FourLaneStreet) { street = (int)StreetType.FourLaneStreet; street_direction = (int)StreetDirection.TwoWay; } // if Avenue else if (street_ype == StreetType.Avenue) { street = (int)StreetType.Avenue; street_direction = (int)StreetDirection.TwoWay; } // if Dense Avenue else if (street_ype == StreetType.DenseAvenue) { street = (int)StreetType.DenseAvenue; street_direction = (int)StreetDirection.TwoWay; } // if Avenue Plus Train else if (street_ype == StreetType.AvenuePlusTrain) { street = (int)StreetType.AvenuePlusTrain; street_direction = (int)StreetDirection.TwoWay; } // if ParkWay else if (street_ype == StreetType.ParkWay) { street = (int)StreetType.ParkWay; street_direction = (int)StreetDirection.TwoWay; } // if Freeway else if (street_ype == StreetType.Freeway) { street = (int)StreetType.Freeway; street_direction = (int)StreetDirection.TwoWay; } // if Ramp else if (street_ype == StreetType.Ramp) { street = (int)StreetType.Ramp; street_direction = (int)StreetDirection.OneWay; } // if Pre-Built else if (street_ype == StreetType.PreBuilt) { street = (int)StreetType.PreBuilt; street_direction = (int)StreetDirection.OneWay; } else { throw new NoSuchTypeException("The street selected does not exist!"); } result[0] = street; result[1] = street_direction; return(result); }
public static string GetReductionStreet(StreetType value) { string ReductionValue = string.Empty; string CurrentValue = EnumHelper <StreetType> .GetDisplayValue(value); if (CurrentValue == "Аллея") { return("ал."); } if (CurrentValue == "Площадь") { return("пл."); } if (CurrentValue == "Бульвар") { return("б-р"); } if (CurrentValue == "Въезд") { return("взд."); } if (CurrentValue == "Набережная") { return("наб."); } if (CurrentValue == "Шоссе") { return("ш."); } if (CurrentValue == "Квартал") { return("кв-л"); } if (CurrentValue == "Микрорайон") { return("мкр."); } if (CurrentValue == "Переулок") { return("пер."); } if (CurrentValue == "Проезд") { return("пр-д"); } if (CurrentValue == "Проспект") { return("пр-кт"); } if (CurrentValue == "Станция") { return("ст."); } if (CurrentValue == "Территория") { return("тер."); } if (CurrentValue == "Тракт") { return("тракт"); } if (CurrentValue == "Тупик") { return("туп."); } if (CurrentValue == "Улица") { return("ул."); } return(CurrentValue.ToLower()); }
private void MapForUpdateentity(StreetType entity, DA.StreetType daEntity) { daEntity.Id = entity.Id; }
private void SetStreetType(StreetType streetType) { this.streetType = streetType; }
/// <summary> /// Returns true if CommonPAFAddress instances are equal /// </summary> /// <param name="other">Instance of CommonPAFAddress to be compared</param> /// <returns>Boolean</returns> public bool Equals(CommonPAFAddress other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Dpid == other.Dpid || Dpid != null && Dpid.Equals(other.Dpid) ) && ( ThoroughfareNumber1 == other.ThoroughfareNumber1 || ThoroughfareNumber1 != null && ThoroughfareNumber1.Equals(other.ThoroughfareNumber1) ) && ( ThoroughfareNumber1Suffix == other.ThoroughfareNumber1Suffix || ThoroughfareNumber1Suffix != null && ThoroughfareNumber1Suffix.Equals(other.ThoroughfareNumber1Suffix) ) && ( ThoroughfareNumber2 == other.ThoroughfareNumber2 || ThoroughfareNumber2 != null && ThoroughfareNumber2.Equals(other.ThoroughfareNumber2) ) && ( ThoroughfareNumber2Suffix == other.ThoroughfareNumber2Suffix || ThoroughfareNumber2Suffix != null && ThoroughfareNumber2Suffix.Equals(other.ThoroughfareNumber2Suffix) ) && ( FlatUnitNumber == other.FlatUnitNumber || FlatUnitNumber != null && FlatUnitNumber.Equals(other.FlatUnitNumber) ) && ( FloorLevelNumber == other.FloorLevelNumber || FloorLevelNumber != null && FloorLevelNumber.Equals(other.FloorLevelNumber) ) && ( LotNumber == other.LotNumber || LotNumber != null && LotNumber.Equals(other.LotNumber) ) && ( BuildingName1 == other.BuildingName1 || BuildingName1 != null && BuildingName1.Equals(other.BuildingName1) ) && ( BuildingName2 == other.BuildingName2 || BuildingName2 != null && BuildingName2.Equals(other.BuildingName2) ) && ( StreetName == other.StreetName || StreetName != null && StreetName.Equals(other.StreetName) ) && ( StreetType == other.StreetType || StreetType != null && StreetType.Equals(other.StreetType) ) && ( StreetSuffix == other.StreetSuffix || StreetSuffix != null && StreetSuffix.Equals(other.StreetSuffix) ) && ( PostalDeliveryType == other.PostalDeliveryType || PostalDeliveryType != null && PostalDeliveryType.Equals(other.PostalDeliveryType) ) && ( PostalDeliveryNumber == other.PostalDeliveryNumber || PostalDeliveryNumber != null && PostalDeliveryNumber.Equals(other.PostalDeliveryNumber) ) && ( PostalDeliveryNumberPrefix == other.PostalDeliveryNumberPrefix || PostalDeliveryNumberPrefix != null && PostalDeliveryNumberPrefix.Equals(other.PostalDeliveryNumberPrefix) ) && ( PostalDeliveryNumberSuffix == other.PostalDeliveryNumberSuffix || PostalDeliveryNumberSuffix != null && PostalDeliveryNumberSuffix.Equals(other.PostalDeliveryNumberSuffix) ) && ( LocalityName == other.LocalityName || LocalityName != null && LocalityName.Equals(other.LocalityName) ) && ( Postcode == other.Postcode || Postcode != null && Postcode.Equals(other.Postcode) ) && ( State == other.State || State != null && State.Equals(other.State) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Dpid != null) { hashCode = hashCode * 59 + Dpid.GetHashCode(); } if (ThoroughfareNumber1 != null) { hashCode = hashCode * 59 + ThoroughfareNumber1.GetHashCode(); } if (ThoroughfareNumber1Suffix != null) { hashCode = hashCode * 59 + ThoroughfareNumber1Suffix.GetHashCode(); } if (ThoroughfareNumber2 != null) { hashCode = hashCode * 59 + ThoroughfareNumber2.GetHashCode(); } if (ThoroughfareNumber2Suffix != null) { hashCode = hashCode * 59 + ThoroughfareNumber2Suffix.GetHashCode(); } if (FlatUnitNumber != null) { hashCode = hashCode * 59 + FlatUnitNumber.GetHashCode(); } if (FloorLevelNumber != null) { hashCode = hashCode * 59 + FloorLevelNumber.GetHashCode(); } if (LotNumber != null) { hashCode = hashCode * 59 + LotNumber.GetHashCode(); } if (BuildingName1 != null) { hashCode = hashCode * 59 + BuildingName1.GetHashCode(); } if (BuildingName2 != null) { hashCode = hashCode * 59 + BuildingName2.GetHashCode(); } if (StreetName != null) { hashCode = hashCode * 59 + StreetName.GetHashCode(); } if (StreetType != null) { hashCode = hashCode * 59 + StreetType.GetHashCode(); } if (StreetSuffix != null) { hashCode = hashCode * 59 + StreetSuffix.GetHashCode(); } if (PostalDeliveryType != null) { hashCode = hashCode * 59 + PostalDeliveryType.GetHashCode(); } if (PostalDeliveryNumber != null) { hashCode = hashCode * 59 + PostalDeliveryNumber.GetHashCode(); } if (PostalDeliveryNumberPrefix != null) { hashCode = hashCode * 59 + PostalDeliveryNumberPrefix.GetHashCode(); } if (PostalDeliveryNumberSuffix != null) { hashCode = hashCode * 59 + PostalDeliveryNumberSuffix.GetHashCode(); } if (LocalityName != null) { hashCode = hashCode * 59 + LocalityName.GetHashCode(); } if (Postcode != null) { hashCode = hashCode * 59 + Postcode.GetHashCode(); } if (State != null) { hashCode = hashCode * 59 + State.GetHashCode(); } return(hashCode); } }
public void updateType(StreetType type) { this.stype = type; initImgType(); }
public Address(int number, string name, StreetType type) { StreetNumber = number; StreetName = name; Type = type; }
static void MatchAddresses(List <string> args) { Console.WriteLine("Match Addresses"); if (args.Count < 3) { throw new NormalException("Not enough arguments! Usage: alba match-addresses <alba-tsv-input-file> <csv-match-file> <alba-tsv-output-file>"); } string inputPath = args[1]; string matchPath = args[2]; string outputPath = args[3]; Console.WriteLine($"Input File Path: {inputPath}"); Console.WriteLine($"Match File Path: {matchPath}"); Console.WriteLine($"Output File Path: {outputPath}"); var addresses = LoadTsvAlbaAddresses.LoadFrom(inputPath); var matches = LoadTsvAlbaAddresses.LoadFrom(matchPath); var errors = new List <AlbaAddressExport>(); var output = new List <AlbaAddressExport>(); var streetTypes = StreetType.Parse(StreetTypes); var parser = new CompleteAddressParser(streetTypes); foreach (var a in addresses) { try { foreach (var b in matches) { //string aText = $"{a.Address}, {a.Suite}, {a.City}, {a.Province} {a.Postal_code}"; //string bText = $"{b.Address}, {b.Suite}, {b.City}, {b.Province} {b.Postal_code}"; //if (parser.Parse(aText) // .SameAs( // other: parser.Parse(bText), // options: Address.SameAsOptions.ComparePostalCode)) //{ if (string.Equals(a.Address, b.Address, StringComparison.OrdinalIgnoreCase) && string.Equals(a.Suite, b.Suite, StringComparison.OrdinalIgnoreCase) && (string.Equals(a.City, b.City, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Postal_code, b.Postal_code, StringComparison.OrdinalIgnoreCase)) && string.Equals(a.Province, b.Province, StringComparison.OrdinalIgnoreCase)) { output.Add(a); } } } catch (Exception e) { errors.Add(a); Console.WriteLine(e.Message); } } if (errors.Count > 0) { Console.WriteLine(); Console.WriteLine("Errors:"); foreach (var a in errors) { Console.WriteLine(a.Address); } Console.WriteLine($"Count: {errors.Count}"); } LoadTsvAlbaAddresses.SaveTo(output, outputPath); if (errors.Count > 0) { LoadTsvAlbaAddresses.SaveTo(errors, $"{outputPath}.errors.txt"); } }
public static void createStreet(StreetType type_of_street) { int[] street_data = StreetHelper.pickStreet(type_of_street); // Pedestrian Pathway if (type_of_street == StreetType.PedestrianPathway) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = PedestrianPathWay.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Pedestrian Pathway else if (type_of_street == StreetType.DirtRoad) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = DirtRoad.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // TwoLaneStreet else if (type_of_street == StreetType.TwoLaneStreet) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = TwoLaneStreet.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // FourLaneStreet else if (type_of_street == StreetType.FourLaneStreet) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = FourLaneStreet.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Avenue else if (type_of_street == StreetType.Avenue) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = Avenue.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // DenseAvenue else if (type_of_street == StreetType.DenseAvenue) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = DenseAvenue.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // AvenuePlusTrain else if (type_of_street == StreetType.AvenuePlusTrain) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = AvenuePlusTrain.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // ParkWay else if (type_of_street == StreetType.ParkWay) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = ParkWay.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Freeway else if (type_of_street == StreetType.Freeway) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = Freeway.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Ramp else if (type_of_street == StreetType.Ramp) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = Ramp.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // PreBuilt else if (type_of_street == StreetType.PreBuilt) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = PreBuilt.CreateComponent(street_obj, (StreetDirection)street_data[1]); } else { throw new NoSuchTypeException("Street Type not found"); } }