0

How to draw lines from points to points not by lon/lat?

What I need is a cross connection with cable like the image below: I have N input and M output points

enter image description here

  • 1
    Have you tried CONNDOTS.mbx mapinfotools.com/… – Jakob Mar 24 '15 at 10:26
  • I think Conndots.mbx draws lines base on lon/lat what i need is based not by lon/lat – Thang Mar 25 '15 at 7:40
2

I'm assuming that you have a table with the cross connections, right?

If so, you can loop this table and for each record:

Get the RowID of current record:

nRowID = CROSS_CONNECTIONS.ROWID

Select the matching record from the input table, extract the CentroidX() and CentroidX()

nID = CROSS_CONNECTIONS.INPUT_ID
Select CentroidX(OBJ) "X", CentroidY(OBJ) "Y" 
   From InputTable
   Where ID = nID
   Into __CENTROID NoSelect
Fetch First From __CENTROID
fInputX = __CENTROID.X
fInputY = __CENTROID.Y

Select the matching record from the output table, extract the CentroidX() and CentroidX()

nID = CROSS_CONNECTIONS.OUTPUT_ID
Select CentroidX(OBJ) "X", CentroidY(OBJ) "Y" 
   From OutputTable
   Where ID = nID
   Into __CENTROID NoSelect
Fetch First From __CENTROID
fOutputX = __CENTROID.X
fOutputY = __CENTROID.Y

Create a new line using CreateLine() where the coordinates are the those you got from the input and output records

oLine = CreateLine(fInputX, fInputY, fOutputX, fOutputY)

And finally assign the new line ot the current record in the CROSSCONNECTION table:

Update CROSSCONNECTION
   Set OBJ = oLine
   Where ROWID = nRowID

You loop could look like this:

'**Let's set the coordsys to match the Input Table
Set CoordSys Table InputTable
'**And now the loop thru the table of Cross Connections
Fetch First From CROSSCONNECTION
Do UNTIL EOT(CROSSCONNECTION)
   '**Here you paste the code from above

   Fetch Next From CROSSCONNECTION
Loop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.