custom select tool mapbasic

210 views
Skip to first unread message

esrispy

unread,
Aug 24, 2010, 4:12:41 AM8/24/10
to MapInfo-L
I have a custom select tool that works fine if its a polygon table but
when hitting a point tables records in the map it does not seem to
work using criteria "Where obj Contains CreatePoint(fx, fy)"
What does one prefarebly use for selection a point?


For i = 1 to i_found
s_table = SearchInfo(i, SEARCH_INFO_TABLE)
Next
'WORKS GOOD
if s_table = "my_polygon table" then
Select * From alla_skisser_lff Where obj Contains CreatePoint(fx,
fy)
'DOES not select any points
elseif s_table = "my_Point_table" then
select * from träd Where obj Contains CreatePoint(fx, fy)
else
Note "Du har inte markerat i rätt skikt!"
Exit sub
End if
Call Marktyp()
END SUB

Peter Horsbøll Møller

unread,
Aug 24, 2010, 6:20:25 AM8/24/10
to mapi...@googlegroups.com
You could use the Intersects operator in stead:

Select * From alla_skisser_lff Where OBJ Intersects CreatePoint(fx, fy)

If you want to add some "slack" to the query, add a Buffer around the point.
Do consider making this dependent of the zoom of the map (here 1%):

Set Distance Units "m"
fZoom = MapperInfo(FrontWindow(), MAPPER_INFO_ZOOM)
oBuffer = Buffer(CreatePoint(fX, fY), 24, (fZoom / 100), "m")
Select * From alla_skisser_lff Where OBJ Intersects oBuffer

Peter Horsbøll Møller
Pitney Bowes Business Insight - MapInfo


2010/8/24 esrispy <turbo...@hotmail.com>
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to
mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

esrispy

unread,
Aug 24, 2010, 10:55:07 AM8/24/10
to MapInfo-L
Thanks that worked in my test envoirment, however
When I tried with the map file to be used I found a different
problem.

This .wor file have multiple layers selectable lower in the layer
hierachy
then the selectable layer at the bottom will become the "s_table"
instead of my desired ones :-(

And I need those other layers to be selectable as I use them for
snapping/editing functions in this .wor file..
Is there any way to point the "s_table" to be the desired one instead?

Spencer Simpson

unread,
Aug 24, 2010, 11:02:41 AM8/24/10
to mapi...@googlegroups.com

You can always write a tool that looks and acts like the Select tool but
really isn't. This tool would start with SearchPoint() or SearchRect(), and
then SearchInfo() to see if the user clicked anywhere near an object in the
layer you're looking for. If they did, SearchInfo() will tell you which
record, and CommandInfo() will tell you if the user was holding down Shift
or Ctrl when they clicked, and finally you can select the desired record(s)
WITHOUT using NoSelect, making the desired selection.

________________________________

Spencer

--

esrispy

unread,
Aug 25, 2010, 4:57:47 AM8/25/10
to MapInfo-L
Thanks for pointing me in the right direction.
I did run in to some problems with points layers and using
"intersects", I dont know why but I did like below instead, dont know
if there are any disadvantages, it seems to be working as desired
anyway.

For i = 1 to i_found
s_table = SearchInfo(i, SEARCH_INFO_TABLE)
if s_table = "My_pointTable" then
i_row_id = SearchInfo(i, SEARCH_INFO_ROW)
select * from s_table where Rowid=i_row_id
Call Marktyp()
exit sub
elseif s_table = "My_PolygonTable" then
Select * From s_table Where obj Intersects CreatePoint(fx, fy)
Call Marktyp()
else
Exit sub
End if
Next
Reply all
Reply to author
Forward
0 new messages