def init_gpx_import(self, gpx_path):
"""
Initializes the gpx import by setting the gpx path. This method must be
called outside the class to properly connect signals.
:param gpx_path: The gpx file path.
:type gpx_path: String
"""
# Open GPX file
if self._file_is_readable(gpx_path):
self.gpx_file_name = os.path.basename(gpx_path)
self.file_name = self.gpx_file_name.rstrip('.gpx')
self.gpx_path = gpx_path
self.gpx_util = GpxUtil(self.gpx_path)
data_source = ogr.Open(gpx_path)
if data_source is not None:
for feature_type in self.feature_types:
if STOP_IMPORT:
return
self.feature_type = feature_type.encode('utf-8')
self.ogr_layer = data_source.GetLayerByName(
self.feature_type
)
if self.ogr_layer.GetFeatureCount() > 0:
try:
self.gpx_to_point_list()
except Exception as ex:
self.error_type = ex
self.add_progress()
if STOP_IMPORT:
return
self.save_valid_folders()
self.save_invalid_folders()
评论列表
文章目录