Compare commits

...

6 commits
round ... main

9 changed files with 303 additions and 8 deletions

2
.gitignore vendored
View file

@ -25,3 +25,5 @@ mapnames
viz1090 viz1090
result

View file

@ -16,4 +16,11 @@ viz1090: viz1090.o AppData.o AircraftList.o Aircraft.o Label.o AircraftLabel.o a
$(CXX) -o viz1090 viz1090.o AppData.o AircraftList.o Aircraft.o Label.o AircraftLabel.o anet.o interactive.o mode_ac.o mode_s.o net_io.o Input.o View.o Map.o parula.o monokai.o $(LIBS) $(LDFLAGS) $(CXX) -o viz1090 viz1090.o AppData.o AircraftList.o Aircraft.o Label.o AircraftLabel.o anet.o interactive.o mode_ac.o mode_s.o net_io.o Input.o View.o Map.o parula.o monokai.o $(LIBS) $(LDFLAGS)
clean: clean:
rm -f *.o viz1090 rm -f \
airportdata.bin \
airportnames \
mapdata/* \
mapdata.bin \
mapnames \
*.o \
viz1090

View file

@ -1088,6 +1088,7 @@ View::View(AppData *appData){
screen_width = 0; screen_width = 0;
screen_height = 0; screen_height = 0;
screen_depth = 32; screen_depth = 32;
metric = 0;
fps = 0; fps = 0;
fullscreen = 0; fullscreen = 0;
screen_index = 0; screen_index = 0;

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1739758141,
"narHash": "sha256-uq6A2L7o1/tR6VfmYhZWoVAwb3gTy7j4Jx30MIrH0rE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c618e28f70257593de75a7044438efc1c1fc0791",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

50
flake.nix Normal file
View file

@ -0,0 +1,50 @@
{
# TODO desc
description = "viz1090";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
in rec
{
# Nix formatter, run using `$ nix fmt`
formatter = pkgs.alejandra;
# Exports the package
# Build with `$ nix build`
packages.viz1090 = pkgs.callPackage ./nix/viz1090.nix {inherit self system;};
packages.viz1090-mapdata = pkgs.callPackage ./nix/viz1090-mapdata.nix {};
packages.default = packages.viz1090;
# Creates a shell with the necessary dependencies
# Enter using `$ nix develop`
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
rtl-sdr-librtlsdr
SDL2
SDL2_ttf
SDL2_gfx
gdal
python3
python312Packages.pip
python312Packages.shapely
python312Packages.fiona
python312Packages.tqdm
unzip
python312Packages.requests
git
];
};
});
}

View file

@ -1,12 +1,24 @@
#!/bin/bash #!/bin/bash
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_1_states_provinces.zip mkdir -p mapdata
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip pushd mapdata > /dev/null
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_airports.zip
wget --no-verbose https://naciscdn.org/naturalearth/10m/cultural/ne_10m_admin_1_states_provinces.zip
wget --no-verbose https://naciscdn.org/naturalearth/10m/cultural/ne_10m_populated_places.zip
wget --no-verbose https://naciscdn.org/naturalearth/10m/cultural/ne_10m_airports.zip
#this may not be up to date #this may not be up to date
wget https://opendata.arcgis.com/datasets/4d8fa46181aa470d809776c57a8ab1f6_0.zip wget --no-verbose https://opendata.arcgis.com/datasets/4d8fa46181aa470d809776c57a8ab1f6_0.zip
unzip '*.zip' for file in *.zip; do
unzip -o "${file}"
rm "${file}"
done
python3 mapconverter.py --mapfile ne_10m_admin_1_states_provinces.shp --mapnames ne_10m_populated_places.shp --airportfile Runways.shp --airportnames ne_10m_airports.shp popd > /dev/null
python3 mapconverter.py \
--mapfile mapdata/ne_10m_admin_1_states_provinces.shp \
--mapnames mapdata/ne_10m_populated_places.shp \
--airportfile mapdata/Runways.shp \
--airportnames mapdata/ne_10m_airports.shp

View file

@ -38,7 +38,7 @@ def extractLines(shapefile, tolerance):
elif(simplified.geom_type == "MultiPolygon" or simplified.geom_type == "Polygon"): elif(simplified.geom_type == "MultiPolygon" or simplified.geom_type == "Polygon"):
if(simplified.boundary.geom_type == "MultiLineString"): if(simplified.boundary.geom_type == "MultiLineString"):
for boundary in simplified.boundary: for boundary in simplified.boundary.geoms:
outlist.extend(convertLinestring(boundary)) outlist.extend(convertLinestring(boundary))
else: else:
outlist.extend(convertLinestring(simplified.boundary)) outlist.extend(convertLinestring(simplified.boundary))

69
nix/viz1090-mapdata.nix Normal file
View file

@ -0,0 +1,69 @@
{
lib,
pkgs,
stdenv,
fetchFromGitea,
}: let
runways = fetchTarball {
url = "https://opendata.arcgis.com/datasets/4d8fa46181aa470d809776c57a8ab1f6_0.zip";
sha256 = "sha256:1ivwx8glk8yk68nmqz467yzvlb3l66l1s3ibmd9p41wz737lmz88";
};
provinces = fetchTarball {
url = "https://naciscdn.org/naturalearth/10m/cultural/ne_10m_admin_1_states_provinces.zip";
sha256 = "sha256:06ai02b8rfsfzpa0gq4nsg29lxvwy4zvjw44099hc78vr7dkfsdp";
};
places = fetchTarball {
url = "https://naciscdn.org/naturalearth/10m/cultural/ne_10m_populated_places.zip";
sha256 = "sha256:1dhh569520f02yml1m5zp2znjv85cqbccl4nvpmigynxd37kid3j";
};
airports = fetchTarball {
url = "https://naciscdn.org/naturalearth/10m/cultural/ne_10m_airports.zip";
sha256 = "sha256:0893zg63ygr2l2d1wpyigls1syfkryjlygvnbbjikpqk5i5cwr56";
};
in
stdenv.mkDerivation rec {
pname = "viz1090-mapdata";
version = "0.1.0";
src = fetchFromGitea {
domain = "git.vulpecula.zone";
owner = "tasiaiso";
repo = pname;
rev = "d1f53019b22a9e605506bed90fcffcdc5f7e6186";
hash = "sha256-gtv0u7o+5fqVgA0CHDWdZr0h9A1Nbky1+okHvSv1cVU=";
};
nativeBuildInputs = with pkgs; [
python3
python312Packages.pip
python312Packages.shapely
python312Packages.fiona
python312Packages.tqdm
python312Packages.requests
];
buildPhase = ''
mkdir -p mapdata
cp ${runways}/* mapdata
cp ${provinces}/* mapdata
cp ${places}/* mapdata
cp ${airports}/* mapdata
# ls -al mapdata
python3 mapconverter.py \
--mapfile mapdata/ne_10m_admin_1_states_provinces.shp \
--mapnames mapdata/ne_10m_populated_places.shp \
--airportfile mapdata/Runways.shp \
--airportnames mapdata/ne_10m_airports.shp
'';
installPhase = ''
mkdir -p $out
cp airportdata.bin $out
cp airportnames $out
cp mapdata.bin $out
cp mapnames $out
'';
}

93
nix/viz1090.nix Normal file
View file

@ -0,0 +1,93 @@
{
lib,
pkgs,
stdenv,
fetchFromGitea,
self,
system,
}: let
viz1090-mapdata = self.packages.${system}.viz1090-mapdata;
in
stdenv.mkDerivation rec {
pname = "viz1090";
version = "0.1.0";
src = fetchFromGitea {
domain = "git.vulpecula.zone";
owner = "tasiaiso";
repo = pname;
rev = "1922324b40f84fd449cec3fbfdade8aa33597bf6";
hash = "sha256-bPVFKbGtPXOitzzHb3yJ6XW3fRh8PF/7kfP7EJkJX3c=";
};
nativeBuildInputs = with pkgs; [
rtl-sdr-librtlsdr
SDL2
SDL2_ttf
SDL2_gfx
gdal
git
];
buildInputs = [
viz1090-mapdata
];
buildPhase = ''
echo "diff --git a/Makefile b/Makefile
index 5e60779..d5b30ab 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
# sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local
#
-CXXFLAGS=-O2 -std=c++11 -g
+CXXFLAGS=-O2 -std=c++11 -g -I ${pkgs.SDL2.dev}/include/SDL2/
LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx -g
CXX=g++
diff --git a/Map.cpp b/Map.cpp
index cd798ec..c5736bd 100644
--- a/Map.cpp
+++ b/Map.cpp
@@ -189,7 +189,7 @@ std::vector<Line*> Map::getLines(float screen_lat_min, float screen_lat_max, flo
Map::Map() {
FILE *fileptr;
- if((fileptr = fopen(\"mapdata.bin\", \"rb\"))) {
+ if((fileptr = fopen(\"${viz1090-mapdata}/mapdata.bin\", \"rb\"))) {
fseek(fileptr, 0, SEEK_END);
@@ -255,7 +255,7 @@ Map::Map() {
//
- if((fileptr = fopen(\"airportdata.bin\", \"rb\"))) {
+ if((fileptr = fopen(\"${viz1090-mapdata}/airportdata.bin\", \"rb\"))) {
fseek(fileptr, 0, SEEK_END);
airportPoints_count = ftell(fileptr) / sizeof(float);
rewind(fileptr);
@@ -350,7 +350,7 @@ Map::Map() {
infile.close();
- infile.open(\"airportnames\");
+ infile.open(\"${viz1090-mapdata}/airportnames\");
while (std::getline(infile, line))
" | git apply -
cat Map.cpp | grep mapdata
make -j $NIX_BUILD_CORES
'';
installPhase = ''
mkdir -p $out/bin
cp -v viz1090 $out/bin
'';
}