RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Python数据转换实现代码深入分析

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

为柯坪等地区用户提供了全套网页设计制作服务,及柯坪网站建设行业解决方案。主营业务为成都网站设计、成都网站制作、柯坪网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

学了几天的Python和FME Objects,发现之间教程里的很多对象已经过时了,而且语法和vb相差比较大,但概念还是一样的,下面写一段Python代码,将这几天学习的对象联系一下,下面的代码功能是读schema feature和data feature,并显示feature的属性和关联的坐标系,并使用FMEDialog对象来设置源和目标,并做格式转换,以下Python数据转换代码经过测试,运行正常。

 
 
 
  1. import pyfme 
  2. FME_GEOMETRY_TYPE={
  3. 0:"FME_GEOM_UNDEFINED",
  4. 1:"FME_GEOM_POINT",
  5. 2:"FME_GEOM_LINE",
  6. 4:"FME_GEOM_POLYGON",
  7. 8:"FME_GEOM_DONUT",
  8. 256:"FME_GEOM_PIP",
  9. 512:"FME_GEOM_AGGREGATE",
  10. } 
  11. session=pyfme.FMESession()
  12. dialog=session.createDialog() 
  13. pr=dialog.sourcePrompt("","")
  14. reader=pyfme.FMEReader(pr[0])
  15. reader.open(pr[1],pr[2]) 
  16. pw=dialog.destPrompt("","")
  17. writer=pyfme.FMEWriter(pw[0])
  18. writer.open(pw[1],pw[2]) 
  19. theend=True
  20. while theend:
  21. feature=pyfme.FMEFeature()
  22. theend=reader.readSchema(feature)
  23. if theend:
  24. print "\n------------%s----------" % "Schema Feature Infomation"
  25. print "Geometry Type: " + str(FME_GEOMETRY_TYPE
    [feature.getGeometryType()])
  26. print "Feature Type: " + str(feature.getFeatureType())
  27. print "CoordinateSystem Name: " + feature.getCoordinateSystem()
  28. csm=pyfme.FMECoordSysManager()
  29. csp=csm.getOGCCoordSys(feature.getCoordinateSystem())
  30. print "CoordinateSystem Information:\n%s\n" % csp
  31. writer.addSchema(feature) 
  32. theend=True
  33. while theend:
  34. feature=pyfme.FMEFeature()
  35. theend=reader.read(feature)
  36. if theend:
  37. print "\n------------%s----------\n" % "Data Feature Infomation"
  38. print "GeometryType: " + str(FME_GEOMETRY_TYPE
    [feature.getGeometryType()])
  39. print "FeatureType: " + str(feature.getFeatureType())
  40. print "CoordinateSystem: " + feature.getCoordinateSystem()
  41. print "CoordinateSystem List:\n%s\n" % feature.getCoordinates()
  42. writer.write(feature) 
  43. reader.close()
  44. writer.close()
  45. del reader
  46. del writer

Python数据转换运行环境 FME DESKTOP 2009 ,pyfme for Python 2.5,Python 2.5


网站题目:Python数据转换实现代码深入分析
本文来源:http://www.zcwtytd.com/article/djidcej.html