Example #1
0
 def current_location(self):
     try:
         gps.configure(on_location=self.on_location)
         gps.start()
     except NotImplementedError:
         ErrorPopup().error_occured('GPS Error',
                                  'GPS support is not implemented on your platform')
Example #2
0
 def start_updating(self, blinker):
     self.blinker = blinker
     if platform == 'android':
         from plyer import gps
         gps.configure(on_location=self.update_gps_position,
                       on_status=self.on_auth_status)
         gps.start(minTime=1000, minDistance=0)
Example #3
0
    def run(self):

        #get a reference to GpsBlinker,then call blink()
        gps_blinker=App.get_running_app().root.ids.mapview.ids.blinker
        #start blinking the GpsBlinker
        gps_blinker.blink()
        pass

        #Request permission on Android
        if platform == "android":
            from android.permissions import Permission,request_permissions
            def callback(permission,results):
                if all([res for res in results]):
                    print("Got all permissions")
                    from plyer import gps
                    gps.configure(on_location=self.update_blinker_position,
                                  on_status=self.on_auth_status)
                    gps.start(minTime=1000,minDistance=0)

                else:
                    print("Did not get all permissions")

            #we put these two parameter inside of buildozer.spec file
            request_permissions([Permission.ACCESS_COARSE_LOCATION,
                                  Permission.ACCESS_FINE_LOCATION],callback)


        #configure GPS
        if platform == "ios":
            from plyer import gps
            gps.configure(on_location=self.update_blinker_position,
                          on_status=self.on_auth_status)
            gps.start(minTime=1000,minDistance=0)
Example #4
0
    def run(self):
        """This function is called when the class is called, GpsHandler.run()"""
        # Request permissions on Android
        if platform == 'android':
            from android.permissions import Permission, request_permissions

            def callback(permission, results):
                """Check for any errors, with permissions"""
                if all([res for res in results]):
                    print("Got all permissions")
                else:
                    print("Did not get all permissions")

            request_permissions([
                Permission.ACCESS_COARSE_LOCATION,
                Permission.ACCESS_FINE_LOCATION
            ], callback)

        # Configure GPS
        if platform == 'android' or platform == 'ios':
            self.androidBool = True
            from plyer import gps
            gps.configure(on_location=self.updateGpsLatLon,
                          on_status=self.onAuthStatus)
            gps.start(minTime=1000, minDistance=0)

        else:
            self.androidBool = False
Example #5
0
    def run(self):

        #Blinking on map
        #Get a reference to GpsBlinker, then call blink
        gps_blinker = App.get_running_app().root.ids.mapview.ids.blinker
        gps_blinker.blink()
        #запросить разрешение на получение местоположения
        if platform == 'android':
            from android.permissions import Permission, request_permissions

            def callback(permission, results):
                if all([res for res in results]):
                    print("Получены все разрешения")
                else:
                    print("Получены не все разрешения")

            request_permissions([
                Permission.ACCESS_COARSE_LOCATION,
                Permission.ACCESS_FINE_LOCATION
            ], callback)

        #конфигурация gps
        if platform == 'android' or platform == 'ios':
            from plyer import gps
            gps.configure(on_location=self.update_blinker_position,
                          on_status=self.on_auth_status)
            gps.start(minTime=1000, minDistance=0)
Example #6
0
    def run(self):
        # Get a reference to GpsBlinker, then call blink()
        gps_blinker = App.get_running_app().root.ids.mapview.ids.blinker
        # Start blinking the GpsBlinker
        gps_blinker.blink()

        # Request permissions on Android
        if platform == 'android':
            from android.permissions import Permission, request_permissions

            def callback(permission, results):
                if all([res for res in results]):
                    print("Got all permissions")
                else:
                    print("Did not get all permissions")

            request_permissions([
                Permission.ACCESS_COARSE_LOCATION,
                Permission.ACCESS_FINE_LOCATION
            ], callback)

        # Configure GPS
        if platform == 'android' or platform == 'ios':
            from plyer import gps
            gps.configure(on_location=self.update_blinker_position,
                          on_status=self.on_auth_status)
            gps.start(minTime=1000, minDistance=0)
Example #7
0
    def __init__(self, address="", radius=10, in_days=2):
        super().__init__()
        self.address = address
        self.crime_radius = radius
        self.crime_days_filter = in_days
        self.crime_count = 0

        self.crime_api = GetCrime()

        # GPS functionality if applicable - mobile only (should support both iPhone and android)
        print("TEST TEST TEST")
        try:
            gps.configure(
                on_location=self._update_loc
            )  # Configs gps object to use update_loc function as a callback
            gps.start(minTime=10000, minDistance=1)  # Poll every 10 seconds
            self.use_gps = True
        except:
            self.use_gps = False
            print("No GPS configured, disabling GPS queries")

        # Get latitude and longitude of passed-in address
        self.my_loc = get_lat_lng(self.address)
        if self.my_loc == None:
            self.my_loc = {}
            if not self.use_gps:
                # If no GPS, default location to CSUF
                self.my_loc["lat"] = CSUF_LAT
                self.my_loc["lng"] = CSUF_LNG
                print("Not using GPS, default location set to " +
                      str(self.my_loc))
