/// <summary> /// Reads all shapes in the Shapefile /// </summary> /// <param name="reader">The Shapefile stream</param> /// <param name="shapeType">The type of shape to read</param> /// <returns>A list of Geometry objects</returns> private async Task <List <Geometry> > ReadShapeRecords(BinaryReader reader, ShapefileShapeType shapeType) { List <Geometry> items = null; // Skip the end of the file header. reader.BaseStream.Seek(100, SeekOrigin.Begin); // Read the shapes depending on the ShapeType. switch (shapeType) { case ShapefileShapeType.NullShape: // Do nothing. break; case ShapefileShapeType.Point: case ShapefileShapeType.PointZ: case ShapefileShapeType.PointM: case ShapefileShapeType.PointZM: items = ReadPointData(reader); break; case ShapefileShapeType.LineString: case ShapefileShapeType.LineStringZ: case ShapefileShapeType.LineStringM: case ShapefileShapeType.LineStringZM: items = await ReadLineStringData(reader); break; case ShapefileShapeType.Polygon: case ShapefileShapeType.PolygonZ: case ShapefileShapeType.PolygonM: case ShapefileShapeType.PolygonZM: items = ReadPolygonData(reader); break; case ShapefileShapeType.MultiPoint: case ShapefileShapeType.MultiPointZ: case ShapefileShapeType.MultiPointM: case ShapefileShapeType.MultiPointZM: items = ReadMultiPointData(reader); break; default: //throw an error indicating that an unsupported shape type is in the file throw new Exception("ShapeType " + shapeType.ToString() + " is not supported."); } return(items); }