Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
docker-compose.yml
Dockerfile
.dockerignore
.tile_cache/
splat/build/
splat/utils/build
node_modules/
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "splat"]
path = splat
url = https://github.com/jmcmellen/splat
url = https://github.com/hoche/splat
68 changes: 35 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
FROM python:3.11-slim
FROM debian:stable-slim AS splat
RUN apt update && apt install -y cmake make clang zlib1g-dev libbz2-dev git && rm -rf /var/lib/apt/lists/*

COPY splat/ /splat/

WORKDIR /splat/build/
RUN cmake .. && make
RUN ln -sf splat splat-hd

WORKDIR /splat/utils/build/
RUN cmake .. && make

FROM node:20-slim AS ui
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

COPY package.json pnpm-lock.yaml /app/
WORKDIR /app

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY index.html tsconfig*json vite.config.ts /app/
COPY src/ /app/src
COPY public/ /app/public

RUN pnpm run build

FROM python:3.12-slim
ENV HOME="/root"
ENV TERM=xterm

# Install system dependencies first (before Python dependencies)
RUN apt-get update && apt-get install -y \
build-essential \
libbz2-dev \
gdal-bin \
libgdal-dev \
&& apt-get clean
RUN apt update && apt install -y libexpat-dev && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy requirements first to leverage Docker caching
COPY requirements.txt /app/
COPY requirements.txt .

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

# Copy the rest of the application files
COPY . .
COPY app/ app/

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

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

# SPLAT utils including srtm2sdf
WORKDIR /app/splat/utils
RUN chmod +x build
RUN ./build all && cp srtm2sdf /app && cp srtm2sdf-hd /app
RUN cp -a ./ /app/splat

WORKDIR /app
RUN chmod +x /app/splat/splat
RUN chmod +x /app/splat/srtm2sdf
RUN chmod +x /app/splat/citydecoder
RUN chmod +x /app/splat/bearing
RUN chmod +x /app/splat/fontdata
RUN chmod +x /app/splat/usgs2sdf
RUN ls -alh
# Expose the application port
EXPOSE 8080
EXPOSE 8080
8 changes: 4 additions & 4 deletions app/services/splat.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ def coverage_prediction(self, request: CoveragePredictionRequest) -> bytes:
"tx.qth",
"-L",
str(request.rx_height),
"-metric",
"-R",
str(request.radius / 1000.0),
"-sc",
Expand All @@ -206,11 +205,12 @@ def coverage_prediction(self, request: CoveragePredictionRequest) -> bytes:
"-ngs",
"-N",
"-o",
"output.ppm",
"output",
"-dbm",
"-db",
str(request.signal_threshold),
"-kml",
"-ppm",
"-olditm"
] # flag "olditm" uses the standard ITM model instead of ITWOM, which has produced unrealistic results.
logger.debug(f"Executing SPLAT! command: {' '.join(splat_command)}")
Expand Down Expand Up @@ -348,7 +348,7 @@ def _create_splat_qth(name: str, latitude: float, longitude: float, elevation: f
f"{name}\n"
f"{latitude:.6f}\n"
f"{abs(longitude) if longitude < 0 else 360 - longitude:.6f}\n" # SPLAT! expects west longitude as a positive number.
f"{elevation:.2f}\n"
f"{elevation:.2f}m\n"
)
logger.debug(f"Generated .qth file contents:\n{contents}")
return contents.encode('utf-8') # Return as bytes
Expand Down Expand Up @@ -653,7 +653,7 @@ def _hgt_filename_to_sdf_filename(hgt_filename: str, high_resolution: bool = Fal
min_lon = int(hgt_filename[4:7]) - (-1 if hgt_filename[3] == 'E' else 1) # fix off-by-one error in eastern hemisphere
min_lon = 360 - min_lon if hgt_filename[3] == 'E' else min_lon
max_lon = 0 if min_lon == 359 else min_lon + 1
return f"{lat}:{lat + 1}:{min_lon}:{max_lon}{'-hd.sdf' if high_resolution else '.sdf'}"
return f"{lat}_{lat + 1}_{min_lon}_{max_lon}{'-hd.sdf' if high_resolution else '.sdf'}"

def _convert_hgt_to_sdf(self, tile: bytes, tile_name: str, high_resolution: bool = False) -> bytes:
"""
Expand Down
234 changes: 0 additions & 234 deletions app/ui/assets/index-C1ENZROj.js

This file was deleted.

Loading