Exemple #1
0
    def loadcsvpolygonCMD(self, _fullfilepath=''):
        """
        Public method
        For CMD mode only
        1. Check if a file path is given, if not, call private method to allow user to select file
        2. Call private method to read in the file and process into list of Points
        3. Return the list of points as a Polygon
        :param _fullfilepath:
        :return:
        """
        while (os.path.exists(_fullfilepath) == False):
            print "Invalid polygon file in argument: " + _fullfilepath              #Ask until a valid file path available
            _fullfilepath = raw_input("Please enter the correct polygon file path:")



        pointlist, status = self.__read_csv_data(_fullfilepath)          #Read the contents
        if (status!=-1):
            loadedPolygon=Geom.Polygon(pointlist)           #If ok, load the points into Polygon class
        return loadedPolygon, _fullfilepath,status
Exemple #2
0
 def loadcsvpolygonUI(self, _fullfilepath=''):
     """
     Public method
     For GUI mode only
     1. Check if a file path is given, if not, call private method to allow user to select file
     2. Call private method to read in the file and process into list of Points
     3. Return the list of points as a Polygon
     :param _fullfilepath:
     :return:
     """
     loadedPolygon=''
     if _fullfilepath=='':
         _fullfilepath=self.__get_csv_filepath()       #If filepath is empty, request for it
     elif(os.path.exists(_fullfilepath)==False):
         self.log.error("Invalid file: " + _fullfilepath)          #If path is invalid, request again
         _fullfilepath = self.__get_csv_filepath()
     # else:
     #     self.__filepath=_fullfilepath
     pointlist, status=self.__read_csv_data(_fullfilepath)            #Read the content
     if (status!=-1):
         loadedPolygon=Geom.Polygon(pointlist)           #If content ok, save the results as Polygon class
     return loadedPolygon, _fullfilepath,status