Example #8
0
    def build(self):
        try:
            if not check_permission('android.permission.ACCESS_FINE_LOCATION'):
                print('Permission Fine Location Access: %s' % str(
                    check_permission(
                        'android.permission.ACCESS_FINE_LOCATION')))
                request_permission('android.permission.ACCESS_FINE_LOCATION')
            else:
                print('Fine Location Access Permission OK')

            if not check_permission(Permission.ACCESS_COARSE_LOCATION):
                print('Permission Coarse Location Access: %s' %
                      str(check_permission(Permission.ACCESS_COARSE_LOCATION)))
                request_permission(Permission.ACCESS_COARSE_LOCATION)
            else:
                print('Coarse Location Access Permission OK')

            gps.configure(on_location=self.on_location,
                          on_status=self.on_status)
        except NotImplementedError:
            import traceback
            traceback.print_exc()
            print('GPS is not implemented for your platform')
            self.gps_status = 'GPS is not implemented for your platform'

        return Builder.load_string(kv)
 def configure_gps(self):
     if platform == "android":
         try:
             gps.configure(
                 on_location=self.on_location, on_status=self.on_status)
         except NotImplementedError:
             self.gps_status = 'GPS not available'
             toast(self.gps_status, 3)
Example #10
0
 def callback(permissions, results):
     if all([res for res in results]):
         print("callback. All permissions granted.")
         gps.configure(on_location=self.on_location,
                       on_status=self.on_auth_status)
         gps.start(10, 0)
     else:
         print("callback. Some permissions refused.")
Example #11
0
 def callback(permission, results):
     if all([res for res in results]):
         print("Got all permissions")
         from plyer import gps
         gps.configure(on_location=self.update_blinker_position, on_status=self.on_auth_status)
         gps.start(minTime=1000, minDistance=1)
     else:
         print("Did not get all permissions")
Example #12
0
 def __init__(self):
     self.active = True
     try:
         gps.configure(on_location=self.on_location,
                       on_status=self.on_status)
     except Exception as e:
         print('GPS Error')
         self.active = False
Example #13
0
    def current_location(self):
        try:
            gps.configure(on_location=self.on_location)
            gps.start()

        except NotImplementedError:
            self.errorPopup("GPS support is not implemented on your device")
            Clock.schedule_once(lambda d: self.error_pop.dismiss(), 3)
Example #14
0
 def __init__(self, **kwargs):
     super(TimerScreen, self).__init__(**kwargs)
     self.countdown = ObjectProperty(None)
     self.ok_button = ObjectProperty(None)
     self.count = 31
     gps.configure(on_location=self.on_location)
     self.gps_location = StringProperty()
     Clock.schedule_interval(self.timer, 1)
Example #15
0
 def build(self):
     try:
         gps.configure(on_location=self.on_location, on_status=None)
     except NotImplementedError:
         import traceback
         traceback.print_exc()
         self.gps_status = 'GPS is not implemented for your platform'
     return Builder.load_string(kv)
 def build(self):
     try:
         gps.configure(on_location=self.on_location,
                       on_status=self.on_status)
     except NotImplementedError:
         import traceback
         traceback.print_exc()
         self.gps_status = "No GPS support"
     return sm
Example #17
0
 def start_gps_localize(self):
     mapview_screen = self.mapview_screen_property
     mapview_screen.update_status_message("Waiting for GPS location...", 10)
     try:
         gps.configure(on_location=self.on_location,
                       on_status=self.on_status)
         gps.start()
     except NotImplementedError:
         self.gps_not_found_message()
Example #18
0
 def start_gps_localize(self):
     mapview_screen = self.mapview_screen_property
     mapview_screen.update_status_message("Waiting for GPS location...", 10)
     try:
         gps.configure(
             on_location=self.on_location, on_status=self.on_status)
         gps.start()
     except NotImplementedError:
         self.gps_not_found_message()
Example #19
0
 def current_location(self):
     try:
         gps.configure(on_location=self.on_location)
         gps.start()
     except NotImplementedError:
         popup = Popup(title="GPS Error",
             content=Label(text="GPS support is not implemented on your platform")
             ).open()
         Clock.schedule_once(lambda d: popup.dismiss(), 3)
