Fix two sampleTerrain problems

Fixes #1739 and #1493.