Feature/3 (integrate with OsmAnd active tracks, process a selected distance range, and export the result back to OsmAnd)#1
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new “Track Corridor” workflow to generate POIs along a selected segment of an OsmAnd GPX track, including OsmAnd AIDL integration, corridor geometry utilities, and supporting documentation/tests.
Changes:
- Added Track Corridor UI flow (track selection, segment/corridor inputs, POI generation, send back to OsmAnd/share).
- Introduced OsmAnd AIDL interface + parcelables, plus track parsing/corridor calculation helpers and cache.
- Added docs and unit tests for the new parsing/corridor/cache components.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new Track Corridor feature and links to new docs. |
| docs/track-corridor-workflow.md | Adds a workflow diagram for the Track Corridor flow. |
| docs/architecture.md | Adds a more complete architecture/project structure overview. |
| app/src/test/java/com/example/googleAttractionsGpx/TrackCacheRepositoryTest.kt | Unit tests for track URI cache serialization/deserialization. |
| app/src/test/java/com/example/googleAttractionsGpx/GpxTrackParserTest.kt | Unit tests for GPX track-point parsing behavior. |
| app/src/test/java/com/example/googleAttractionsGpx/CorridorCalculatorTest.kt | Unit tests for corridor distance/segment extraction/bounds calculation. |
| app/src/main/java/net/osmand/aidlapi/gpx/ImportGpxParams.java | Parcelable params for importing GPX into OsmAnd via AIDL. |
| app/src/main/java/net/osmand/aidlapi/gpx/ASelectedGpxFile.java | Parcelable for selected/active GPX file references from OsmAnd. |
| app/src/main/java/net/osmand/aidlapi/gpx/AGpxFileDetails.java | Parcelable details container for GPX metadata returned by OsmAnd. |
| app/src/main/java/net/osmand/aidlapi/gpx/AGpxFile.java | Parcelable for imported GPX file entries returned by OsmAnd. |
| app/src/main/java/net/osmand/aidlapi/AidlParams.java | Base Parcelable implementation used by added OsmAnd AIDL parcelables. |
| app/src/main/java/com/example/googleAttractionsGpx/presentation/TrackCorridorScreen.kt | New Compose screen implementing the Track Corridor feature. |
| app/src/main/java/com/example/googleAttractionsGpx/presentation/MainActivity.kt | Adds navigation route + toolbar entry point to Track Corridor screen. |
| app/src/main/java/com/example/googleAttractionsGpx/data/repository/TrackCacheRepository.kt | SharedPreferences-backed cache mapping track names to persisted URIs. |
| app/src/main/java/com/example/googleAttractionsGpx/data/repository/OsmAndConnection.kt | AIDL binding + APIs to fetch tracks and import GPX into OsmAnd. |
| app/src/main/java/com/example/googleAttractionsGpx/data/repository/GpxTrackParser.kt | SAX-based track-point parsing from GPX files. |
| app/src/main/java/com/example/googleAttractionsGpx/data/repository/CorridorCalculator.kt | Distance accumulation, sub-segment extraction, and corridor bounds computation. |
| app/src/main/AndroidManifest.xml | Adds <queries> entries for OsmAnd package visibility. |
| app/src/main/aidl/net/osmand/aidlapi/IOsmAndAidlInterface.aidl | Adds OsmAnd AIDL interface definition used for integration. |
| app/src/main/aidl/net/osmand/aidlapi/gpx/ImportGpxParams.aidl | Declares ImportGpxParams as AIDL parcelable. |
| app/src/main/aidl/net/osmand/aidlapi/gpx/ASelectedGpxFile.aidl | Declares ASelectedGpxFile as AIDL parcelable. |
| app/src/main/aidl/net/osmand/aidlapi/gpx/AGpxFileDetails.aidl | Declares AGpxFileDetails as AIDL parcelable. |
| app/src/main/aidl/net/osmand/aidlapi/gpx/AGpxFile.aidl | Declares AGpxFile as AIDL parcelable. |
| app/build.gradle.kts | Enables AIDL build feature and bumps version. |
| .gitignore | Ignores additional build output directories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+43
to
+72
| fun bind(onConnected: () -> Unit, onFailed: () -> Unit) { | ||
| val pkg = getOsmAndPackage() | ||
| Log.d(TAG, "bind: resolved package=$pkg") | ||
| if (pkg == null) { | ||
| Log.w(TAG, "bind: no OsmAnd package found") | ||
| onFailed() | ||
| return | ||
| } | ||
| val intent = Intent("net.osmand.aidl.OsmandAidlServiceV2") | ||
| intent.setPackage(pkg) | ||
| Log.d(TAG, "bind: binding to action=net.osmand.aidl.OsmandAidlServiceV2 package=$pkg") | ||
| val bound = context.bindService(intent, object : ServiceConnection { | ||
| override fun onServiceConnected(name: ComponentName?, service: IBinder?) { | ||
| Log.d(TAG, "onServiceConnected: name=$name") | ||
| osmAndInterface = IOsmAndAidlInterface.Stub.asInterface(service) | ||
| boundPackage = pkg | ||
| onConnected() | ||
| } | ||
|
|
||
| override fun onServiceDisconnected(name: ComponentName?) { | ||
| Log.d(TAG, "onServiceDisconnected") | ||
| osmAndInterface = null | ||
| boundPackage = null | ||
| } | ||
| }, Context.BIND_AUTO_CREATE) | ||
| Log.d(TAG, "bind: bindService returned $bound") | ||
| if (!bound) { | ||
| Log.w(TAG, "bind: bindService failed") | ||
| onFailed() | ||
| } |
| val settingsRepository: SettingsRepository = remember { SettingsRepositoryImpl(context) } | ||
| val osmAnd = remember { OsmAndConnection(context) } | ||
| val trackCache = remember { TrackCacheRepository(context) } | ||
|
|
Comment on lines
+1
to
+12
| package net.osmand.aidlapi; | ||
|
|
||
| import net.osmand.aidlapi.gpx.ASelectedGpxFile; | ||
| import net.osmand.aidlapi.gpx.AGpxFile; | ||
| import net.osmand.aidlapi.gpx.ImportGpxParams; | ||
|
|
||
| interface IOsmAndAidlInterface { | ||
| // 1 | ||
| boolean addMapMarker(in Bundle params); | ||
| // 2 | ||
| boolean removeMapMarker(in Bundle params); | ||
| // 3 |
Comment on lines
+11
to
+15
| fun parseTrackPoints(input: InputStream): List<Coordinates> { | ||
| val points = mutableListOf<Coordinates>() | ||
| val factory = SAXParserFactory.newInstance() | ||
| val parser = factory.newSAXParser() | ||
| parser.parse(input, object : DefaultHandler() { |
Comment on lines
+134
to
+147
| fun generate() { | ||
| val start = startKm.toDoubleOrNull() | ||
| val end = endKm.toDoubleOrNull() | ||
| val width = widthMeters.toIntOrNull() | ||
|
|
||
| if (start == null || end == null || width == null) { | ||
| statusText = "Please enter valid numbers for all fields"; return | ||
| } | ||
| if (start >= end) { statusText = "Start distance must be less than end distance"; return } | ||
| if (end > totalLengthKm) { | ||
| statusText = "End distance exceeds track length (${"%.1f".format(totalLengthKm)} km)"; return | ||
| } | ||
| if (width <= 0) { statusText = "Corridor width must be a positive number"; return } | ||
|
|
| val gpxContent = if (includeTrack) { | ||
| buildCorridorGpxContent(allPoints, segment) | ||
| } else { | ||
| buildGpxContent(allPoints) |
Comment on lines
+229
to
+233
| val intent = Intent(Intent.ACTION_VIEW).apply { | ||
| setDataAndType(uri, "application/octet-stream") | ||
| addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | ||
| } | ||
| context.startActivity(Intent.createChooser(intent, "Open GPX")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.