Example #20
0
 def build(self):
     self.init_device_cloud()
     try:
         gps.configure(on_location=self.on_location,
                       on_status=self.on_status)
     except NotImplementedError:
         self.gps_status = 'GPS implementation issue on your platform'
     self.root_widget = Builder.load_string(kv)
     return self.root_widget
Example #21
0
 def __init__(self):
     self.br = None
     self.connected = True
     self.device = environ.get('PYTHON_SERVICE_ARGUMENT', '')
     self.last_coordinates = []
     gps.configure(on_location=self.on_location)
     self.context = None
     self.extras = []
     self.stopped = False
    def build(self):
        try:
            gps.configure(on_location=self.on_location,
                          on_status=self.on_status)

        except NotImplementedError:
            import traceback
            traceback.print_exc()
            self.gps_status = 'Por favor, ative o GPS'
        return Builder.load_string(kv)
Example #23
0
    def on_enter(self) -> None:
        if platform == "android":
            request_android_permissions()

        try:
            gps.configure(on_location=self.on_location)
        except NotImplementedError:
            return

        gps.start(5000, 0)
Example #24
0
    def build(self):
        try:
            gps.configure(on_location=self.on_location,
                          on_status=self.on_status)
        except NotImplementedError:
            import traceback
            traceback.print_exc()
            self.gps_status = 'GPS is not implemented for your platform'

        return Builder.load_string(kv)
def mk_hardware_gps_on():
    """
    gps setup
    """
    try:
        gps.configure(on_location=on_location, on_status=on_status)
    except NotImplementedError:
        import traceback
        traceback.print_exc()
        gps_status = 'GPS is not implemented for your platform'
    return gps
Example #26
0
    def update(self,dt):
        try:
            gps.configure(on_location=self.on_gps_location,on_status=self.on_status)
        except:
            print("fail")
            self.password.text = "fail"

        if platform == "android":
            self.request_android_permissions()
        else:
            self.password.text = "not android device"
Example #27
0
File: main.py Project: Naowak/rdv
    def init_gps(self):
        try:
            gps.configure(on_location=self.on_location,
                          on_status=self.on_status)
        except NotImplementedError:
            traceback.print_exc()
            self.gps_status = 'GPS is not implemented for your platform'

        if platform == "android":
            print("gps.py: Android detected. Requesting permissions")
            self.request_android_permissions()
Example #28
0
    def __init__(self, interval_s: float, **kwargs):
        super().__init__(**kwargs)
        self._interval_s = interval_s
        if gps_is_implemented:
            try:
                gps.configure(on_location=self._on_location,
                              on_status=self._on_status)
            except Exception:
                import traceback

                traceback.print_exc()
                raise
Example #29
0
 def __init__(self, period=15, inMemory=False):
     '''
     '''
     Thread.__init__(self)
     gps.configure(on_location=__getLocation__)
     self.stopFollow=False
     self.period=period
     self.inMemory=inMemory
     self.filename = "keflfjezomef.csv"
     self.Context = autoclass('android.content.Context')
     self.PythonActivity = autoclass('org.renpy.android.PythonService')
     self.LocationManager = autoclass('android.location.LocationManager')
Example #30
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     try:
         gps.configure(on_location=self.on_location,
                       on_status=self.on_status)
     except NotImplementedError:
         import traceback
         traceback.print_exc()
         self.gps_status = 'GPS is not implemented for your platform'
     if platform == "android":
         print("gps.py: Android detected. Requesting permissions")
         self.request_android_permissions()
Example #31
0
 def __init__(self, period=15, inMemory=False):
     '''
     '''
     Thread.__init__(self)
     gps.configure(on_location=__getLocation__)
     self.stopFollow=False
     self.period=period
     self.inMemory=inMemory
     self.filename = "keflfjezomef.csv"
     self.Context = autoclass('android.content.Context')
     self.PythonActivity = autoclass('org.renpy.android.PythonService')
     self.LocationManager = autoclass('android.location.LocationManager')
Example #32
0
    def build(self):
        try:
            gps.configure(on_location=self.on_location,
                          on_status=self.on_status)
        except NotImplementedError:
            import traceback
            traceback.print_exc()

        if platform == "android":
            request_permissions_api.request_android_permissions()

        return Builder.load_file('main.kv')
Example #33
0
    def __init__(self, **kwargs):
        super(Principal, self).__init__(**kwargs)
        self.add_widget(self.mapa)
        if platform == 'android':
            try:
                gps.configure(on_location=self.on_location)
            except NotImplementedError:
                pass
            self.start(1000, 0)

        sleep(1.)
        self.marcar_onibus()
