Converting a tile map into geometry

I recently needed to convert a tile map consisting of squares and triangles into chunks of geometry and after trying a couple of different approaches, I eventually settled on one which seems to work. I didn’t come across it anywhere else, so I thought I’d post it here in case anyone else is wanting to do something similar.