MCPcopy Index your code
hub / github.com/WebODM/WebODM / update_georef_fields

Method update_georef_fields

app/models/task.py:1236–1280  ·  view source on GitHub ↗

Updates the epsg and wkt field with the correct values :param commit: when True also saves the model, otherwise the user should manually call save()

(self, commit=False)

Source from the content-addressed store, hash-verified

1234
1235
1236 def update_georef_fields(self, commit=False):
1237 """
1238 Updates the epsg and wkt field with the correct values
1239 :param commit: when True also saves the model, otherwise the user should manually call save()
1240 """
1241 epsg = None
1242 wkt = None
1243
1244 for asset in ['orthophoto.tif', 'dsm.tif', 'dtm.tif']:
1245 asset_path = self.assets_path(self.ASSETS_MAP[asset])
1246 if os.path.isfile(asset_path):
1247 try:
1248 with rasterio.open(asset_path) as f:
1249 if f.crs is not None:
1250 code = f.crs.to_epsg()
1251 if code is not None:
1252 epsg = code
1253 break # We assume all assets are in the same CRS
1254 else:
1255 # Try to get code from WKT
1256 wkt = f.crs.to_wkt()
1257 if wkt is not None:
1258 code = epsg_from_wkt(wkt)
1259 if code is not None:
1260 epsg = code
1261 break
1262 except Exception as e:
1263 logger.warning(e)
1264
1265 # If point cloud is not georeferenced, dataset is not georeferenced
1266 # (2D assets might be using pseudo-georeferencing)
1267 point_cloud = self.assets_path(self.ASSETS_MAP['georeferenced_model.laz'])
1268 if (epsg is not None or wkt is not None) and os.path.isfile(point_cloud):
1269 if not is_pointcloud_georeferenced(point_cloud):
1270 logger.info("{} is not georeferenced".format(self))
1271 epsg = None
1272 wkt = None
1273
1274 self.epsg = epsg
1275 if epsg is None:
1276 self.wkt = wkt
1277 else:
1278 self.wkt = None # Only save one or the other
1279
1280 if commit: self.save()
1281
1282
1283 def update_orthophoto_bands_field(self, commit=False):

Callers 1

Calls 5

assets_pathMethod · 0.95
saveMethod · 0.95
epsg_from_wktFunction · 0.90
formatMethod · 0.45

Tested by

no test coverage detected