本文整理匯總了Python中simplekml.Kml.newmodel方法的典型用法代碼示例。如果您正苦於以下問題:Python Kml.newmodel方法的具體用法?Python Kml.newmodel怎麽用?Python Kml.newmodel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類simplekml.Kml
的用法示例。
在下文中一共展示了Kml.newmodel方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import newmodel [as 別名]
def main(input, output, ElRes, axes, nokeepfiles=True):
# Parse input file ##############################
data=parse_csv(input)
Ellipsoids={}
AxL={}
AxM={}
AxS={}
for i in range(len(data)):
# instantiate #####################################
Ellipsoids[i]=Icosahedron(ElRes,data['description'][i])
if axes:
AxL[i]=Axis(data['description'][i]+'_axisLong')
AxM[i]=Axis(data['description'][i]+'_axisMed')
AxM[i].rotate_about_zaxis(math.pi/2.) # get correct orientation
AxS[i]=Axis(data['description'][i]+'_axisShort')
AxS[i].rotate_about_yaxis(math.pi/2.) # get correct orientation
# re-shape ########################################
ax=([data['A'][i],data['B'][i],data['C'][i]])
ax.sort(key=float,reverse=True)
Ellipsoids[i].stretch(ax[0],ax[1],ax[2])
if axes:
AxL[i].stretch(ax[0],ax[0],ax[0])
AxM[i].stretch(ax[0],ax[1],ax[0]) # axis is in y-direction
AxS[i].stretch(ax[0],ax[0],ax[2]) # axis is in z-direction
#Define Rotations ################################
plunge=data['plunge'][i]*math.pi/180.
# trend and strike are modified to make them measured relative to North at 0 with clockwise positive
trend =math.pi/2.-data['trend'][i] *math.pi/180.
strike=math.pi/2.-data['strike'][i]*math.pi/180.
dip=data['dip'][i]*math.pi/180.
# gamma, third rotation about the ellipsoid long axis, is derived as below
gamma=-1*math.atan(-1*math.tan(dip)*math.cos(strike-trend))
# Rotate ellipsoid to match user-defined orientation
Ellipsoids[i].rotate_AlphaBetaGamma(plunge,trend,gamma)
if axes:
AxL[i].rotate_AlphaBetaGamma(plunge,trend,gamma)
AxM[i].rotate_AlphaBetaGamma(plunge,trend,gamma)
AxS[i].rotate_AlphaBetaGamma(plunge,trend,gamma)
# Rotate ellipsoid to match google-earth coordinates
Ellipsoids[i].rotate_eulerXY(math.pi,math.pi/2.)
if axes:
AxL[i].rotate_eulerXY(math.pi,math.pi/2.)
AxM[i].rotate_eulerXY(math.pi,math.pi/2.)
AxS[i].rotate_eulerXY(math.pi,math.pi/2.)
# Write .dae files ###############################
name='./'+Ellipsoids[i].name+'.dae'
c=colours(data['colour'][i])
t=(1.0)*data['transparency'][i].item()
write_collada_file(Ellipsoids[i].TP,
Ellipsoids[i].NP,
Ellipsoids[i].indices,
name,
c[0],c[1],c[2],t)
if axes:
write_collada_file(AxL[i].TP,
AxL[i].NP,
AxL[i].indices,
'./'+AxL[i].name+'.dae',
colours('black')[0],
colours('black')[1],
colours('black')[2],
0.0,
double_sided=True)
write_collada_file(AxM[i].TP,
AxM[i].NP,
AxM[i].indices,
'./'+AxM[i].name+'.dae',
colours('grey')[0],
colours('grey')[1],
colours('grey')[2],
0.0,
double_sided=True)
write_collada_file(AxS[i].TP,
AxS[i].NP,
AxS[i].indices,
'./'+AxS[i].name+'.dae',
colours('white')[0],
colours('white')[1],
colours('white')[2],
0.0,
double_sided=True)
# Create a KML document #########################
kml = Kml()
kml.document.name = "Ellipsoids"
for i in range(len(data)):
mod = kml.newmodel(altitudemode=AltitudeMode.relativetoground,
location='<longitude>'+repr(data['lon'][i])+'</longitude>'+
#.........這裏部分代碼省略.........