Skip to content

Commit

Permalink
added textual adsb weather
Browse files Browse the repository at this point in the history
  • Loading branch information
apps4av committed Mar 7, 2024
1 parent 3587e3b commit c8fff11
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 67 deletions.
7 changes: 0 additions & 7 deletions lib/gdl90/Id63NexradProduct.dart

This file was deleted.

9 changes: 0 additions & 9 deletions lib/gdl90/Id64NexradConusProduct.dart

This file was deleted.

10 changes: 10 additions & 0 deletions lib/gdl90/airmet_product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:avaremp/gdl90/product.dart';

class AirmetProduct extends Product {
AirmetProduct(super.time, super.line, super.coordinate);

@override
void parse() {
}

}
35 changes: 35 additions & 0 deletions lib/gdl90/dlac.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class Dlac {

static final List<int> _dlacCode = [
0x03, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B,
0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0X52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5A, 0x00, 0x09, 0x1e, 0x0a, 0x00, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0x3E, 0x3F
];

static String decode(int b1, int b2, int b3) {
int holder = ((b1 & 0xFF) << 24) + ((b2 & 0xFF) << 16) + ((b3 & 0xFF) << 8);

/*
* 4 chars in 3 bytes
*/
int firstChar = _dlacCode[((holder & 0xFC000000) >> 26) & 0x3F];
int secondChar = _dlacCode[((holder & 0x03F00000) >> 20) & 0x3F];
int thirdChar = _dlacCode[((holder & 0x000FC000) >> 14) & 0x3F];
int fourthChar = _dlacCode[((holder & 0x00003F00) >> 8) & 0x3F];

String output = String.fromCharCodes([firstChar, secondChar, thirdChar, fourthChar]);
return output;
}

static String format(String input) {
if (input.isNotEmpty) {
input = input.split("\u001E")[0];
input = input.replaceAll("\n\t[A-Z]{1}", "\n"); /* remove invalid chars after newline */
}
return input;
}

}
6 changes: 4 additions & 2 deletions lib/gdl90/fis_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import 'dart:typed_data';
import 'package:avaremp/gdl90/product.dart';
import 'package:avaremp/gdl90/product_factory.dart';
import 'package:flutter/foundation.dart';
import 'package:latlong2/latlong.dart';

