MapInfo Pro

 View Only
  • 1.  Extending Polylines so that they join if within a certain distance

    Posted 29 days ago
    Hello,

    I have a table of polylines which relate to road condition data. I want to extend the polylines so that they join each other, if they are within a certain distance of each other on the same road. In my attribute table I have a column which has the same road name for each object on that road.

    For example, i have four polylines on the road in the screenshot below, they all have the same road name in the attribute table. I want to extend them to make one long line, if they are within 30 meters of each other. I have a large amount of data, so want to run this over hundreds of objects.

    Any help would be greatly appreciated.

    Rob



    ------------------------------
    Robert Hodgson
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Extending Polylines so that they join if within a certain distance

    Employee
    Posted 28 days ago
    Hi Robert

    Does it matter which line gets extended or do you want to extend both ends to that they meet in the middle?

    Some pseudo code to get you thinking:
    For each line in the table:
    Get the start point from the line
    1. Use a buffer around the start point to find neighboring lines within a distance larger than 0 but smaller than tolerance and with the same road name sorted by distance
    2. Fetch the first neighbor (which will be the nearest)
    3. Move the start point to the nearest point on the neighbor line
    Get the end point from the line
    1. Use a buffer around the start point to find neighboring lines within a distance larger than 0 but smaller than tolerance and with the same road name sorted by distance
    2. Fetch the first neighbor (which will be the nearest)
    3. Move the end point to the nearest point on the neighbor line

    You basically repeat the same for the start and end points of each line.

    This solution will just extend the first line found to it's neighboring lines.

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 3.  RE: Extending Polylines so that they join if within a certain distance

    Employee
    Posted 28 days ago
    Have a look at the LineSnap sample tool installed with MapBasic download:
    \Samples\MAPBASIC\LINESNAP
    Tool is used to extend or trim a line or polyline object to its point of intersection with another line or polyline.
    See if that meets your needs.

    -Bill

    ------------------------------
    Bill Wemple
    Principal Software Engineer, Quality Management
    Precisely, Inc
    precisely.com
    ------------------------------