Skip to content

Commit 43bc404

Browse files
committed
refactor: rename gtfs import to remoteGtfs to avoid conflict with internal package
1 parent 01c0fbd commit 43bc404

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

internal/geo/geo_cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55

66
"github.com/golang/geo/s2"
7-
"github.com/jamespfennell/gtfs"
7+
remoteGtfs "github.com/jamespfennell/gtfs"
88
)
99

1010
const s2Level = 13 // S2 cell level with 850–1225 m spatial resolution
@@ -65,7 +65,7 @@ func s2ClusterID(lat, lon float64, level int) string {
6565
// - Invalid: grandparent exists but is not a Station, or coordinates are missing for fallback - data is malformed.
6666
//
6767
// Returns false if hierarchy rules are violated or required parent/coordinate data is missing.
68-
func getClusterID(stop gtfs.Stop) (clusterID string, clusterType string, ok bool) {
68+
func getClusterID(stop remoteGtfs.Stop) (clusterID string, clusterType string, ok bool) {
6969
switch stop.Type {
7070
case 0: // Stop or Platform
7171
if stop.Parent != nil {

internal/gtfs/gtfs_bundles.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/getsentry/sentry-go"
15-
"github.com/jamespfennell/gtfs"
15+
remoteGtfs "github.com/jamespfennell/gtfs"
1616
"watchdog.onebusaway.org/internal/geo"
1717
"watchdog.onebusaway.org/internal/models"
1818
"watchdog.onebusaway.org/internal/report"
@@ -157,7 +157,7 @@ func downloadAndStoreGTFSBundle(url string, serverID int, staticStore *StaticSto
157157
return err
158158
}
159159

160-
staticBundle, err := gtfs.ParseStatic(data, gtfs.ParseStaticOptions{})
160+
staticBundle, err := remoteGtfs.ParseStatic(data, remoteGtfs.ParseStaticOptions{})
161161
if err != nil {
162162
err = fmt.Errorf("failed to parse GTFS static data from %s: %w", url, err)
163163
report.ReportErrorWithSentryOptions(err, report.SentryReportOptions{
@@ -180,7 +180,7 @@ func downloadAndStoreGTFSBundle(url string, serverID int, staticStore *StaticSto
180180

181181
// ParseGTFSFromCache reads a GTFS bundle from the cache and parses it into a gtfs.Static object.
182182
// It returns the parsed static data or an error if parsing fails.
183-
func ParseGTFSFromCache(cachePath string, serverID int) (*gtfs.Static, error) {
183+
func ParseGTFSFromCache(cachePath string, serverID int) (*remoteGtfs.Static, error) {
184184
fileBytes, err := os.ReadFile(cachePath)
185185
if err != nil {
186186
report.ReportErrorWithSentryOptions(err, report.SentryReportOptions{
@@ -192,7 +192,7 @@ func ParseGTFSFromCache(cachePath string, serverID int) (*gtfs.Static, error) {
192192
return nil, err
193193
}
194194

195-
staticData, err := gtfs.ParseStatic(fileBytes, gtfs.ParseStaticOptions{})
195+
staticData, err := remoteGtfs.ParseStatic(fileBytes, remoteGtfs.ParseStaticOptions{})
196196
if err != nil {
197197
report.ReportErrorWithSentryOptions(err, report.SentryReportOptions{
198198
Tags: utils.MakeMap("server_id", strconv.Itoa(serverID)),
@@ -209,7 +209,7 @@ func ParseGTFSFromCache(cachePath string, serverID int) (*gtfs.Static, error) {
209209
// getStopLocationsByIDs retrieves stop locations by their IDs from the GTFS cache.
210210
// It returns a map of stop IDs to gtfs.Stop objects.
211211

212-
func getStopLocationsByIDs(serverID int, stopIDs []string, staticStore *StaticStore) (map[string]gtfs.Stop, error) {
212+
func getStopLocationsByIDs(serverID int, stopIDs []string, staticStore *StaticStore) (map[string]remoteGtfs.Stop, error) {
213213
staticData, ok := staticStore.Get(serverID)
214214
if !ok || staticData == nil {
215215
err := fmt.Errorf("no GTFS static data found for server ID %d", serverID)
@@ -224,7 +224,7 @@ func getStopLocationsByIDs(serverID int, stopIDs []string, staticStore *StaticSt
224224
stopIDSet[id] = struct{}{}
225225
}
226226

227-
result := make(map[string]gtfs.Stop)
227+
result := make(map[string]remoteGtfs.Stop)
228228
for _, stop := range staticData.Stops {
229229
if _, exists := stopIDSet[stop.Id]; exists {
230230
result[stop.Id] = stop
@@ -283,7 +283,7 @@ func fetchAndStoreGTFSRTFeed(server models.ObaServer, realtimeStore *RealtimeSto
283283
return err
284284
}
285285

286-
gtfsRT, err := gtfs.ParseRealtime(data, &gtfs.ParseRealtimeOptions{})
286+
gtfsRT, err := remoteGtfs.ParseRealtime(data, &remoteGtfs.ParseRealtimeOptions{})
287287
if err != nil {
288288
report.ReportError(err)
289289
return err

internal/gtfs/gtfs_bundles_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/jamespfennell/gtfs"
13+
remoteGtfs "github.com/jamespfennell/gtfs"
1414
"watchdog.onebusaway.org/internal/geo"
1515
"watchdog.onebusaway.org/internal/models"
1616
)
@@ -54,7 +54,7 @@ func TestDownloadAndStoreGTFSBundle(t *testing.T) {
5454
}
5555

5656
data := readFixture(t, "gtfs.zip")
57-
expectedStaticData, err := gtfs.ParseStatic(data, gtfs.ParseStaticOptions{})
57+
expectedStaticData, err := remoteGtfs.ParseStatic(data, remoteGtfs.ParseStaticOptions{})
5858
if err != nil {
5959
t.Fatalf("failed to parse expected GTFS static data from fixture: %v", err)
6060
}
@@ -117,7 +117,7 @@ func TestGetStopLocationsByIDs(t *testing.T) {
117117
server := models.ObaServer{ID: 1, Name: "test"}
118118

119119
data := readFixture(t, "gtfs.zip")
120-
staticBundle, err := gtfs.ParseStatic(data, gtfs.ParseStaticOptions{})
120+
staticBundle, err := remoteGtfs.ParseStatic(data, remoteGtfs.ParseStaticOptions{})
121121
if err != nil {
122122
t.Fatal("failed to parse gtfs static data")
123123
}
@@ -215,7 +215,7 @@ func TestFetchAndStoreGTFSRTFeed(t *testing.T) {
215215
}
216216

217217
data := readFixture(t, "gtfs_rt_feed_vehicles.pb")
218-
gtfsRT, err := gtfs.ParseRealtime(data, &gtfs.ParseRealtimeOptions{})
218+
gtfsRT, err := remoteGtfs.ParseRealtime(data, &remoteGtfs.ParseRealtimeOptions{})
219219
if err != nil {
220220
t.Fatalf("Failed to parse GTFS-RT data: %v", err)
221221
}

internal/metrics/stop_clusters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package metrics
22

33
import (
4-
"github.com/jamespfennell/gtfs"
4+
remoteGtfs "github.com/jamespfennell/gtfs"
55
"watchdog.onebusaway.org/internal/geo"
66
)
77

@@ -19,7 +19,7 @@ import (
1919
// - slugID: a unique identifier for the server or deployment instance
2020
// - agencyID: the GTFS agency identifier
2121
// - unmatchedStops: a map of stop IDs to GTFS stop objects not matched to gtfs static data
22-
func reportUnmatchedStopClusters(slugID, agencyID string, unmatchedStops map[string]gtfs.Stop) {
22+
func reportUnmatchedStopClusters(slugID, agencyID string, unmatchedStops map[string]remoteGtfs.Stop) {
2323
clusterCount := make(map[string]int)
2424
clusterType := make(map[string]string) // station or s2
2525

0 commit comments

Comments
 (0)