Skip to content

Commit 56103e3

Browse files
Merge pull request #112 from MobilityData/copilot/gtfs-flex-feeds-detail-map-fix
Fix GTFS Flex feed detail map defaulting to bounding box when feed has no routes
2 parents 7bcc0e1 + 7d32c50 commit 56103e3

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/app/components/CoveredAreaMap.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ interface CoveredAreaMapProps {
5757
boundingBox?: LngLatTuple[];
5858
latestDataset?: LatestDatasetLite;
5959
feed: AllFeedType;
60+
totalRoutes?: number;
6061
}
6162

6263
export const fetchGeoJson = async (
@@ -83,6 +84,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
8384
boundingBox,
8485
latestDataset,
8586
feed,
87+
totalRoutes,
8688
}) => {
8789
const t = useTranslations('feeds');
8890
const tCommon = useTranslations('common');
@@ -106,6 +108,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
106108
const routesJsonLoadingStatus = useSelector(
107109
selectGtfsDatasetRoutesLoadingStatus,
108110
);
111+
const hasNoRoutes = totalRoutes == undefined || totalRoutes === 0;
109112

110113
const getAndSetGeoJsonData = (urlToExtract: string): void => {
111114
setGeoJsonLoading(true);
@@ -166,6 +169,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
166169
if (
167170
feed?.data_type === 'gtfs' &&
168171
routesJsonLoadingStatus != 'failed' &&
172+
!hasNoRoutes &&
169173
boundingBox != undefined
170174
) {
171175
setView('gtfsVisualizationView');
@@ -180,7 +184,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
180184
return;
181185
}
182186
setView('boundingBoxView');
183-
}, [feed, routesJsonLoadingStatus, boundingBox, geoJsonData]);
187+
}, [feed, routesJsonLoadingStatus, totalRoutes, boundingBox, geoJsonData]);
184188

185189
const handleViewChange = (
186190
_: React.MouseEvent<HTMLElement>,
@@ -279,9 +283,10 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
279283
return (
280284
feed?.data_type === 'gtfs' &&
281285
routesJsonLoadingStatus != 'failed' &&
286+
!hasNoRoutes &&
282287
boundingBox != undefined
283288
);
284-
}, [feed?.data_type, routesJsonLoadingStatus, boundingBox]);
289+
}, [feed?.data_type, routesJsonLoadingStatus, hasNoRoutes, boundingBox]);
285290

286291
return (
287292
<Box

src/app/screens/Feed/FeedView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ export default async function FeedView({
384384
boundingBox={boundingBox}
385385
latestDataset={latestDataset}
386386
feed={feed}
387+
totalRoutes={totalRoutes}
387388
/>
388389
)}
389390
<Box sx={{ width: { xs: '100%', md: '475px' } }}>

0 commit comments

Comments
 (0)