Exemplo n.º 1
0
    def on_button_test_clicked(self, widget, data=None):
        #get content of textviews
        buff = self.ui.textview1.get_buffer()
        name = t.iterTextview(buff)
        buff2 = self.ui.textview2.get_buffer()
        #this is a global variable to call it global ;-) --> defined while initialization
        global proj
        proj = name = t.iterTextview(buff2)
        #That is the test - it's just the reprojection and if it doesn't work...the syntax is not right
        #Could be done better...but I only have 3 weeks...and I will do it later
        try:
            #just a test but not a good one...should be replaced later
            dict1 = t.readProj('./data/media', 'projections.txt')
            command = 'ogr2ogr -f \'ESRI Shapefile\' ./data/media/cache/syntaxtest ./data/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure'
        except:
            home = os.getenv("HOME")
            folder = home + '/maproj/media'
            command = 'ogr2ogr -f \'ESRI Shapefile\' ' + folder + '/cache/syntaxtest /usr/share/maproj/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure'

        tester = os.system(command)  #--> Failure = 256
        #just do when the test gave 0 --> means everything was done well
        if tester == 256:
            self.ui.label_status.set_text('Sorry...thats not right!')
        elif tester == 0:
            self.ui.label_status.set_text('Yes...thats the right Syntax!')
            global setted
            setted = True
            #the OK-button shows no text after initialiation
            #best would be if it doesn't react also but I don't know how to do that...not now!!!
            self.ui.btn_ok.set_label('Add')
        else:
            self.ui.label_status.set_text('Unknown error!')
Exemplo n.º 2
0
    def on_btn_ok_clicked(self, widget, data=None):
        """The user has elected to save the changes.

        Called before the dialog returns Gtk.ResponseType.OK from run().
        """
        if setted == True:
            #Read the textview and add text to the dictionary
            buff = self.ui.textview1.get_buffer()
            name = t.iterTextview(buff)
            buff2 = self.ui.textview2.get_buffer()
            global proj
            proj = t.iterTextview(buff2)
            #Append the new projection to the file, containing all projections
            #Therefore the file is opened with "a"
            try:
                wobj = open('./data/media/projections.txt', "a")
            except:
                home = os.getenv("HOME")
                wobj = open(home + '/maproj/media/projections.txt', "a")
                wobj.write(name + ' : ' + proj + '\n')
                wobj.close()

        pass