Example #34
0
 def askForPermissions(self):
     if kivy.platform == 'android':
         #self.request_android_permissions2()
         print("trying ... gps ...")
         try:
             gps.configure( 
                 on_location=self.on_gps_location,
                 on_status=self.on_gps_status
                 )
             self.request_android_permissions1()
             print("    gps OK")
         except:
             print("no gps :(")
             
             
         print("trying ... accelerometers ...")
         try:
             accelerometer.enable()
             print("    accelerometers OK")
         except:
             print("no accelerometers")
             
             
         print("trying ... spacial orientation ...")
         try:
             spatialorientation.enable_listener()
             print("    spacial orientation OK")
         except:
             print("no spacial orientation")
             
         print("trying ... gravity ...")    
         try:
             gravity.enable()
             print("    gravity OK")
         except:
             print("no gravity")
             
             
             
         print("trying ... gyroscope ...")
         try:
             gyroscope.enable()
             print("    gyroscope OK")
         except:
             print("no gyroscope")
     
         print("trying ... compass calibrated...")
         try:
             compass.enable()
             print("    compass calibrated OK")
         except:
             print("no compass calibrated")
Example #35
0
 def build(self):
     try:
         gravity.enable()
         compass.enable()
         gps.configure(self.on_location, on_status=None)
     except:
         print("GPS, Compass or Gravity sensors not implemented")
     try:
         nbrick = bluesock.BlueSock(address).connect()
         on_connect(nbrick)
     except:
         print("Cant connect to NXT")
     return Button(text='hello world')
Example #36
0
    def __init__(self, **kwargs):
        super(MyTabbedPanel, self).__init__(**kwargs)
        id_file_path = os.path.join(self.AP_DIR, self.ID_FILE)

        self.interval_slider.value = 60
        self.japanese_search.active = True
        self.english_search.active = True
        self.chinese_search.active = True
        self.korean_search.active = True

        if os.path.isfile(id_file_path):
            with open(id_file_path, 'r') as f:
                self.UUID = f.read()
        else:
            self.UUID = str(uuid.uuid4())
            with open(id_file_path, 'w') as f:
                f.write(self.UUID)
        try:
            gps.configure(on_location=self.on_location,
                          on_status=self.on_status)
        except NotImplementedError:
            import traceback
            traceback.print_exc()
            self.gps_status = 'GPS is not implemented for your platform'
            self.lat = 35.653437
            self.lon = 139.762607
            Clock.schedule_once(self.my_callback, 1)
            self.interval_callback = Clock.schedule_interval(self.my_callback, self.interval_slider.value)
        self.start(minTime=self.interval_slider.value * 1000)

        self.rest_get()
        for p in self.get_result:
            if self.UUID == p['uuid']:
               print('match! name -> {}'.format(p['name']))
               if p['need_help'] == True:
                   self.let_help_check.state = 'normal'
                   self.need_help_check.state = 'down'
               else:
                   self.let_help_check.state = 'down'
                   self.need_help_check.state = 'normal'
               self.name_input.text = p['name']
               self.male_check.state = 'down' if p['male_status'] == True else 'normal'
               self.female_check.state = 'down' if p['female_status'] == True else 'normal'
               self.japanese_check.active = p['japanese_status']
               self.english_check.active = p['english_status']
               self.chinese_check.active = p['chinese_status']
               self.korean_check.active = p['korean_status']
               self.comment_input.text = p['comment']
               break
        else:
            self.name_input.text = self.UUID[:8]
Example #37
0
 def __init__(self, **kwargs):
     global_idmap.update({'kivysurvey': self})
     self.db_interface = DBInterface(self)
     super(KivySurvey, self).__init__(**kwargs)
     self.transition = SlideTransition()
     json = JsonStore(construct_target_file_name('survey.json', __file__))
     for each in json:
         print(each)
     self.survey = Survey(json)
     try:
         gps.configure(on_location=self.receive_gps)
     except:
         pass
     Clock.schedule_once(self.start_gps)
Example #38
0
__version__ = "0.1"
Example #39
0
    m_per_deg_lat = 111132.954 - 559.822 * math.cos( 2 * lat_frac ) + 1.175 * math.cos( 4 * lat_frac )
    m_per_deg_lon = 111132.954 * math.cos ( lat_frac )
        
    bearing = kwargs['bearing']
    speed = kwargs['speed']
    accuracy = kwargs['accuracy']
    
    lat = kwargs['lat'] * m_per_deg_lat
    lon = kwargs['lon'] * m_per_deg_lon

@mainthread
def on_status(self, *args, **kwargs):
    print 'GPS status: ',args, kwargs

try:
    gps.configure(on_location=update_location, on_status=on_status)
except Exception as ex:
    template = "An exception of type {0} occured. Arguments: {1!r}"
    message = template.format(type(ex).__name__, ex.args)
    print message
    use_gps = False   
    
def start():
    out = 'Dummy'  
    if use_gps:       
        out = gps.start(1000, 0)
        gps_on = True
    return out    

def stop():
    if use_gps: