Skip to content

Commit

Permalink
bug fixes, version 22.
Browse files Browse the repository at this point in the history
  • Loading branch information
apps4av committed Jul 21, 2024
1 parent 1885252 commit 407988f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 45 deletions.
2 changes: 1 addition & 1 deletion lib/longpress_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class LongPressFuture {
// show first plate
String? apd = await PathUtils.getAirportDiagram(Storage().dataDir, showDestination.locationID);
if(apd != null) {
File file = File(PathUtils.getPlatePath(Storage().dataDir, showDestination.locationID, apd));
File file = File(PathUtils.getFilePath(Storage().dataDir, PathUtils.getFilePath(showDestination.locationID, apd)));
airportDiagram = Image.file(file);
}

Expand Down
83 changes: 47 additions & 36 deletions lib/map_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,20 @@ class MapScreen extends StatefulWidget {
}

class MapScreenState extends State<MapScreen> {

StreamController<void> mapReset = StreamController<void>(); // to reset the radar map
void resetRadar() {
mapReset.add(null);
for(int i = 0; i < Storage().mesonetCache.length; i++) {
Storage().mesonetCache[i].clean(); // clean mesonet cache
}
}

final List<String> _charts = DownloadScreenState.getCategories();
LatLng? _previousPosition;
bool _interacting = false;
bool _rubberBanding = false;
final Ruler _ruler = Ruler();

TileLayer osmLayer = TileLayer(
urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
tileProvider: CachedTileProvider(
// maxStale keeps the tile cached for the given Duration and
// tries to revalidate the next time it gets requested
maxStale: const Duration(days: 30),
store: Storage().osmCache),
);
/* To be added later as it has issues
TileLayer aipLayer = TileLayer(
urlTemplate: "https://api.tiles.openaip.net/api/data/openaip/{z}/{x}/{y}.png",
tileProvider: FMTC.instance('mapStoreAIP').getTileProvider(headers: {"x-openaip-client-id" : "@@___openaip_client_id__@@"}));
*/

// 5 images for animation
List<TileLayer> nexradLayer = List.generate(5, (int index) {
List<String> mesonets = [
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m40m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m30m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m20m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m10m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{z}/{x}/{y}.png"
];
return TileLayer(
maxNativeZoom: 5,
reset: Storage().mapReset.stream,
urlTemplate: mesonets[index],
tileProvider: CachedTileProvider(
// maxStale keeps the tile cached for the given Duration and
// tries to revalidate the next time it gets requested
maxStale: const Duration(minutes: 1),
store: Storage().mesonetCache[index]),
);
});

String _type = Storage().settings.getChartType();
int _maxZoom = ChartCategory.chartTypeToZoom(Storage().settings.getChartType());
MapController? _controller;
Expand Down Expand Up @@ -154,9 +127,43 @@ class MapScreenState extends State<MapScreen> {
@override
Widget build(BuildContext context) {

TileLayer osmLayer = TileLayer(
urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
tileProvider: CachedTileProvider(
// maxStale keeps the tile cached for the given Duration and
// tries to revalidate the next time it gets requested
maxStale: const Duration(days: 30),
store: Storage().osmCache),
);
/* To be added later as it has issues
TileLayer aipLayer = TileLayer(
urlTemplate: "https://api.tiles.openaip.net/api/data/openaip/{z}/{x}/{y}.png",
tileProvider: FMTC.instance('mapStoreAIP').getTileProvider(headers: {"x-openaip-client-id" : "@@___openaip_client_id__@@"}));
*/
String index = ChartCategory.chartTypeToIndex(_type);
_maxZoom = ChartCategory.chartTypeToZoom(_type);

// 5 images for animation
List<TileLayer> nexradLayer = List.generate(5, (int index) {
List<String> mesonets = [
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m40m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m30m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m20m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m10m/{z}/{x}/{y}.png",
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{z}/{x}/{y}.png"
];
return TileLayer(
maxNativeZoom: 5,
reset: mapReset.stream,
urlTemplate: mesonets[index],
tileProvider: CachedTileProvider(
// maxStale keeps the tile cached for the given Duration and
// tries to revalidate the next time it gets requested
maxStale: const Duration(minutes: 1),
store: Storage().mesonetCache[index]),
);
});

//add layers
List<Widget> layers = [];

Expand Down Expand Up @@ -217,6 +224,10 @@ class MapScreenState extends State<MapScreen> {
ValueListenableBuilder<int>(
valueListenable: Storage().timeChange,
builder: (context, value, _) {
if(value % 300 == 0) {
// download new nexrad every 5 minutes
resetRadar();
}
return nexradLayer[value % nexradLength]; // animate every 3 seconds
})
);
Expand Down
5 changes: 0 additions & 5 deletions lib/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class Storage {
late final FlightTimer flightDownTimer;
Destination? plateAirportDestination;
late UnitConversion units;
final StreamController mapReset = StreamController();

List<bool> activeChecklistSteps = [];
String activeChecklistName = "";
Expand Down Expand Up @@ -393,10 +392,6 @@ class Storage {
airep.download();
airSigmet.download();
// nexrad update
mapReset.add(null);
for(int i = 0; i < mesonetCache.length; i++) {
mesonetCache[i].clean(); // clean mesonet cache
}
}
// check GPS enabled
});
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.0.21+21
version: 0.0.22+22

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down Expand Up @@ -162,7 +162,7 @@ msix_config:
publisher_display_name: Apps4Av Inc.
identity_name: Apps4AvInc.AvareX
publisher: CN=97AA5BF2-3109-4884-8224-A2AB9E6DB29A
msix_version: 1.0.21.0
msix_version: 1.0.22.0
logo_path: assets/images/logo.png
capabilities: internetClient, location
store: true
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: avarex
version: 0.0.21
version: 0.0.22
icon: assets/images/logo.png
summary: AvareX Flight Support
description: AvareX provide FAA charts, plates, airport data, weather, air traffic over ADS-B, and lets you create and file flight plans.
Expand Down

0 comments on commit 407988f

Please sign in to comment.