Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST_Transform error with doughnuts #45

Closed
oskaresparza opened this issue Mar 6, 2023 · 12 comments
Closed

ST_Transform error with doughnuts #45

oskaresparza opened this issue Mar 6, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@oskaresparza
Copy link

oskaresparza commented Mar 6, 2023

I am facing an error when tryng to transform geometries that include doughnouts (holes)
One example is:
SELECT ST_Transform( ST_GeomFromText('POLYGON ((3301892.7081 2305424.6332, 3297641.4146 2293854.3149, 3311252.1571 2288743.8019, 3322410.9401 2280361.8837, 3322085.273 2275041.252, 3318903.5687 2269530.8181, 3315052.0551 2262870.2843, 3313598.2675 2255611.9221, 3304356.0358 2255544.4336, 3299995.8432 2251719.8828, 3300298.3817 2248820.3076, 3304266.6753 2247578.2129, 3301776.1263 2238082.5652, 3283221.0582 2241578.9782, 3280799.4261 2245695.1826, 3281142.5189 2253859.4624, 3276773.4563 2256390.7988, 3270589.2771 2251898.2402, 3268897.3401 2260428.3755, 3263191.4445 2269557.4174, 3249571.2601 2278693.3564, 3249773.3834 2281355.1971, 3250227.7287 2287323.6797, 3247573.221 2288352.4905, 3242476.1795 2290332.0758, 3243878.6509 2296591.2115, 3246594.6023 2298063.0509, 3249026.1976 2297136.9709, 3259898.26 2293011.2743, 3262495.8129 2295521.9721, 3260589.2171 2300629.207, 3263318.1856 2300530.7404, 3264794.3518 2302409.892, 3262145.1912 2304764.0635, 3262200.7379 2307365.4, 3260625.93 2307497.7578, 3256755.1595 2303490.781, 3252545.7222 2307836.9957, 3253121.686 2318845.3297, 3255442.84 2321747.7637, 3260779.9173 2319719.2841, 3268846.0956 2323205.8617, 3271079.6228 2317750.6139, 3270372.2206 2315806.1767, 3268797.8507 2311480.5666, 3279698.4348 2303347.7128, 3292652.3093 2299850.1394, 3294313.4361 2305713.7012, 3301892.7081 2305424.6332), (3270969.4748 2271758.2972, 3272874.4151 2267708.8757, 3275976.4969 2266056.1655, 3276737.0802 2262242.684, 3280734.3288 2261171.7626, 3285660.5305 2261369.8463, 3286896.4781 2258685.4039, 3291253.9138 2258101.4314, 3293829.2967 2256241.5158, 3296529.1289 2256778.6072, 3296722.7488 2260852.6801, 3292037.8003 2260114.8086, 3290215.1655 2263282.8501, 3294438.177 2267457.5003, 3291842.5399 2271360.9896, 3288472.2535 2271349.9963, 3281847.6405 2275670.851, 3278803.0097 2276290.0461, 3273515.1866 2277201.8981, 3270969.4748 2271758.2972))',3035),4326)

The error is:
IllegalArgumentException: Points of LinearRing do not form a closed linestring

@sheinbergon
Copy link
Owner

Hi @bilbomaticaeugis.

Thank you for the expressed interest in my project.

I will have a look and revert back to you shortly.

Please state:

  • Which Library version are you using?
  • Which Dremio version are you using?
  • Which JVM Runtime are you using?

@oskaresparza
Copy link
Author

Hi again
I am using a Docker image based on Dremio 23.1 running on Kubernetes ( https://github.com/dremio/dremio-cloud-tools/blob/master/charts/dremio/README.md )
Library version 0.8.8.jar
JVM :
openjdk version "1.8.0_352"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_352-b08)
OpenJDK 64-Bit Server VM (Temurin)(build 25.352-b08, mixed mode)

Thanks

@sheinbergon
Copy link
Owner

sheinbergon commented Mar 6, 2023

Given the original geom is valid, seems like a PROJ4 issue. I will give it a further look in the upcoming days.

@oskaresparza
Copy link
Author

I am using proj4j-1.1.0
Do you suggest any version in version in particular?

@sheinbergon
Copy link
Owner

sheinbergon commented Mar 6, 2023

Not sure what you mean by that. proj4j is baked into the library via jts-proj4

@oskaresparza
Copy link
Author

In the Dockerfile I copy the following jar files into /opt/dremio/jars/3rdparty/ folder
FROM dremio/dremio-oss:23.1
COPY "esri-geometry-api-2.2.2.jar" "proj4j-1.2.3.jar" "proj4j-epsg-1.2.0.jar" "dremio-udf-gis-0.8.4.jar" /opt/dremio/jars/3rdparty/

I am testing with different proj4j-1.x.j.jar files with the same result.

@sheinbergon
Copy link
Owner

sheinbergon commented Mar 7, 2023

So, at best, you'll be getting classpath collosions. You should not be copying any additional jar aside from dremio-udf-gis, as it's what you call a "fat jar" (includes all dependencies within). Again, it's seems to be an issue with the PROJ4 library implementation itself. as coordinate transformation creates a non closed polygon (could also be an issue with my interface).

Please allow for a few days for me to test it out

@oskaresparza
Copy link
Author

Sure, no problem

@sheinbergon
Copy link
Owner

So, good news, it's a problem with my interface, I do not break down the rings for multi-ring polygons.
I will release a fix in the upcoming version. Great catch!

@sheinbergon sheinbergon added bug Something isn't working and removed bug Something isn't working labels Mar 7, 2023
@oskaresparza
Copy link
Author

Good news indeed! Many thanks for looking into this.

@sheinbergon
Copy link
Owner

Released.

You can use the most recent 0.8.10 version which contains the fix (should be available in maven central in a matter of an hour or two)

@oskaresparza
Copy link
Author

Many thanks !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants