Fix #1123: 'Unexpected function' error

Error being caused because PHP5.2- don't support anonymous function.
Another error being thrown when more than one "Specific area" location
was used due to function re-declaration in the loop.

Moved flatten() and collapse_points() to WKT object to clean the view.
Replaced flatten() code to use a recursive call instead of an anonymous
function.
Updating function comments
Setting proper scope on new functions

'Cause we like tidy.
Updating brackets and parenthesis

Adhering to Ushahidi Guidelines
Unit test for new functions

Unit tests written and a wee fix for an issue that they pointed out
(yay!)
Fixing white spaces
Merge pull request #1195 from ditorelo/1123

Fix #1123: 'Unexpected function' error