Unverified Commit 5c26476b authored by Michael Daniels's avatar Michael Daniels Committed by GitHub
Browse files

nixos/tests/dawarich: fix points being flagged as anomalies (#507673)

parents f1b15585 58206c89
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;
        };
    };