private void AddUsedMatchNames(CodedLocation codedLocation) { InputColumnHeaders columnHeaders = geoCoder.MatchedNameColumnHeaders(); // add the actual name used to get the code if different to that on the input if (codedLocation.IsName1Different()) { dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level1] .Value = codedLocation.GeoCode1.Name; } if (codedLocation.IsName2Different()) { dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level2] .Value = codedLocation.GeoCode2.Name; } if (codedLocation.IsName3Different()) { dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level3] .Value = codedLocation.GeoCode3.Name; } }
private void DisplaySelectedRecord() { InputColumnHeaders columnHeaders = geoCoder.LocationNameColumnHeaders(); txtLevel1Original.Text = dataGridView1.Rows[selectedRowIndex].Cells[ columnHeaders.Level1] .Value as string; // level 2 is optional if (!string.IsNullOrEmpty(columnHeaders.Level2)) { txtLevel2Original.Text = dataGridView1.Rows[selectedRowIndex].Cells[ columnHeaders.Level2] .Value as string; } // level 3 is optional if (!string.IsNullOrEmpty(columnHeaders.Level3)) { txtLevel3Original.Text = dataGridView1.Rows[selectedRowIndex].Cells[ columnHeaders.Level3] .Value as string; } }
private void AddCodes(CodedLocation codedLocation) { // add the codes to the input data InputColumnHeaders columnHeaders = geoCoder.LocationCodeColumnHeaders(); if (codedLocation.GeoCode1 != null) { dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level1] .Value = codedLocation.GeoCode1.Code; } if (codedLocation.GeoCode2 != null) { dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level2] .Value = codedLocation.GeoCode2.Code; } if (codedLocation.GeoCode3 != null) { dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level3] .Value = codedLocation.GeoCode3.Code; } // add the names used to generate those codes as information for the user. AddUsedMatchNames(codedLocation); }
private static InputColumnHeaders InputColumnNames() { InputColumnHeaders inputColumnHeaders = new InputColumnHeaders(); inputColumnHeaders.Level1 = "admin1"; inputColumnHeaders.Level2 = "admin2"; inputColumnHeaders.Level3 = "admin3"; return(inputColumnHeaders); }
public void CodeAll_InputContainMissSpellingsWithDifferentCasingToSavedMatches_AllCodesAdded() { // arrange GeoCoder geoCoder = new GeoCoder(MockRepository.GenerateStub <IDbConnection>() as DbConnection); InputColumnHeaders inputColumnHeaders = InputColumnNames(); GazetteerColumnHeaders gazetteerColumnHeaders = GazetteerColumnNames(); //gazetteer data string[] names1 = { "P1", "T1", "V1" }; string[] codes1 = { "1", "10", "100" }; // saved matched names data string[] names2 = { "P1x", "T1x", "V1x" }; // input data // line 1, all names miss-spelt with different casing string[] names3 = { "p1x", "t1x", "v1x" }; InputTestData inputTestData = new InputTestData(); inputTestData.AddLine(names3); geoCoder.SetInputData(inputTestData.Data(inputColumnHeaders)); geoCoder.SetInputColumns(inputColumnHeaders); // create gazetteer data GazetteerRecords gazetteerRecords = new GazetteerRecords(); gazetteerRecords.AddLine(names1, codes1); geoCoder.SetGazetteerData(gazetteerRecords.Data(gazetteerColumnHeaders)); // add records matched names records MatchProviderTestData matchProviderTestData = new MatchProviderTestData(); // add records matching saved matched names to gazetteer names matchProviderTestData.AddLevel1(names2, names1); matchProviderTestData.AddLevel2(names2, names1); matchProviderTestData.AddLevel3(names2, names1); MatchProviderStub matchProviderStub = new MatchProviderStub(matchProviderTestData); geoCoder.SetMatchProvider(matchProviderStub.MatchProvider()); geoCoder.SetGazetteerColumns(gazetteerColumnHeaders, false); // act geoCoder.AddAllLocationCodes(); // assert var columns = geoCoder.LocationCodeColumnHeaders(); //line 1 - should contain codes 1 DataRow line1 = geoCoder.InputData.Rows[0]; Assert.AreEqual(codes1[0], line1[columns.Level1]); Assert.AreEqual(codes1[1], line1[columns.Level2]); Assert.AreEqual(codes1[2], line1[columns.Level3]); }
private void SetColumnNames() { InputColumnHeaders inputColumnHeaders = new InputColumnHeaders(); inputColumnHeaders.Level1 = cboLevel1.SelectedValue as string; inputColumnHeaders.Level2 = cboLevel2.SelectedValue as string; inputColumnHeaders.Level3 = cboLevel3.SelectedValue as string; geoCoder.SetInputColumns(inputColumnHeaders); }
private void ClearUsedNames() { InputColumnHeaders columnHeaders = geoCoder.MatchedNameColumnHeaders(); dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level1].Value = null; dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level2].Value = null; dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level3].Value = null; }
private void ClearCodes() { InputColumnHeaders columnHeaders = geoCoder.LocationCodeColumnHeaders(); dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level1] .Value = null; dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level2] .Value = null; dataGridView1.Rows[selectedRowIndex].Cells[columnHeaders.Level3] .Value = null; }
public DataTable Data(InputColumnHeaders inputColumnHeaders) { DataTable dt = new DataTable(); dt.Columns.Add("Row"); dt.Columns.Add(inputColumnHeaders.Level1); dt.Columns.Add(inputColumnHeaders.Level2); dt.Columns.Add(inputColumnHeaders.Level3); foreach (KeyValuePair <int, string[]> line in lines2) { object[] values = { line.Key, line.Value[0], line.Value[1], line.Value[2] }; dt.LoadDataRow(values, true); } return(dt); }
private void DisplayColumnNameLists() { InputColumnHeaders defaultColumnHeaders = geoCoder.DefaultInputColumnHeaders(); cboLevel1.DataSource = geoCoder.InputColumnHeaders(); //level 2 and 3 columns are optional so display a blank row at the top IList <string> columnNames2 = geoCoder.InputColumnHeaders(); columnNames2.Insert(0, string.Empty); cboLevel2.DataSource = columnNames2; IList <string> columnNames3 = geoCoder.InputColumnHeaders(); columnNames3.Insert(0, string.Empty); cboLevel3.DataSource = columnNames3; // set defaults if they exist in the input sheet cboLevel1.SelectedIndex = cboLevel1.FindStringExact(defaultColumnHeaders.Level1); cboLevel2.SelectedIndex = cboLevel2.FindStringExact(defaultColumnHeaders.Level2); cboLevel3.SelectedIndex = cboLevel3.FindStringExact(defaultColumnHeaders.Level3); }
CodeAll_CorrectAndMissSpeltInputWithSavedMatchesForMissSpellings_AllCodesAdded () { // arrange GeoCoder geoCoder = new GeoCoder(MockRepository.GenerateStub <IDbConnection>() as DbConnection); InputColumnHeaders inputColumnHeaders = InputColumnNames(); GazetteerColumnHeaders gazetteerColumnHeaders = GazetteerColumnNames(); // create input test data with // line 1, all names correct // line 2, all names correct // line 3, all names miss-spelt string[] names1 = { "P1", "T1", "V1" }; string[] names2 = { "P2", "T2", "V2" }; string[] names3 = { "P1x", "T1x", "V1x" }; string[] codes1 = { "1", "10", "100" }; string[] codes2 = { "2", "20", "200" }; InputTestData inputTestData = new InputTestData(); inputTestData.AddLine(names1); inputTestData.AddLine(names2); inputTestData.AddLine(names3); geoCoder.SetInputData(inputTestData.Data(inputColumnHeaders)); geoCoder.SetInputColumns(inputColumnHeaders); // create gazetteer data GazetteerRecords gazetteerRecords = new GazetteerRecords(); gazetteerRecords.AddLine(names1, codes1); gazetteerRecords.AddLine(names2, codes2); geoCoder.SetGazetteerData(gazetteerRecords.Data(gazetteerColumnHeaders)); // add records matching input line 3 names to gazetteer names 1 MatchProviderTestData matchProviderTestData = new MatchProviderTestData(); matchProviderTestData.AddLevel1(names3, names1); matchProviderTestData.AddLevel2(names3, names1); matchProviderTestData.AddLevel3(names3, names1); MatchProviderStub matchProviderStub = new MatchProviderStub(matchProviderTestData); geoCoder.SetMatchProvider(matchProviderStub.MatchProvider()); geoCoder.SetGazetteerColumns(gazetteerColumnHeaders, false); // act geoCoder.AddAllLocationCodes(); // assert var columns = geoCoder.LocationCodeColumnHeaders(); //line 1 - should contain codes 1 DataRow line1 = geoCoder.InputData.Rows[0]; Assert.AreEqual(codes1[0], line1[columns.Level1]); Assert.AreEqual(codes1[1], line1[columns.Level2]); Assert.AreEqual(codes1[2], line1[columns.Level3]); //line 2 - should contain codes 2 DataRow line2 = geoCoder.InputData.Rows[1]; Assert.AreEqual(codes2[0], line2[columns.Level1]); Assert.AreEqual(codes2[1], line2[columns.Level2]); Assert.AreEqual(codes2[2], line2[columns.Level3]); //line 3 - should contain codes 1 DataRow line3 = geoCoder.InputData.Rows[2]; Assert.AreEqual(codes1[0], line3[columns.Level1]); Assert.AreEqual(codes1[1], line3[columns.Level2]); Assert.AreEqual(codes1[2], line3[columns.Level3]); }
/// <summary> /// Sets the column names that hold the input data to be coded. /// </summary> /// <param name="columnHeaders">The column names.</param> public void SetInputColumns(InputColumnHeaders columnHeaders) { inputData.SetColumnNames(columnHeaders); }