Skip to content

Commit

Permalink
Some null avoidance attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
EdLoach committed Feb 27, 2019
1 parent 2fb52f8 commit 807f9db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 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
32 changes: 19 additions & 13 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 @@ -1248,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

0 comments on commit 807f9db

Please sign in to comment.