#!/bin/sh
# Copyright (C) 2026 David Nichols
# SPDX-License-Identifier: MIT
set -eu
unset QORE_MODULE_DIR QORE_MODULE_DIR_ONLY QORE_INCLUDE_DIR LD_LIBRARY_PATH LD_PRELOAD
cd "$AUTOPKGTEST_TMP"
cat > proj-smoke.q <<'EOF'
%modern
%requires proj
%requires ProjGeos
Qore::PROJ::ProjTransformer transformer("EPSG:4326", "EPSG:25832");
Qore::GEOS::GEOSGeometry point = parse_wkt("POINT (11.5754 48.1371)");
Qore::GEOS::GEOSGeometry projected = ProjGeos::transform_geometry(transformer, point);
hash<auto> coord = projected.getCoordinate();
if (abs(coord.x - 691596.710) > 1.0 || abs(coord.y - 5334746.441) > 1.0) {
    throw "PACKAGE-TEST-ERROR", "Installed projection returned incorrect coordinates";
}
hash<auto> restored = ProjGeos::transform_geometry_inverse(transformer, projected).getCoordinate();
if (abs(restored.x - 11.5754) > 1e-9 || abs(restored.y - 48.1371) > 1e-9) {
    throw "PACKAGE-TEST-ERROR", "Installed inverse projection did not round trip";
}
EOF
/usr/bin/qcc -o proj-smoke proj-smoke.q
./proj-smoke
