Unverified Commit 58206c89 authored by Diogo Correia's avatar Diogo Correia
Browse files

nixos/tests/dawarich: fix points being flagged as anomalies

Due to a change upstream [1], points with velocity over 1000 km/h are
flagged as anomalies and do not show up in the /points endpoint.
This results in an assertion failure.

To fix this, the dummy data file that was in use has been replaced with
custom data that has spaced out timestamps, which avoids the points
being flagged as anomalies.

[1]: https://github.com/Freika/dawarich/commit/95ea3ed962c99b3790527655d512993b28270018
parent 77bb0683
Loading
Loading
Loading
Loading
+38 −5
Original line number Diff line number Diff line
@@ -3,16 +3,49 @@
  name = "dawarich-nixos";

  nodes.machine =
    { pkgs, ... }:
    { lib, pkgs, ... }:
    {
      services.dawarich = {
        enable = true;
        localDomain = "localhost";
      };

      environment.etc.geojson.source = pkgs.fetchurl {
        url = "https://github.com/Freika/dawarich/raw/8c24764aa56a084e980e21bc2ffd13a72fd611db/spec/fixtures/files/geojson/export.json";
        hash = "sha256-qI00E5ixKTRJduAD+qB3JzvrpoJmC55llNtSiPVyxz4=";
      environment.etc.geojson.text =
        let
          # based on https://github.com/Freika/dawarich/raw/8c24764aa56a084e980e21bc2ffd13a72fd611db/spec/fixtures/files/geojson/export.json
          # but with different timestamps to avoid points being flagged as anomalies
          points = map (i: {
            lat = i / 10.0;
            lon = i / 10.0;
            timestamp = 1609459200 + i * 1000;
          }) (lib.range 1 10);

          mkGeoJsonPoint =
            {
              lat,
              lon,
              timestamp,
            }:
            {
              type = "Feature";
              geometry = {
                type = "Point";
                coordinates = [
                  lon
                  lat
                ];
              };
              properties = {
                altitude = 1;
                vertical_accuracy = 1;
                accuracy = 1;
                inherit timestamp;
              };
            };
        in
        builtins.toJSON {
          type = "FeatureCollection";
          features = map mkGeoJsonPoint points;
        };
    };