MapBasic connection Points to Regions in Map

226 views Asked by At

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

2

There are 2 answers

1
Wernfried Domscheit On BEST ANSWER

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
0
Michael On

Okay found it myself.

Because MapBasic understands SQL its super easy:

Add Column Value (tab1) From tab2 Set To Value Where contains

and we are finished. Somehow i couldnt accept that no loop is needed here.