资源描述
Include "mapbasic.def"
Include "icons.def"
Declare sub Main
Declare sub Rmv_map
Declare sub Rmv_map_neighbor_query
Declare sub Rmv_map_Center_cell_query
Declare sub Show_PN
Declare sub Show_perf
Declare sub Neighbor_tool
Declare sub About_map_tool
Declare sub get_table_name
Declare sub get_neighbortable_name
Declare sub get_perftable_name
Declare sub get_region
Declare sub get_freq
Declare 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,
freq as string
'-------------------------------------------------------------------------------------------------主函数,创建菜单\子菜单
Sub Main
beep
Create 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 About_map_tool
Alter Menu Bar Add "Maptool"
'-------------------------------------------------------------------------------------------------主函数,创建按钮
Create buttonpad "Maptool" As
pushbutton Calling Show_PN
helpmsg "\n在地图上显示输入的PN码"
Icon MI_ICON_MAPSYMB_16
separator
ToolButton Calling Neighbor_tool
helpmsg "\n显示邻区"
Icon MI_ICON_MAPSYMB_1
Cursor MI_CURSOR_FINGER_UP
separator
pushButton Calling get_freq
helpmsg "\n输入邻区频点"
Icon MI_ICON_MAPSYMB_17
separator
pushbutton calling Show_perf
helpmsg "\n性能地理化"
Icon MI_ICON_DISTRICT_MANY
ToolbarPosition(1,0)
Show
Fixed
End Sub
'-------------------------------------------------------------------------------------------------About maptool
sub 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_map
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 on
call Rmv_map_neighbor_query
Else
call Rmv_map_neighbor_query
End if
End sub
Sub 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 Neighbor_query Interactive
set map redraw on
call Rmv_map_Center_cell_query
Else
call Rmv_map_Center_cell_query
End if
End sub
Sub 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_cell_query" then
set map redraw off
Remove Map Layer Center_cell_query Interactive
set map redraw on
call exit
Else
call exit
End if
End sub
Sub exit
Dim ack As Logical
ack = Ask("Do you want quit?", "OK", "Cancel")
If ack=0
then exit sub
Else
End program
End if
End sub
'-------------------------------------------------------------------------------------------------选择主表
sub get_table_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 layer"
control statictext
title "select map layer:"
control popupmenu
title from variable i_table_name
ID 1
Into table_number '/table_number是你选择的主表的ID,这个ID将在后面使用时来获得主表的名称
control okbutton
title "OK"
control cancelbutton
title "Cancel"
End 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 Neighbortable"
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 "Cancel"
End sub
'-------------------------------------------------------------------------------------------------选择包含指标的表
sub get_perftable_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 performance"
control statictext
position 5,5
title "select Performance table:"
control popupmenu
position 90,5
title from variable i_table_name
ID 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_region
End sub
'-------------------------------------------------------------------------------------------------输入频点
sub get_freq
dialog
title "Input frequency"
control statictext
title "Frequency:"
control edittext
into freq
width 30
control okbutton
title "OK"
control cancelbutton
title "Cancel"
end 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 region_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
into 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 width 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 "OK"
control cancelbutton
title "Cancel"
end 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 statictext
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,16777215)
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 object
End sub
'-------------------------------------------------------------------------------------------------在表中添加性能指标,并分颜色显示
Sub show_perf
dim query_map_name, perftable_name as string, query_map_number, perftable_num as integer
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_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 (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,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_table, 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=tableinfo(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)
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 '/将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"
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)
select 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 "( "+center_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_query 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 object
End sub
展开阅读全文