Permalink
Browse files

Forgot to dispose StringReader in GooglePolylineEncoder

  • Loading branch information...
1 parent 7134ce1 commit 8193e2519d006cb036bdba663db39b7491271552 @sibartlett committed Mar 13, 2013
Showing with 14 additions and 14 deletions.
  1. +14 −14 Geo/IO/Google/GooglePolylineEncoder.cs
@@ -39,20 +39,20 @@ public string Encode(LineString lineString)
}
public LineString Decode(string polyline)
- {
- var reader = new StringReader(polyline);
- var coordinates = new List<Coordinate>();
- int lat = 0, lng = 0;
-
- while (reader.Peek() != -1)
- {
- lat += DecodeNumber(reader);
- lng += DecodeNumber(reader);
-
- var p = new Coordinate(lat / CoordinateFactor, lng / CoordinateFactor);
- coordinates.Add(p);
- }
-
+ {
+ var coordinates = new List<Coordinate>();
+ using (var reader = new StringReader(polyline))
+ {
+ int lat = 0, lng = 0;
+ while (reader.Peek() != -1)
+ {
+ lat += DecodeNumber(reader);
+ lng += DecodeNumber(reader);
+
+ var p = new Coordinate(lat / CoordinateFactor, lng / CoordinateFactor);
+ coordinates.Add(p);
+ }
+ }
return new LineString(coordinates);
}

0 comments on commit 8193e25

Please sign in to comment.