Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShapefileDataWriter"/> class.
        /// </summary>
        /// <param name="fileName">File path without any extension</param>
        /// <param name="geometryFactory"></param>
        public ShapefileDataWriter(string fileName, IGeometryFactory geometryFactory)
        {
            this.geometryFactory = geometryFactory;

            // Files
            shpFile = fileName;
            dbfFile = fileName + ".dbf";

            // Writers
            shapeWriter = new ShapefileWriter(geometryFactory);
            dbaseWriter = new DbaseFileWriter(dbfFile);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="recordCount"></param>
        public static void WriteDummyDbf(string filename, int recordCount)
        {
            DbaseFileHeader dbfHeader = new DbaseFileHeader();

            dbfHeader.AddColumn("Description", 'C', 20, 0);

            DbaseFileWriter dbfWriter = new DbaseFileWriter(filename);

            dbfWriter.Write(dbfHeader);
            for (int i = 0; i < recordCount; i++)
            {
                ArrayList columnValues = new ArrayList();
                columnValues.Add((double)i);
                dbfWriter.Write(columnValues);
            }
            dbfWriter.Close();
        }
Beispiel #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="recordCount"></param>
		public static void WriteDummyDbf(string filename, int recordCount)
		{
			DbaseFileHeader dbfHeader = new DbaseFileHeader();
			dbfHeader.AddColumn("Description",'C', 20, 0);
			
			DbaseFileWriter dbfWriter = new DbaseFileWriter(filename);
			dbfWriter.Write(dbfHeader);
			for (int i = 0; i < recordCount; i++)
			{
				ArrayList columnValues = new ArrayList();
				columnValues.Add((double) i);                
				dbfWriter.Write(columnValues);
			}
			dbfWriter.Close();
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="ShapefileDataWriter"/> class.
        /// </summary>
        /// <param name="fileName">File path without any extension</param>
        /// <param name="geometryFactory"></param>
        public ShapefileDataWriter(string fileName, IGeometryFactory geometryFactory)
        {
            this.geometryFactory = geometryFactory;

            // Files            
            shpFile = fileName;
            dbfFile = fileName + ".dbf";

            // Writers
            shapeWriter = new ShapefileWriter(geometryFactory);
            dbaseWriter = new DbaseFileWriter(dbfFile);
        }
		private void WriteGridAbundances(Project currentProject, string shapefileName)
		{
			try {
				List<IPolygon>projectGrids=new List<IPolygon>();
				General_queries projq=new General_queries(currentProject);
				
				foreach(Station st in currentProject.StationsList)
				{
					
					IPolygon grid=st.Grid;
					StationStats tempStationStats=new StationStats(st.Guid,st.StationID);
					
					foreach(StationStats stst in projq.AllStatsByStation)
					{
						if(stst.StationGUID==st.Guid)
						{
							tempStationStats=stst;
							grid.UserData=tempStationStats;
						}
					}
					
					projectGrids.Add(grid);
				}
				
				GeometryCollection gc=new GeometryCollection(projectGrids.ToArray());
				
				//Open Writer
				ShapefileWriter shpWriter = new ShapefileWriter();
				shpWriter.Write(shapefileName, gc);
				
				//Create Header & Columns for points
				DbaseFileHeader dbfHeader = new DbaseFileHeader();
				

				dbfHeader.AddColumn("Station_ID",'C',20,0);
				//One column for each species in project
				foreach(SpeciesStats spcst in projq.AllStatsBySpecies)
				{
					dbfHeader.AddColumn(spcst.SpeciesName,'N',20,0);
				}
				
				dbfHeader.NumRecords = gc.Count;
				
				//DBF Writer
				DbaseFileWriter dbfWriter = new DbaseFileWriter(shapefileName+".dbf");
				dbfWriter.Write(dbfHeader);
				
				//Loop through Business Object to get Features
				foreach (IPolygon p in gc.Geometries)
				{
					StationStats data = (StationStats)p.UserData;
					
					
					ArrayList columnValues = new System.Collections.ArrayList();
					//Add Values
					
					columnValues.Add(data.StationID);
					foreach(SpeciesStats s in data.SpeciesStats)
					{
						columnValues.Add(s.SpeciesPictures);
					}
					
					dbfWriter.Write(columnValues);

				}
				
				//Close File
				dbfWriter.Close();
			} catch (Exception ex) {
				throw ex;
			}
			

		}