/** Reads the stream, consuming a format that is a tab-separated values of 3 columns: * an "id", a "name" and the "shape". Empty lines and lines starting with a '#' are skipped. * The stream is closed. */ public static IEnumerator<SpatialTestData> GetTestData(Stream @in, SpatialContext ctx) { List<SpatialTestData> results = new List<SpatialTestData>(); TextReader bufInput = new StreamReader(@in, Encoding.UTF8); try { String line; while ((line = bufInput.ReadLine()) != null) { if (line.Length == 0 || line[0] == '#') continue; SpatialTestData data = new SpatialTestData(); String[] vals = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (vals.Length != 3) throw new ArgumentException("bad format; expecting 3 tab-separated values for line: " + line); data.id = vals[0]; data.name = vals[1]; try { data.shape = ctx.ReadShapeFromWkt(vals[2]); } catch (ParseException e) { throw new ApplicationException(e.Message, e); } results.Add(data); } } finally { bufInput.Dispose(); } return results.GetEnumerator(); }
protected virtual IShape ParseShape(string str, SpatialContext ctx) { //return ctx.readShape(str);//still in Spatial4n 0.4 but will be deleted return ctx.ReadShapeFromWkt(str); }