Search code examples
gismapinfomap-basic

MapBasic connection Points to Regions in Map


I'm new to MapBasic, and it is really hard to find tutorials, so here the Question:

I have a map with Regions( every Region has a different attribute ) and i have a List of Points (x-y karthesian koordinates). I managed to read in this Tables (found a Tutorial).

But now i have to do the following: Take every Point of my List, locate it in the Map and assign the Attribute of the Region to the Point.

I thought about:

For lengthList
   select Attribute from Map where Map contains PointofList
   PointofList += Atrribute to PointofList
next

This is not intended to be a working miniexample, it should just illustrate what i want to do.

I'm pretty unexperienced with this BASIC/SQL crossover, and its hard to find good examples online, so i would be thankfull for any help u can provide


Solution

  • In deed, MapBasic is not very common (at least here at StackOverflow).

    Anyway, here a simple example how a loop would look like. Doing it in a single SQL as you did is of course the more efficient and preferred way.

    i = 1
    Fetch First From PointofList
    Do Until EOT(PointofList)
        Set Style Pen MakePen(100, 2, BLUE)
        Update PointofList Set Obj = CreateLine(Temp.FROM_X, Temp.FROM_Y, Temp.TO_X, Temp.TO_Y) Where RowId = i
        Fetch Next From PointofList
        i = i + 1
    Loop
    Commit Table PointofList