Skip to content

Commit 3a23ce4

Browse files
committed
Add GeosOpEngine
1 parent a7c0d81 commit 3a23ce4

File tree

7 files changed

+490
-16
lines changed

7 files changed

+490
-16
lines changed

.docker/.env.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ POSTGIS_VERSION=3
88

99
# Paths.
1010
SOURCES_PATH=/application
11+
GEOSOP_PATH=/usr/local/bin/geosop
1112

1213
# Postgres credentials.
1314
POSTGRES_HOST=postgres

.docker/compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ services:
1717
- MYSQL_PORT
1818
- MYSQL_USER
1919
- MYSQL_PASSWORD
20+
- GEOSOP_PATH
2021
working_dir: ${SOURCES_PATH}
2122
cap_drop:
2223
- ALL

.docker/php/Dockerfile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
ARG PHP_VERSION
22
FROM php:${PHP_VERSION}-cli
33

4-
RUN apt update && apt install --yes git libpq-dev libgeos-dev libsqlite3-mod-spatialite
4+
SHELL ["/bin/sh", "-e", "-c"]
5+
6+
RUN apt update && apt install --yes git cmake libpq-dev libgeos-dev libsqlite3-mod-spatialite
57
RUN docker-php-ext-install pdo pdo_pgsql pdo_mysql
68

9+
# SQLite3 configuration
710
RUN echo "[sqlite3]\nsqlite3.extension_dir = /usr/lib/x86_64-linux-gnu"> /usr/local/etc/php/conf.d/sqlite3.ini
811

12+
# GEOS PHP extension
913
RUN <<EOF
1014
git clone https://git.osgeo.org/gitea/geos/php-geos.git
1115
cd php-geos
@@ -14,8 +18,23 @@ cd php-geos
1418
make
1519
mv modules/geos.so $(php -r "echo ini_get('extension_dir');")
1620
echo "extension=geos.so" > /usr/local/etc/php/conf.d/geos.ini
21+
cd ..
22+
rm -rf php-geos
23+
EOF
24+
25+
# geosop CLI
26+
RUN <<EOF
27+
git clone --depth 1 --branch 3.13.1 https://github.com/libgeos/geos.git
28+
mkdir geos/build
29+
cd geos/build
30+
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS="-static -static-libstdc++ -static-libgcc"
31+
cmake --build . -- -j$(nproc)
32+
make install
33+
cd ../..
34+
rm -rf geos
1735
EOF
1836

37+
# Composer
1938
COPY --from=composer /usr/bin/composer /usr/bin/composer
2039

2140
CMD sleep infinity

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,49 @@ jobs:
269269
run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
270270
env:
271271
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
272+
273+
phpunit-geosop:
274+
name: PHPUnit geosop
275+
runs-on: ubuntu-22.04
276+
277+
strategy:
278+
matrix:
279+
php-version:
280+
- "8.1"
281+
282+
steps:
283+
- name: Checkout
284+
uses: actions/checkout@v4
285+
286+
- name: Setup PHP
287+
uses: shivammathur/setup-php@v2
288+
with:
289+
php-version: ${{ matrix.php-version }}
290+
extensions: geos
291+
coverage: xdebug
292+
293+
- name: Install composer dependencies
294+
uses: ramsey/composer-install@v3
295+
296+
- name: Install geosop
297+
run: |
298+
sudo apt update
299+
sudo apt install geos-bin
300+
301+
- name: Test geosop
302+
run: |
303+
geosop
304+
geosop -a "MULTILINESTRING ((1 1, 2 2))" length
305+
306+
- name: Run PHPUnit with coverage
307+
run: |
308+
mkdir -p mkdir -p build/logs
309+
vendor/bin/phpunit --coverage-clover build/logs/clover.xml
310+
env:
311+
ENGINE: geosop
312+
GEOSOP_PATH: /usr/bin/geosop
313+
314+
- name: Upload coverage report to Coveralls
315+
run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
316+
env:
317+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

phpunit-bootstrap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Brick\Geo\Engine\GeosOpEngine;
34
use Brick\Geo\Engine\PDOEngine;
45
use Brick\Geo\Engine\SQLite3Engine;
56
use Brick\Geo\Engine\GEOSEngine;
@@ -127,6 +128,13 @@ function getRequiredEnv(string $name): string
127128
$engine = new GEOSEngine();
128129
break;
129130

131+
case 'geosop':
132+
echo 'Using GeosOpEngine', PHP_EOL;
133+
134+
$geosopPath = getRequiredEnv('GEOSOP_PATH');
135+
$engine = new GeosOpEngine($geosopPath);
136+
break;
137+
130138
default:
131139
echo 'Unknown engine: ', $engine, PHP_EOL;
132140
exit(1);

0 commit comments

Comments
 (0)