mapx vb實戰摘要(四)

2021-03-31 08:56:30 字數 4205 閱讀 3724

ppp80上個月去天津(2004)做這個專案,加班加點忙乎過了十一,現在專案終

於完成了第一階段,可以閒下來總結一下了。

在做這個專案之前我只是自學了乙個月的supermap,不過感覺gis這些東

西都是大同小異,沒什莫可怕;關鍵比較鬱悶的是本來根本就是做.***,現

在卻要用vb實在太。。。算了,趕鴨子上架,不會也得會呀!

其實本人對這個實在只能稱得上一知半解,學的和用的一樣多,不過還

是給自己和別人留下點東西吧,也許會有幫助呢:)(共五篇)

12 查詢圖元

mapx查詢地圖上的圖元有多種方法

a, findobj.search

這種方法在用的時候有侷限性:資料集必須要有索引,查詢的字段型別不能是10進製型別(可能還有其它的型別,忘了),否則在圖上找不到。

set findobj = fmainform.map1.layers(layer***bo.text).find

set findobj.finddataset = fmainform.map1.datasets(layer***bo.text & " dataset")

set findobj.findfield = findobj.finddataset.fields(field***bo.text)

set foundfeature = findobj.search(findtext.text)

if foundfeature.findrc mod 10 = 1 or foundfeature.findrc mod 10 = 2 then       

fmainform.map1.layers(layer***bo.text).selection.add foundfeature

fmainform.map1.autoredraw = false

fmainform.map1.centerx = foundfeature.centerx

fmainform.map1.centery = foundfeature.centery

end if

b,sql語句方法

dim ftrs as mapxlib.features

dim lyr as layer

dim i as integer

set lyr = fmainform.map1.layers(roadlyrname)

dim strs as string

strs = trim("路線編碼 = " + chr(34) + ***roadid.list(***roadid.listindex) + chr(34))『在值前面加雙引號如:id="001",         觀測點名稱 like "%天平莊"

set ftrs = lyr.search(strs)

lyr.selection.clearselection

lyr.selection.add ftrs

if ftrs.count > 0 then

fmainform.map1.centerx = ftrs.item(1).centerx

fmainform.map1.centery = ftrs.item(1).centery

end if

13顯示滑鼠當前的經緯度

private sub map1_mousemove(button as integer, shift as integer, x as single, y as single)

dim mx as double, my as double

map1.convertcoord x, y, mx, my, 1

text1.item(1).caption = "當前位置"

text1.item(2).caption = "東經 " & format(mx, "###0.0000") + ",北緯 " + format(my, "###0.0000")               

text1.item(3).caption = " 當前圖層"

text1.item(4).caption = map1.layers(1).name

end sub

14自動滾屏

private sub map1_mousemove(button as integer, shift as integer, x as single, y as single)

if mnumovecenter.checked = true then

if x > map1.mapscreenwidth - 10 then

map1.centerx = map1.centerx + 0.05

map1.refresh

else

if x < 10 then

map1.centerx = map1.centerx - 0.05

map1.refresh

else

if y > map1.mapscreenheight - 10 then

map1.centery = map1.centery - 0.05

map1.refresh

else

if y < 10 then

map1.centery = map1.centery + 0.05

map1.refresh

end if

end if

end if

end if

end if

end sub

15測距和測面積

private sub form_load()

map1.createcustomtool polyrulertoolid, mitooltypepoly, misizeallcursor

map1.createcustomtool polyareatoolid, mitooltypepolygon, miselectregionminuscursor

end sub

private sub map1_polytoolused(byval toolnum as integer, byval flags as long, byval points as object, byval bshift as boolean, byval bctrl as boolean, enabledefault as boolean)

if toolnum = polyrulertoolid then

dim i as integer

dim distancesofar as double

map1.mapunit = rulerunit

distancesofar = 0#

if points.count > 1 then

for i = 2 to points.count

distancesofar = distancesofar + map1.distance(points.item(i).x, points.item(i).y, points.item(i - 1).x, points.item(i - 1).y)

next

end if

if flags = mipolytoolend then

'first, clear the status bar

text1.item(4).caption = ""

msgbox "距離: " & distancesofar & " " & rulerunitstring

else

text1.item(3).caption = "距離"

text1.item(4).caption = distancesofar & " " & rulerunitstring

end if

end if

if toolnum = polyareatoolid then

'面積map1.areaunit = miunitsquarekilometer

on error resume next

dim apolygon as new mapxlib.feature

dim ax as double

if (points.count > 2) then

set apolygon = new feature

set apolygon = map1.featurefactory.createregion(points)

ax = apolygon.area

msgbox "面積: " & ax

end if

end if

end sub

mapxtreme c 實戰摘要 一

ppp80近日用了一下mapxtreme for net。雖然感覺沒有mapx的好用,不過這 個可以和.net結合,已經很滿足了。不過我的程式只用了一點點mapxtreme的 東西,所以發掘的東西很少,先記在下邊 1建立臨時層 mapinfo.data.tableinfomemtable tblin...

《Effective C 》重點摘要(四)

讓介面容易被正確使用,不易被誤用。乙個介面由返回型別 介面名稱 和引數列表組成,為了讓介面容易被正確的使用,需要小心設計返回型別,最好是簡單 直接 自然。介面名稱選擇很重要,做到簡單 達意 無歧義。引數列表形參型別需要身份小心,如果能防範非法輸入,盡力為之,形參名也盡可能做到同介面名稱一樣的標準。另...

AI實戰 文字自動摘要簡述

分為無監督和有監督。大部分都是基於的seq2seq框架 neural headline generation with minimum risk training attention model attention based summarization abs abs recurrent atte...