Subscribe to this thread
Home - General / All posts - Bug when selecting areas in Postgres DB -

473 post(s)
#06-Jan-20 15:17

Hi there,

When I have a drawing stored in a Postgres database, selecting (ctrl-click) or editing (alt-click) does not work correct in case of multibranched areas. Only clicking the first branch works as expected. With multibranched lines there are no problems.

Can somebody confirm this behaviour?



9,321 post(s)
#08-Jan-20 11:27

Yes, I just reproduced this. We will fix it.

Thanks a lot for the note!


9,321 post(s)
#08-Jan-20 13:12

A follow-up:

Actually, we will not fix the issue automatically just yet, because it is part of a bigger picture for which we already started reworks (in a parallel code branch, to appear in the builds later) and any short-term patches we could do specifically for the scenario above would be pretty incomplete and hackish.

The root of the issue is that when we are clicking into an object, we are asking PostgreSQL to perform the selection and the spatial functions that PostgreSQL uses to do that require the geometry to be normalized. Inserting new objects into PostgreSQL, however - including inserting interactively - does not currently automatically normalize them. Because our current normalization code loses curves and some other data, may rearrange coordinates of an already normalized object, and is slower than we'd like it to be - it's good as an intermediate clean-up step for internal processing, but less good as a clean-up step for permanent storage. We are going to rewrite the relevant code and then we will do normalization automatically on all writes to data sources that need it.

(What happens without normalization in the case of an area with multiple branches is that we are seeing a area with multiple branches, we tell PostgreSQL that this is a 'POLYGON', PostgreSQL believes that it is a 'POLYGON' and handles it accordingly - the first branch is used as an outer contour and all other branches are used as inner contours, even though they are not. The real type of geometry should be 'MULTIPOLYGON', but we cannot determine that real type without normalizing geometry first, and we cannot normalize geometry because of the reasons above - this currently does not support some types of geometry, etc.)

OK, so we are going to fix the issue in the future. Until then, what you can do is run PostgreSQL normalization. You can do this without leaving 9 - right-click the data source, select New Command Window, then run PostgreSQL code from that window:


UPDATE "public"."test" SET "geom" = ST_MakeValid("geom");

This should make all branches of a multi-branched area clickable.

PostgreSQL version of ST_MakeValid is also not without its issues, eg, it also does not support curves, but it will work for simple cases.

Manifold User Community Use Agreement Copyright (C) 2007-2019 Manifold Software Limited. All rights reserved.