Add spatial support to code generation #631