On Tue, 18 Jul 2023 05:12:31 -0700 (PDT), Elham Peiravian wrote:
> I initially tested this method with a small dataset, (~3000) rows and
> everything worked perfectly. Now that I want to run the query on a
> larger dataset, I am getting a geometry constraint error.
>
Hi Elham,
evidently all this means that in a few rare cases your approach fails,
so you simply have ot discover where, when and why this happans.
luckily there is a very quick and easy way to find out; let SQL
do the work for you.
CREATE TABLE test_table AS
SELECT id,
ST_Transform(ST_OffsetCurve(
ST_Transform(segment, 3347), -5), 4326) AS segmentA,
ST_Transform(ST_OffsetCurve(
ST_Transform(segment, 3347), 5), 4326) AS segmentB
FROM roads;
this query is exactly equivalent to yours, except for one detail.
now no constraints will be applied to output geometries, and
any possible result will be inserted into the target table.
SELECT * FROM test_table
WHERE GeometryType(segmentA) <> 'LINESTRING'
OR Srid(segmentA) <> 4326
OR GeometryType(segmentB) <> 'LINESTRING'
OR Srid(segmentB) <> 4326;
at this point a trivial SQL query will allow you to identify
any issue causing a violation the constraints imposed
on the geometries.
you'll see that at this point you'll be able to understand with
very little effort where you need to correct your initial query.
conclusion: nothing is better than a bit of healthy debugging :-D
bye Sandro