Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Commit 4354aa0

Browse files
committed
netex: Support format provided by Mobigo (FR), throw exception if unsupported format
1 parent d7bbe31 commit 4354aa0

File tree

3 files changed

+77
-4
lines changed

3 files changed

+77
-4
lines changed

GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ private void readNetexStopsFile(String netexFilePath) {
798798
netexParentSitesByGtfsId = netexParser.getParentSiteListByGtfsId();
799799
netexAllStopPlacesByGtfsId = netexParser.getAllStopPlaceListByGtfsId();
800800
netexAllStopPlacesByStopPlaceId = netexParser.getAllStopPlaceListByStopPlaceId();
801+
} catch (UnsupportedOperationException e) {
802+
throw e;
801803
} catch (Exception e) {
802804
e.printStackTrace();
803805
}

GO_Sync/src/main/java/edu/usf/cutr/go_sync/object/NetexQuay.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,36 @@ public NetexQuay(String id) {
2424
}
2525

2626
public String getIdAsGtfs() {
27-
return id.split(":")[3];
27+
String return_value = null;
28+
switch (OperatorInfo.getFullName()) {
29+
case "Fluo Grand Est 67":
30+
case "FLUO 68":
31+
case "Fluo88":
32+
return_value = getIdAsGtfsFRFluo();
33+
break;
34+
case "MOBIGO (58)":
35+
return_value = getIdAsGtfsFRMobigo();
36+
break;
37+
default:
38+
throw new UnsupportedOperationException(String.format("Method to extract gtfs id inside netex file not set for %s. Please set it in code nearby the NO_METHOD_TO_FIND_GTFSID_IN_NETEX_QUAY_ID or don't use the netex file.", OperatorInfo.getFullName()));
39+
}
40+
return return_value;
41+
}
42+
43+
private String getIdAsGtfsFRFluo() {
44+
if (id.split(":").length >= 4) {
45+
return id.split(":")[3];
46+
}
47+
System.out.println(String.format("Unexpected format for Quay id %s", id));
48+
return null;
49+
}
50+
51+
private String getIdAsGtfsFRMobigo() {
52+
if (id.split(":").length >= 3) {
53+
return id.split(":")[2];
54+
}
55+
System.out.println(String.format("Unexpected format for Quay id %s", id));
56+
return null;
2857
}
2958

3059
public String printContent() {

GO_Sync/src/main/java/edu/usf/cutr/go_sync/object/NetexStopPlace.java

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,60 @@ public String getParentSiteRef() {
3838
}
3939

4040
public String getGtfsEquivalentId() {
41+
String return_value = null;
42+
switch (OperatorInfo.getFullName()) {
43+
case "Fluo Grand Est 67":
44+
case "FLUO 68":
45+
case "Fluo88":
46+
return_value = getGtfsEquivalentIdFRFluo();
47+
break;
48+
case "MOBIGO (58)":
49+
return_value = getGtfsEquivalentIdFRMobigo();
50+
break;
51+
default:
52+
throw new UnsupportedOperationException(String.format("Method to extract gtfs id inside netex file not set for %s. Please set it in code nearby the NO_METHOD_TO_FIND_GTFSID_IN_NETEX_STOP_PLACE_ID or don't use the netex file.", OperatorInfo.getFullName()));
53+
}
54+
return return_value;
55+
}
56+
57+
private String getGtfsEquivalentIdFRFluo() {
58+
String[] base_id;
59+
if (parentSiteRef != null) {
60+
base_id = parentSiteRef.split(":");
61+
if (base_id.length >= 3) {
62+
return base_id[2].replace("log", "S");
63+
}
64+
} else {
65+
//if (childSiteRef != null) {
66+
// Case when we are on a logical StopPlace or a parentStopPlace
67+
base_id = id.split(":");
68+
if (base_id.length >= 3) {
69+
return base_id[2].replace("log", "S");
70+
}
71+
//}
72+
}
73+
System.out.println(String.format("Unexpected format for StopPlace id %s", id));
74+
return null;
75+
}
76+
77+
private String getGtfsEquivalentIdFRMobigo() {
4178
String[] base_id;
4279
if (parentSiteRef != null) {
4380
base_id = parentSiteRef.split(":");
44-
return base_id[3].replace("log", "S");
81+
if (base_id.length >= 3) {
82+
return base_id[2].replace("Navitia_", "");
83+
}
4584
} else {
4685
//if (childSiteRef != null) {
4786
// Case when we are on a logical StopPlace or a parentStopPlace
4887
base_id = id.split(":");
49-
return base_id[3].replace("log", "S");
88+
if (base_id.length >= 3) {
89+
return base_id[2].replace("Navitia_", "");
90+
}
5091
//}
5192
}
52-
//return "Unexpected case: TODO";
93+
System.out.println(String.format("Unexpected format for StopPlace id %s", id));
94+
return null;
5395
}
5496

5597
public void setParentSiteRef(String parentSiteRef) {

0 commit comments

Comments
 (0)