static void Main(string[] args) { try{ Console.WriteLine("Starting Harlow interactions."); string shapeFile = @"D:\Data\geo\tiger\TIGER2016\STATE\tl_2016_us_state.shp"; ShapeFileReader reader = new ShapeFileReader(shapeFile); reader.RequiredPrecision = 6; reader.LoadFile(); using (StreamWriter sw = new StreamWriter(@"C:\Projects\Layered.io\Data\JSON\HarlowFeatures\us_states_features_temp.txt")){ // sw.WriteLine("["); foreach (var f in reader.Features) { string json = JsonConvert.SerializeObject(f); // var fe = JsonConvert.DeserializeObject<VectorShape>(json); sw.WriteLine(json); // sw.WriteLine(","); } // sw.WriteLine("]"); } } finally { Console.WriteLine("Press any key to exit."); Console.ReadKey(); } }
private void FillInformationLayer() { StreamResourceInfo shapeResourceInfo = Application.GetResourceStream(new Uri("/ShapefileManualReading;component/Resources/world.shp", UriKind.RelativeOrAbsolute)); StreamResourceInfo dbfResourceInfo = Application.GetResourceStream(new Uri("/ShapefileManualReading;component/Resources/world.dbf", UriKind.RelativeOrAbsolute)); List <FrameworkElement> shapes = ShapeFileReader.Read(shapeResourceInfo.Stream, dbfResourceInfo.Stream); foreach (var shape in shapes) { this.informationLayer.Items.Add(shape); } }
public void USGS_CitiesAndTowns() { ShapeFileReader reader = new ShapeFileReader(pointFile); reader.LoadFile(); string json = reader.FeaturesAsJson(); File.WriteAllText("point.json", reader.FeatureAsJson(42)); Assert.AreEqual(6062745, json.Length); Assert.AreEqual(38187, reader.Features.Length); Assert.AreEqual(157, reader.FeatureAsJson(0).Length); Assert.AreEqual(159, reader.FeatureAsJson(38186).Length); VectorPoint[] features = reader.Features as VectorPoint[]; Assert.AreEqual(-100.06096779999996, features[0].Coordinates[0]); Assert.AreEqual(48.813056899065479, features[0].Coordinates[1]); Assert.AreEqual(-101.22071379999994, features[42].Coordinates[0]); Assert.AreEqual(48.513074399064209, features[42].Coordinates[1]); Assert.AreEqual(-149.22967529296875, features[38186].Coordinates[0]); Assert.AreEqual(61.541870116397909, features[38186].Coordinates[1]); Assert.AreEqual(5, reader.Features[0].Properties.Count); Assert.AreEqual("dunseith", reader.Features[0].Properties["nam"]); Assert.AreEqual("al020", reader.Features[0].Properties["f_code"]); Assert.AreEqual("773", reader.Features[0].Properties["pop"]); Assert.AreEqual("2010", reader.Features[0].Properties["ypc"]); Assert.AreEqual("usa", reader.Features[0].Properties["soc"]); Assert.AreEqual(reader.Features[42].Properties.Count, 5); Assert.AreEqual("glenburn", reader.Features[42].Properties["nam"]); Assert.AreEqual("al020", reader.Features[42].Properties["f_code"]); Assert.AreEqual("380", reader.Features[42].Properties["pop"]); Assert.AreEqual("2010", reader.Features[42].Properties["ypc"]); Assert.AreEqual("usa", reader.Features[42].Properties["soc"]); Assert.AreEqual(reader.Features[38186].Properties.Count, 5); Assert.AreEqual("matanuska", reader.Features[38186].Properties["nam"]); Assert.AreEqual("al020", reader.Features[38186].Properties["f_code"]); Assert.AreEqual("-999", reader.Features[38186].Properties["pop"]); Assert.AreEqual("2010", reader.Features[38186].Properties["ypc"]); Assert.AreEqual("usa", reader.Features[38186].Properties["soc"]); }
public void Tiger_US_PlaceBoundaries() { ShapeFileReader reader = new ShapeFileReader(polyFile); reader.LoadFile(); string json = reader.FeaturesAsJson(); File.WriteAllText("polygon.json", reader.FeatureAsJson(42)); Assert.AreEqual(25301992, json.Length); Assert.AreEqual(1516, reader.Features.Length); Assert.AreEqual(4780, reader.FeatureAsJson(0).Length); Assert.AreEqual(13137, reader.FeatureAsJson(1515).Length); VectorShape[] features = reader.Features as VectorShape[]; Assert.AreEqual(-118.456008, features[0].Coordinates[0][0].Value[0]); Assert.AreEqual(34.284903, features[0].Coordinates[0][0].Value[1]); Assert.AreEqual(-118.30807, features[42].Coordinates[0][0].Value[0]); Assert.AreEqual(34.161224, features[42].Coordinates[0][0].Value[1]); Assert.AreEqual(-122.060783, features[1515].Coordinates[0][0].Value[0]); Assert.AreEqual(37.05574, features[1515].Coordinates[0][0].Value[1]); Assert.AreEqual(16, reader.Features[0].Properties.Count); Assert.AreEqual("06", reader.Features[42].Properties["statefp"]); Assert.AreEqual("30000", reader.Features[42].Properties["placefp"]); Assert.AreEqual("02410597", reader.Features[42].Properties["placens"]); Assert.AreEqual("0630000", reader.Features[42].Properties["geoid"]); Assert.AreEqual("glendale", reader.Features[42].Properties["name"]); Assert.AreEqual("glendale city", reader.Features[42].Properties["namelsad"]); Assert.AreEqual("25", reader.Features[42].Properties["lsad"]); Assert.AreEqual("c1", reader.Features[42].Properties["classfp"]); Assert.AreEqual("y", reader.Features[42].Properties["pcicbsa"]); Assert.AreEqual("n", reader.Features[42].Properties["pcinecta"]); Assert.AreEqual("g4110", reader.Features[42].Properties["mtfcc"]); Assert.AreEqual("a", reader.Features[42].Properties["funcstat"]); Assert.AreEqual("78848571", reader.Features[42].Properties["aland"]); Assert.AreEqual("337673", reader.Features[42].Properties["awater"]); Assert.AreEqual("+34.1813929", reader.Features[42].Properties["intptlat"]); Assert.AreEqual("-118.2458301", reader.Features[42].Properties["intptlon"]); }
public void Tiger_CA_SanFran_Roads() { ShapeFileReader reader = new ShapeFileReader(lineFile); reader.LoadFile(); string json = reader.FeaturesAsJson(); File.WriteAllText("line.json", reader.FeatureAsJson(42)); Assert.AreEqual(2166881, json.Length); Assert.AreEqual(4589, reader.Features.Length); Assert.AreEqual(283, reader.FeatureAsJson(0).Length); Assert.AreEqual(649, reader.FeatureAsJson(4588).Length); VectorShape[] features = reader.Features as VectorShape[]; Assert.AreEqual(-122.480706, features[0].Coordinates[0][0].Value[0]); Assert.AreEqual(37.792316, features[0].Coordinates[0][0].Value[1]); Assert.AreEqual(-122.469023, features[42].Coordinates[0][0].Value[0]); Assert.AreEqual(37.737949, features[42].Coordinates[0][0].Value[1]); Assert.AreEqual(-122.364304, features[4588].Coordinates[0][0].Value[0]); Assert.AreEqual(37.819468, features[4588].Coordinates[0][0].Value[1]); Assert.AreEqual(4, reader.Features[0].Properties.Count); Assert.AreEqual("110498938555", reader.Features[0].Properties["linearid"]); Assert.AreEqual("n van horn ln", reader.Features[0].Properties["fullname"]); Assert.AreEqual("m", reader.Features[0].Properties["rttyp"]); Assert.AreEqual("s1400", reader.Features[0].Properties["mtfcc"]); Assert.AreEqual("110498935016", reader.Features[42].Properties["linearid"]); Assert.AreEqual("w portal ave", reader.Features[42].Properties["fullname"]); Assert.AreEqual("m", reader.Features[42].Properties["rttyp"]); Assert.AreEqual("s1400", reader.Features[42].Properties["mtfcc"]); Assert.AreEqual("110498933806", reader.Features[4588].Properties["linearid"]); Assert.AreEqual("avenue n", reader.Features[4588].Properties["fullname"]); Assert.AreEqual("m", reader.Features[4588].Properties["rttyp"]); Assert.AreEqual("s1400", reader.Features[4588].Properties["mtfcc"]); }
public async Task <IEnumerable <Location> > RetrieveLocationsFromContent() { var importFolder = Directory.GetParent(_fileLocation).FullName; var extractionFolder = Path.GetFileNameWithoutExtension(_fileLocation); var fullExtractionFolder = Path.Combine(importFolder, extractionFolder); await Task.Run(() => ZipFile.ExtractToDirectory(_fileLocation, fullExtractionFolder, true)); var shapeFileDirectory = Directory.EnumerateDirectories(fullExtractionFolder, "MSI", SearchOption.AllDirectories).First(); var shapeFileLocation = Directory.EnumerateFiles(shapeFileDirectory, "*.shp").First(); var shape = new ShapeFileReader(shapeFileLocation); var featuresAsJson = await Task.Run(() => shape.FeaturesAsJson()); var jsonContent = featuresAsJson.Replace("\\u0000", string.Empty); jsonContent = MapJsonToCorrectFormat(jsonContent); var data = JsonConvert.DeserializeObject <IEnumerable <Feature> >(jsonContent); return(data); }
private void SetupMapLayers() { string dir = Directory.GetCurrentDirectory(); string dataPath = "\\..\\..\\..\\data\\geodata\\maps\\"; string fileName = "europe_nation"; ShapeFileReader shapeReader = new ShapeFileReader(); iMapData = shapeReader.Read(dir + dataPath + fileName + ".shp" , dir + dataPath + fileName + ".dbf" , dir + dataPath + fileName + ".shx"); // Border Layer borderLayer = new MapPolygonBorderLayer(); borderLayer.MapData = iMapData; // Polygon Layer polygonLayer = new MapPolygonLayer(); polygonLayer.MapData = iMapData; polygonLayer.ColorMap = iColorMap; polygonLayer.IndexVisibilityHandler = iPcPlot.IndexVisibilityHandler; iPcPlot.FilterChanged += new EventHandler(iPcPlot_FilterChanged); polygonSelectionLayer = new MapPolygonLayer(); polygonSelectionLayer.MapData = iMapData; polygonSelectionLayer.PolygonColor = Color.FromArgb(220, 220, 220); polygonSelectionLayer.Alpha = 120; borderSelectionLayer = new MapPolygonBorderLayer(); borderSelectionLayer.MapData = iMapData; borderSelectionLayer.BorderColor = Color.Black; borderSelectionLayer.Translation = new Vector3(0.6f, 0.6f, 0); // borderSelectionLayer.Translation.X; iSelectedInVisibility = new IndexVisibilityHandler(iMapData.RegionList.Count); iSelectedVisibility = new IndexVisibilityHandler(iMapData.RegionList.Count); iSelectedInVisibility.Clear(); iInVisibilityList = iSelectedInVisibility.CreateVisibilityList(); iVisibilityList = iSelectedVisibility.CreateVisibilityList(); for (int i = 0, endI = iMapData.RegionList.Count; i < endI; i++) { iVisibilityList.SetVisibility(i, 0, false); } polygonSelectionLayer.IndexVisibilityHandler = iSelectedInVisibility; borderSelectionLayer.IndexVisibilityHandler = iSelectedVisibility; // polygonSelectionLayer.SelectedPolygonColor = Color.Transparent; // Glyph Layer glyphLayer = new CountryGlyphLayer(iPanel); glyphLayer.ActiveGlyphPositioner = new CenterGlyphPositioner(); glyphLayer.ActiveGlyphPositioner.MapData = iMapData; glyphLayer.Input = iDataCube; glyphLayer.IndexVisibilityHandler = iPcPlot.IndexVisibilityHandler; // Choropleth Map choroMap = new ChoroplethMap(); choroMap.VizComponentMouseDown += new EventHandler <VizComponentMouseEventArgs>(MouseDown); choroMap.VizComponentMouseUp += new EventHandler <VizComponentMouseEventArgs>(MouseUp); // Add layers on the proper order choroMap.AddLayer(polygonLayer); choroMap.AddLayer(borderLayer); choroMap.AddLayer(polygonSelectionLayer); choroMap.AddLayer(borderSelectionLayer); choroMap.AddLayer(glyphLayer); Invalidate(); //iSelectedColorLegend = new InteractiveColorLegend(); //iSelectedColorLegend.ColorMap = iLegendColorMap; //iSelectedColorLegend.BorderColor = Color.Black; //iSelectedColorLegend.ShowMinMaxValues = false; //iSelectedColorLegend.SetLegendSize(10, 200); //iSelectedColorLegend.SetPosition(50F, 10F); //iSelectedColorLegend.SetLegendSize(0.02f, 0.2f); //iSelectedColorLegend.ShowColorEdgeSliders = false; //iSelectedColorLegend.ShowColorEdgeSliderValue = false; ////iSelectedColorLegend.ColorEdgeValuesChanged += new EventHandler(ColorLegendChanged); //choroMap.AddSubComponent(iSelectedColorLegend); iColorLegend = new InteractiveColorLegend(); iColorLegend.ColorMap = iColorMap; //iColorLegend.BorderColor = Color.Black; //iColorLegend.SliderTextColor = Color.Black; //iColorLegend.ShowMinMaxValues = true; iColorLegend.SetPosition(10, 10); iColorLegend.SetLegendSize(15, 200); iColorLegend.ShowColorEdgeSliders = true; iColorLegend.ShowColorEdgeSliderValue = false; iColorLegend.ColorEdgeValuesChanged += new EventHandler(ColorLegendChanged); //iColorLegend.ShowValueSliders = true; //iColorLegend.ShowValueSliderValue = true; //iColorLegend.ValueSliderValuesChanged += new EventHandler(ColorLegendChanged); //iColorLegend.SetEdgeSliders(InteractiveColorLegend.SliderLinePosition.Center, InteractiveColorLegend.TextPosition.RightOrBottom, true); choroMap.AddSubComponent(iColorLegend); renderer.Add(choroMap, iPanel); }
public GLib Load() { foreach (string filePath in fileNames) { using (ShapeFileReader sr = new ShapeFileReader(filePath)) { UpdateBounds(sr.bound); } } if (!boundsUpdated) { return(null); } SetTransform(); CreateLib(); foreach (string filePath in fileNames) { using (ShapeFileReader sr = new ShapeFileReader(filePath)) { // object[] attrs; if (!CreateType(sr.GetUnitType())) { continue; } curType.Name = Path.GetFileNameWithoutExtension(filePath); while (sr.Read()) { switch (sr.GetUnitType()) { case ShapeUnit.Arc: // Read((ShapeArc)sr.Get()); break; case ShapeUnit.Point: Read((ShapePoint)sr.Get()); break; case ShapeUnit.Polygon: Read((ShapePolygon)sr.Get()); break; // case ShapeUnit.PointGroup: // Read((ShapePointGroup)sr.Get()); // break; case ShapeUnit.PolyLine: Read((ShapePolyline)sr.Get()); break; } } } } lib.SMin = 10; if (lib.Bounds.IsNull) { lib.SetBounds(new Rect(0, 0, 1000000, 1000000)); } lib.SMax = Geomethod.GeoLib.GeoLibUtils.RoundScale(lib.Bounds.MaxSize / 10); lib.Scales.InitScales(); return(lib); }
/// <summary> /// Insert Map into AreaMapLayer table and MapFile name in AreaMapMetadata for all language tables /// </summary> /// <returns>Layer NId. If return value = -1 it implies that layer could not be inserted for some reasons</returns> public int InsertMap(MapInfo mapInfo) { int RetVal = -1; DbCommand Command = this.DBConnection.GetCurrentDBProvider().CreateCommand(); DbParameter ParameterShp; DbParameter ParameterShx; DbParameter ParameterDbf; try { if (!string.IsNullOrEmpty(mapInfo.MapFilePath) && File.Exists(mapInfo.MapFilePath)) { string sFilePath = Path.GetDirectoryName(mapInfo.MapFilePath); string sFileName = Path.GetFileNameWithoutExtension(mapInfo.MapFilePath); ShapeInfo shapeInfo = ShapeFileReader.GetShapeInfo(sFilePath, sFileName); //-- Validate that shape file is valid and devinfo compliant format if (shapeInfo != null) { //-- Get shp file byte array FileStream Shp = new FileStream(sFilePath + "\\" + sFileName + ".shp", FileMode.Open); byte[] ShpBuffer = new byte[(int)Shp.Length - 1 + 1]; Shp.Read(ShpBuffer, 0, (int)Shp.Length); Shp.Close(); //-- Get shx file byte array FileStream Shx = new FileStream(sFilePath + "\\" + sFileName + ".shx", FileMode.Open); byte[] ShxBuffer = new byte[(int)Shx.Length - 1 + 1]; Shx.Read(ShxBuffer, 0, (int)Shx.Length); Shx.Close(); //-- Get dbf file byte array FileStream Dbf = new FileStream(sFilePath + "\\" + sFileName + ".dbf", FileMode.Open); byte[] DbfBuffer = new byte[(int)Dbf.Length - 1 + 1]; Dbf.Read(DbfBuffer, 0, (int)Dbf.Length); Dbf.Close(); //-- Update mapInfo mapInfo.LayerSize = ShpBuffer.Length + "," + ShxBuffer.Length + "," + DbfBuffer.Length; if (mapInfo.IsFeatureLayer) { mapInfo.LayerType = (ShapeType)((int)shapeInfo.ShapeType - 1); } else { mapInfo.LayerType = (ShapeType)shapeInfo.ShapeType; } mapInfo.BoundingBox = shapeInfo.Extent; mapInfo.UpdateTimestamp = DateTime.Now; string sSql = DevInfo.Lib.DI_LibDAL.Queries.Area.Insert.InsertLayerWParamName(this.DBQueries.DataPrefix, mapInfo.LayerSize, (int)mapInfo.LayerType, mapInfo.BoundingBox.Left, mapInfo.BoundingBox.Top, mapInfo.BoundingBox.Right, mapInfo.BoundingBox.Bottom, mapInfo.StartDate, mapInfo.EndDate, mapInfo.UpdateTimestamp); Command.Connection = this.DBConnection.GetConnection(); Command.CommandText = sSql; Command.CommandType = CommandType.Text; ParameterShp = this.DBConnection.GetCurrentDBProvider().CreateParameter(); ParameterShx = this.DBConnection.GetCurrentDBProvider().CreateParameter(); ParameterDbf = this.DBConnection.GetCurrentDBProvider().CreateParameter(); //-- Set the data type for parameter ParameterShp.DbType = DbType.Binary; ParameterShx.DbType = DbType.Binary; ParameterDbf.DbType = DbType.Binary; //-- Assign the contents of the buffer to the value of the parameter ParameterShp.ParameterName = "@" + Area_Map_Layer.LayerShp; ParameterShp.Value = ShpBuffer; ParameterShx.ParameterName = "@" + Area_Map_Layer.LayerShx; ParameterShx.Value = ShxBuffer; ParameterDbf.ParameterName = "@" + Area_Map_Layer.Layerdbf; ParameterDbf.Value = DbfBuffer; //-- Add the parameter to the command Command.Parameters.Add(ParameterShp); Command.Parameters.Add(ParameterShx); Command.Parameters.Add(ParameterDbf); //-- Insert the layer record Command.ExecuteNonQuery(); RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY")); //-- Append record in Area_Map_Metadata table and set Layer_Name //-- Insert record in Area_Map_Metadata table and set Layer_Name for all languages string DefaultLanguageCode = this.DBQueries.LanguageCode; string MapName = mapInfo.MapName; string LanguageCode = string.Empty; foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows) { LanguageCode = languageRow[Language.LanguageCode].ToString(); MapName = mapInfo.MapName; this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Area.Insert.InsertAreaMapMetadata(this.DBQueries.DataPrefix, "_" + LanguageCode, string.Empty, RetVal, Utility.DICommon.RemoveQuotes(MapName))); } } } } catch (Exception ex) { System.Diagnostics.Debug.Print(ex.Message); //throw new ApplicationException(ex.Message); } finally { if ((Command != null)) { Command.Dispose(); } } return(RetVal); }
public TestShape(string filename) { int cnt = 0; int pcnt = 0; try { // string drv = "Driver={Microsoft dBase Driver (*.dbf)};DBQ="; // OdbcConnection con = new OdbcConnection(drv + Path.GetDirectoryName( filename )); // con.Open(); using (ShapeFileReader sr = new ShapeFileReader(filename)) { while (sr.Read()) { cnt++; if (sr.shapeType == ShapeUnit.Polygon) { ShapePolygon sp = (ShapePolygon)sr.Get( ); for (int p = 0; p < sp.numParts; p++) { uint max = sp.numPoints; if (p < sp.numParts - 1) { max = sp.parts[p + 1]; } uint len = sp.numPoints; if (p < sp.numParts - 1) { len = sp.parts[p + 1] - sp.parts[p]; } else { len = sp.numPoints - sp.parts[p]; } Point[] pnt = new Point[len]; int j = 0; for (uint i = sp.parts[p]; i < max; i++) { pnt[j].X = (int)sp.points[i].X; pnt[j].Y = (int)sp.points[i].Y; j++; } pcnt += (int)len; } } if (sr.shapeType == ShapeUnit.PolyLine) { ShapePolyline sp = (ShapePolyline)sr.Get(); for (int p = 0; p < sp.numParts; p++) { uint max = sp.numPoints; if (p < sp.numParts - 1) { max = sp.parts[p + 1]; } uint len = sp.numPoints; if (p < sp.numParts - 1) { len = sp.parts[p + 1] - sp.parts[p]; } else { len = sp.numPoints - sp.parts[p]; } Point[] pnt = new Point[len]; int j = 0; for (uint i = sp.parts[p]; i < max; i++) { pnt[j].X = (int)sp.points[i].X; pnt[j].Y = (int)sp.points[i].Y; j++; } pcnt += (int)len; } } /* string str = null; * object[] an = sr.GetAttrNames(); * object[] tp = sr.GetAttrTypes(); * for (int i = 0; i < an.Length; i++) * str += an[i] + " " + tp[i] + "\n"; * Console.WriteLine(str, "»мена полей и типов"); */ } } // con.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.WriteLine("Read " + cnt.ToString() + " objects, " + pcnt.ToString() + " points", this.GetType().ToString()); }
public TestShape() { /* string drv = "Driver={Microsoft dBase Driver (*.dbf)};DBQ="; * * // «десь конструктор с connection * * // string filename1 = @"f:\dima\shape\bk_st.shp"; * string filename1 = @"f:\dima\shape\detroit\hist.shp"; * // string filename1 = @"f:\dima\shape\detroit\roads.shp"; * * OdbcConnection con = new OdbcConnection( drv + Path.GetDirectoryName( filename1 ) ); * con.Open(); * * using( ShapeFileReader sr = new ShapeFileReader( filename1, con ) ) * { * string str = null; * object[] an = sr.GetAttrNames(); * object[] tp = sr.GetAttrTypes(); * for( int i = 0; i < an.Length; i++ ) * str += an[i] + " " + tp[i] + "\n"; * Console.WriteLine( str, "»мена полей и типов" ); * * int cnt = 0; * while( sr.Read() ) * { * if( sr.shapeType == ShapeUnit.Point ) * { * object[] attrs; * ShapePoint sp = (ShapePoint)sr.Get( out attrs ); * if( cnt < 2 ) * { * Console.WriteLine( sp.point.X.ToString() + " " + sp.point.Y.ToString(), " оординаты" ); * string at = null; * for( int i = 0; i < attrs.Length; i++ ) * at += attrs[i].ToString() + "\n"; * Console.WriteLine( at, "јтрибуты" ); * } * } * cnt++; * } * string Bound = sr.shapeType.ToString() + "\n " + * sr.bound.maxx.ToString() + "\n " + * sr.bound.maxy.ToString() + "\n " + * sr.bound.minx.ToString() + "\n " + * sr.bound.miny.ToString() + "\n " + * cnt.ToString(); * Console.WriteLine( Bound, "“ип, границы и количество объектов" ); * * } * con.Close(); */ // «десь конструктор без connection string filename2 = @"f:\dima\shape\bk_tb.shp"; using (ShapeFileReader sr = new ShapeFileReader(filename2)) { while (sr.Read()) { if (sr.shapeType == ShapeUnit.Polygon) { ShapePolygon sp = (ShapePolygon)sr.Get( ); for (int p = 0; p < sp.numParts; p++) { uint max = sp.numPoints; if (p < sp.numParts - 1) { max = sp.parts[p + 1]; } uint len = sp.numPoints; if (p < sp.numParts - 1) { len = sp.parts[p + 1] - sp.parts[p]; } else { len = sp.numPoints - sp.parts[p]; } Point[] pnt = new Point[len]; int j = 0; for (uint i = sp.parts[p]; i < max; i++) { pnt[j].X = (int)sp.points[i].X; pnt[j].Y = (int)sp.points[i].Y; j++; } } } } } // «десь конструктор с connection и таблицей /* try * { * // string filename3 = @"f:\dima\shape\bk_st.shp"; * // string filename3 = @"f:\dima\shape\detroit\roads.shp"; * string filename3 = @"f:\dima\shape\detroit\hist.shp"; * string drvJet = @"Provider=Microsoft.Jet.OLEDB.4.0;"; * string ext = @";Extended Properties=dBASE IV;User ID=Admin;Password="******"Data Source=" + Path.GetDirectoryName( filename3 ) + ext; * OleDbConnection con3 = new OleDbConnection( str2 ); * con3.Open(); * * DataTable dt = new DataTable(); * * ShapeFileReader sr1 = new ShapeFileReader( filename3, con3, dt ); * sr1.Dispose(); * con3.Close(); * * for( int i = 0; i < dt.Rows.Count; i++ ) * { * string str = null; * for( int j = 0; j < dt.Columns.Count; j++ ) * str += dt.Columns[j].ColumnName + "\t = " + dt.Rows[i][j].ToString() + "\n"; * Console.WriteLine( str, dt.TableName + "[" + i + "]" ); * * if( i > 2 ) * break; * } * * } * catch( Exception e ) * { * Console.WriteLine( e.ToString() ); * } */ }