I was basically copying algorithms over from one project to another, but found I wasn’t getting results. The problem was a number of significant changes were made to the data. So I was looking at some daunting debugging. But then it turned out to be a case of fixing one line of code:
//var coordPattern = new Regex(@"[0-9]+.[0-9]+,[0-9]+.[0-9]+"); var coordPattern = new Regex(@"[-0-9.]+,[-0-9.]+");
The old regex illustrated the pitfalls of working with one particular dataset, in this case spatial coordinates in a UTM projection. Then I switched to Web Mercator. Using that projection, the coordinates now include negative values, such as -10539358.2537, 3394430.3346999986 (space added for ease of reading). I also found that some values don’t include any decimal places. So the new pattern is looser, but still specific enough given what it will be fed.