1、Include mapbasic.defInclude icons.defDeclare sub MainDeclare sub Rmv_mapDeclare sub Rmv_map_neighbor_queryDeclare sub Rmv_map_Center_cell_queryDeclare sub Show_PNDeclare sub Show_perfDeclare sub Neighbor_toolDeclare sub About_map_toolDeclare sub get_table_nameDeclare sub get_neighbortable_nameDeclar
2、e sub get_perftable_nameDeclare sub get_regionDeclare sub get_freqDeclare sub Exit-全局变量Global Table_number,Neighbortable_number,perftable_number as integer, region_1,region_2,region_3,region_4,region_5,region_6,region_7,region_8,region_9,region_10,region_11,region_12 AS integer, column_name as alias
3、 freq as string-主函数,创建菜单子菜单Sub MainbeepCreate Menu &Maptool As Select the basetable. calling get_table_name, Select a performancetable. calling get_perftable_name, Select a neighbortable. calling get_neighbortable_name, (-, Exit Maptool.mbx calling Rmv_map, 退出时需要删除临时图层,先转入删除程序 About maptool calling
4、 About_map_toolAlter Menu Bar Add Maptool-主函数,创建按钮Create buttonpad Maptool As pushbutton Calling Show_PN helpmsg n在地图上显示输入的PN码 Icon MI_ICON_MAPSYMB_16separator ToolButton Calling Neighbor_tool helpmsg n显示邻区 Icon MI_ICON_MAPSYMB_1 Cursor MI_CURSOR_FINGER_UPseparator pushButton Calling get_freq helpms
5、g n输入邻区频点 Icon MI_ICON_MAPSYMB_17separator pushbutton calling Show_perf helpmsg n性能地理化 Icon MI_ICON_DISTRICT_MANY ToolbarPosition(1,0) Show FixedEnd Sub-About maptoolsub About_map_tool Note Maptool.mbx & chr$(10) & chr$(10) &Yekan 2009-04-15 & chr$(10) &E-mail:Yekan_zj& chr$(10)end sub-退出程序Sub Rmv_m
6、ap dim map_win_id as integer, layer_name as string map_win_id=frontwindow() layer_name=layerinfo(map_win_id,1,layer_info_name) delete object from windowinfo(frontwindow(),win_info_table) /删除装饰层OBJECT If layer_name=PN_Query then set map redraw off Remove Map Layer PN_Query Interactive set map redraw
7、on call Rmv_map_neighbor_query Else call Rmv_map_neighbor_query End ifEnd subSub Rmv_map_neighbor_query dim map_win_id as integer, layer_name as string map_win_id=frontwindow() layer_name=layerinfo(map_win_id,1,layer_info_name) If layer_name=Neighbor_query then set map redraw off Remove Map Layer Ne
8、ighbor_query Interactive set map redraw on call Rmv_map_Center_cell_query Else call Rmv_map_Center_cell_query End ifEnd subSub Rmv_map_Center_cell_query dim map_win_id as integer, layer_name as string map_win_id=frontwindow() layer_name=layerinfo(map_win_id,1,layer_info_name) If layer_name=Center_ce
9、ll_query then set map redraw off Remove Map Layer Center_cell_query Interactive set map redraw on call exit Else call exit End ifEnd subSub exit Dim ack As Logical ack = Ask(Do you want quit?, OK, Cancel) If ack=0 then exit sub Else End program End ifEnd sub-选择主表sub get_table_name dim i_table_name(2
10、0) as string, i, num_table as integer num_table=numtables() for i=1 to num_table i_table_name(i)=tableinfo(i , tab_info_name) next dialog title select layer control statictext title select map layer: control popupmenu title from variable i_table_name ID 1 Into table_number /table_number是你选择的主表的ID,这个
11、ID将在后面使用时来获得主表的名称 control okbutton title OK control cancelbutton title CancelEnd sub-选择包含邻区的表sub get_neighbortable_name dim i_table_name(20) as string, i, num_table as integer num_table=numtables() for i=1 to num_table i_table_name(i)=tableinfo(i , tab_info_name) next dialog title select Neighbortab
12、le control statictext title select a Neighbortable: control popupmenu title from variable i_table_name ID 1 Into neighbortable_number /neighbortable_number是你选择邻区的表的ID,这个ID将在后面显示邻区时用来获得表的名称 control okbutton title OK control cancelbutton title CancelEnd sub-选择包含指标的表sub get_perftable_name dim i_table_n
13、ame(20) as string, i, num_table as integer num_table=numtables() for i=1 to num_table i_table_name(i)=tableinfo(i , tab_info_name) next dialog title select performance control statictext position 5,5 title select Performance table: control popupmenu position 90,5 title from variable i_table_name ID
14、1 Into perftable_number /table_number是你选择显示PN的表的ID,这个ID将在后面显示PN时用来获得表的名称 control statictext position 5,25 title The column you want: control edittext into column_name position 90,25 control okbutton title OK control cancelbutton title Cancel call get_regionEnd sub-输入频点sub get_freq dialog title Input
15、 frequency control statictext title Frequency: control edittext into freq width 30 control okbutton title OK control cancelbutton title Cancelend sub-输入区间sub get_region dialog title Input region control statictext position 5,5 title Input range you want control edittext position 5,25 width 25 into r
16、egion_1 control statictext position 37,25 title to control edittext position 48,25 width 25 into region_2 control edittext position 5,50 width 25 into region_3 control statictext position 37,50 title to control edittext position 48,50 width 25 into region_4 control edittext position 5,75 width 25 in
17、to region_5 control statictext position 37,75 title to control edittext position 48,75 width 25 into region_6 control edittext position 5,100 width 25 into region_7 control statictext position 37,100 title to control edittext position 48,100 width 25 into region_8 control edittext position 5,125 wid
18、th 25 into region_9 control statictext position 37,125 title to control edittext position 48,125 width 25 into region_10 control edittext position 5,150 width 25 into region_11 control statictext position 37,150 title to control edittext position 48,150 width 25 into region_12 control okbutton title
19、 OK control cancelbutton title Cancelend sub-生成新的显示PN图层Sub Show_PN dim query_map_name as string,query_map_number, PN_number, pn_input as integer query_map_number=table_number /选择表时获得的ID query_map_name=tableinfo(query_map_number , tab_info_name) /根据表的ID,得到表的名称 dialog title Search PN control statictex
20、t title The PN you want: control edittext into PN_input control okbutton title OK control cancelbutton title Cancel PN_number=PN_input select*from query_map_name where PN=PN_number into PN_Query set map redraw off Add Map Layer PN_Query Set map layer PN_Query Display Global Global Brush (1,6316128,1
21、6777215) Label Font (Arial,256,30,16711680,65280) With PN Auto On Overlap On set map redraw on Set Map Layer PN_Query Selectable Off select*from query_map_name where not objectEnd sub-在表中添加性能指标,并分颜色显示Sub show_perf dim query_map_name, perftable_name as string, query_map_number, perftable_num as integ
22、er dim column_name_add as alias query_map_number=table_number query_map_name=tableinfo(query_map_number , tab_info_name) perftable_num=neighbortable_number /前面选表时,表所在的ID perftable_name=tableinfo(perftable_num , tab_info_name) /获得包含指标的表的名字 column_name_add=column_name add column query_map_name(column_
23、name_add) from perftable_name set to column_name_add where index=index dynamic shade window frontwindow() query_map_name with column_name_add ranges apply color use all Brush (2,0,16777215) region_1: region_2 Brush (2,white,white), region_3: region_4 Brush (2,yellow,yellow), region_5: region_6 Brush
24、 (2,green,white), region_7: region_8 Brush (2,blue,blue), region_9: region_10 brush (2,16711935,16777215), region_11: region_12 Brush (2,red,red) default Symbol (35,16777215,4) set legend window frontwindow() layer prev display on shades on symbols off lines off count on title Calldrop Font (Arial,0
25、12,0) subtitle auto Font (Arial,0,11,0) ascending off ranges Font (Arial,0,11,0) auto display off ,auto display on ,auto display on ,auto display on ,auto display on End sub-显示邻区关系Sub Neighbor_tool Dim x,y as float, i, win_id, num_obj_found,row_id, neighbortable_num,num_neighbor as integer, click_t
26、able, Center_cell_index,neighbortable_name, cell_nbr as string, cell_index, column_name, neighbor_srvcell, neighbor_nbrcell,neighbor_frequency, neighbor_priority, sitemap_index, sitemap_obj as Alias, singlenbr_obj as object neighbortable_num=neighbortable_number /前面选表时,表所在的ID neighbortable_name=tabl
27、einfo(neighbortable_num , tab_info_name) /获得邻区表的名字 win_id=frontwindow() x = CommandInfo(CMD_INFO_X) y = CommandInfo(CMD_INFO_Y) num_obj_found = SearchPoint(win_id, x, y) If num_obj_found = 0 Then note Click a sector on the map exit sub End if click_table=SearchInfo(num_obj_found, SEARCH_INFO_TABLE)
28、row_id = SearchInfo(num_obj_found, SEARCH_INFO_ROW) delete object from windowinfo(frontwindow(),win_info_table) /删除装饰层OBJECT Fetch rec row_id From click_table cell_index=click_table+.index Center_cell_index=str$(cell_index) select*from click_table where index=Center_cell_index into Center_cell_query
29、 /将selection存为Center_cell_query图层 set map redraw off Add Map Layer Center_cell_query Set map layer Center_cell_query Set Map Layer Center_cell_query Display Global Global Brush (2,blue,blue) set map redraw on Set Map Layer Center_cell_query Selectable Off neighbor_srvcell=neighbortable_name+.srvcell
30、 neighbor_nbrcell=neighbortable_name+.nbrcell neighbor_frequency=neighbortable_name+.frequency neighbor_priority=neighbortable_name+.priority sitemap_obj=click_table+.obj sitemap_index=click_table+.index create index on neighbortable_name(srvcell) /创建索引加快搜索进度 create index on click_table(index) selec
31、t neighbor_nbrcell, neighbor_frequency, neighbor_priority, sitemap_obj from neighbortable_name, click_table where sitemap_index=neighbor_nbrcell and neighbor_srvcell=center_cell_index and neighbor_frequency=freq into neighbor_query num_neighbor=tableinfo(neighbor_query, tab_info_nrows) print ( +cent
32、er_cell_index+ ) has +(num_neighbor)+ neighbors. set map redraw off Add Map Layer neighbor_query Set Map Layer neighbor_query Display global global Brush (2,green,green) Label Font (Arial,257,18,255,16777215) With priority Auto On Overlap On Duplicates Off set map redraw on Set Map Layer neighbor_qu
33、ery Selectable Off for i=1 to num_neighbor /查询双向邻区 fetch rec i from neighbor_query cell_nbr=str$(neighbor_query.nbrcell) select * from neighbortable_name where srvcell=cell_nbr and nbrcell=center_cell_index and frequency=freq into temp if tableinfo(temp, tab_info_nrows)=0 then /未查出双向,则修改颜色为黄色 singlenbr_obj=neighbor_query.obj alter object singlenbr_obj info obj_info_brush, makebrush(2,yellow,yellow) insert into windowinfo(frontwindow(),win_info_table) (object) values(singlenbr_obj) end if next select * from click_table where not objectEnd sub