public static Graphic ToGraphic(this ShapeFileRecord record) { if (record == null) { return(null); } Graphic graphic = new Graphic(); //add all the attributes to the graphic foreach (var item in record.Attributes) { graphic.Attributes.Add(item.Key, item.Value); } //add the geometry to the graphic switch (record.ShapeType) { case (int)ShapeType.NullShape: break; case (int)ShapeType.Point: graphic.Geometry = GetPoint(record); graphic.Symbol = DEFAULT_MARKER_SYMBOL; break; case (int)ShapeType.Polygon: graphic.Geometry = GetPolygon(record); graphic.Symbol = DEFAULT_FILL_SYMBOL; break; case (int)ShapeType.PolyLine: graphic.Geometry = GetPolyline(record); graphic.Symbol = DEFAULT_LINE_SYMBOL; break; default: break; } return(graphic); }
/// <summary> /// Read a shapefile MultiPoint record. /// </summary> /// <param name="stream">Input stream.</param> /// <param name="record">Shapefile record to be updated.</param> private static void ReadMultipoint(Stream stream, ShapeFileRecord record) { // Bounding Box. record.XMin = ShapeFile.ReadDouble64_LE(stream); record.YMin = ShapeFile.ReadDouble64_LE(stream); record.XMax = ShapeFile.ReadDouble64_LE(stream); record.YMax = ShapeFile.ReadDouble64_LE(stream); // Num Points. int numPoints = ShapeFile.ReadInt32_LE(stream); // Points. for (int i = 0; i < numPoints; i++) { Point p = new Point(); p.X = ShapeFile.ReadDouble64_LE(stream); p.Y = ShapeFile.ReadDouble64_LE(stream); record.Points.Add(p); } }