Commit Graph

48 Commits

Author SHA1 Message Date
Doug Borg
2d92214bed Add offline-first tile system with per-provider caching and error retry
- Add ServicePolicy framework with OSM-specific rate limiting and TTL
- Add per-provider disk tile cache (ProviderTileCacheStore) with O(1)
  lookup, oldest-modified eviction, and ETag/304 revalidation
- Rewrite DeflockTileProvider with two paths: common (NetworkTileProvider)
  and offline-first (disk cache -> local tiles -> network with caching)
- Add zoom-aware offline routing so tiles outside offline area zoom ranges
  use the efficient common path instead of the overhead-heavy offline path
- Fix HTTP client lifecycle: dispose() is now a no-op for flutter_map
  widget recycling; shutdown() handles permanent teardown
- Add TileLayerManager with exponential backoff retry (2s->60s cap),
  provider switch detection, and backoff reset
- Guard null provider/tileType in download dialog with localized error
- Fix Nominatim cache key to use normalized viewbox values
- Comprehensive test coverage (1800+ lines across 6 test files)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 12:34:01 -07:00
Doug Borg
8983939b05 Delegate network tile fetching to NetworkTileProvider
Replace our custom tile pipeline (fetchRemoteTile / _SimpleSemaphore /
exponential backoff) with flutter_map's built-in NetworkTileProvider,
gaining persistent disk cache, ETag revalidation, RetryClient, and
obsolete request aborting for free.

DeflockTileProvider now extends NetworkTileProvider and overrides
getTileUrl() to route through TileType.getTileUrl() (quadkey,
subdomains, API keys). getImageWithCancelLoadingSupport() routes
between two paths at runtime: the common network path (super) when
no offline areas exist, and a DeflockOfflineTileImageProvider for
offline-first when they do.

- Delete tiles_from_remote.dart (semaphore, retry loop, spatial helpers)
- Simplify MapDataProvider._fetchRemoteTileFromCurrentProvider to plain
  http.get (only used by offline area downloader now)
- Remove dead clearTileQueue/clearTileQueueSelective from MapDataProvider
- Remove 7 tile fetch constants from dev_config.dart
- TileLayerManager now disposes provider on cache clear and uses actual
  urlTemplate for cache key generation
- 9 new tests covering URL delegation, routing, and equality

Closes #87 Phase 2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 20:07:56 -07:00
Doug Borg
0137fd66aa Add consistent User-Agent header to all HTTP clients
Create UserAgentClient (http.BaseClient wrapper) that injects a
User-Agent header into every request, reading app name and version
from VersionService and contact/homepage from dev_config.dart.

