Hi Bradley
Here's a suggestion that can be adjusted.
The example has some additional statements that can be excluded once you can see that it works as expected.
Here's how the script works:
1. Select the polyline you want to use for your query
2. Run the script either through the new SQL Window or through the MapBasic window
3. The query will extract the endpoint from the selected polyline, create a buffer around this node and query your layer using this buffer.
In my example, I select and query the same layer. That's not required.
Here's the statement that will analyze the endpoint of the selected polyline:
Set CoordSys Table Roads
Select *
From Roads As "h"
Where Obj Intersects Any
(Select Buffer(CreatePoint(
ObjectNodeX(obj, 1, ObjectInfo(obj, OBJ_INFO_NPNTS)),
ObjectNodeY(obj, 1, ObjectInfo(obj, OBJ_INFO_NPNTS))
) , 12, 1, "m")
From Selection)
Into qIntersectsAtEnd NoSelect
Add Map Auto Layer qIntersectsAtEnd
Set Map Window 3237 Layer qIntersectsAtEnd
Display Global Global Line (7,2,22015)
Print TableInfo(qIntersectsAtEnd, TAB_INFO_NROWS) + " records selected"
Select s.*, Buffer(CreatePoint(
ObjectNodeX(s.obj, 1, ObjectInfo(s.obj, OBJ_INFO_NPNTS)),
ObjectNodeY(s.obj, 1, ObjectInfo(s.obj, OBJ_INFO_NPNTS))
) , 12, 10, "m") Object
From Selection As "s"
Into qSelectionBuffer NoSelect
Add Map Layer qSelectionBuffer
Set Map Window 3237 Layer qSelectionBuffer
Display Global Global Pen (2,2,14680288)
Global Brush (2,12583104,16777215)
You don't need more than the first 10 lines to make it work. The rest is more to be able to verify that it's correct.
The resulting buffer created in the map is larger than the one you use for your query - just to make it stand out.
Here's a similar query for the start point of the selected polyline:
Set CoordSys Table Roads
Select *
From Roads As "h"
Where Obj Intersects Any
(Select Buffer(CreatePoint(
ObjectNodeX(obj, 1, 1),
ObjectNodeY(obj, 1, 1)
) , 12, 1, "m")
From Selection)
Into qIntersectsAtStart NoSelect
Print TableInfo(qIntersectsAtStart, TAB_INFO_NROWS) + " records selected"
Add Map Auto Layer qIntersectsAtStart
Set Map Window 3237 Layer qIntersectsAtStart
Display Global Global Line (7,2,22015)
Select s.*, Buffer(CreatePoint(
ObjectNodeX(s.obj, 1, 1),
ObjectNodeY(s.obj, 1, 1)
) , 12, 10, "m") Object
From Selection As "s"
Into qSelectionBuffer NoSelect
Happy to discuss further if required
Add Map Layer qSelectionBuffer
Set Map Window 3237 Layer qSelectionBuffer
Display Global Global Pen (2,2,14680288)
Global Brush (2,12583104,16777215)
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------
Original Message:
Sent: 04-26-2021 04:22
From: Bradley Trounson
Subject: Script that looks at the two end vertices of a line and reports objects (on different layers) directly on those vertices
Greetings,
I am wanting to write a script that looks at the two end vertices of a line and reports which objects (on different layers) sit directly on those vertices. The line will have its own ID.
Does anyone have some suggestions or useful functions? Is there a function to get the co-ordinates for the end vertices and another to see what objects at those co-ordinates?
Thanks in advance.
------------------------------
Bradley Trounson]
NBN Co Limited]
------------------------------