Creating and selecting lists of objects on the map |
Based on the results of the analysis and processing the objects of vector map, some objects can be selected, which expediently to mark on the map as a result of working the script and/or for further processing in the chain of executed scripts or by interactive GIS tools. For this purpose, MAPAPI functions are used for selecting the objects into the general map lists or forming the named lists for further operations on lists.
The easiest way is to create a list of selected objects in the general conditions of searching for objects for the map. But this method will not work correctly when multithreaded scripts are executed.
seekapi.mapSetTotalSeekAccess(hmap, 0) # Очистить условия общего поиска
mapname = mapsyst.WTEXT(1024) mapapi.mapGetListNameUn(hmap,1, mapname, mapname.size())
count = 0 objcount = mapapi.mapGetObjectCount(hmap,1)+1 # Количество объектов на карте + 1 for i in range(1,objcount): # Цикл по объектам карты ret = seekapi.mapReadObjectByNumber(hmap, hmap, work, 1, i) if ret == 0: break if mapapi.mapPointCount(work, -1) < 1000: continue count += 1 key = mapapi.mapObjectKey(work) seekapi.mapSetTotalSeekSampleUn(hmap, mapname, key) # Добавить в список
if count > 0: mapapi.mapSelectObjects(1) # Выделить на карте объекты, которые были найдены
After the script is completed, the selected objects will be highlighted on the map. If objects are selected for further processing in another script, then instead of selecting on the map, you can set the feature for selecting objects without redrawing the map.
if count > 0: seekapi. mapSetTotalSelectFlag(hmap, 1)
|