예제 #1
0
파일: gui_qt5.py 프로젝트: dikonov/modrana
 def store_poi(self, point_dict):
     success = False
     db = self.gui.modules.storePOI.db
     name = point_dict.get("name")
     description = point_dict.get("description", "")
     lat = point_dict.get("lat")
     lon = point_dict.get("lon")
     category_id = point_dict.get("category_id")
     # make sure lat & lon is a floating point number
     try:
         lat = float(lat)
         lon = float(lon)
     except Exception:
         self.gui.log.exception("can't save POI: lat or lon not float")
     # default to "Other" if no category is provided
     if category_id is None:
         category_id = 11  # TODO: this should ge dynamically queried from the database
     # sanity check
     if name and lon is not None and lat is not None:
         poi = point.POI(name=name,
                         description=description,
                         lat=lat,
                         lon=lon,
                         db_cat_id=category_id)
         self.gui.log.info("saving POI: %s", poi)
         db.store_poi(poi)
         self.gui.log.info("POI saved")
         success = True
     else:
         self.gui.log.error(
             "cant's save poi, missing name or coordinates: %s", point_dict)
     return success
예제 #2
0
 def get_all_poi_from_category(self, category_id):
     db = self.gui.modules.storePOI.db
     poi_list = []
     for poi_tuple in db.get_all_poi_from_category(category_id):
         # TODO: to this already in poi_db
         (name, desc, lat, lon, poi_id) = poi_tuple
         poi_dict = point2dict(
             point.POI(name, desc, lat, lon, category_id, poi_id))
         poi_list.append(poi_dict)
     return poi_list