Authentication method changed. UCLouvain users, please use the "UCLouvain SSO" button to connect on the website and use ssh + ssh key (https://git.immc.ucl.ac.be/-/profile/keys) or https + personnal access token (https://git.immc.ucl.ac.be/-/profile/personal_access_tokens) in your git clients.

Commit 1a617708 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

much faster import thanks to cached transformation

parent cff115d5
Pipeline #8383 passed with stages
in 2 minutes
......@@ -41,10 +41,15 @@ else:
lib = c.CDLL(libpath)
_transform_cache = {}
def _ensure_valid_points(x, pfrom, pto):
x = np.asarray(x)[:, :2]
if not pfrom.IsSame(pto):
x = osr.CoordinateTransformation(pfrom, pto).TransformPoints(x)
trans = _transform_cache.get((pfrom,pto),None)
if trans is None :
trans = osr.CoordinateTransformation(pfrom, pto)
_transform_cache[(pfrom,pto)] = trans
x = trans.TransformPoints(x)
x = np.asarray(x)[:, :2]
return x
......@@ -243,6 +248,7 @@ class Domain:
layerdef = layer.GetLayerDefn()
physfield = None
count = 0
tic = time.time()
if physical_name_field is not None:
for i in range(layerdef.GetFieldCount()):
field_name = layerdef.GetFieldDefn(i).GetName()
......@@ -259,6 +265,7 @@ class Domain:
_lineup()
print("{} features imported".format(count))
count += 1
print("time : ",time.time()-tic)
def add_interior_points(self, points: np.ndarray, physical_tag: str,
projection: osr.SpatialReference) -> None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment