JorgeDeJesus

Untitled

Sep 10th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. # 46,102,47,103,urn:ogc:def:crs:EPSG:6.6:4326,2
  2.  
  3. #    LOGIC TREE:
  4. #        1) Do we have an URI (something with ':' )
  5. #            YES:
  6. #                Get URI set to CRS
  7. #                Is there a number in interval [1-4] after ?
  8. #                YES:
  9. #                    number is dimension
  10. #                NO:
  11. #                    pass
  12. #            NO:
  13. #                Assume EPSG:4326
  14. #            Pop CRS/Dimension
  15. #        2) Number of numbers remaining
  16. #            split into 2 (lower and upper conner)
  17. #            Is dimension set:
  18. #            YES:
  19. #                pass
  20. #            NO:
  21. #                Get number of dimensions from len/2    
  22. #            
  23.    
  24. testStr="46,102,47,56,urn:ogc:def:crs:EPSG:6.6:4326,2"
  25. testList=testStr.split(",")
  26. crsStr=None
  27. dimensions=None
  28. crsIndex=[idx for idx,item in enumerate(testList) if ':' in item]
  29. if len(crsIndex)>0:
  30.     crsStr=testList[crsIndex[0]]
  31.     #is there something after crs
  32.     try:
  33.         dimensions=int(testList[crsIndex[0]+1])
  34.     except:
  35.         pass #try to get dimension from the rest string
  36.     #remove CRS and DIM
  37.     testList=testList[:crsIndex[0]]
  38. else:
  39.     crsStr="EPSG:4326"
  40. if type(dimensions) is type(None):
  41.     dimensions=int(len(testList)/2)
  42.  
  43. lowerList=testList[:dimensions]
  44. upperList=testList[dimensions:]
  45.  
  46. print lowerList
  47. print upperList
  48. print crsStr
  49. print dimensions
Advertisement
Add Comment
Please, Sign In to add comment