Subscribe to this thread
Home - General / All posts - GeomTouches
bgroff
22 post(s)
#21-Oct-20 23:27

I am trying to do a simple selection of polygons from Drawing A that are touching polygons in Drawing B, and copying the selection to a New Drawing. In Manifold 8, this was very easy. I am not proficient at 9 yet and need some help. I just updated to build 9.0.172.5 today and I don't seem to have any templates in the select tab to do this. I am also having some difficulty understanding the helpfile, and I will apologize for the newbie question in advance. What is the procedure?

HMS116 post(s)
#21-Oct-20 23:59

Hi bgroff, I believe those select templates are not present yet in the build 9.0.172.5, but you can use the ones mentioned in http://www.manifold.net/doc/mfd9/select_templates.htm (Geoms Adjacent, Geoms Contained, Geoms Containing, Geoms Intersecting, Geoms Touching) running the Release 9 Official.

bgroff
22 post(s)
#22-Oct-20 01:19

Yeah ... there are no templates as the link describes. I am trying a query:

SELECT *

INTO New

FROM Drawing_A, Drawing_B

WHERE GeomTouches([Drawing_A].[Geom][Drawing_B].[Geom], 0)

It sort of works but does not produce the expected results where everything from Drawing_A touching objects in Drawing_B is selected and placed in the New table. Clearly I am doing something wrong at a basic level.

HMS116 post(s)
#22-Oct-20 01:34

You can still run those templates with the release 9 official that is already installed in your computer. Instead of starting manifold edge (built 9.0.172.5) just run the official 9 version and there you can set the select template and edit the query to adjust to your goal.

tjhb

9,475 post(s)
#22-Oct-20 06:52

The query is not quite right. You can see this if you comment out the INTO line.

You are telling the engine you want everything from both drawings’ tables, wherever an object from either drawing touches an object from the other. Some objects might appear twice, if they happen to touch more than one in the opposite drawing.

All fields from A will be followed by all fields from B. There will be two Geom fields, with names made distinct by a suffix. And so on.

If you picked the right Geom field to make a new drawing from (the first one), this would sort of work, but not perfectly.

There are at least a couple of good ways to do what you need. The simplest is possibly a LEFT JOIN followed by a filter.

SELECT DISTINCT

A.[source_id], A.[Geom], A.[example]

INTO [Touching]

FROM

(

SELECT

A.[mfd_id] AS [source_id], A.[Geom], A.[example],

B.[mfd_id]

FROM

[Drawing_A] AS A

LEFT JOIN

[Drawing_B] AS B

ON GeomTouches(A.[Geom], B.[Geom], 0)

)

WHERE B.[mfd_id] IS NOT NULL;

A.[example] is a placeholder for any other field(s) you might need from A.

Then it is a question of sorting out a new drawing to take data from the new table.

bgroff
22 post(s)
#22-Oct-20 07:56

Thanks for the suggestion. I rolled back my version to 9.0.172.0 (Official) and grabbed the Select Template for Geoms Touching. It uses a slightly different approach.

TABLE CALL GeomOverlayTouchingFilterPar(

  [Drawing_A],

  [Drawing_B],

  0,

  ThreadConfig(SystemCpuCount()));

The result is a table that can be saved as a new drawing using the [Geom] field. This approach appears to have worked on first glance. Would be nice to place the results into a new drawing from the Query.

I have not used Manifold 9 much yet, but have been re-watching Arthur Lembo's Udemy course to refresh my memory. I'll get there ...

tjhb

9,475 post(s)
#22-Oct-20 08:48

Yes that is a better approach, and also faster.

tjhb

9,475 post(s)
#22-Oct-20 19:16

Would be nice to place the results into a new drawing from the Query.

To accomplish this, it’s easiest to use an existing drawing and table as a model. Here the obvious choice is the source drawing and table for Drawing_A.

The technique is useful for other reasons as well:

With a Query or Command window open, move over to the Project pane, and select the model table. Now move back to the code panel (upper left), and Paste. Do the same for the model drawing.

This automatically writes SQL to (re)create the model table and its drawing, along with all current properties including coordinate system, any current formatting, and the properties that link the drawing to the table and the Geom field currently used. Really useful.

Now creating a new table and drawing with matching properties is just a question of changing the two target component names, and the name of the target table (a second time) in the ‘Table’ property for the drawing.

Then below, add an INSERT INTO query to fill the target table taking fields FROM the SELECT or TABLE query you have written. Note that you must also specify all target fields explicitly, in brackets after INSERT INTO.

See manual and forum for plenty of INSERT INTO examples for 9.

tjhb

9,475 post(s)
#22-Oct-20 19:38

P.s. you probably noticed that the example in the manual entry for GeomOverlayTouchingFilter(Par) under SQL > SQL functions uses the old EXECUTE CALL... syntax that has been replaced by TABLE CALL... as in your example above.

tjhb

9,475 post(s)
#22-Oct-20 22:13

Left out something necessary (maybe a silly enough mistake for it to be obvious).

With a Query or Command window open, move over to the Project pane, and select the model table, then Copy (using the button in the Project pane). Now move back to the code panel (upper left), and Paste. Do the same for the model drawing.

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