Subscribe to this thread
Home - General / All posts - Split lines at intersection
Sloots

712 post(s)
#14-Oct-25 14:39

Hi,

I have a drawing of roads that I want to split at intersections with other roads. My starting situation is like the image below. Two lines that meet at an infliction point.

I want to end up in a situation where the purple line is broken into two parts as in the following image.

Important is that I don't want to lose the attributes. Class in this example. Any suggestions? I must go fast since i want to run it on millions of lines.

Chris


http://www.mppng.nl/manifold/pointlabeler

apo
198 post(s)
#14-Oct-25 19:37

maybe a lead to follow

SELECT *

FROM (

  SELECT D1.[mfd_id] AS LINE1, FIRST( D1.[Geom]AS GEOM1, -- ADD ALL THE ATTRIBUTES FROM D1 THAT YOU WANT TO KEEP HERE

  SPLIT CALL GeomToBranches(GeomNormalize(GeomMergeLines(D2.[Geom]), 0)) -- MERGE, NORMALIZE TO GENERATE BRANCHES AND SPLIT BY BRANCHES, THANKS TO ADAM

  FROM [Drawing] AS D1

  INNER JOIN [Drawing] AS D2

    ON  geomtouches(d1.[Geom],d2.[Geom],0)

  GROUP BY  D1.[mfd_id] 

)

WHERE GEOMCONTAINS(GEOM1, VALUE,0) -- TO REMOVE THE NEIGHBOUR LINES USED TO SPLIT AND KEEP ONLY THE PARTS OF THE LINE

Sloots

712 post(s)
#15-Oct-25 07:36

Thanks a lot. I took a while before I realised that [Value] contains the geometries I was looking for!


http://www.mppng.nl/manifold/pointlabeler

apo
198 post(s)
#15-Oct-25 07:44

yes that's one of the limit of M9 which does not allow you to directly add an alias to the results of CALL, I should have done it in the last SELECT instead of *. The same problem, even worse, with the SPLIT COLLECT which add a strange char in the name

tjhb
10,119 post(s)
#16-Oct-25 06:12

I don't think it's fair to call this a limit(ation).

An extra wrap easily does the renaming.

Unlike other platforms (notably M8), Manifold 9 does this for free.

Apart from the extra jot (perhaps) at compile time, a redundant extra wrap costs no execution time at all.

In M8, SQL is interpreted. Any knobbly syntax means that stuff has to be shuffled around in memory at runtime.

In M9, SQL is compiled. Only actual work is done.

Among other things, redundant layers (including those that only do renaming) are 100% free in Manifold 9.

You can spill ink.

apo
198 post(s)
#16-Oct-25 17:22

Thanks Tim to both correct my english and my use of the word limitation.

I should have say "M9 does not allow you to add an alias directly".

My remark on the "problem" (only based on my own interpretation) of an extra char in the result of the SPLIT COLLECT remains ( as mentioned here and reported as bug)

Dimitri


7,593 post(s)
#17-Oct-25 06:16

I've tried a few test cases and the extra character (a \u0001) inserted after the . character in the concatenated composite field created by the query looks like a bug to me. It's always that Unicode character and always at the beginning of the name concatenated after the . character. Just guessing, but looks like it might be the result of a simple fence-posting error when building the concatenated name. I've reported it in case the original bug report got overlooked somehow.

artlembo


3,450 post(s)
online
#18-Oct-25 01:02

another option of course would be to use Normalize Topology in Manifold 8. Just make sure to set the Transfer Rules to Copy/Copy. You can use the Transform Bar, or write a quick little script:

Sub Main

 Set theDrawing = document.ComponentSet("D")

 Set NewAnalyzer = document.NewAnalyzer

 NewAnalyzer.NormalizeTopology theDrawing,theDrawing.ObjectSet

End Sub

that's it. It really is that easy in Manifold 8 :-)

tomasfa
195 post(s)
#30-Nov-25 08:00

That was the solution I was thinking, Normalize Topology does that with 3 clics. Chris how did you solve it? Run it in M8 at the end?

Cheers and Happy Thanksgiving to all our friends in the USA.

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