Ignore far away vehicles locations - #181
Conversation
- mtransitapps:mtransit-for-android#388
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds agency-area coordinate clamping and public GTFS bounds access, introduces nearby vehicle validation with tests, and filters GTFS-RT and NextBus vehicle positions using that validation before creating ChangesNearby vehicle filtering
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant VehiclePositionFeed
participant VehicleLocationProvider
participant VehicleLocationProviderUtils
participant GTFSProvider
participant VehicleLocation
VehiclePositionFeed->>VehicleLocationProvider: provide vehicle positions
VehicleLocationProvider->>VehicleLocationProviderUtils: validate vehicle coordinates
VehicleLocationProviderUtils->>GTFSProvider: read agency bounds
GTFSProvider-->>VehicleLocationProviderUtils: return min/max latitude and longitude
VehicleLocationProviderUtils-->>VehicleLocationProvider: return nearby result
VehicleLocationProvider->>VehicleLocation: create accepted location
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adds a reusable filter to drop GTFS-RT vehicle positions that are too far from the agency coverage area (addressing “far away vehicles” in some feeds), and wires it into the GTFS real-time vehicle positions provider.
Changes:
- Introduces
VehicleLocationProviderUtils.vehicleNearbyAgencyLocation(...)and a unit test suite for the core logic. - Adds
Area.getNearestLatLng(...)to compute the closest point on an agency bounding box for distance checks. - Filters out far-away GTFS-RT vehicle positions before building
VehicleLocationobjects; exposes GTFS area bounds accessors needed by the utility.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProviderUtilsTest.kt | Adds unit tests for “nearby agency area” vehicle filtering logic. |
| src/main/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProviderUtils.kt | Adds the shared utility that validates vehicle coordinates against agency bounds and distance threshold. |
| src/main/java/org/mtransit/android/commons/provider/vehiclelocations/GTFSRealTimeVehiclePositionsProvider.kt | Applies the new “nearby agency area” filter to GTFS-RT vehicle positions. |
| src/main/java/org/mtransit/android/commons/provider/GTFSProvider.java | Makes area bound getters public so they can be read from other packages (utility). |
| src/main/java/org/mtransit/android/commons/data/Area.kt | Adds helper to clamp a point to the nearest lat/lng on the area bounds. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/org/mtransit/android/commons/data/Area.kt`:
- Around line 74-87: Update Area.isInside and getNearestLatLng to recognize
longitude intervals where minLng exceeds maxLng, treating them as wrapping
across the antimeridian; preserve normal interval behavior otherwise. Ensure
points inside the wrapped interval remain unchanged while outside points clamp
to the nearest wrapped boundary, and add a dateline-crossing test before vehicle
filtering relies on these bounds.
In
`@src/test/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProviderUtilsTest.kt`:
- Around line 14-31: Update the distance calculation in distanceToInMeters to
return metres rather than kilometres, while preserving the existing haversine
calculation and callback contract. Convert the earth-radius value or final
result consistently so the returned Float is expressed in metres.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e39d2c36-e9d7-43fb-87c3-68ff4863c5d3
📒 Files selected for processing (5)
src/main/java/org/mtransit/android/commons/data/Area.ktsrc/main/java/org/mtransit/android/commons/provider/GTFSProvider.javasrc/main/java/org/mtransit/android/commons/provider/vehiclelocations/GTFSRealTimeVehiclePositionsProvider.ktsrc/main/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProviderUtils.ktsrc/test/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProviderUtilsTest.kt
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/main/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProviderUtils.kt:25
- Avoid converting
Float->String->DoubleforvehicleLat/vehicleLng. This allocates strings for every vehicle and adds unnecessary parsing work in a hot path (called per-vehicle). Converting directly toDoublepreserves NaN/Infinity handling and is more efficient.
vehicleLat = vehicleLat.toString().toDoubleOrNull()?.takeIf { it.isFinite() },
vehicleLng = vehicleLng.toString().toDoubleOrNull()?.takeIf { it.isFinite() },
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
- commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181
…parser': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons: Update maps dependencies mtransitapps/commons#826 - commons: Update Kotlin from `2.3.21` to `2.4.10` mtransitapps/commons#827 - commons: Update Hilt from `2.59.2` to `2.60.1` mtransitapps/commons#828 - commons: Update Protobuf from `4.34.1` to `4.35.1` mtransitapps/commons#825 - commons: Update OkHttp from `5.3.2` to `5.4.0` mtransitapps/commons#824 - commons: Update Glide version from `5.0.7` to `5.0.9` mtransitapps/commons#823 - commons: Bump org.xerial:sqlite-jdbc from 3.53.0.0 to 3.53.2.0 mtransitapps/commons#822 - commons: Build(deps): Bump android-gradlePlugin from 9.3.0 to 9.3.1 mtransitapps/commons#821 - commons: Use `git update-index --skip-worktree` to hide locally changed "key" files mtransitapps/commons#820 - commons: Build(deps): Bump com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk from 1.2.1 to 1.3.0 mtransitapps/commons#819 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-android: GTFS-RT Trip Update schedule status > fix wrong 1 min `validity` mtransitapps/commons-android#180 - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file - parser: Auto enable direction splitter when `trips.txt` doesn't have `direction_id` column mtransitapps/parser#82 - parser: `JSON` > `use_route_long_name_for_route_short_name` > use RSN cleaners
…parser': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons: Update maps dependencies mtransitapps/commons#826 - commons: Update Kotlin from `2.3.21` to `2.4.10` mtransitapps/commons#827 - commons: Update Hilt from `2.59.2` to `2.60.1` mtransitapps/commons#828 - commons: Update Protobuf from `4.34.1` to `4.35.1` mtransitapps/commons#825 - commons: Update OkHttp from `5.3.2` to `5.4.0` mtransitapps/commons#824 - commons: Update Glide version from `5.0.7` to `5.0.9` mtransitapps/commons#823 - commons: Bump org.xerial:sqlite-jdbc from 3.53.0.0 to 3.53.2.0 mtransitapps/commons#822 - commons: Build(deps): Bump android-gradlePlugin from 9.3.0 to 9.3.1 mtransitapps/commons#821 - commons: Use `git update-index --skip-worktree` to hide locally changed "key" files mtransitapps/commons#820 - commons: Build(deps): Bump com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk from 1.2.1 to 1.3.0 mtransitapps/commons#819 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-android: GTFS-RT Trip Update schedule status > fix wrong 1 min `validity` mtransitapps/commons-android#180 - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file - parser: Auto enable direction splitter when `trips.txt` doesn't have `direction_id` column mtransitapps/parser#82 - parser: `JSON` > `use_route_long_name_for_route_short_name` > use RSN cleaners
…er': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file
…er': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons: Update maps dependencies mtransitapps/commons#826 - commons: Update Kotlin from `2.3.21` to `2.4.10` mtransitapps/commons#827 - commons: Update Hilt from `2.59.2` to `2.60.1` mtransitapps/commons#828 - commons: Update Protobuf from `4.34.1` to `4.35.1` mtransitapps/commons#825 - commons: Update OkHttp from `5.3.2` to `5.4.0` mtransitapps/commons#824 - commons: Update Glide version from `5.0.7` to `5.0.9` mtransitapps/commons#823 - commons: Bump org.xerial:sqlite-jdbc from 3.53.0.0 to 3.53.2.0 mtransitapps/commons#822 - commons: Build(deps): Bump android-gradlePlugin from 9.3.0 to 9.3.1 mtransitapps/commons#821 - commons: Use `git update-index --skip-worktree` to hide locally changed "key" files mtransitapps/commons#820 - commons: Build(deps): Bump com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk from 1.2.1 to 1.3.0 mtransitapps/commons#819 - commons: Target SDK `36` (Android 16) before Aug 31, 2026 mtransitapps/commons#817 - commons: Create `.aiexclude` to manage AI file exclusions mtransitapps/commons#816 - commons: Allow `download()` user-agent override via `MT_DOWNLOAD_USER_AGENT` mtransitapps/commons#815 - commons: Build(deps): Bump android-gradlePlugin from 9.2.1 to 9.3.0 mtransitapps/commons#814 - commons: Fix `mt-record-screenshots.yml` #810 - commons: Switch latest APK fetch to `gh release download` and pick first APK artifact mtransitapps/commons#810 - commons: Build(deps): Bump com.google.ads.mediation:facebook from 6.21.0.3 to 6.21.0.4 in the ads group across 1 directory mtransitapps/commons#813 - commons: Build(deps): Bump com.google.firebase:firebase-bom from 34.15.0 to 34.16.0 in the gms group across 1 directory mtransitapps/commons#812 - commons: Build(deps): Bump com.google.devtools.ksp from 2.3.9 to 2.3.10 in the kotlin-ksp-compose group across 1 directory mtransitapps/commons#811 - commons: Gradle 9.4+ > enable parallel sync - commons: Skip GitHub release creation when existing release is already latest mtransitapps/commons#809 - commons: runall.sh > print current directory on failure - commons: Build(deps): Bump com.google.android.libraries.places:places from 5.2.0 to 5.3.0 mtransitapps/commons#808 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-android: GTFS-RT Trip Update schedule status > fix wrong 1 min `validity` mtransitapps/commons-android#180 - commons-android: GTFS-RT > Trip Updates > try to fix wrong stop sequence when trip stop passed once & keep all cancelled trips/stops mtransitapps/commons-android#178 - commons-android: Update SSL cert mtransitapps/commons-android#177 - commons-android: GTFS-RT > Trip Updates > handle wrong stop sequence w/o loosing all data mtransitapps/commons-android#176 - commons-android: GTFS-RT Trip Update > fix same stop matching mtransitapps/commons-android#175 - commons-android: suppress - commons-android: GTFS-RT > Trip filtering > allow ignore `direction_id` when `trip_id` is provided mtransitapps/commons-android#172 - commons-android: Status > `hasData` != `!noData` ('no data' means loaded w/o data) mtransitapps/commons-android#173 - commons-android: #isAndroidApp cleanup - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - commons-java: String utils > "and" -> "&" always (tests) - commons-java: String utils > "and" -> "&" always - commons-java: Add build-time `MT_DEBUG_DEFAULT` support for `Constants.DEBUG` mtransitapps/commons-java#45 - commons-java: Replace `(?U)` (no compat /w Android) with Unicode Property Classes like `\p{L}`. - commons-java: CRASH fix created 5 hours ago in 478717d - commons-java: regex scratch++ - parser: Add .coderabbit.yaml configuration file - parser: Auto enable direction splitter when `trips.txt` doesn't have `direction_id` column mtransitapps/parser#82 - parser: `JSON` > `use_route_long_name_for_route_short_name` > use RSN cleaners - parser: comment fix - parser: `JSON` > + `[keep/exclude]_routes`.`route_short_name_regex` #NRT mtransitapps/parser#79 - parser: Use GTFS directions file when provided #lio mtransitapps/parser#77
Summary by CodeRabbit