資源簡(jiǎn)介
arcgis實(shí)現(xiàn)對(duì)面數(shù)據(jù)中圖形的夾角小于指定的多邊形進(jìn)行檢查,輸入的角度單位度。

代碼片段和文件信息
#??在使用過(guò)程中如有疑問(wèn)請(qǐng)發(fā)郵件至ryx_32@126.com聲明:該軟件僅限中測(cè)新圖內(nèi)部使用,請(qǐng)勿用于商業(yè)用途,否則后果自負(fù)!?。?br/>#?---------------------------------------------------------------------------
class?Feature_No():
????
????pass
import?sys?string?osmath?arcgisscripting
gp?=?arcgisscripting.create(9.3)
gp.SetProduct(“ArcInfo“)
input_poly?=?gp.GetParameterAsText(0)
angle_min?=?long(gp.GetParameterAsText(1))
try:
????gp.Addmessage(“***********************************************“)
????
????gp.AddMessage(“本工具由中測(cè)新圖(北京)遙感技術(shù)有限責(zé)任公司?任延旭編制“)
????gp.AddMessage(“使用前請(qǐng)做好數(shù)據(jù)備份,工具產(chǎn)生的不良后果請(qǐng)自行承擔(dān)!“)
????gp.Addmessage(“***********************************************“)
????result?=?gp.GetCount_management(input_poly?)
??
????count_n?=?int(result.GetOutput(0))
????if?count_n?<=?0:
????????raise?Feature_No
????str_Err?=?““
????if?len(gp.ListFields(input_poly“Angle_chk“))?<=0:
????????gp.AddField_management(input_poly?“Angle_chk“?“TEXT“?““?““?255)
????str_Err?=?““
????cur?=?gp.UpdateCursor(input_poly““““““““)
????
????row?=?cur.next()
????gp.SetProgressor(“step“?“正在檢查圖形銳角...“?0count_n?1)
????
????angle_rj?=?0
????angle_cf?=?0
????num?=?0
????
????while?row:
????????
????????num?+=?1
????????gp.SetProgressorLabel(“共有“?+str(count_n)+“個(gè)圖形正在檢查第“?+?str(num)?+?“個(gè)圖形的夾角還剩余“+str(count_n-num+1)+“個(gè)請(qǐng)稍候...“)?
????????
????????shapeName?=?gp.Describe(input_poly).shapeFieldName
????
????????geom?=?row.getValue(shapeName)
????????part_count?=?geom.partCount
????????count?=?0
?????
????????while?count?
????????????p?=?geom.getPart(count)
????????????p_b?=?p.next()
????????????
????????????p_S?=?p_b
????????????
????????????p1?=?p_b
????????????
????????????p2?=?p.next()
????????????
????????????p3?=?p.next()
????????????
????????????p_2?=?p2
????????????while?p3:
????????????????x1?=?round(p1.X3)
????????????????y1?=?round(p1.Y3)
????????????????x2?=?round(p2.X3)
????????????????y2?=?round(p2.Y3)
????????????????x3?=?round(p3.X3)
????????????????y3?=?round(p3.Y3)
????????????????if?(math.fabs(x1-x2)<0.5?and?math.fabs(x2-x3)<0.5)?or?(math.fabs(y1-y2)<0.5?and?math.fabs(y2-y3)<0.5):
????????????????????jiao?=?-1
????????????????else:
????????????????
????????????????????l1?=?math.sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3))
????????????????????l2?=?math.sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3))
????????????????????l3?=?math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
????????????????????if?l1==0?or?l2==0?or?l3==0:
????????????????????????angle_cf?+=?1
????????????????????else:
????????????????????????
????????????????????????cj?=?(l1*l1+l3*l3-l2*l2)/(2*l1*l3)
????????????????????????jiao?=?math.cos(angle_min*3.1415926/180)
????????????????????????
????????????????????????if?cj?>=?jiao:
????????????????????????????
????????????????????????????angle_rj?+=?1
????????????????p1?=?p2
????????????????
????????????????p2?=?p3
????????????????
???????????
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????6656??2012-11-05?10:27??銳角檢查工具.tbx
?????文件?????536604??2012-11-06?15:19??使用說(shuō)明.pdf
?????文件???????5596??2012-11-06?16:50??jianjiao_check.py
-----------?---------??----------?-----??----
???????????????548856????????????????????3
評(píng)論
共有 條評(píng)論