Very slow queries in the Geo JSON generation using cursors

Hi good day, I would like to ask your support in the revision of the cursor that I am using for the construction of a geo json that from certain records is taking a long time to generate, I would like to know if there is any other function or process for the construction of the Geo json other than cursors.

sp_get_estructura.txt (1.72 KB)