class FisBuffer {

Uint8List buffer;
List<Product> products = [];
FisBuffer(this.buffer);
FisBuffer(this.buffer, this.coordinate);
LatLng? coordinate;

//Parse products out of the Fis
void makeProducts() {
Expand All @@ -33,7 +35,7 @@ class FisBuffer {
Uint8List fis = buffer.sublist(count + 2, count + 2 + iFrameLength);

try {
Product? p = ProductFactory.buildProduct(fis);
Product? p = ProductFactory.buildProduct(fis, coordinate);
if(p != null) {
products.add(p);
}
Expand Down
7 changes: 3 additions & 4 deletions lib/gdl90/nexrad_cache.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:avaremp/constants.dart';
import 'package:avaremp/gdl90/Id63NexradProduct.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:image/image.dart';
import 'Id64NexradConusProduct.dart';
import 'nexrad_medium_product.dart';
import 'nexrad_product.dart';
import 'dart:typed_data';
import 'package:latlong2/latlong.dart';
Expand Down Expand Up @@ -49,7 +48,7 @@ class NexradCache {

void putImg(NexradProduct product) {

Map<int, NexradImage> map = (product is Id63NexradProduct ? _cacheNexrad : _cacheNexradConus);
Map<int, NexradImage> map = (product is NexradMediumProduct ? _cacheNexrad : _cacheNexradConus);

if (product.empty.isNotEmpty) {
// Empty, make dummy bitmaps of all.
Expand All @@ -66,7 +65,7 @@ class NexradCache {
img?.discard();
}
// put
map[product.block] = NexradImage(product.full, product.block, product is Id64NexradConusProduct);
map[product.block] = NexradImage(product.full, product.block, product is NexradMediumProduct);
}

// remove expired
Expand Down
7 changes: 7 additions & 0 deletions lib/gdl90/nexrad_high_product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

import 'nexrad_product.dart';

class NexradHighProduct extends NexradProduct {

NexradHighProduct(super.time, super.data, super.coordinate);
}
8 changes: 8 additions & 0 deletions lib/gdl90/nexrad_medium_product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import 'nexrad_product.dart';

class NexradMediumProduct extends NexradProduct {

NexradMediumProduct(super.time, super.data, super.coordinate);

}
42 changes: 21 additions & 21 deletions lib/gdl90/nexrad_product.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:avaremp/gdl90/product.dart';

class NexradProduct extends Product {
NexradProduct(super.time, super.data);
NexradProduct(super.time, super.line, super.coordinate);

static const int numRows = 4;
static const int numCols = 32;
Expand All @@ -25,12 +25,12 @@ class NexradProduct extends Product {
void parse() {

// Get blocks, skip first 3.
bool elementIdentifier = ((data[0]).toInt() & 0x80) != 0; // RLE or Empty?
bool elementIdentifier = ((line[0]).toInt() & 0x80) != 0; // RLE or Empty?

int len = data.lengthInBytes;
block = (data[0].toInt() & 0x0F) << 16;
block += (data[1].toInt() & 0xFF) << 8;
block += data[2].toInt() & 0xFF;
int len = line.lengthInBytes;
block = (line[0].toInt() & 0x0F) << 16;
block += (line[1].toInt() & 0xFF) << 8;
block += line[2].toInt() & 0xFF;

int index = 3;

Expand All @@ -44,13 +44,13 @@ class NexradProduct extends Product {
int j = 0;
int i;
while (index < len) {
int numberOfBins = ((data[index].toInt() & 0xF8) >> 3) + 1;
int numberOfBins = ((line[index].toInt() & 0xF8) >> 3) + 1;
for (i = 0; i < numberOfBins; i++) {
if (j >= full.length) {
full = [];
return;
}
full[j] = _intensity[(data[index].toInt() & 0x07)];
full[j] = _intensity[(line[index].toInt() & 0x07)];
j++;
}
index++;
Expand All @@ -61,54 +61,54 @@ class NexradProduct extends Product {
full = [];
empty = [];
empty.add(block);
int bitmapLen = data[index].toInt() & 0x0F;
int bitmapLen = line[index].toInt() & 0x0F;

if ((data[index].toInt() & 0x10) != 0) {
if ((line[index].toInt() & 0x10) != 0) {
empty.add(block + 1);
}

if ((data[index].toInt() & 0x20) != 0) {
if ((line[index].toInt() & 0x20) != 0) {
empty.add(block + 2);
}

if ((data[index].toInt() & 0x30) != 0) {
if ((line[index].toInt() & 0x30) != 0) {
empty.add(block + 3);
}

if ((data[index].toInt() & 0x40) != 0) {
if ((line[index].toInt() & 0x40) != 0) {
empty.add(block + 4);
}

for (int i = 1; i < bitmapLen; i++) {
if ((data[index + i].toInt() & 0x01) != 0) {
if ((line[index + i].toInt() & 0x01) != 0) {
empty.add(block + i * 8 - 3);
}

if ((data[index + i].toInt() & 0x02) != 0) {
if ((line[index + i].toInt() & 0x02) != 0) {
empty.add(block + i * 8 - 2);
}

if ((data[index + i].toInt() & 0x04) != 0) {
if ((line[index + i].toInt() & 0x04) != 0) {
empty.add(block + i * 8 - 1);
}

if ((data[index + i].toInt() & 0x08) != 0) {
if ((line[index + i].toInt() & 0x08) != 0) {
empty.add(block + i * 8 - 0);
}

if ((data[index + i].toInt() & 0x10) != 0) {
if ((line[index + i].toInt() & 0x10) != 0) {
empty.add(block + i * 8 + 1);
}

if ((data[index + i].toInt() & 0x20) != 0) {
if ((line[index + i].toInt() & 0x20) != 0) {
empty.add(block + i * 8 + 2);
}

if ((data[index + i].toInt() & 0x40) != 0) {
if ((line[index + i].toInt() & 0x40) != 0) {
empty.add(block + i * 8 + 3);
}

if ((data[index + i].toInt() & 0x80) != 0) {
if ((line[index + i].toInt() & 0x80) != 0) {
empty.add(block + i * 8 + 4);
}
}
Expand Down
10 changes: 10 additions & 0 deletions lib/gdl90/notam_product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:avaremp/gdl90/product.dart';

class NotamProduct extends Product {
NotamProduct(super.time, super.line, super.coordinate);

@override
void parse() {
}

}
7 changes: 5 additions & 2 deletions lib/gdl90/product.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'dart:typed_data';

import 'package:latlong2/latlong.dart';

class Product {

final DateTime time;
final Uint8List data;
final Uint8List line;
final LatLng? coordinate;

Product(this.time, this.data);
Product(this.time, this.line, this.coordinate);

void parse() {

Expand Down
22 changes: 16 additions & 6 deletions lib/gdl90/product_factory.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import 'dart:typed_data';
import 'package:avaremp/gdl90/product.dart';
import 'package:avaremp/gdl90/sigmet_product.dart';
import 'package:avaremp/gdl90/sua_product.dart';
import 'package:flutter/foundation.dart';

import 'Id63NexradProduct.dart';
import 'Id64NexradConusProduct.dart';
import 'package:latlong2/latlong.dart';
import 'airmet_product.dart';
import 'textual_weather_product.dart';
import 'nexrad_high_product.dart';
import 'nexrad_medium_product.dart';
import 'notam_product.dart';

class ProductFactory {

static Product? buildProduct(Uint8List fis) {
static Product? buildProduct(Uint8List fis, LatLng? coordinate) {
BitInputStream s = BitInputStream(fis);

bool flagAppMethod = s.getBits(1) != 0;
Expand Down Expand Up @@ -60,24 +65,29 @@ class ProductFactory {

switch (productID) {
case 8:
p = NotamProduct(time, data, coordinate); // NOTAM graphics
break;
case 9:
break;
case 10:
break;
case 11:
p = AirmetProduct(time, data, coordinate); // AIRMET graphics
break;
case 12:
p = SigmetProduct(time, data, coordinate); // SIGMET graphics
break;
case 13:
p = SuaProduct(time, data, coordinate); // SUA graphics
break;
case 63:
p = Id63NexradProduct(time, data);
p = NexradHighProduct(time, data, coordinate);
break;
case 64:
p = Id64NexradConusProduct(time, data);
p = NexradMediumProduct(time, data, coordinate);
break;
case 413:
p = TextualWeatherProduct(time, data, coordinate); // MEATR, TAF, SPECI, WINDS, PIREP
break;
default:
break;
Expand Down
10 changes: 10 additions & 0 deletions lib/gdl90/sigmet_product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:avaremp/gdl90/product.dart';

class SigmetProduct extends Product {
SigmetProduct(super.time, super.line, super.coordinate);

@override
void parse() {
}

}
10 changes: 10 additions & 0 deletions lib/gdl90/sua_product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:avaremp/gdl90/product.dart';

class SuaProduct extends Product {
SuaProduct(super.time, super.line, super.coordinate);

@override
void parse() {
}

}
Loading

0 comments on commit c8fff11

Please sign in to comment.