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
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityHow 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
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