Format follows OSM tile usage policy:
  DeFlock/<version> (+https://deflock.org; contact: admin@stopflock.com)

Replaces 4 inconsistent hardcoded UA strings and adds UA to the 9
call sites that previously sent none.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 19:31:27 -07:00
Doug Borg
037165653c Fix lint warnings and cleanup unused code after RadioGroup migration
Remove unused imports, fields, variables, and dead code introduced
during the RadioGroup widget migration and prior changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 13:36:18 -07:00
Doug Borg
c712aba724 Add flutter_lints and fix analyzer errors, dead code, and unused imports 2026-02-08 14:23:06 -07:00
stopflock
83d7814fb6 Network status indicator should only respect the latest / current request. Others finish in background. Replace stupid bools with an enum to track state. Be smarter about split requests. 2026-01-31 17:21:31 -06:00
stopflock
4a36c52982 Node fetch rework 2026-01-30 19:11:00 -06:00
stopflock
8b44b3abf5 Better loading indicator 2025-12-23 16:17:06 -06:00
stopflock
ae795a7607 configurable overpass query timeout; increased to 45s 2025-12-23 12:03:53 -06:00
stopflock
4a4fc30828 Improve overpass efficiency by omitting profiles which are subsumed by any other 2025-12-10 15:26:42 -06:00
stopflock
e6b18bf89b NSI and tag refinement 2025-12-10 12:52:20 -06:00
stopflock
df0377b41f Get rid of double cache, filesystem checking for every tile fetch, swap out http interception for a fluttermap tileprovider that calls map_data, fix node rendering limit 2025-11-28 21:48:17 -06:00
stopflock
45f1635e10 Get rid of double cache layer, remove tiles from network status indicator, fix status callbacks from split fetches, use tileprovider instead of http catching. 2025-11-24 18:28:36 -06:00
stopflock
7ff04851f4 Fix tile loading finally 2025-11-22 13:22:17 -06:00
stopflock
192c6e5158 Disallow editing location of nodes attached to ways/relations 2025-11-16 00:17:53 -06:00
stopflock
4ccf3cace3 Wrap a few things trying to prevent UI / main thread hang we saw one time 2025-11-09 13:59:05 -06:00
stopflock
ca68bd6059 fix network indicator, simplify overpass fetching 2025-10-22 11:56:01 -05:00
stopflock
de0bd7f275 too much, sorry 2025-10-21 15:11:50 -05:00
stopflock
2ccd01c691 Pre-fetch larger areas to reduce calls to overpass; split large requests up 2025-10-21 10:22:04 -05:00
stopflock
71fa212d71 More camera -> node, notifications for approaching 2025-09-29 19:22:22 -05:00
stopflock
38f15a1f8b fetch from sandbox 2025-09-28 22:18:59 -05:00
stopflock
4053c9b39b use real node id for pending uploads, more camera -> node 2025-09-28 20:20:00 -05:00
stopflock
25f0e358a3 clean up debug logging 2025-09-28 17:02:58 -05:00
stopflock
0cbcec7017 improve data indicator, offline fetching, offline area loading 2025-09-28 17:00:34 -05:00
stopflock
fa16e3c299 phase 1 2025-08-30 23:17:08 -05:00
stopflock
a8ac237317 more cameras -> nodes 2025-08-29 18:20:42 -05:00
stopflock
eeedbd7da7 clean up overpass fetching 2025-08-29 16:52:50 -05:00
stopflock
a3edcfc2de finalize code paths for offline areas, caching, in light of multiple tile providers 2025-08-26 17:52:14 -05:00
stopflock
17c9ee0c5c idk but it's better - cache busting works. 2025-08-24 19:38:42 -05:00
stopflock
9e620ef9e4 Consolidate / dedupe some code 2025-08-24 17:46:58 -05:00
stopflock
4ee783793f genericize tiles_from submodule, simpletileservice. 2025-08-24 15:08:36 -05:00
stopflock
a21e807d88 lot of changes, got rid of custom cache stuff, now stepping in the way of http fetch instead of screwing with flutter map. 2025-08-23 17:42:53 -05:00
stopflock
a2bc3309c0 chasing excess tile fetching and lack of correct cache clearing - NOT WORKING 2025-08-23 12:27:04 -05:00
stopflock
f6adffc84e fixes tile re-rendering after long rate limit periods without having to zoom/pan 2025-08-22 23:44:49 -05:00
stopflock
ff9a052d3f broke download dialog, cleaned up debug stuff 2025-08-21 18:52:53 -05:00
stopflock
df5e26f78d breakup app_state 2025-08-21 18:39:09 -05:00
stopflock
55b25a39c1 fix paging - overpass doesnt do that - just fetch all when we are fetching all 2025-08-12 21:51:27 -05:00
stopflock
160bc8f9f2 add dev_config to centralize hardcoded stuff into one place. 2025-08-10 23:31:17 -05:00
stopflock
312f71af4b first time loading tiles from local storage! 2025-08-10 23:07:06 -05:00
stopflock
20bd04e338 first attempts to pull local data from offline areas 2025-08-10 16:42:31 -05:00
stopflock
96f3a9f108 app launches again, sorta working, map broken, settings page has configurable max cams. 2025-08-10 13:15:48 -05:00
stopflock
6bf9556c65 icons and splash screens 2025-08-10 00:19:55 -05:00
stopflock
63675bd18a tbh not sure, left for a bit. sorry. pretty sure closer than last commit.. 2025-08-09 22:44:24 -05:00
stopflock
cf8df39f1e gentler backoffs 2025-08-09 18:02:31 -05:00
stopflock
c76626eb33 map updates slowly with retry logic as tiles become available 2025-08-09 18:00:00 -05:00
stopflock
385f6f3683 sorta works for tiles from osm and cams from overpass 2025-08-09 17:38:33 -05:00
stopflock
7f91d5aec4 more debug logging 2025-08-09 14:04:31 -05:00
stopflock
3dca7d5751 tiles not working but new map data provider exists in theory 2025-08-09 13:50:10 -05:00