新聞中心
對于大多數(shù)開發(fā)人員來說,掌握Python這一編程語言其實是比較容易的,雖然其中有很多不同于其他語言的使用方法,但是其應(yīng)用方便簡單的特點使其在開發(fā)領(lǐng)域中占據(jù)主要地位。在這里我們就可以先從Python數(shù)據(jù)轉(zhuǎn)換的實現(xiàn)方法來看看這一語言的具體編寫方式。

為柯坪等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及柯坪網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站設(shè)計、成都網(wǎng)站制作、柯坪網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
學(xué)了幾天的Python和FME Objects,發(fā)現(xiàn)之間教程里的很多對象已經(jīng)過時了,而且語法和vb相差比較大,但概念還是一樣的,下面寫一段Python代碼,將這幾天學(xué)習(xí)的對象聯(lián)系一下,下面的代碼功能是讀schema feature和data feature,并顯示feature的屬性和關(guān)聯(lián)的坐標(biāo)系,并使用FMEDialog對象來設(shè)置源和目標(biāo),并做格式轉(zhuǎn)換,以下Python數(shù)據(jù)轉(zhuǎn)換代碼經(jīng)過測試,運行正常。
- import pyfme
- FME_GEOMETRY_TYPE={
- 0:"FME_GEOM_UNDEFINED",
- 1:"FME_GEOM_POINT",
- 2:"FME_GEOM_LINE",
- 4:"FME_GEOM_POLYGON",
- 8:"FME_GEOM_DONUT",
- 256:"FME_GEOM_PIP",
- 512:"FME_GEOM_AGGREGATE",
- }
- session=pyfme.FMESession()
- dialog=session.createDialog()
- pr=dialog.sourcePrompt("","")
- reader=pyfme.FMEReader(pr[0])
- reader.open(pr[1],pr[2])
- pw=dialog.destPrompt("","")
- writer=pyfme.FMEWriter(pw[0])
- writer.open(pw[1],pw[2])
- theend=True
- while theend:
- feature=pyfme.FMEFeature()
- theend=reader.readSchema(feature)
- if theend:
- print "\n------------%s----------" % "Schema Feature Infomation"
- print "Geometry Type: " + str(FME_GEOMETRY_TYPE
[feature.getGeometryType()])- print "Feature Type: " + str(feature.getFeatureType())
- print "CoordinateSystem Name: " + feature.getCoordinateSystem()
- csm=pyfme.FMECoordSysManager()
- csp=csm.getOGCCoordSys(feature.getCoordinateSystem())
- print "CoordinateSystem Information:\n%s\n" % csp
- writer.addSchema(feature)
- theend=True
- while theend:
- feature=pyfme.FMEFeature()
- theend=reader.read(feature)
- if theend:
- print "\n------------%s----------\n" % "Data Feature Infomation"
- print "GeometryType: " + str(FME_GEOMETRY_TYPE
[feature.getGeometryType()])- print "FeatureType: " + str(feature.getFeatureType())
- print "CoordinateSystem: " + feature.getCoordinateSystem()
- print "CoordinateSystem List:\n%s\n" % feature.getCoordinates()
- writer.write(feature)
- reader.close()
- writer.close()
- del reader
- del writer
Python數(shù)據(jù)轉(zhuǎn)換運行環(huán)境 FME DESKTOP 2009 ,pyfme for Python 2.5,Python 2.5
分享名稱:Python數(shù)據(jù)轉(zhuǎn)換實現(xiàn)代碼深入分析
網(wǎng)頁URL:http://fisionsoft.com.cn/article/djidcej.html


咨詢
建站咨詢
