Skip to content

Commit 4ae1df0

Browse files
committed
feat: switch to multithreaded SPLAT!
1 parent 5463433 commit 4ae1df0

File tree

9 files changed

+48
-293
lines changed

9 files changed

+48
-293
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
docker-compose.yml
2+
Dockerfile
3+
.dockerignore
4+
.tile_cache/
5+
splat/build/
6+
splat/utils/build
7+
node_modules/

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "splat"]
22
path = splat
3-
url = https://github.com/jmcmellen/splat
3+
url = https://github.com/hoche/splat

Dockerfile

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
1-
FROM python:3.11-slim
1+
FROM debian:stable-slim AS splat
2+
RUN apt update && apt install -y cmake make clang zlib1g-dev libbz2-dev git && rm -rf /var/lib/apt/lists/*
23

4+
COPY splat/ /splat/
5+
6+
WORKDIR /splat/build/
7+
RUN cmake .. && make
8+
RUN ln -sf splat splat-hd
9+
10+
WORKDIR /splat/utils/build/
11+
RUN cmake .. && make
12+
13+
FROM node:20-slim AS ui
14+
ENV PNPM_HOME="/pnpm"
15+
ENV PATH="$PNPM_HOME:$PATH"
16+
RUN corepack enable
17+
18+
COPY package.json pnpm-lock.yaml /app/
19+
WORKDIR /app
20+
21+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
22+
COPY index.html tsconfig*json vite.config.ts /app/
23+
COPY src/ /app/src
24+
COPY public/ /app/public
25+
26+
RUN pnpm run build
27+
28+
FROM python:3.12-slim
329
ENV HOME="/root"
430
ENV TERM=xterm
531

6-
# Install system dependencies first (before Python dependencies)
7-
RUN apt-get update && apt-get install -y \
8-
build-essential \
9-
libbz2-dev \
10-
gdal-bin \
11-
libgdal-dev \
12-
&& apt-get clean
32+
RUN apt update && apt install -y libexpat-dev && rm -rf /var/lib/apt/lists/*
1333

1434
# Set the working directory
1535
WORKDIR /app
1636

1737
# Copy requirements first to leverage Docker caching
18-
COPY requirements.txt /app/
38+
COPY requirements.txt .
1939

2040
# Install Python dependencies
2141
RUN pip install --no-cache-dir -r requirements.txt
2242

2343
# Copy the rest of the application files
24-
COPY . .
44+
COPY app/ app/
2545

26-
# Change to SPLAT directory and set permissions
27-
WORKDIR /app/splat
28-
RUN chmod +x build && chmod +x configure && chmod +x install
46+
# Copy UI build from the previous stage
47+
COPY --from=ui /app/app/ui/ app/ui/
2948

30-
# Modify build script and configure SPLAT
31-
RUN sed -i.bak 's/-march=\$cpu/-march=native/g' build && \
32-
printf "8\n4\n" | ./configure && \
33-
./install splat
34-
# RUN cp ./splat /app/splat
49+
# Copy SPLAT build from the previous stage
50+
COPY --from=splat /splat/build/splat /splat/build/splat-hd /splat/utils/build/srtm2sdf* splat/
3551

36-
# SPLAT utils including srtm2sdf
37-
WORKDIR /app/splat/utils
38-
RUN chmod +x build
39-
RUN ./build all && cp srtm2sdf /app && cp srtm2sdf-hd /app
40-
RUN cp -a ./ /app/splat
41-
42-
WORKDIR /app
43-
RUN chmod +x /app/splat/splat
44-
RUN chmod +x /app/splat/srtm2sdf
45-
RUN chmod +x /app/splat/citydecoder
46-
RUN chmod +x /app/splat/bearing
47-
RUN chmod +x /app/splat/fontdata
48-
RUN chmod +x /app/splat/usgs2sdf
49-
RUN ls -alh
5052
# Expose the application port
51-
EXPOSE 8080
53+
EXPOSE 8080

app/services/splat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def coverage_prediction(self, request: CoveragePredictionRequest) -> bytes:
197197
"tx.qth",
198198
"-L",
199199
str(request.rx_height),
200-
"-metric",
201200
"-R",
202201
str(request.radius / 1000.0),
203202
"-sc",
@@ -206,11 +205,12 @@ def coverage_prediction(self, request: CoveragePredictionRequest) -> bytes:
206205
"-ngs",
207206
"-N",
208207
"-o",
209-
"output.ppm",
208+
"output",
210209
"-dbm",
211210
"-db",
212211
str(request.signal_threshold),
213212
"-kml",
213+
"-ppm",
214214
"-olditm"
215215
] # flag "olditm" uses the standard ITM model instead of ITWOM, which has produced unrealistic results.
216216
logger.debug(f"Executing SPLAT! command: {' '.join(splat_command)}")
@@ -348,7 +348,7 @@ def _create_splat_qth(name: str, latitude: float, longitude: float, elevation: f
348348
f"{name}\n"
349349
f"{latitude:.6f}\n"
350350
f"{abs(longitude) if longitude < 0 else 360 - longitude:.6f}\n" # SPLAT! expects west longitude as a positive number.
351-
f"{elevation:.2f}\n"
351+
f"{elevation:.2f}m\n"
352352
)
353353
logger.debug(f"Generated .qth file contents:\n{contents}")
354354
return contents.encode('utf-8') # Return as bytes
@@ -653,7 +653,7 @@ def _hgt_filename_to_sdf_filename(hgt_filename: str, high_resolution: bool = Fal
653653
min_lon = int(hgt_filename[4:7]) - (-1 if hgt_filename[3] == 'E' else 1) # fix off-by-one error in eastern hemisphere
654654
min_lon = 360 - min_lon if hgt_filename[3] == 'E' else min_lon
655655
max_lon = 0 if min_lon == 359 else min_lon + 1
656-
return f"{lat}:{lat + 1}:{min_lon}:{max_lon}{'-hd.sdf' if high_resolution else '.sdf'}"
656+
return f"{lat}_{lat + 1}_{min_lon}_{max_lon}{'-hd.sdf' if high_resolution else '.sdf'}"
657657

658658
def _convert_hgt_to_sdf(self, tile: bytes, tile_name: str, high_resolution: bool = False) -> bytes:
659659
"""

app/ui/assets/index-C1ENZROj.js

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)