Skip to content

Commit

Permalink
Merge pull request #25 from EdLoach/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
EdLoach authored Mar 16, 2019
2 parents e4423b2 + 807f9db commit 82d6535
Show file tree
Hide file tree
Showing 9 changed files with 1,048 additions and 323 deletions.
2 changes: 1 addition & 1 deletion CheckPublicTransportRelations/BusStop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public BusStop(string elementType, long elementId, string elementAtcoCode, strin
this.Type = elementType;
this.Id = elementId;
this.AtcoCode = elementAtcoCode;
this.StopName = stopName;
this.StopName = stopName ?? string.Empty;
this.NaptanCode = naptanCode;
this.BusStopType = busStopType;
this.Status = stopStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
<Compile Include="LocationsForm.Designer.cs">
<DependentUpon>LocationsForm.cs</DependentUpon>
</Compile>
<Compile Include="NaptanForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NaptanForm.Designer.cs">
<DependentUpon>NaptanForm.cs</DependentUpon>
</Compile>
<Compile Include="OpenStreetMapRouteMaster.cs" />
<Compile Include="OpenStreetMapRouteVariant.cs" />
<Compile Include="OpenStreetMapStop.cs" />
Expand Down Expand Up @@ -125,6 +131,9 @@
<EmbeddedResource Include="LocationsForm.resx">
<DependentUpon>LocationsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NaptanForm.resx">
<DependentUpon>NaptanForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="TravelineDownloadForm.resx">
<DependentUpon>TravelineDownloadForm.cs</DependentUpon>
</EmbeddedResource>
Expand Down
10 changes: 8 additions & 2 deletions CheckPublicTransportRelations/ExtractRoutesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ private void ExtractRoutesBackgroundWorker_DoWork(object sender, DoWorkEventArgs
string subFolder = DateTime.Today.ToString("yyyyMMdd");
string copyPath = Path.Combine(Properties.Settings.Default.LocalPath, MainForm.ValidPathString(this.SelectedLocation.Description), subFolder);
Directory.CreateDirectory(copyPath);
var directoryInfo = new DirectoryInfo(copyPath);
FileInfo[] files = directoryInfo.GetFiles("*.xml");
foreach (FileInfo file in files)
{
File.Delete(file.FullName);
}

var openStreetMapStops = new HashSet<string>();
foreach (BusStop stop in this.OverpassBusStops)
Expand All @@ -175,8 +181,8 @@ private void ExtractRoutesBackgroundWorker_DoWork(object sender, DoWorkEventArgs
}

// get files in local path
var directoryInfo = new DirectoryInfo(Properties.Settings.Default.LocalPath);
FileInfo[] files = directoryInfo.GetFiles("*.zip");
directoryInfo = new DirectoryInfo(Properties.Settings.Default.LocalPath);
files = directoryInfo.GetFiles("*.zip");
this.fileProgressBar.Minimum = 0;
int filesCount = files.Length;
var counter = 0;
Expand Down
629 changes: 328 additions & 301 deletions CheckPublicTransportRelations/MainForm.Designer.cs

Large diffs are not rendered by default.

97 changes: 78 additions & 19 deletions CheckPublicTransportRelations/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,20 +354,20 @@ private static BusStop BusStop(dynamic element)
{
string type = element.type;
long id = element.id;
string atcoCode = element.tags["naptan:AtcoCode"];
string stopName = element.tags["name"];
string naptanCode = element.tags["naptan:NaptanCode"];
string stopStatus = element.tags["naptan:Status"];
string busStopType = element.tags["naptan:BusStopType"];
string notName = element.tags["not:name"];
string highway = element.tags["highway"];
string atcoCode = element.tags["naptan:AtcoCode"] ?? string.Empty;
string stopName = element.tags["name"] ?? string.Empty;
string naptanCode = element.tags["naptan:NaptanCode"] ?? string.Empty;
string stopStatus = element.tags["naptan:Status"] ?? string.Empty;
string busStopType = element.tags["naptan:BusStopType"] ?? string.Empty;
string notName = element.tags["not:name"] ?? string.Empty;
string highway = element.tags["highway"] ?? string.Empty;

// layby tag ignored in this list as may be visible on imagery and not indicative of a survey
string physicallyPresent = element.tags["physically_present"];
string flagTagValue = element.tags["flag"];
string shelterTagValue = element.tags["shelter"];
string kerbTagValue = element.tags["kerb"];
string timetableCaseTagValue = element.tags["timetable_case"];
string physicallyPresent = element.tags["physically_present"] ?? string.Empty;
string flagTagValue = element.tags["flag"] ?? string.Empty;
string shelterTagValue = element.tags["shelter"] ?? string.Empty;
string kerbTagValue = element.tags["kerb"] ?? string.Empty;
string timetableCaseTagValue = element.tags["timetable_case"] ?? string.Empty;
string surveyedValue = !string.IsNullOrEmpty(physicallyPresent) || !string.IsNullOrEmpty(flagTagValue)
|| !string.IsNullOrEmpty(shelterTagValue)
|| !string.IsNullOrEmpty(kerbTagValue)
Expand All @@ -376,7 +376,7 @@ private static BusStop BusStop(dynamic element)
? "yes"
: string.Empty;

string naptanVerified = element.tags["naptan:verified"];
string naptanVerified = element.tags["naptan:verified"] ?? string.Empty;
var busStop = new BusStop(
type,
id,
Expand Down Expand Up @@ -938,6 +938,15 @@ private void ExtractLocalRoutesToolStripMenuItem_Click(object sender, EventArgs
this.ExtractTravelineRoutes();
this.travelineDataGridView.DataSource = this.TravelineRoutes;
this.RefreshStatus();
string areaPath = Path.Combine(Settings.Default.LocalPath, ValidPathString(this.SelectedLocation.Description));
string areaFileName = Path.Combine(areaPath, "LocalStops.csv");
if (File.Exists(areaFileName))
{
File.Delete(areaFileName);
}

this.ExtractNaptanStops();
this.RefreshStopsGrid();
this.CompareResults();
this.Enabled = true;
}
Expand Down Expand Up @@ -1239,6 +1248,12 @@ private void ExtractOpenStreetMapRoutes()
BusStop busStop = BusStop(element);
routeBusStops.Add(busStop);
}
else if (element.tags != null && element.tags["highway"] == "bus_stop")
{
stopsDictionary.Add(nodeId, string.Empty);
BusStop busStop = BusStop(element);
routeBusStops.Add(busStop);
}
}

if (type != "relation")
Expand Down Expand Up @@ -1848,6 +1863,13 @@ private async void RefreshBusStopsToolStripMenuItem_Click(object sender, EventAr
this.SelectedLocation.LastOpenStreetMapBusStopRefresh = DateTime.Today;
this.Locations.Save();
this.RefreshStatus();
string areaPath = Path.Combine(Settings.Default.LocalPath, ValidPathString(this.SelectedLocation.Description));
string areaFileName = Path.Combine(areaPath, "LocalStops.csv");
if (File.Exists(areaFileName))
{
File.Delete(areaFileName);
}

this.ExtractNaptanStops();
this.RefreshStopsGrid();
}
Expand Down Expand Up @@ -2224,15 +2246,26 @@ private void RefreshStopsGrid()
// ===========================================================================================================
private void StopsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (this.stopsDataGridView.Columns["stopIdColumn"] == null
|| e.ColumnIndex != this.stopsDataGridView.Columns["stopIdColumn"].Index || e.RowIndex == -1)
var senderGrid = (DataGridView)sender;
if (this.stopsDataGridView.Columns["stopIdColumn"] != null
&& e.ColumnIndex == this.stopsDataGridView.Columns["stopIdColumn"].Index && e.RowIndex != -1)
{
string value = "http://127.0.0.1:8111/zoom?left=0&right=0&top=0&bottom=0&select=n"
+ this.stopsDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
Process.Start(value);
}

if (!(senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
|| senderGrid.Columns[e.ColumnIndex].Name != this.naptanInfoStopButtonColumn.Name || e.RowIndex < 0)
{
return;
}

string value = "http://127.0.0.1:8111/zoom?left=0&right=0&top=0&bottom=0&select=n"
+ this.stopsDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
Process.Start(value);

this.Enabled = false;
var selectedRow = (BusStop)senderGrid.Rows[e.RowIndex].DataBoundItem;
var editForm = new NaptanForm(selectedRow);
editForm.ShowDialog();
this.Enabled = true;
}

// ===========================================================================================================
Expand Down Expand Up @@ -2555,5 +2588,31 @@ private void OrphansDataGridViewCellContentClick(object sender, DataGridViewCell
+ this.orphansDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
Process.Start(value);
}

// ===========================================================================================================
/// <createdBy>EdLoach - 24 February 2019 (1.5.0.0)</createdBy>
///
/// <summary>Event handler. Called by TravelineStopsDataGridView for cell content click events.</summary>
///
/// <param name="sender">Source of the event.</param>
/// <param name="e"> Data grid view cell event information.</param>
// ===========================================================================================================
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
private void TravelineStopsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
var senderGrid = (DataGridView)sender;

if (!(senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
|| senderGrid.Columns[e.ColumnIndex].Name != this.naptanInfoButtonColumn.Name || e.RowIndex < 0)
{
return;
}

this.Enabled = false;
var selectedRow = (JourneyStop)senderGrid.Rows[e.RowIndex].DataBoundItem;
var editForm = new NaptanForm(selectedRow);
editForm.ShowDialog();
this.Enabled = true;
}
}
}
6 changes: 6 additions & 0 deletions CheckPublicTransportRelations/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@
<metadata name="tndsActivityColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="naptanInfoButtonColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fromToServiceColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down Expand Up @@ -291,6 +294,9 @@
<metadata name="stopTypeMatchColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="naptanInfoStopButtonColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="operatorOrphanColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down
Loading

0 comments on commit 82d6535

Please sign in to comment.