diff --git a/builder/build_pymeos_functions.py b/builder/build_pymeos_functions.py index cf30396..94e5ce8 100644 --- a/builder/build_pymeos_functions.py +++ b/builder/build_pymeos_functions.py @@ -84,6 +84,7 @@ def __init__(self, ctype: str, ptype: str, conversion: str | None) -> None: "textset_make": textset_make_modifier, "geoset_make": array_length_remover_modifier("values", "count"), "tsequenceset_make_gaps": array_length_remover_modifier("instants", "count"), + "tpointseq_make_coords": tpointseq_make_coords_modifier, "mi_span_span": mi_span_span_modifier, } diff --git a/builder/build_pymeos_functions_modifiers.py b/builder/build_pymeos_functions_modifiers.py index df851e1..efc2a11 100644 --- a/builder/build_pymeos_functions_modifiers.py +++ b/builder/build_pymeos_functions_modifiers.py @@ -115,6 +115,34 @@ def spanset_make_modifier(function: str) -> str: ) +def tpointseq_make_coords_modifier(function: str) -> str: + return "import numpy as np\n" + function.replace( + "interp: 'interpType'", "linear: bool" + ).replace('("const double', '("double').replace( + "xcoords)", "np.ascontiguousarray(xcoords, dtype=np.float64).ctypes.data)" + ).replace( + "ycoords)", "np.ascontiguousarray(ycoords, dtype=np.float64).ctypes.data)" + ).replace( + "zcoords_converted = _ffi.cast('const double *', zcoords)", + "if zcoords is not None:\n" + " zcoords = np.ascontiguousarray(zcoords, dtype=np.float64)\n" + " zcoords_converted = _ffi.cast('double *', zcoords.ctypes.data)\n" + " else:\n" + " zcoords_converted = _ffi.NULL", + ).replace( + "interp_converted = _ffi.cast('interpType', interp)", "" + ).replace( + "interp_converted", "linear" + ).replace( + "times_converted = _ffi.cast('const TimestampTz *', times)", "" + ).replace( + "srid_converted = _ffi.cast('int32', srid)", "" + ).replace( + "times_converted", "times" + ).replace( + "srid_converted", "srid" + ) + def mi_span_span_modifier(function: str) -> str: return function.replace( '-> Annotated[_ffi.CData, "Span *"]', '-> tuple[Annotated[_ffi.CData, "Span *"], int]'