对于大多数开发人员来说,掌握Python这一编程语言其实是比较容易的,虽然其中有很多不同于其他语言的使用方法,但是其应用方便简单的特点使其在开发领域中占据主要地位。在这里我们就可以先从Python数据转换的实现方法来看看这一语言的具体编写方式。

为柯坪等地区用户提供了全套网页设计制作服务,及柯坪网站建设行业解决方案。主营业务为成都网站设计、成都网站制作、柯坪网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
学了几天的Python和FME Objects,发现之间教程里的很多对象已经过时了,而且语法和vb相差比较大,但概念还是一样的,下面写一段Python代码,将这几天学习的对象联系一下,下面的代码功能是读schema feature和data feature,并显示feature的属性和关联的坐标系,并使用FMEDialog对象来设置源和目标,并做格式转换,以下Python数据转换代码经过测试,运行正常。
- 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数据转换运行环境 FME DESKTOP 2009 ,pyfme for Python 2.5,Python 2.5
                网页标题:Python数据转换实现代码深入分析
                
                新闻来源:http://www.csdahua.cn/qtweb/news34/77134.html
            
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网