incubator-baremaps icon indicating copy to clipboard operation
incubator-baremaps copied to clipboard

CGAlgorithmsDD::orientationIndex encountered NaN/Inf numbers

Open leonardcser opened this issue 2 years ago • 5 comments

Building the basemap with the the following osm pbf, produces the error below:

Config

{
    "osmPbfUrl": "https://download.geofabrik.de/europe/france/ile-de-france-latest.osm.pbf",
}

Stacktrace

[INFO ] 2023-10-28 14:41:49.168 [pool-2-thread-8] WorkflowExecutor - Executing task ExecuteSql[database=jdbc:postgresql://localhost:5432/baremaps?&user=bertil, file=layers/ocean/prepare.sql, parallel=false] of step openstreetmap-ocean
[INFO ] 2023-10-28 14:42:04.928 [pool-2-thread-8] WorkflowExecutor - Executing task ExecuteSql[database=jdbc:postgresql://localhost:5432/baremaps?&user=bertil, file=layers/ocean/index.sql, parallel=false] of step openstreetmap-ocean
java.util.concurrent.ExecutionException: org.apache.baremaps.workflow.WorkflowException: org.apache.baremaps.workflow.WorkflowException: org.postgresql.util.PSQLException: ERROR: GEOSTopologyPreserveSimplify: IllegalArgumentException: CGAlgorithmsDD::orientationIndex encountered NaN/Inf numbers
  Where: parallel worker
        at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
        at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
        at org.apache.baremaps.cli.workflow.Execute.call(Execute.java:53)
        at org.apache.baremaps.cli.workflow.Execute.call(Execute.java:34)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at org.apache.baremaps.cli.Baremaps.main(Baremaps.java:66)
Caused by: org.apache.baremaps.workflow.WorkflowException: org.apache.baremaps.workflow.WorkflowException: org.postgresql.util.PSQLException: ERROR: GEOSTopologyPreserveSimplify: IllegalArgumentException: CGAlgorithmsDD::orientationIndex encountered NaN/Inf numbers
  Where: parallel worker
        at org.apache.baremaps.workflow.WorkflowExecutor.lambda$createFutureStep$3(WorkflowExecutor.java:167)
        at java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:787)
        at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: org.apache.baremaps.workflow.WorkflowException: org.postgresql.util.PSQLException: ERROR: GEOSTopologyPreserveSimplify: IllegalArgumentException: CGAlgorithmsDD::orientationIndex encountered NaN/Inf numbers
  Where: parallel worker
        at org.apache.baremaps.workflow.tasks.ExecuteSql.lambda$execute$0(ExecuteSql.java:46)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1006)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
        at org.apache.baremaps.workflow.tasks.ExecuteSql.execute(ExecuteSql.java:39)
        at org.apache.baremaps.workflow.WorkflowExecutor.lambda$createFutureStep$3(WorkflowExecutor.java:162)
        ... 5 more
Caused by: org.postgresql.util.PSQLException: ERROR: GEOSTopologyPreserveSimplify: IllegalArgumentException: CGAlgorithmsDD::orientationIndex encountered NaN/Inf numbers
  Where: parallel worker
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:335)
        at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:321)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:297)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:292)
        at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94)
        at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
        at org.apache.baremaps.workflow.tasks.ExecuteSql.lambda$execute$0(ExecuteSql.java:44)
        ... 9 more

leonardcser avatar Oct 28 '23 12:10 leonardcser

Is a specific PostGIS version required?

Edit: Running it again, crashes again. Probably an issue with the data that is not handled gracefully.

louwers avatar May 09 '24 09:05 louwers

@louwers Thanks a lot for reporting this, I'm currently not able to reproduce the issue. I tried several files from geofabrick without getting this exception.

I currently use the following docker image for postgis on the mac (kartoza/postgis:15-3.3). Could you provide some information about your postgis setup?

bchapuis avatar May 10 '24 20:05 bchapuis

I'm using PostgreSQL 16 with PostGIS 3.4. I'm using https://postgresapp.com/ on macOS, you might want to try that (no Docker overhead).

It happens for the Switzerland data as well as the the Netherlands data (did not try other downloads).

louwers avatar May 10 '24 20:05 louwers

Great, I have now been able to reproduce the error. It looks like st_simplifypreservetopology is causing this issue. A quick workaround was to replace these calls with st_simplify, but I will try to find for a better alternative.

bchapuis avatar May 11 '24 13:05 bchapuis

The problem seems related to the version of geos used in PostgresApp (3.12.1) and specific to the use of st_simplifypreservetopology.

https://github.com/PostgresApp/PostgresApp/blob/bb7118f1b17224f0efd8cf094e20be3da812f88b/src-16/makefile#L24

The kartoza/postgis:16-3.4 docker image uses an older version of geos (3.11.1-CAPI-1.17.1). I will try to compile PostgressApp with geos 3.11.1 to confirm this. Only a few people seems to have encountered this problem yet, but I guess that it will become pervasive as people start building against the latest version of geos.

bchapuis avatar May 13 '24 06:05 bchapuis