Esempio n. 1
0
    def _getStringList (self, thisTile):

        '''
        Search for lines in the file that are in Tile thisTile
        return a list of those matched lines.
        '''

        lstLines = []

        try:

           fs = open ( self.filePath, 'r' )

           if (self.hasHeader): 
               fs.readline ()

           allLines = fs.readlines ()

           for thisLine in allLines:

#               print thisLine

               cols = thisLine.split ("|")
               centroidWKT= cols [8]

               # centroidWKT is like "POINT (0.2343 0.2332432)"
               tmpList = centroidWKT.replace ('POINT(','' ).replace ( ')','' ).split (" ")
               X     = float (tmpList[0] )
               Y     = float (tmpList[1] )

               # Find the integer "floor" value of x & y co-ordinates
               xVal = int (math.floor ( X ) )
               yVal = int (math.floor ( Y ) )

               if ( Tile ( xVal , yVal ) == thisTile  ):
                   lstLines.append ( thisLine )

           fs.close ()

        except IOError as e:
            import traceback, utils
            utils.logError ( traceback.format_exc() )
            raise AppError (utils.timestampStr (), 'FileDataStore', 'open/read file',   e )
 
        return lstLines