From 159556d7c0931e7a96cc4c0aa2a824360facb0e6 Mon Sep 17 00:00:00 2001 From: Frithjof Winkelmann Date: Tue, 24 Sep 2024 18:15:13 +0200 Subject: [PATCH] Move backend to rust --- .dockerignore | 2 + Dockerfile | 41 +- Dockerfile_python_backend | 33 + backend-rust/.gitignore | 2 + backend-rust/.vscode/settings.json | 3 + backend-rust/Cargo.lock | 2523 ++++++++++++++++++++++++++ backend-rust/Cargo.toml | 18 + backend-rust/download_data.sh | 25 + backend-rust/src/colors.rs | 38 + backend-rust/src/colors_test.rs | 16 + backend-rust/src/height_data.rs | 254 +++ backend-rust/src/height_data_test.rs | 46 + backend-rust/src/main.rs | 357 ++++ backend-rust/src/pqueue.rs | 236 +++ backend-rust/src/pqueue_test.rs | 118 ++ backend-rust/src/search.rs | 684 +++++++ backend-rust/src/search_test.rs | 20 + backend/src/data_analysis/pqueue.py | 48 +- backend/src/data_analysis/search.py | 20 +- backend/src/server.py | 2 +- frontend/src/App.tsx | 10 +- 21 files changed, 4446 insertions(+), 50 deletions(-) create mode 100644 Dockerfile_python_backend create mode 100644 backend-rust/.gitignore create mode 100644 backend-rust/.vscode/settings.json create mode 100644 backend-rust/Cargo.lock create mode 100644 backend-rust/Cargo.toml create mode 100755 backend-rust/download_data.sh create mode 100644 backend-rust/src/colors.rs create mode 100644 backend-rust/src/colors_test.rs create mode 100644 backend-rust/src/height_data.rs create mode 100644 backend-rust/src/height_data_test.rs create mode 100644 backend-rust/src/main.rs create mode 100644 backend-rust/src/pqueue.rs create mode 100644 backend-rust/src/pqueue_test.rs create mode 100644 backend-rust/src/search.rs create mode 100644 backend-rust/src/search_test.rs diff --git a/.dockerignore b/.dockerignore index ba834b9..d8d1782 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,5 @@ backend/data/ +backend-rust/data/ +backend-rust/target/ __pycache__ frontend/node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1bb3e92..70f0016 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,9 @@ FROM node:20.5.1 AS frontend_build WORKDIR /app +COPY ./backend-rust/download_data.sh ./ +RUN ./download_data.sh && ls && ls data + COPY ./frontend/package.json ./ COPY ./frontend/package-lock.json ./ @@ -11,23 +14,37 @@ COPY ./frontend ./ RUN npm run build -FROM python:3.11 +FROM docker.io/rust:1-slim-bookworm AS backend_build + +ARG pkg=backend-rust + +WORKDIR /build -ENV PROD=true +COPY ./backend-rust . -WORKDIR /code +RUN --mount=type=cache,target=/build/target \ + --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/usr/local/cargo/git \ + set -eux; \ + cargo build --release --target-dir /build/target; \ + ls; \ + objcopy --compress-debug-sections target/release/$pkg ./main -COPY ./backend/download_data.sh /code -RUN ./download_data.sh +FROM docker.io/debian:bookworm-slim + +WORKDIR /app -COPY ./backend/requirements.txt /code +COPY --from=frontend_build /app/data ./data -RUN pip install --no-cache-dir --upgrade -r requirements.txt +## copy the main binary +COPY --from=backend_build /build/main ./ -COPY ./backend /code +RUN mkdir static +COPY --from=frontend_build /app/build/index.html ./static +COPY --from=frontend_build /app/build ./static -RUN mkdir -p /static -COPY --from=frontend_build /app/build/index.html /static -COPY --from=frontend_build /app/build /static +## ensure the container listens globally on port 8080 +ENV ROCKET_ADDRESS=0.0.0.0 +ENV ROCKET_PORT=8080 -CMD ["fastapi", "run", "src/server.py", "--port", "80"] \ No newline at end of file +CMD ./main diff --git a/Dockerfile_python_backend b/Dockerfile_python_backend new file mode 100644 index 0000000..1bb3e92 --- /dev/null +++ b/Dockerfile_python_backend @@ -0,0 +1,33 @@ +FROM node:20.5.1 AS frontend_build + +WORKDIR /app + +COPY ./frontend/package.json ./ +COPY ./frontend/package-lock.json ./ + +RUN npm install + +COPY ./frontend ./ + +RUN npm run build + +FROM python:3.11 + +ENV PROD=true + +WORKDIR /code + +COPY ./backend/download_data.sh /code +RUN ./download_data.sh + +COPY ./backend/requirements.txt /code + +RUN pip install --no-cache-dir --upgrade -r requirements.txt + +COPY ./backend /code + +RUN mkdir -p /static +COPY --from=frontend_build /app/build/index.html /static +COPY --from=frontend_build /app/build /static + +CMD ["fastapi", "run", "src/server.py", "--port", "80"] \ No newline at end of file diff --git a/backend-rust/.gitignore b/backend-rust/.gitignore new file mode 100644 index 0000000..5ae1c3b --- /dev/null +++ b/backend-rust/.gitignore @@ -0,0 +1,2 @@ +target +data \ No newline at end of file diff --git a/backend-rust/.vscode/settings.json b/backend-rust/.vscode/settings.json new file mode 100644 index 0000000..ebfde9a --- /dev/null +++ b/backend-rust/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.formatOnSave": true, +} \ No newline at end of file diff --git a/backend-rust/Cargo.lock b/backend-rust/Cargo.lock new file mode 100644 index 0000000..151c24d --- /dev/null +++ b/backend-rust/Cargo.lock @@ -0,0 +1,2523 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "aligned-vec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "anyhow" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + +[[package]] +name = "atomic" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "av1-grain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678909d8c5d46a42abcf571271e15fdbc0a225e3646cf23762cd415046c78bf" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876c75a42f6364451a033496a14c44bffe41f5f4a8236f697391f11024e596d2" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "backend-rust" +version = "0.1.0" +dependencies = [ + "approx", + "byteorder", + "cached", + "image", + "ndarray", + "num-traits", + "rocket", + "serde", +] + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide 0.8.0", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "binascii" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" + +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bitstream-io" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b81e1519b0d82120d2fd469d5bfb2919a9361c48b02d82d04befc1cdd2002452" + +[[package]] +name = "built" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "236e6289eda5a812bc6b53c3b024039382a2895fbbeef2d748b2931546d392c4" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytemuck" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "bytes" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" + +[[package]] +name = "cached" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4d73155ae6b28cf5de4cfc29aeb02b8a1c6dab883cb015d15cd514e42766846" +dependencies = [ + "ahash", + "cached_proc_macro", + "cached_proc_macro_types", + "hashbrown", + "once_cell", + "thiserror", + "web-time", +] + +[[package]] +name = "cached_proc_macro" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f42a145ed2d10dce2191e1dcf30cfccfea9026660e143662ba5eec4017d5daa" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cached_proc_macro_types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" + +[[package]] +name = "cc" +version = "1.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "devise" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d90b0c4c777a2cad215e3c7be59ac7c15adf45cf76317009b7d096d46f651d" +dependencies = [ + "devise_codegen", + "devise_core", +] + +[[package]] +name = "devise_codegen" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71b28680d8be17a570a2334922518be6adc3f58ecc880cbb404eaeb8624fd867" +dependencies = [ + "devise_core", + "quote", +] + +[[package]] +name = "devise_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b035a542cf7abf01f2e3c4d5a7acbaebfefe120ae4efc7bde3df98186e4b8af7" +dependencies = [ + "bitflags 2.6.0", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "exr" +version = "1.72.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" +dependencies = [ + "bit_field", + "flume", + "half", + "lebe", + "miniz_oxide 0.7.4", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + +[[package]] +name = "fdeflate" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "figment" +version = "0.10.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3" +dependencies = [ + "atomic 0.6.0", + "pear", + "serde", + "toml", + "uncased", + "version_check", +] + +[[package]] +name = "flate2" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +dependencies = [ + "crc32fast", + "miniz_oxide 0.8.0", +] + +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "spin", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generator" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gif" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "gimli" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "image" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10" +dependencies = [ + "bytemuck", + "byteorder-lite", + "color_quant", + "exr", + "gif", + "image-webp", + "num-traits", + "png", + "qoi", + "ravif", + "rayon", + "rgb", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79afb8cbee2ef20f59ccd477a218c12a93943d075b492015ecb1bb81f8ee904" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imgref" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" + +[[package]] +name = "indexmap" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +dependencies = [ + "equivalent", + "hashbrown", + "serde", +] + +[[package]] +name = "inlinable_string" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" + +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi 0.4.0", + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + +[[package]] +name = "jpeg-decoder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" + +[[package]] +name = "js-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + +[[package]] +name = "libc" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + +[[package]] +name = "libfuzzer-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +dependencies = [ + "arbitrary", + "cc", + "once_cell", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "loom" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "serde", + "serde_json", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matrixmultiply" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" +dependencies = [ + "autocfg", + "rawpointer", +] + +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http 1.1.0", + "httparse", + "memchr", + "mime", + "spin", + "tokio", + "tokio-util", + "version_check", +] + +[[package]] +name = "ndarray" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "portable-atomic", + "portable-atomic-util", + "rawpointer", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.9", + "libc", +] + +[[package]] +name = "object" +version = "0.36.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pear" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi", +] + +[[package]] +name = "pear_codegen" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "png" +version = "0.17.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.7.4", +] + +[[package]] +name = "portable-atomic" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" + +[[package]] +name = "portable-atomic-util" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcdd8420072e66d54a407b3316991fe946ce3ab1083a7f575b2463866624704d" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "version_check", + "yansi", +] + +[[package]] +name = "profiling" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "system-deps", + "thiserror", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f0bfd976333248de2078d350bfdf182ff96e168a24d23d2436cef320dd4bdd" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rgb", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rgb" +version = "0.8.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "rocket" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a516907296a31df7dc04310e7043b61d71954d703b603cc6867a026d7e72d73f" +dependencies = [ + "async-stream", + "async-trait", + "atomic 0.5.3", + "binascii", + "bytes", + "either", + "figment", + "futures", + "indexmap", + "log", + "memchr", + "multer", + "num_cpus", + "parking_lot", + "pin-project-lite", + "rand", + "ref-cast", + "rocket_codegen", + "rocket_http", + "serde", + "serde_json", + "state", + "tempfile", + "time", + "tokio", + "tokio-stream", + "tokio-util", + "ubyte", + "version_check", + "yansi", +] + +[[package]] +name = "rocket_codegen" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575d32d7ec1a9770108c879fc7c47815a80073f96ca07ff9525a94fcede1dd46" +dependencies = [ + "devise", + "glob", + "indexmap", + "proc-macro2", + "quote", + "rocket_http", + "syn", + "unicode-xid", + "version_check", +] + +[[package]] +name = "rocket_http" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e274915a20ee3065f611c044bd63c40757396b6dbc057d6046aec27f14f882b9" +dependencies = [ + "cookie", + "either", + "futures", + "http 0.2.12", + "hyper", + "indexmap", + "log", + "memchr", + "pear", + "percent-encoding", + "pin-project-lite", + "ref-cast", + "serde", + "smallvec", + "stable-pattern", + "state", + "time", + "tokio", + "uncased", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +dependencies = [ + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "stable-pattern" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4564168c00635f88eaed410d5efa8131afa8d8699a612c80c455a0ba05c21045" +dependencies = [ + "memchr", +] + +[[package]] +name = "state" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" +dependencies = [ + "loom", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml", + "version-compare", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "tempfile" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tiff" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tokio" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "ubyte" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f720def6ce1ee2fc44d40ac9ed6d3a59c361c80a75a7aa8e75bb9baed31cf2ea" +dependencies = [ + "serde", +] + +[[package]] +name = "uncased" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" +dependencies = [ + "serde", + "version_check", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "v_frame" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version-compare" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "weezl" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +dependencies = [ + "memchr", +] + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +dependencies = [ + "is-terminal", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768" +dependencies = [ + "zune-core", +] diff --git a/backend-rust/Cargo.toml b/backend-rust/Cargo.toml new file mode 100644 index 0000000..9409b71 --- /dev/null +++ b/backend-rust/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "backend-rust" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +byteorder = "1.5.0" +cached = "0.53.1" +image = "0.25.2" +ndarray = "0.16.1" +num-traits = "0.2.19" +rocket = { version = "0.5.1", features = ["json"] } +serde = { version = "1.0.210", features = ["derive", "serde_derive"] } + +[dev-dependencies] +approx = "0.5.1" diff --git a/backend-rust/download_data.sh b/backend-rust/download_data.sh new file mode 100755 index 0000000..125bd33 --- /dev/null +++ b/backend-rust/download_data.sh @@ -0,0 +1,25 @@ +mkdir ./data + +cd data + +wget http://viewfinderpanoramas.org/dem1/M32.zip +wget http://viewfinderpanoramas.org/dem1/M33.zip +wget http://viewfinderpanoramas.org/dem1/L31.zip +wget http://viewfinderpanoramas.org/dem1/L32.zip +wget http://viewfinderpanoramas.org/dem1/L33.zip + +unzip M32.zip +unzip M33.zip +unzip L31.zip +unzip L32.zip +unzip L33.zip + +mv M32/*.hgt ./ +mv M33/*.hgt ./ +mv L31/*.hgt ./ +mv L32/*.hgt ./ +mv L33/*.hgt ./ + + +rm M32.zip M33.zip L31.zip L32.zip L33.zip +rm -rf M32/ M33/ L31/ L32/ L33/ diff --git a/backend-rust/src/colors.rs b/backend-rust/src/colors.rs new file mode 100644 index 0000000..4186737 --- /dev/null +++ b/backend-rust/src/colors.rs @@ -0,0 +1,38 @@ +pub fn lerp_f32(a: f32, b: f32, s: f32) -> f32 { + a + (b - a) * s +} + +pub fn lerp_color(a: &[f32; 4], b: &[f32; 4], s: f32) -> [f32; 4] { + [ + lerp_f32(a[0], b[0], s), + lerp_f32(a[1], b[1], s), + lerp_f32(a[2], b[2], s), + lerp_f32(a[3], b[3], s), + ] +} + +pub fn lerp(lerp_colors: &[[f32; 4]; S], steps: &[f32; S], s: f32) -> [f32; 4] { + for i in 0..(S - 1) { + if s >= steps[i] && s < steps[i + 1] { + return lerp_color( + &lerp_colors[i], + &lerp_colors[i + 1], + (s - steps[i]) / (steps[i + 1] - steps[i]), + ); + } + } + return lerp_colors[S - 1]; +} + +pub fn f32_color_to_u8(color: [f32; 4]) -> [u8; 4] { + return [ + color[0].trunc().min(255.0).max(0.0) as u8, + color[1].trunc().min(255.0).max(0.0) as u8, + color[2].trunc().min(255.0).max(0.0) as u8, + color[3].trunc().min(255.0).max(0.0) as u8, + ]; +} + +#[cfg(test)] +#[path = "./colors_test.rs"] +mod colors_test; diff --git a/backend-rust/src/colors_test.rs b/backend-rust/src/colors_test.rs new file mode 100644 index 0000000..f62d7e7 --- /dev/null +++ b/backend-rust/src/colors_test.rs @@ -0,0 +1,16 @@ +use crate::colors::lerp_f32; + +#[test] +fn test_lerp_f32() { + assert_eq!(lerp_f32(0.0, 10.0, 0.5), 5.0); + assert_eq!(lerp_f32(0.0, 10.0, 1.0), 10.0); + assert_eq!(lerp_f32(0.0, 10.0, 0.0), 0.0); + + assert_eq!(lerp_f32(1.0, 6.0, 0.5), 3.5); + assert_eq!(lerp_f32(1.0, 6.0, 1.0), 6.0); + assert_eq!(lerp_f32(1.0, 6.0, 0.0), 1.0); + + assert_eq!(lerp_f32(3.5, 7.75, 0.5), 5.625); + assert_eq!(lerp_f32(3.5, 7.75, 0.25), 4.5625); + assert_eq!(lerp_f32(3.5, 8.5, 0.2), 4.5); +} diff --git a/backend-rust/src/height_data.rs b/backend-rust/src/height_data.rs new file mode 100644 index 0000000..ed202ca --- /dev/null +++ b/backend-rust/src/height_data.rs @@ -0,0 +1,254 @@ +use byteorder::{BigEndian, ByteOrder}; +use cached::proc_macro::cached; +use ndarray::linspace; +use ndarray::s; +use ndarray::Array; +use ndarray::Array1; +use ndarray::Array2; +use ndarray::ArrayView; +use ndarray::ArrayViewMut; +use ndarray::AssignElem; +use ndarray::Ix2; +use std::f32::consts::PI; +use std::fs::File; +use std::io::BufReader; +use std::io::Read; + +const HGT_SIZE: usize = 3601; +const HGT_SIZE_SQUARED: usize = HGT_SIZE * HGT_SIZE; +const HGT_N_BYTES: usize = HGT_SIZE_SQUARED << 1; + +const ANGLE_TO_RADIANS: f32 = PI / 180.0; +const ARC_SECOND_IN_M_EQUATOR: f32 = 1852.0 / 60.0; +const ARC_SECOND_IN_DEGREE: f32 = 1.0 / (60.0 * 60.0); //TODO is this safe + +#[cached] +pub fn load_hgt(latitude: i32, longitude: i32) -> Array2 { + /*# TODO: S & W! + assert latitude >= 0 + assert longitude >= 0 + + */ + let file_name = format!("./data/N{}E{:03}.hgt", latitude, longitude); + let file = File::open(file_name).expect("Could not open hgt file"); + let mut reader = BufReader::new(file); + let mut content = Vec::::with_capacity(HGT_N_BYTES); + + let total_read = reader + .read_to_end(&mut content) + .expect("Could not read hgt file"); + + assert!(total_read == HGT_N_BYTES, "Wrong number of bytes read!"); + + let mut result_vec = Vec::::with_capacity(HGT_SIZE_SQUARED); + for i in (0..HGT_N_BYTES).step_by(2) { + result_vec.push(BigEndian::read_i16(&content[i..i + 2])); + } + + return Array::from_shape_vec((HGT_SIZE, HGT_SIZE), result_vec).unwrap(); +} + +#[cached] +pub fn read_hgt_file(latitude: i32, longitude: i32) -> Vec { + let file_name = format!("./data/N{}E{:03}.hgt", latitude, longitude); + let file = File::open(file_name).expect("Could not open hgt file"); + let mut reader = BufReader::new(file); + let mut content = Vec::::with_capacity(HGT_N_BYTES); + + let total_read = reader + .read_to_end(&mut content) + .expect("Could not read hgt file"); + + assert!(total_read == HGT_N_BYTES, "Wrong number of bytes read!"); + + return content; +} + +pub fn load_hgt_to_array(latitude: i32, longitude: i32, array: &mut ArrayViewMut<'_, i16, Ix2>) { + let bytes = read_hgt_file(latitude, longitude); + + for i in (0..HGT_N_BYTES).step_by(2) { + let ix = i >> 1; + array[[ix / HGT_SIZE, ix % HGT_SIZE]].assign_elem(BigEndian::read_i16(&bytes[i..i + 2])); + } +} + +pub fn arcsecond_in_meters(latitude: f32) -> f32 { + return (latitude * ANGLE_TO_RADIANS).cos() * ARC_SECOND_IN_M_EQUATOR; +} + +pub fn meter_in_arcseconds(latitude: f32) -> f32 { + return 1.0 / arcsecond_in_meters(latitude); +} + +#[derive(Clone)] +pub struct HeightGrid { + pub heights: Array2, + pub cell_size: f32, + pub latitudes: (f32, f32), + pub longitudes: (f32, f32), +} + +pub fn usize_f32(x: usize) -> f32 { + f32::from(x as u16) +} + +pub fn f32_usize(x: f32) -> usize { + usize::from(x as u16) +} + +pub fn i32_f32(x: i32) -> f32 { + f32::from(x as i16) +} + +pub fn scale_2d_array(values: &ArrayView<'_, i16, Ix2>, scales: (f32, f32)) -> Array2 { + //TODO: Specialize for square shapes? + let size_x = values.shape()[0] as u16; + let size_y = values.shape()[1] as u16; + + let n_elems_x = (f32::from(size_x) * scales.0).ceil() as usize; + let n_elems_y = (f32::from(size_y) * scales.1).ceil() as usize; + + let x_indices = Array1::from_iter(linspace(0.0, f32::from(size_x - 1), n_elems_x)).round(); + let y_indices = Array1::from_iter(linspace(0.0, f32::from(size_y - 1), n_elems_y)).round(); + + let mut result = Array2::zeros((n_elems_x, n_elems_y)); + for (new_x, old_x) in x_indices.iter().enumerate() { + for (new_y, old_y) in y_indices.iter().enumerate() { + result[[new_x, new_y]] = values[[old_x.clone() as usize, old_y.clone() as usize]] + } + } + result +} + +impl HeightGrid { + pub fn scale(&self, factor: f32) -> HeightGrid { + HeightGrid { + heights: scale_2d_array(&self.heights.view(), (factor, factor)), + cell_size: self.cell_size / factor, + latitudes: self.latitudes, + longitudes: self.longitudes, + } + } + + pub fn get_angular_resolution(&self) -> (f32, f32) { + ( + (self.latitudes.1 - self.latitudes.0) / self.heights.shape()[0] as f32, + (self.longitudes.1 - self.longitudes.0) / self.heights.shape()[1] as f32, + ) + } + + pub fn get_coordinates_for_indices(&self) -> (Vec, Vec) { + let lats = linspace(self.latitudes.0, self.latitudes.1, self.heights.shape()[0]); + let lons = linspace( + self.longitudes.0, + self.longitudes.1, + self.heights.shape()[1], + ); + + (Vec::from_iter(lats), Vec::from_iter(lons)) + } +} + +pub fn get_height_at_point(latitude: f32, longitude: f32) -> i16 { + let lat_i = latitude.trunc(); + let lon_i = longitude.trunc(); + + let data = load_hgt(lat_i as i32, lon_i as i32); + + let lat_ix = ((latitude - lat_i) * usize_f32(data.shape()[0])).trunc() as usize; + let lon_ix = ((longitude - lon_i) * usize_f32(data.shape()[1])).trunc() as usize; + + return data + .get((data.shape()[0] - lat_ix - 1, lon_ix)) + .unwrap() + .clone(); +} + +pub fn get_height_data_around_point( + latitude: f32, + longitude: f32, + distance_m_opt: Option, +) -> HeightGrid { + let distance_m = distance_m_opt.unwrap_or(15000.0); + + let distance_degree_lat = distance_m * ARC_SECOND_IN_DEGREE / ARC_SECOND_IN_M_EQUATOR; + let distance_degree_lon = meter_in_arcseconds(latitude) * distance_m * ARC_SECOND_IN_DEGREE; + + let lower_latitude = latitude - distance_degree_lat; + let upper_latitude = latitude + distance_degree_lat; + + let lower_longitude = longitude - distance_degree_lon; + let upper_longitude = longitude + distance_degree_lon; + + let lower_lat_i = lower_latitude.trunc() as i32; + let upper_lat_i = upper_latitude.trunc() as i32; + + let lower_lon_i = lower_longitude.trunc() as i32; + let upper_lon_i = upper_longitude.trunc() as i32; + + let n_lat = upper_lat_i - lower_lat_i + 1; + let n_lon = upper_lon_i - lower_lon_i + 1; + + let mut arr = Array2::zeros(((n_lat as usize) * HGT_SIZE, (n_lon as usize) * HGT_SIZE)); + + for lat_i in lower_lat_i..upper_lat_i + 1 { + for lon_i in lower_lon_i..upper_lon_i + 1 { + //let lat_ix = (n_lat - (lat_i - lower_lat_i) - 1) as usize; + let lat_ix = (lat_i - lower_lat_i) as usize; + let lon_ix = (lon_i - lower_lon_i) as usize; + + let mut sub_slice = arr.slice_mut(s![ + lat_ix * HGT_SIZE..(lat_ix + 1) * HGT_SIZE;-1, + lon_ix * HGT_SIZE..(lon_ix + 1) * HGT_SIZE + ]); + + load_hgt_to_array(lat_i, lon_i, &mut sub_slice); + } + } + let degree_per_lat_ix = i32_f32((upper_lat_i + 1) - lower_lat_i) / usize_f32(arr.shape()[0]); + let degree_per_lon_ix = i32_f32((upper_lon_i + 1) - lower_lon_i) / usize_f32(arr.shape()[1]); + + let lower_lat_ix = + f32_usize(((lower_latitude - i32_f32(lower_lat_i)) / degree_per_lat_ix).trunc()); + let upper_lat_ix = + f32_usize(((upper_latitude - i32_f32(lower_lat_i)) / degree_per_lat_ix).trunc()); + + let lower_lon_ix = + f32_usize(((lower_longitude - i32_f32(lower_lon_i)) / degree_per_lon_ix).trunc()); + let upper_lon_ix = + f32_usize(((upper_longitude - i32_f32(lower_lon_i)) / degree_per_lon_ix).trunc()); + + let result_arr = arr.slice(s![lower_lat_ix..upper_lat_ix, lower_lon_ix..upper_lon_ix]); + + let lat_resolution_degree = + (upper_latitude - lower_latitude) / usize_f32(result_arr.shape()[0]); + let lon_resolution_degree = + (upper_longitude - lower_longitude) / usize_f32(result_arr.shape()[1]); + + let lat_resolution_meters = + lat_resolution_degree / ARC_SECOND_IN_DEGREE * ARC_SECOND_IN_M_EQUATOR; + let lon_resolution_meters = + lon_resolution_degree / ARC_SECOND_IN_DEGREE * arcsecond_in_meters(latitude); + + let max_resolution = f32::max(lat_resolution_meters, lon_resolution_meters); + + let final_grid = scale_2d_array( + &result_arr, + ( + lat_resolution_meters / max_resolution, + lon_resolution_meters / max_resolution, + ), + ); + + return HeightGrid { + heights: final_grid, + cell_size: max_resolution, + latitudes: (lower_latitude, upper_latitude), + longitudes: (lower_longitude, upper_longitude), + }; +} + +#[cfg(test)] +#[path = "./height_data_test.rs"] +mod height_data_test; diff --git a/backend-rust/src/height_data_test.rs b/backend-rust/src/height_data_test.rs new file mode 100644 index 0000000..402db94 --- /dev/null +++ b/backend-rust/src/height_data_test.rs @@ -0,0 +1,46 @@ +use approx::assert_relative_eq; + +use crate::height_data::get_height_at_point; + +use super::{get_height_data_around_point, load_hgt}; + +#[test] +fn test_load_hgt() { + let data = load_hgt(47, 11); + + assert_eq!(data.get((22, 35)).unwrap().clone(), 644i16); + assert_eq!(data.get((1065, 2354)).unwrap().clone(), 1067i16); + assert_eq!(data.get((3456, 2985)).unwrap().clone(), 2472i16); + assert_eq!(data.get((3443, 3292)).unwrap().clone(), 2561i16); + assert_eq!(data.get((1922, 848)).unwrap().clone(), 1105i16); +} + +#[test] +fn test_height_data_at_point() { + assert_eq!(get_height_at_point(47.534, 11.7645), 1183); + assert_eq!(get_height_at_point(47.0324, 11.3235), 1713); + assert_eq!(get_height_at_point(47.87345, 11.01324), 717); + assert_eq!(get_height_at_point(47.9943, 11.999234), 486); +} + +#[test] +fn test_get_height_data_around_point() { + let height_grid = get_height_data_around_point(47.05, 11.05, None); + + assert_eq!(height_grid.heights.shape()[0], 973); + assert_eq!(height_grid.heights.shape()[1], 973); + assert_relative_eq!(height_grid.cell_size, 30.832, max_relative = 0.01); + assert_relative_eq!(height_grid.latitudes.0, 46.915, max_relative = 0.01); + assert_relative_eq!(height_grid.latitudes.1, 47.185, max_relative = 0.01); + assert_relative_eq!(height_grid.longitudes.0, 10.852, max_relative = 0.01); + assert_relative_eq!(height_grid.longitudes.1, 11.248, max_relative = 0.01); + + assert_eq!(height_grid.heights.get((125, 654)).unwrap().clone(), 2436); + assert_eq!(height_grid.heights.get((583, 762)).unwrap().clone(), 2388); + assert_eq!(height_grid.heights.get((76, 234)).unwrap().clone(), 3149); + assert_eq!(height_grid.heights.get((22, 423)).unwrap().clone(), 2448); + assert_eq!(height_grid.heights.get((7, 5)).unwrap().clone(), 3156); + assert_eq!(height_grid.heights.get((13, 920)).unwrap().clone(), 2648); + assert_eq!(height_grid.heights.get((15, 956)).unwrap().clone(), 2131); + assert_eq!(height_grid.heights.get((970, 967)).unwrap().clone(), 2085); +} diff --git a/backend-rust/src/main.rs b/backend-rust/src/main.rs new file mode 100644 index 0000000..ca8c957 --- /dev/null +++ b/backend-rust/src/main.rs @@ -0,0 +1,357 @@ +use core::f32; +use std::{ + cmp::{max, min}, + hash::{Hash, Hasher}, + io::Cursor, +}; + +use colors::{f32_color_to_u8, lerp}; +use image::{DynamicImage, GenericImage, ImageFormat, Rgba}; +use rocket::{ + fs::FileServer, + http::ContentType, + response::Redirect, + serde::{json::Json, Serialize}, +}; + +use height_data::HeightGrid; +use ndarray::{s, Array2}; +use search::{search_from_point, Explored, GridIx, SearchQuery}; + +use cached::proc_macro::cached; + +mod colors; +mod height_data; +mod pqueue; +mod search; + +#[macro_use] +extern crate rocket; + +#[get("/")] +fn index() -> Redirect { + Redirect::to("/static") +} + +const cell_size_default: f32 = 200.0; +const glide_number_default: f32 = 8.0; +const additional_height_default: f32 = 10.0; +const wind_speed_default: f32 = 0.0; +const wind_direction_default: f32 = 0.0; +const trim_speed_default: f32 = 38.0; +const safety_margin_default: f32 = 0.0; +const start_distance_default: f32 = 0.0; + +#[derive(Debug, Clone)] +struct Distance(f32); + +impl Distance { + fn canonicalize(&self) -> i32 { + (self.0 * 1024.0 * 1024.0).round() as i32 + } +} + +impl PartialEq for Distance { + fn eq(&self, other: &Distance) -> bool { + self.canonicalize() == other.canonicalize() + } +} + +impl Eq for Distance {} + +impl Hash for Distance { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + self.canonicalize().hash(state); + } +} + +#[derive(Hash, PartialEq, Eq, Clone)] +pub struct SearchQueryHashable { + pub glide_ratio: Distance, + pub trim_speed: Distance, + pub wind_direction: Distance, + pub wind_speed: Distance, + pub additional_height: Distance, + pub safety_margin: Distance, + pub start_distance: Distance, +} + +impl SearchQueryHashable { + pub fn to_search_query(&self) -> SearchQuery { + SearchQuery { + glide_ratio: self.glide_ratio.0, + trim_speed: self.trim_speed.0, + wind_direction: self.wind_direction.0, + wind_speed: self.wind_speed.0, + additional_height: self.additional_height.0, + safety_margin: self.safety_margin.0, + start_distance: self.start_distance.0, + } + } +} + +#[cached] +fn search_from_point_memoized( + latitude: Distance, + longitude: Distance, + cell_size: Distance, + query: SearchQueryHashable, +) -> (Explored, HeightGrid) { + search_from_point( + latitude.0, + longitude.0, + cell_size.0, + query.to_search_query(), + ) +} + +pub fn search_from_request( + lat: f32, + lon: f32, + cell_size_opt: Option, + glide_number_opt: Option, + additional_height_opt: Option, + wind_speed_opt: Option, + wind_direction_opt: Option, + trim_speed_opt: Option, + safety_margin_opt: Option, + start_distance_opt: Option, +) -> (Explored, HeightGrid, Array2) { + let cell_size = cell_size_opt.unwrap_or(cell_size_default); + let glide_number = glide_number_opt.unwrap_or(glide_number_default); + let additional_height = additional_height_opt.unwrap_or(additional_height_default); + let wind_speed = wind_speed_opt.unwrap_or(wind_speed_default); + let wind_direction = wind_direction_opt.unwrap_or(wind_direction_default); + let trim_speed = trim_speed_opt.unwrap_or(trim_speed_default); + let safety_margin = safety_margin_opt.unwrap_or(safety_margin_default); + let start_distance = start_distance_opt.unwrap_or(start_distance_default); + + let lat_rounded = (lat * 1000.0).round() / 1000.0; + let lon_rounded = (lon * 1000.0).round() / 1000.0; + + let (explored, grid) = search_from_point_memoized( + Distance(lat_rounded), + Distance(lon_rounded), + Distance(cell_size), + SearchQueryHashable { + additional_height: Distance(additional_height), + wind_speed: Distance(wind_speed), + wind_direction: Distance(wind_direction), + glide_ratio: Distance(1.0 / glide_number), + trim_speed: Distance(trim_speed), + safety_margin: Distance(safety_margin), + start_distance: Distance(start_distance), + }, + ); + + // TODO: Memoization + /*state, grid = memoized_search( + lat, + lon, + cell_size, + SearchQuery( + 1 / glide_number, + trim_speed, + wind_direction / 180 * math.pi, + wind_speed, + additional_height, + safety_margin, + start_distance, + ), + )*/ + + let mut heights = + Array2::from_elem((grid.heights.shape()[0], grid.heights.shape()[1]), -1000.0); + + for (ix, node) in explored.iter() { + if node.reachable { + heights[ix.clone()] = node.height - grid.heights[ix.clone()] as f32; + } + } + + return (explored, grid, heights); +} + +#[derive(Serialize)] + +struct NodeResponse { + index: GridIx, + height: f32, + distance: f32, + lat: f32, + lon: f32, + reference: Option, + size: f32, + agl: f32, + gl: i16, +} + +#[derive(Serialize)] +struct FlightConeResponse { + nodes: Vec, + cell_size: f32, + angular_resolution: (f32, f32), + lat: (f32, f32), + lon: (f32, f32), + grid_shape: (usize, usize), +} + +#[get("/flight_cone?&&&&&&&&&")] +fn get_flight_cone( + lat: f32, + lon: f32, + cell_size: Option, + glide_number: Option, + additional_height: Option, + wind_speed: Option, + wind_direction: Option, + trim_speed: Option, + safety_margin: Option, + start_distance: Option, +) -> Json { + let (explored, grid, _) = search_from_request( + lat, + lon, + cell_size, + glide_number, + additional_height, + wind_speed, + wind_direction, + trim_speed, + safety_margin, + start_distance, + ); + + let (lats, lons) = grid.get_coordinates_for_indices(); + let resolution = grid.get_angular_resolution(); + + let mut response = FlightConeResponse { + nodes: vec![], + cell_size: grid.cell_size, + angular_resolution: resolution, + lat: grid.latitudes, + lon: grid.longitudes, + grid_shape: (grid.heights.shape()[0], grid.heights.shape()[1]), + }; + + for (grid_ix, node) in explored { + if node.reachable { + response.nodes.push(NodeResponse { + index: grid_ix, + height: node.height, + distance: node.distance, + lat: lats[grid_ix.0], + lon: lons[grid_ix.1], + reference: node.reference, + size: grid.cell_size, + agl: node.height - grid.heights[[grid_ix.0, grid_ix.1]] as f32, + gl: grid.heights[[grid_ix.0, grid_ix.1]], + }) + } + } + + return Json(response); +} + +const default_lerp_colors: [[f32; 4]; 3] = [ + [255.0, 0.0, 0.0, 255.0], + [180.0, 190.0, 0.0, 255.0], + [0.0, 150.0, 255.0, 255.0], +]; +const default_lerp_steps: [f32; 3] = [0.0, 0.5, 1.0]; + +#[get("/agl_image?&&&&&&&&&")] +fn get_agl_image<'a>( + lat: f32, + lon: f32, + cell_size: Option, + glide_number: Option, + additional_height: Option, + wind_speed: Option, + wind_direction: Option, + trim_speed: Option, + safety_margin: Option, + start_distance: Option, +) -> (ContentType, Vec) { + let (_, _, heights) = search_from_request( + lat, + lon, + cell_size, + glide_number, + additional_height, + wind_speed, + wind_direction, + trim_speed, + safety_margin, + start_distance, + ); + + let mut imgx = heights.shape()[0]; + let mut imgy = heights.shape()[1]; + + let mut hmin = f32::MAX; + let mut hmax = f32::MIN; + let mut x_lower = usize::MAX; + let mut x_upper = usize::MIN; + let mut y_lower = usize::MAX; + let mut y_upper = usize::MIN; + + for x in 0..imgx { + for y in 0..imgy { + if heights[(x, y)] > 0.0 { + hmin = hmin.min(heights[(x, y)]); + hmax = hmax.max(heights[(x, y)]); + + x_lower = min(x_lower, x); + x_upper = max(x_upper, x); + y_lower = min(y_lower, y); + y_upper = max(y_upper, y); + } + } + } + + imgx = (x_upper - x_lower) + 1; + imgy = (y_upper - y_lower) + 1; + + let heights_sub = heights.slice(s![x_lower..(x_upper + 1), y_lower..(y_upper + 1)]); + + let mut img = DynamicImage::new_rgba8(imgy as u32, imgx as u32); + + // Iterate over the coordinates and pixels of the image + for x in 0..imgx { + for y in 0..imgy { + let ix = (x, y); + if heights_sub[ix] > 0.0 { + let agl = heights_sub[ix]; + let s = (agl - hmin) / (hmax - hmin); + img.put_pixel( + y as u32, + (imgx - x) as u32 - 1, + Rgba(f32_color_to_u8(lerp( + &default_lerp_colors, + &default_lerp_steps, + s, + ))), + ); + } else { + img.put_pixel(y as u32, (imgx - x) as u32 - 1, Rgba([255, 255, 255, 0])); + } + } + } + + let mut c = Cursor::new(Vec::new()); + img.write_to(&mut c, ImageFormat::Png).expect(""); + (ContentType::PNG, c.into_inner()) +} + +#[launch] +fn rocket() -> _ { + rocket::build() + .mount("/", routes![index]) + .mount("/", routes![get_flight_cone]) + .mount("/", routes![get_agl_image]) + .mount("/static", FileServer::from("./static")) +} diff --git a/backend-rust/src/pqueue.rs b/backend-rust/src/pqueue.rs new file mode 100644 index 0000000..505971c --- /dev/null +++ b/backend-rust/src/pqueue.rs @@ -0,0 +1,236 @@ +use std::collections::HashMap; +use std::hash::Hash; + +#[derive(Debug)] +pub struct HeapNode { + pub priority: P, + pub item: V, + pub key: K, +} + +#[derive(Debug)] +pub struct PriorityQueue { + heap: Vec>, + positions: HashMap, +} + +impl PriorityQueue { + pub fn new() -> Self { + Self { + heap: Vec::new(), + positions: HashMap::new(), + } + } + + pub fn with_capacity(capacity: usize) -> Self { + Self { + heap: Vec::with_capacity(capacity), + positions: HashMap::with_capacity(capacity), + } + } + + pub fn len(&self) -> usize { + self.heap.len() + } + + pub fn capacity(&self) -> usize { + self.heap.capacity() + } +} + +impl PriorityQueue { + pub fn push(&mut self, key: K, item: V, priority: P) -> () { + self.heap.push(HeapNode { + priority: priority, + item: item, + key: key, + }); + + let ix = self.heap.len() - 1; + + self.positions.insert(key, ix); + + self.siftup(ix); + } + + pub fn update_priority(&mut self, key: K, priority: P) -> &mut HeapNode { + let ix = self + .positions + .get(&key) + .expect("Update priority called with invalid key") + .clone(); + + let node = self.heap.get_mut(ix).unwrap(); + let old_priority = node.priority; + node.priority = priority; + + let new_ix = if old_priority > priority { + self.siftup(ix) + } else { + self.siftdown(ix) + }; + + return self.heap.get_mut(new_ix).unwrap(); + } + + pub fn update_priority_if_less( + &mut self, + key: K, + priority: P, + ) -> Option<&mut HeapNode> { + let ix = self + .positions + .get(&key) + .expect("Update priority called with invalid key") + .clone(); + + let node = self.heap.get_mut(ix).unwrap(); + let old_priority = node.priority; + + if old_priority <= priority { + return None; + } + node.priority = priority; + let new_ix = self.siftup(ix); + + return self.heap.get_mut(new_ix); + } + + pub fn pop(&mut self) -> Option> { + let len = self.len(); + if len == 0 { + return None; + } + + self.heap.swap(0, len - 1); + let element = self.heap.pop().unwrap(); + self.positions.remove_entry(&element.key); + + if len == 1 { + return Some(element); + } + + *self + .positions + .get_mut(&self.heap.get(0).unwrap().key) + .unwrap() = 0; + + self.siftdown(0); + + return Some(element); + } + + pub fn contains_key(&self, key: &K) -> bool { + self.positions.contains_key(key) + } + + pub fn get(&self, key: &K) -> Option<&HeapNode> { + let position = self.positions.get(key); + if position.is_none() { + return None; + } + self.heap.get(position.unwrap().clone()) + } + + pub fn get_mut(&mut self, key: &K) -> Option<&mut HeapNode> { + let position = self.positions.get(key); + if position.is_none() { + return None; + } + self.heap.get_mut(position.unwrap().clone()) + } + + fn siftup(&mut self, mut ix: usize) -> usize { + let newitem: &HeapNode = + self.heap.get(ix).expect("siftup called with invalid index"); + let key = newitem.key; + let priority = newitem.priority; + + while ix > 0 { + let parent_ix = (ix - 1) >> 1; + let parent = self.heap.get(parent_ix).unwrap(); + let parent_key = parent.key; + if priority >= parent.priority { + break; + } + + self.heap.swap(ix, parent_ix); + *self.positions.get_mut(&parent_key).unwrap() = ix; + ix = parent_ix; + } + + *self.positions.get_mut(&key).unwrap() = ix; + + return ix; + } + + fn siftdown(&mut self, mut ix: usize) -> usize { + let end_ix = self.len(); + let newitem = self + .heap + .get(ix) + .expect("siftdown called with invalid index"); + let newitem_priority = newitem.priority; + let newitem_key = newitem.key; + + // Bubble up the smaller child until hitting a leaf. + let mut child_ix = (ix << 1) + 1; + + while child_ix < end_ix { + // Set childpos to index of smaller child. + let right_ix = child_ix + 1; + + if right_ix < end_ix + && self.heap.get(right_ix).unwrap().priority + < self.heap.get(child_ix).unwrap().priority + { + child_ix = right_ix + } + // Move the smaller child up. + let child = self.heap.get(child_ix).unwrap(); + let child_key = child.key; + let child_priority = child.priority; + + if child_priority >= newitem_priority { + break; + } + + self.heap.swap(ix, child_ix); + *self.positions.get_mut(&child_key).unwrap() = ix; + + ix = child_ix; + child_ix = (ix << 1) + 1; + } + + *self.positions.get_mut(&newitem_key).unwrap() = ix; + + return ix; + } +} + +pub struct PriorityQueueIterator { + priority_queue: PriorityQueue, +} + +impl IntoIterator for PriorityQueue { + type Item = HeapNode; + type IntoIter = PriorityQueueIterator; + + fn into_iter(self) -> Self::IntoIter { + PriorityQueueIterator { + priority_queue: self, + } + } +} + +impl Iterator for PriorityQueueIterator { + type Item = HeapNode; + + fn next(&mut self) -> Option { + return self.priority_queue.pop(); + } +} + +#[cfg(test)] +#[path = "./pqueue_test.rs"] +mod pqueue_test; diff --git a/backend-rust/src/pqueue_test.rs b/backend-rust/src/pqueue_test.rs new file mode 100644 index 0000000..7b5b164 --- /dev/null +++ b/backend-rust/src/pqueue_test.rs @@ -0,0 +1,118 @@ +use crate::pqueue::PriorityQueue; + +use super::HeapNode; + +type TestPQueue = PriorityQueue; + +#[test] +fn test_pqueue_starts_empty() { + let pqueue: TestPQueue = PriorityQueue::new(); + assert_eq!(pqueue.len(), 0); +} + +#[test] +fn test_pqueue_with_capacity() { + let pqueue: TestPQueue = PriorityQueue::with_capacity(20); + assert_eq!(pqueue.len(), 0); + assert_eq!(pqueue.capacity(), 20) +} + +#[test] +fn test_pqueue_only_inserts_in_order() { + let mut pqueue: TestPQueue = PriorityQueue::new(); + + pqueue.push(0, 0, 0); + pqueue.push(1, 1, 1); + pqueue.push(2, 2, 2); + pqueue.push(3, 3, 3); + pqueue.push(4, 4, 4); + + let ordered = pqueue.into_iter().map(|x| x.item).collect::>(); + assert_eq!(ordered, vec![0, 1, 2, 3, 4]) +} + +#[test] +fn test_pqueue_inserts_out_of_order() { + let mut pqueue: TestPQueue = PriorityQueue::new(); + + pqueue.push(0, 0, 0); + pqueue.push(3, 3, 3); + pqueue.push(1, 1, 1); + pqueue.push(4, 4, 4); + pqueue.push(2, 2, 2); + + let ordered = pqueue.into_iter().map(|x| x.item).collect::>(); + assert_eq!(ordered, vec![0, 1, 2, 3, 4]) +} + +#[test] +fn test_pqueue_inserts_and_pops() { + let mut pqueue: TestPQueue = PriorityQueue::new(); + + pqueue.push(0, 0, 0); + pqueue.push(3, 3, 3); + pqueue.push(5, 5, 5); + pqueue.pop(); + pqueue.push(4, 4, 4); + pqueue.push(2, 2, 2); + pqueue.pop(); + pqueue.push(9, 9, 9); + pqueue.push(22, 22, 22); + pqueue.push(6, 6, 6); + pqueue.pop(); + pqueue.push(7, 7, 7); + pqueue.push(1, 1, 1); + + let ordered = pqueue.into_iter().map(|x| x.item).collect::>(); + assert_eq!(ordered, vec![1, 4, 5, 6, 7, 9, 22]) +} + +#[test] +fn test_pqueue_update_priority() { + let mut pqueue: TestPQueue = PriorityQueue::new(); + + pqueue.push(0, 0, 0); + pqueue.push(3, 3, 3); + pqueue.push(5, 5, 5); + pqueue.pop(); + pqueue.push(4, 4, 4); + pqueue.push(2, 2, 2); + pqueue.update_priority(2, 8); + pqueue.pop(); + pqueue.push(9, 9, 9); + pqueue.push(22, 22, 22); + pqueue.push(6, 6, 6); + pqueue.update_priority(4, 7); + pqueue.pop(); + pqueue.push(3, 3, 3); + pqueue.push(1, 1, 1); + pqueue.update_priority(22, 2); + + let ordered = pqueue.into_iter().map(|x| x.item).collect::>(); + assert_eq!(ordered, vec![1, 22 /*2 */, 3, 6, 4 /*7 */, 2 /*8 */, 9]) +} + +#[test] +fn test_pqueue_update_priority_if_less() { + let mut pqueue: TestPQueue = PriorityQueue::new(); + + pqueue.push(0, 0, 0); + pqueue.push(3, 3, 3); + pqueue.push(5, 5, 5); + pqueue.pop(); + pqueue.push(4, 4, 4); + pqueue.push(2, 2, 2); + assert!(pqueue.update_priority_if_less(3, 0).is_some()); + pqueue.pop(); + pqueue.push(9, 9, 9); + pqueue.push(22, 22, 22); + pqueue.push(6, 6, 6); + assert!(pqueue.update_priority_if_less(4, 7).is_none()); + pqueue.pop(); + pqueue.push(3, 3, 3); + pqueue.push(0, 0, 0); + assert!(pqueue.update_priority_if_less(22, 1).is_some()); + + let ordered = pqueue.into_iter().map(|x| x.item).collect::>(); + assert_eq!(ordered, vec![0, 22, 3, 4, 5, 6, 9]); +} diff --git a/backend-rust/src/search.rs b/backend-rust/src/search.rs new file mode 100644 index 0000000..0e5fc96 --- /dev/null +++ b/backend-rust/src/search.rs @@ -0,0 +1,684 @@ +use std::{ + cmp::{max, min}, + collections::{HashMap, HashSet}, + iter::zip, + usize, +}; + +use ndarray::{linspace, s}; + +use crate::{ + height_data::{get_height_at_point, get_height_data_around_point, HeightGrid}, + pqueue::PriorityQueue, +}; + +pub type GridIx = (usize, usize); + +#[derive(Clone)] +pub struct Node { + pub height: f32, + pub ix: GridIx, + pub reference: Option, + pub distance: f32, + pub reachable: bool, + pub effective_glide_ratio: f32, +} + +pub type Explored = HashMap; +pub struct SearchState { + pub explored: Explored, + pub queue: PriorityQueue, +} + +pub fn put_node(queue: &mut PriorityQueue, node: Node) { + if queue.contains_key(&node.ix) { + let item = queue.update_priority_if_less(node.ix, node.distance); + if item.is_some() { + item.unwrap().item = node; + } + } else { + let prio = node.distance; + queue.push(node.ix, node, prio); + } +} + +impl SearchState { + pub fn put_node(&mut self, node: Node) { + if self.queue.contains_key(&node.ix) { + let item = self + .queue + .update_priority_if_less(node.ix, node.distance) + .unwrap(); + item.item = node; + } else { + let prio = node.distance; + self.queue.push(node.ix, node, prio); + } + } +} + +struct EffectiveGlide { + speed: f32, + glide_ratio: f32, +} + +pub fn get_effective_glide_ratio( + effective_wind_angle: f32, + wind_speed: f32, + trim_speed: f32, + glide_ratio: f32, +) -> EffectiveGlide { + let side_wind = effective_wind_angle.sin() * wind_speed; + let back_wind = effective_wind_angle.cos() * wind_speed; + + let rs = trim_speed * trim_speed - side_wind * side_wind; + if rs <= 0.0 { + return EffectiveGlide { + speed: 0.0, + glide_ratio: f32::INFINITY, + }; + } + + let rest_speed = rs.sqrt(); + + let effective_speed = rest_speed + back_wind; + if effective_speed <= 0.0 { + return EffectiveGlide { + speed: 0.0, + glide_ratio: f32::INFINITY, + }; + } + + let effective_glide_ratio = glide_ratio / (effective_speed / trim_speed); + + return EffectiveGlide { + speed: effective_speed, + glide_ratio: effective_glide_ratio, + }; +} + +pub struct SearchQuery { + pub glide_ratio: f32, + pub trim_speed: f32, + pub wind_direction: f32, + pub wind_speed: f32, + pub additional_height: f32, + pub safety_margin: f32, + pub start_distance: f32, +} + +pub struct SearchConfig<'a> { + pub grid: &'a HeightGrid, + pub glide_ratio: f32, + pub trim_speed: f32, + pub wind_direction: f32, + pub wind_speed: f32, + pub safety_margin: f32, + pub start_distance: f32, +} + +impl<'a> SearchConfig<'a> { + pub fn get_safety_margin_at_distance(&self, distance: f32) -> f32 { + if distance < self.start_distance { + return 0.0; + } + return self.safety_margin; + } +} + +pub fn get_neighbor_indices(ix: GridIx, height_grid: &HeightGrid) -> Vec { + let mut result = Vec::new(); + + let x = ix.0 as i32; + let y = ix.1 as i32; + for (a, b) in vec![(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)] { + if a >= 0 + && a < (height_grid.heights.shape()[0]) as i32 + && b >= 0 + && b < (height_grid.heights.shape()[1]) as i32 + { + result.push((a as usize, b as usize)); + } + } + + return result; +} + +pub fn l2_distance(a: GridIx, b: GridIx) -> f32 { + let ax = a.0 as f32; + let ay = a.1 as f32; + let bx = b.0 as f32; + let by = b.1 as f32; + + ((ax - bx).powi(2) + (ay - by).powi(2)).sqrt() +} + +pub fn l2_diff(a: GridIx, b: GridIx) -> (i32, i32) { + (a.0 as i32 - b.0 as i32, a.1 as i32 - b.1 as i32) +} + +const PI: f32 = 3.14159265359; +const PI_2: f32 = PI / 2.0; + +pub fn get_effective_glide_ratio_from_to( + config: &SearchConfig, + start: GridIx, + end: GridIx, +) -> EffectiveGlide { + if config.wind_speed == 0.0 { + return EffectiveGlide { + speed: config.trim_speed, + glide_ratio: config.glide_ratio, + }; + } + + let diff = l2_diff(end, start); + let angle = (diff.0 as f32).atan2(diff.1 as f32); + + let effective_wind_angle = (-config.wind_direction + PI_2) - angle; + + return get_effective_glide_ratio( + effective_wind_angle, + config.wind_speed, + config.trim_speed, + config.glide_ratio, + ); +} + +pub fn is_straight(a: (i32, i32)) -> bool { + a.0 == 0 || a.1 == 0 +} + +pub fn is_in_line(point: GridIx, start: GridIx, end: GridIx) -> bool { + if point.0 == start.0 && point.0 == end.0 { + return point.1 >= min(start.1, end.1) && point.1 <= max(start.1, end.1); + } else if point.1 == start.1 && point.1 == end.1 { + return point.0 >= min(start.0, end.0) && point.0 <= max(start.0, end.0); + } + false +} + +fn get_straight_line_ref<'a>(ix: GridIx, neighbor: &'a Node, explored: &'a Explored) -> &'a Node { + let mut n = neighbor; + while n.reference.is_some() { + if is_straight(l2_diff(n.reference.unwrap(), ix)) { + n = explored.get(&n.reference.unwrap()).unwrap() + } else { + break; + } + } + return n; +} + +pub fn update_one_neighbor( + neighbor: &Node, + ix: GridIx, + config: &SearchConfig, + explored: &Explored, + queue: &mut PriorityQueue, + do_intersection_check_opt: Option, +) { + let do_intersection_check = do_intersection_check_opt.unwrap_or(false); + + if !neighbor.reachable { + return; + } + + let mut reference = neighbor; + if neighbor.reference.is_some() + && (config.wind_speed >= config.trim_speed || do_intersection_check) + { + reference = explored.get(&neighbor.reference.unwrap()).unwrap(); + + if queue.contains_key(&ix) { + let a = &queue.get(&ix).unwrap().item; + if a.reference.is_some() && a.reference.unwrap() == reference.ix { + return; + } + } + + if is_line_intersecting(reference, ix, config) { + reference = neighbor; + } + } + + let effective_glide = get_effective_glide_ratio_from_to(config, ix, reference.ix); + let distance = l2_distance(ix, reference.ix) * config.grid.cell_size; + let height = reference.height - distance * effective_glide.glide_ratio; + + if f32::is_infinite(effective_glide.glide_ratio) { + return; + } + + let total_distance = distance + reference.distance; + + let reachable = config.grid.heights[[ix.0, ix.1]] as f32 + + config.get_safety_margin_at_distance(total_distance) + < height; + + put_node( + queue, + Node { + height: height, + ix: ix, + reference: Some(get_straight_line_ref(ix, reference, &explored).ix), + distance: total_distance, + reachable: reachable, + effective_glide_ratio: effective_glide.glide_ratio, + }, + ) +} + +pub fn update_two_with_different_references( + neighbor_1: &Node, + neighbor_2: &Node, + ix: GridIx, + config: &SearchConfig, + explored: &Explored, + queue: &mut PriorityQueue, +) { + update_one_neighbor(neighbor_1, ix, config, explored, queue, Some(true)); + update_one_neighbor(neighbor_2, ix, config, explored, queue, Some(true)); +} + +pub fn update_two_neighbors( + neighbor_1: &Node, + neighbor_2: &Node, + ix: GridIx, + config: &SearchConfig, + explored: &Explored, + queue: &mut PriorityQueue, +) { + if neighbor_1.reachable && neighbor_2.reachable { + let ref_path_intersection = ref_paths_intersection( + neighbor_1.ix, + neighbor_1.reference, + neighbor_2.ix, + neighbor_2.reference, + ); + if ref_path_intersection.is_some() { + if queue.contains_key(&ix) + && queue.get(&ix).unwrap().item.reference == ref_path_intersection + { + return; + } + + let distance = l2_distance(ix, ref_path_intersection.unwrap()) * config.grid.cell_size; + + let effective_glide = + get_effective_glide_ratio_from_to(config, ix, ref_path_intersection.unwrap()); + + if f32::is_infinite(effective_glide.glide_ratio) { + return; + } + + let height = explored[&ref_path_intersection.unwrap()].height + - distance * effective_glide.glide_ratio; + + let total_distance = distance + explored[&ref_path_intersection.unwrap()].distance; + + let reachable = config.grid.heights[ix] as f32 + + config.get_safety_margin_at_distance(total_distance) + < height; + + put_node( + queue, + Node { + height: height, + ix: ix, + reference: ref_path_intersection, + distance: total_distance, + reachable: reachable, + effective_glide_ratio: effective_glide.glide_ratio, + }, + ) + } else { + update_two_with_different_references( + neighbor_1, neighbor_2, ix, config, explored, queue, + ); + } + } else if neighbor_1.reachable { + update_one_neighbor(neighbor_1, ix, config, explored, queue, None); + } else if neighbor_2.reachable { + update_one_neighbor(neighbor_2, ix, config, explored, queue, None); + } +} + +pub fn update_three_neighbors( + explored_neighbors: Vec, + ix: GridIx, + config: &SearchConfig, + explored: &Explored, + queue: &mut PriorityQueue, +) { + let mut reachable = Vec::from_iter( + explored_neighbors + .iter() + .filter(|x| explored[x].reachable) + .map(|x| explored.get(x).unwrap()), + ); + + if reachable.len() == 0 { + return; + } else if reachable.len() == 1 { + update_one_neighbor(&reachable[0], ix, config, explored, queue, None); + } else if reachable.len() == 2 { + update_two_neighbors(&reachable[0], &reachable[1], ix, config, explored, queue); + } else if reachable.len() == 3 { + let reference_set = + HashSet::>::from_iter(reachable.iter().map(|x| x.reference)); + if reference_set.len() == 3 { + reachable.sort_by(|x, y| x.distance.partial_cmp(&y.distance).unwrap()); // TODO: Sort needed + + update_one_neighbor(&reachable[0], ix, config, explored, queue, None); + update_one_neighbor(&reachable[1], ix, config, explored, queue, None); + update_one_neighbor(&reachable[2], ix, config, explored, queue, None); + } else if reference_set.len() == 2 { + if reachable[0].reference == reachable[1].reference { + update_two_neighbors(&reachable[0], &reachable[1], ix, config, explored, queue); + update_one_neighbor(&reachable[2], ix, config, explored, queue, None); + } else if reachable[0].reference == reachable[2].reference { + update_two_neighbors(&reachable[0], &reachable[2], ix, config, explored, queue); + update_one_neighbor(&reachable[1], ix, config, explored, queue, None); + } else { + update_two_neighbors(&reachable[1], &reachable[2], ix, config, explored, queue); + update_one_neighbor(&reachable[0], ix, config, explored, queue, None); + } + } + } +} + +pub fn update_four_neighbors( + explored_neighbors: Vec, + ix: GridIx, + config: &SearchConfig, + explored: &Explored, + queue: &mut PriorityQueue, +) { + let mut reachable = Vec::from_iter( + explored_neighbors + .iter() + .filter(|x| explored[x].reachable) + .map(|x| explored.get(x).unwrap()), + ); + if reachable.len() == 0 { + put_node( + queue, + Node { + height: 0.0, + ix: ix, + reference: None, + distance: 0.0, + reachable: false, + effective_glide_ratio: 0.0, + }, + ); + } else if reachable.len() < 4 { + update_three_neighbors(explored_neighbors, ix, config, explored, queue); + } else if reachable.len() == 4 { + let reference_set = + HashSet::>::from_iter(reachable.iter().map(|x| x.reference)); + if reference_set.len() == 4 { + reachable.sort_by(|x, y| x.distance.partial_cmp(&y.distance).unwrap()); + update_one_neighbor(reachable[0], ix, config, explored, queue, None); + } + } +} + +pub fn update_node(ix: GridIx, config: &SearchConfig, state: &mut SearchState) { + let neighbors = get_neighbor_indices(ix, &config.grid); + let explored_neighbors: Vec = neighbors + .into_iter() + .filter(|x| state.explored.contains_key(x)) + .collect(); + + if explored_neighbors.len() == 1 { + let neighbor = &state.explored[&explored_neighbors[0]]; + + update_one_neighbor( + neighbor, + ix, + config, + &state.explored, + &mut state.queue, + None, + ); + } else if explored_neighbors.len() == 2 { + let neighbor_1 = &state.explored[&explored_neighbors[0]]; + let neighbor_2 = &state.explored[&explored_neighbors[1]]; + + update_two_neighbors( + neighbor_1, + neighbor_2, + ix, + config, + &state.explored, + &mut state.queue, + ) + } else if explored_neighbors.len() == 3 { + update_three_neighbors( + explored_neighbors, + ix, + config, + &state.explored, + &mut state.queue, + ) + } else if explored_neighbors.len() == 4 { + update_four_neighbors( + explored_neighbors, + ix, + config, + &state.explored, + &mut state.queue, + ) + } +} + +pub fn search(start: GridIx, height: f32, config: &SearchConfig) -> SearchState { + let mut state = SearchState { + explored: HashMap::new(), + queue: PriorityQueue::new(), + }; + state.put_node(Node { + height: height, + ix: start, + reference: None, + distance: 0.0, + reachable: true, + effective_glide_ratio: config.glide_ratio, + }); + + while state.queue.len() > 0 { + let first = state.queue.pop().unwrap(); + state.explored.insert(first.key, first.item); + + let neighbors = get_neighbor_indices(first.key, &config.grid); + for neighbor in neighbors { + if !state.explored.contains_key(&neighbor) { + update_node(neighbor, &config, &mut state); + } + } + } + + return state; +} + +pub fn ref_paths_intersection( + ix_1: GridIx, + ref_1: Option, + ix_2: GridIx, + ref_2: Option, +) -> Option { + if ref_1 == ref_2 { + return ref_1; + } + if ref_1.is_none() || ref_2.is_none() { + return None; + } + + if is_straight(l2_diff(ix_1, ref_1.unwrap())) { + if is_in_line(ref_2.unwrap(), ix_1, ref_1.unwrap()) { + return ref_2; + } + } + if is_straight(l2_diff(ix_2, ref_2.unwrap())) { + if is_in_line(ref_1.unwrap(), ix_2, ref_2.unwrap()) { + return ref_1; + } + } + + return None; +} + +pub fn usize_f32(x: usize) -> f32 { + f32::from(x as u16) +} + +pub fn f32_usize(x: f32) -> usize { + usize::from(x as u16) +} + +pub fn is_line_intersecting(to: &Node, ix: GridIx, config: &SearchConfig) -> bool { + let effective_glide = get_effective_glide_ratio_from_to(config, ix, to.ix); + if f32::is_infinite(effective_glide.glide_ratio) { + return true; + } + + let length = l2_distance(to.ix, ix); + + let i_len = length.ceil() as usize; + + let x_indices = linspace(usize_f32(to.ix.0), usize_f32(ix.0), i_len); + let y_indices = linspace(usize_f32(to.ix.1), usize_f32(ix.1), i_len); + + /*let safety_margins = config.safety_margin; + if to.distance < config.start_distance: + safety_margins = np.ones(i_len)*config.safety_margin + n_no_safety_margin = math.ceil(i_len*((config.start_distance - to.distance)/length)) + safety_margins[:n_no_safety_margin] = 0*/ + // TODO: Safety margin + + let real_heights = linspace( + to.height, + to.height - length * config.grid.cell_size * effective_glide.glide_ratio, + i_len, + ); + + //TODO: Use brennans line algorithm + for ((x_i, y_i), real_height) in zip(zip(x_indices, y_indices), real_heights) { + if real_height < config.grid.heights[[f32_usize(x_i), f32_usize(y_i)]] as f32 { + return true; + } + } + return false; +} + +fn reindex_node(node: Node, lats: (usize, usize), lons: (usize, usize)) -> Node { + // TODO: Update instead of copy? + Node { + ix: (node.ix.0 - lats.0, node.ix.1 - lons.0), + reference: match node.reference { + Some((x, y)) => Some((x - lats.0, y - lons.0)), + None => None, + }, + height: node.height, + distance: node.distance, + reachable: node.reachable, + effective_glide_ratio: node.effective_glide_ratio, + } +} + +pub fn reindex(explored: Explored, grid: &HeightGrid) -> (Explored, HeightGrid) { + let mut lat_min = usize::MAX; + let mut lat_max = usize::MIN; + let mut lon_min = usize::MAX; + let mut lon_max = usize::MIN; + for node in explored.values() { + if node.reachable { + lat_min = min(lat_min, node.ix.0); + lat_max = max(lat_max, node.ix.0); + lon_min = min(lon_min, node.ix.1); + lon_max = max(lon_max, node.ix.1); + } + } + + let new_explored_iter = explored.into_iter().filter(|x| x.1.reachable).map(|x| { + ( + (x.0 .0 - lat_min, x.0 .1 - lon_min), + reindex_node(x.1, (lat_min, lat_max), (lon_min, lon_max)), + ) + }); + + let new_explored = HashMap::from_iter(new_explored_iter); + + let old_shape = grid.heights.shape(); + + let new_grid = HeightGrid { + heights: grid + .heights + .slice(s![lat_min..(lat_max + 1), lon_min..(lon_max + 1)]) + .to_owned(), + cell_size: grid.cell_size, + latitudes: ( + grid.latitudes.0 + + (grid.latitudes.1 - grid.latitudes.0) / (old_shape[0] as f32) * (lat_min as f32), + grid.latitudes.0 + + (grid.latitudes.1 - grid.latitudes.0) / (old_shape[0] as f32) * (lat_max as f32), + ), + longitudes: ( + grid.longitudes.0 + + (grid.longitudes.1 - grid.longitudes.0) / (old_shape[1] as f32) + * (lon_min as f32), + grid.longitudes.0 + + (grid.longitudes.1 - grid.longitudes.0) / (old_shape[1] as f32) + * (lon_max as f32), + ), + }; + + return (new_explored, new_grid); +} + +pub fn search_from_point( + latitude: f32, + longitude: f32, + cell_size: f32, + query: SearchQuery, +) -> (Explored, HeightGrid) { + let height = get_height_at_point(latitude, longitude) as f32 + query.additional_height; + + let max_glide_ratio = + query.glide_ratio / ((query.wind_speed + query.trim_speed) / (query.trim_speed)); + + let max_distance = height / max_glide_ratio; + + let mut grid = get_height_data_around_point(latitude, longitude, Some(max_distance + 1.0)); + + let mut cell_s = cell_size; + if cell_size < grid.cell_size { + cell_s = grid.cell_size; + } + + grid = grid.scale(grid.cell_size / cell_s); + + let start_ix = (grid.heights.shape()[0] / 2, grid.heights.shape()[0] / 2); + + let config = SearchConfig { + grid: &grid, + glide_ratio: query.glide_ratio, + trim_speed: query.trim_speed, + wind_direction: query.wind_direction, + wind_speed: query.wind_speed, + safety_margin: query.safety_margin, + start_distance: query.start_distance, + }; + + let state = search(start_ix, height, &config); + + let (explored, new_grid) = reindex(state.explored, &grid); + + return (explored, new_grid); +} + +#[cfg(test)] +#[path = "./search_test.rs"] +mod search_test; diff --git a/backend-rust/src/search_test.rs b/backend-rust/src/search_test.rs new file mode 100644 index 0000000..1c217c7 --- /dev/null +++ b/backend-rust/src/search_test.rs @@ -0,0 +1,20 @@ +use super::{search_from_point, SearchQuery}; + +#[test] +fn test_get_height_data_around_point() { + let query = SearchQuery { + glide_ratio: 0.5, + trim_speed: 38.0, + wind_direction: 0.0, + wind_speed: 0.0, + additional_height: 10.0, + safety_margin: 0.0, + start_distance: 0.0, + }; + let result = search_from_point(47.695412103118734, 11.868152618408203, 200.0, query); + + let len_explored = result.0.len(); + println!("Explored {len_explored}"); + + assert!(len_explored > 50); +} diff --git a/backend/src/data_analysis/pqueue.py b/backend/src/data_analysis/pqueue.py index ae10d2a..d5a4bc8 100644 --- a/backend/src/data_analysis/pqueue.py +++ b/backend/src/data_analysis/pqueue.py @@ -1,19 +1,19 @@ import collections -from typing import Generic, List, TypeVar, NamedTuple +from typing import Generic, TypeVar, NamedTuple -T = TypeVar("T") -U = TypeVar("U") +V = TypeVar("V") +K = TypeVar("K") -class HeapNode(NamedTuple, Generic[T, U]): +class HeapNode(NamedTuple, Generic[V, K]): priority: float - item: T - key: U + item: V + key: K -class PriorityQueue(Generic[T, U]): - heap: list[HeapNode[T, U]] - positions: dict[U, int] +class PriorityQueue(Generic[V, K]): + heap: list[HeapNode[V, K]] + positions: dict[K, int] def __init__(self): self.heap = [] @@ -22,13 +22,13 @@ def __init__(self): def __len__(self): return len(self.heap) - def put(self, item: T, key: U, priority: float): + def put(self, item: V, key: K, priority: float): self.heap.append(HeapNode(priority, item, key)) self.positions[key] = len(self.heap) - 1 _siftup(self.heap, len(self.heap) - 1, self.positions) - def update(self, key: U, item: T, priority: float): + def update(self, key: K, item: V, priority: float): position = self.positions[key] old_node = self.heap[position] @@ -39,7 +39,7 @@ def update(self, key: U, item: T, priority: float): else: _siftdown(self.heap, position, self.positions) - def update_if_less(self, item: T, key: U, priority: float): + def update_if_less(self, item: V, key: K, priority: float): if self.contains(key): old_item = self.get(key) if old_item.priority > priority: @@ -64,10 +64,10 @@ def pop(self) -> HeapNode: return head - def contains(self, key: U): + def contains(self, key: K): return key in self.positions - def get(self, key: U) -> HeapNode: + def get(self, key: K) -> HeapNode: return self.heap[self.positions[key]] def all(self): @@ -78,7 +78,7 @@ def all(self): return x -def _siftup(heap: list[HeapNode[T, U]], pos: int, positions: dict[U, int]): +def _siftup(heap: list[HeapNode[V, K]], pos: int, positions: dict[K, int]): newitem = heap[pos] key = newitem.key # Follow the path to the root, moving parents down until finding a place @@ -97,7 +97,7 @@ def _siftup(heap: list[HeapNode[T, U]], pos: int, positions: dict[U, int]): positions[key] = pos -def _siftdown(heap: list[HeapNode[T, U]], pos: int, positions: dict[U, int]): +def _siftdown(heap: list[HeapNode[V, K]], pos: int, positions: dict[K, int]): endpos = len(heap) newitem = heap[pos] # Bubble up the smaller child until hitting a leaf. @@ -123,9 +123,9 @@ def _siftdown(heap: list[HeapNode[T, U]], pos: int, positions: dict[U, int]): positions[newitem.key] = pos -class FakePriorityQueue(Generic[T, U]): - keys: collections.deque[U] - items: dict[U, (float, T)] +class FakePriorityQueue(Generic[V, K]): + keys: collections.deque[K] + items: dict[K, (float, V)] def __init__(self): self.keys = collections.deque() @@ -134,14 +134,14 @@ def __init__(self): def __len__(self): return len(self.items) - def put(self, item: T, key: U, priority: float): + def put(self, item: V, key: K, priority: float): self.keys.append(key) self.items[key] = (priority, item) - def update(self, key: U, item: T, priority: float): + def update(self, key: K, item: V, priority: float): self.items[key] = (priority, item) - def update_if_less(self, item: T, key: U, priority: float): + def update_if_less(self, item: V, key: K, priority: float): if self.contains(key): old_item = self.get(key) if old_item.priority > priority: @@ -157,10 +157,10 @@ def pop(self) -> HeapNode: return HeapNode(priority, item, key) - def contains(self, key: U): + def contains(self, key: K): return key in self.items - def get(self, key: U) -> HeapNode: + def get(self, key: K) -> HeapNode: priority, item = self.items[key] return HeapNode(priority, item, key) diff --git a/backend/src/data_analysis/search.py b/backend/src/data_analysis/search.py index b887fe8..7ff87b2 100644 --- a/backend/src/data_analysis/search.py +++ b/backend/src/data_analysis/search.py @@ -232,8 +232,10 @@ def is_line_intersecting(to: Node, ix: GridIndex, config: SearchConfig): safety_margins = config.safety_margin if to.distance < config.start_distance: - safety_margins = np.ones(i_len)*config.safety_margin - n_no_safety_margin = math.ceil(i_len*((config.start_distance - to.distance)/length)) + safety_margins = np.ones(i_len) * config.safety_margin + n_no_safety_margin = math.ceil( + i_len * ((config.start_distance - to.distance) / length) + ) safety_margins[:n_no_safety_margin] = 0 heights = config.grid.heights[x.astype(int), y.astype(int)] @@ -430,10 +432,6 @@ def search(start: GridIndex, height: float, config: SearchConfig): i = 0 while len(state.queue) > 0: - if i % 500 == 0: - _logger.info( - "Explored %d, queue size %d", len(state.explored), len(state.queue) - ) first = state.queue.pop() state.explored[first.key] = first.item @@ -462,9 +460,11 @@ def reindex(state: SearchState, grid: HeightGrid): (grid_ix[0] - mins[0], grid_ix[1] - mins[1]): Node( node.height, [node.ix[0] - mins[0], node.ix[1] - mins[1]], - [node.ref[0] - mins[0], node.ref[1] - mins[1]] - if node.ref is not None - else None, + ( + [node.ref[0] - mins[0], node.ref[1] - mins[1]] + if node.ref is not None + else None + ), node.distance, node.reachable, node.effective_glide_ratio, @@ -537,7 +537,7 @@ def search_from_point( query.wind_direction, query.wind_speed, query.safety_margin, - query.start_distance + query.start_distance, ), ) diff --git a/backend/src/server.py b/backend/src/server.py index 5397db3..72ce5d3 100644 --- a/backend/src/server.py +++ b/backend/src/server.py @@ -112,7 +112,7 @@ def get_flight_cone( "distance": node.distance, "lat": lats[grid_ix[0]], "lon": lons[grid_ix[1]], - "ref": node.ref, + "reference": node.ref, "size": grid.cell_size, "agl": node.height - grid.heights[grid_ix[0], grid_ix[1]], "gl": grid.heights[grid_ix[0], grid_ix[1]], diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 92b6563..a2cabfc 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -20,7 +20,7 @@ interface GridTile { distance: number; lat: number; lon: number; - ref: number[]; + reference: number[]; agl: number; gl: number; } @@ -166,9 +166,9 @@ function Grid({ grid }: { grid: GridState }) { const node = grid.grid[latIx][lonIx]; let current = node; let path = []; - while (current.ref !== null) { + while (current.reference !== null) { path.push(new LatLng(current.lat, current.lon, current.height)); - current = grid.grid[current.ref[0]][current.ref[1]]; + current = grid.grid[current.reference[0]][current.reference[1]]; } path.push(new LatLng(current.lat, current.lon, current.height)); setPath(path); @@ -239,6 +239,8 @@ async function doSearchFromLocation(setImageState: (state: ImageState | undefine let response = await fetch(url); let cone: ConeSearchResponse = await response.json(); + console.log(cone.nodes.length) + const grid = setupGrid(cone) setGrid({ loading: false, @@ -247,6 +249,8 @@ async function doSearchFromLocation(setImageState: (state: ImageState | undefine startPosition: latLng }); + console.log(grid); + const searchParams = getSearchParams(latLng.lat, latLng.lng, settings).toString(); let heightAglUrl = new URL(window.location.origin + "/agl_image"); heightAglUrl.search = searchParams;