public static List<Band> GetBandsOrderName(bool asc) { List<Band> bands = new List<Band>(); try { // Get data DbDataReader reader; if (asc) reader = Database.GetData("SELECT * FROM band ORDER BY Name ASC"); else reader = Database.GetData("SELECT * FROM band ORDER BY Name DESC"); foreach (DbDataRecord record in reader) { Band band = new Band(); // Get ID if (DBNull.Value.Equals(record["ID"])) band.ID = -1; else band.ID = Convert.ToInt32(record["ID"]); // Get Name if (DBNull.Value.Equals(record["Name"])) band.Name = ""; else band.Name = record["Name"].ToString(); // Get Twitter if (DBNull.Value.Equals(record["Twitter"])) band.Twitter = ""; else band.Twitter = record["Twitter"].ToString(); // Get Facebook if (DBNull.Value.Equals(record["Facebook"])) band.Facebook = ""; else band.Facebook = record["Facebook"].ToString(); // Get Picture if (DBNull.Value.Equals(record["Picture"])) band.Picture = null; else band.Picture = (byte[])record["Picture"]; // Get Description if (DBNull.Value.Equals(record["Description"])) band.Description = ""; else band.Description = record["Description"].ToString(); // Get Genres band.Genres = GenreSQLRepository.GetGenresFromBand(band.ID); //Get Timeslots band.TimeSlots = TimeSlotSQLRepository.GetTimeSlotFromBand(band.ID); bands.Add(band); } reader.Close(); return bands; } // Fail catch (Exception ex) { Console.WriteLine(ex.Message); } return null; }
//Constructor public LBandsVM() { Bands = Band.GetBands(); Genres = Genre.GetGenres(); SelectedBand = Bands[0]; NewBand = new Band(); SelectedGenres = new ObservableCollection<Genre>(); }
public BandDashboardVM(Band band, bool userIsAdmin = false) { BandId = band.Id; CreatedOn = band.CreatedOn; BandName = band.Name; BandMembers = band.Members; BandAdmins = band.Admins; IsUserAdmin = userIsAdmin; NeedMemberQueries = band.NeedMemberQueries; }
public void SetConnectionStatus(Band.ConnectionState newState) { if (newState == BandPowerPointRemote.iOS.Band.ConnectionState.Connecting) { Flash (); } else if (newState == BandPowerPointRemote.iOS.Band.ConnectionState.NotConnected) { UIView.AnimationsEnabled = false; this.Layer.Opacity = 0; } else if (newState == BandPowerPointRemote.iOS.Band.ConnectionState.Connected) { this.Layer.Opacity = 1; } }
public static Band GetBand(int ID) { try { // Get data DbParameter param = Database.AddParameter("@id", ID); DbDataReader reader = Database.GetData("SELECT * FROM band WHERE ID = @id", param); foreach (DbDataRecord record in reader) { Band band = new Band(); // Get ID if (DBNull.Value.Equals(record["ID"])) band.ID = -1; else band.ID = Convert.ToInt32(record["ID"]); // Get Name if (DBNull.Value.Equals(record["Name"])) band.Name = ""; else band.Name = record["Name"].ToString(); // Get Twitter if (DBNull.Value.Equals(record["Twitter"])) band.Twitter = ""; else band.Twitter = record["Twitter"].ToString(); // Get Facebook if (DBNull.Value.Equals(record["Facebook"])) band.Facebook = ""; else band.Facebook = record["Facebook"].ToString(); // Get Picture if (DBNull.Value.Equals(record["Picture"])) band.Picture = null; else band.Picture = (byte[])record["Picture"]; // Get Description if (DBNull.Value.Equals(record["Description"])) band.Description = ""; else band.Description = record["Description"].ToString(); // Get Genres band.Genres = GenreSQLRepository.GetGenresFromBand(ID); //Get Timeslots band.TimeSlots = TimeSlotSQLRepository.GetTimeSlotFromBand(band.ID); return band; } reader.Close(); } // Fail catch (Exception ex) { Console.WriteLine(ex.Message); } return null; }
protected override void ExecuteInsertPerformerCommand(string[] commandWords) { switch (commandWords[2]) { case "band": var band = new Band(commandWords[3]); this.InsertPerformer(band); break; default: base.ExecuteInsertPerformerCommand(commandWords); break; } }
public LineUpViewModel() { FormBand = new Band(); SelectedIndexStage = 0; GenreList = Genre.GetGenres(); ListBands = Band.GetBands(); AddContVis = "Hidden"; GenreContVis = "Hidden"; TimeList = GetTimes(); DatumList = Festival.GetDates(); StageList = Stage.GetStages(); SelectedDatum = DatumList[0]; SelectedStage = StageList[0]; SelectedStartIndex = 0; SelectedEndIndex = 0; SelectedBandIndex = 0; AddLineUpVis = "Visible"; EditLineUpVis = "Hidden"; EditGenre = new Genre(); LineUpList = LineUp.GetLineUp(DatumList[0], StageList[0]); }
protected void addBand_Click(object sender, EventArgs e) { Band band = new Band("New Band", "0"); List<Band> temp = bands.ToList(); temp.Add(band); bands = temp.ToArray(); //Create at least one member Member newMember = new Member("Enter name", ""); //Set selected band selectedBand = band; //Add Member selectedBand.addMember(newMember); //Save save(); //Reload the page Response.Redirect(String.Format("~/band.aspx?b={0}", selectedBand.getName())); }
public LineUp GetLineUpByBand(Band band) { List<Stage> lS = StageRepository.GetStages(); String sql = "SELECT * FROM LineUp WHERE Band=@BandId"; DbParameter idPar = Database.AddParameter("@BandId", band.Id); DbDataReader reader = Database.GetData(sql, idPar); while (reader.Read()) { int IdStage = int.Parse(reader["Stage"].ToString()); //nog aanpassen Stage stage = StageRepository.GetStageById(lS, IdStage); LineUp lineup = CreateLineUpFromBand(reader, stage); reader.Close(); return lineup; } reader.Close(); return null; }
public static string AddLineUp(Band SelectedBandAdd, string StartTime, string EndTime, Stage SelectedStage, DateTime SelectedDatum) { string error = ""; error = CheckTime(StartTime, EndTime, SelectedStage,SelectedDatum); if (error == null) { error = CheckBand(StartTime, EndTime, SelectedStage, SelectedBandAdd,SelectedDatum); if (error == null) { Database.ModifyData("INSERT INTO tbl_lineup (DatePreformance,FromTime,UntilTime,Stage,Band) VALUES (@date,@from,@until,@stage,@band)", Database.AddParameter("@date", SelectedDatum), Database.AddParameter("@from", StartTime), Database.AddParameter("@until", EndTime), Database.AddParameter("@stage", Convert.ToInt32(SelectedStage.ID)), Database.AddParameter("@band", Convert.ToInt32(SelectedBandAdd.ID)) ); } else { return error; } } return error; }
public NeedMembersQueryViewModel(Band band, Instrument instrument) { Band = band; SelectedInstrument = instrument; }
public void UpdateBand(Band band) { throw new NotImplementedException(); }
public int GetNextSerial(Band band) { return 1; }
public IActionResult UpdateBandImageMobile(BandForm model) { if (model.BandImageMobile != null) { var tupleSmall = UploadedFileSmall(model); string uniqueFileNameSmall = tupleSmall.Item1; string fileExtSmall = tupleSmall.Item2; long fileSizeSmall = tupleSmall.Item3; string[] permittedExtensions = { ".gif", ".jpg", ".jpeg", ".png" }; // if file is greater than 5 MB if (fileSizeSmall > 5000000) { ViewBag.msg = "Image Small Too Big: " + fileSizeSmall.ToString(); return(View()); } // if file is not a whitelisted type if (!permittedExtensions.Contains(fileExtSmall)) { ViewBag.msg = "Wrong File type " + fileExtSmall; return(View()); } if (model.BandImageName != null) { Band editBand = new Band { BandID = model.BandID, BandTitle = model.BandTitle, BandGenre = model.BandGenre, BandDescription = model.BandDescription, BandImage = model.BandImageName, BandImageMobile = uniqueFileNameSmall, BandPrice = model.BandPrice, Stars = model.Stars, BandDate = model.BandDate, BandArea = model.BandArea }; _context.Bands.Update(editBand); } else { Band editBand = new Band { BandID = model.BandID, BandTitle = model.BandTitle, BandGenre = model.BandGenre, BandDescription = model.BandDescription, BandImageMobile = uniqueFileNameSmall, BandPrice = model.BandPrice, Stars = model.Stars, BandDate = model.BandDate, BandArea = model.BandArea }; _context.Bands.Update(editBand); } _context.SaveChanges(); return(RedirectToAction("Index")); } if (model.BandImageMobileName != null) { Band editBand = new Band { BandID = model.BandID, BandTitle = model.BandTitle, BandGenre = model.BandGenre, BandDescription = model.BandDescription, BandImage = model.BandImageName, BandImageMobile = model.BandImageMobileName, BandPrice = model.BandPrice, Stars = model.Stars, BandDate = model.BandDate, BandArea = model.BandArea }; _context.Bands.Update(editBand); _context.SaveChanges(); } return(RedirectToAction("Index")); }
private static Bitmap CreateCompatibleBitmap(Dataset ds, int imageWidth, int imageHeight) { if (ds.RasterCount == 0) { return(null); } bandMap = new int[4] { 1, 1, 1, 1 }; channelCount = 1; hasAlpha = false; isPremultiplied = false; isIndexed = false; channelSize = 8; // Evaluate the bands and find out a proper image transfer format for (int i = 0; i < ds.RasterCount; i++) { Band band = ds.GetRasterBand(i + 1); if (Gdal.GetDataTypeSize(band.DataType) > 8) { channelSize = 16; } // retrieving the premultiplied alpha flag string[] metadata = band.GetMetadata(""); for (int iMeta = 0; iMeta < metadata.Length; iMeta++) { if (metadata[iMeta].StartsWith("PREMULTIPLIED_ALPHA")) { isPremultiplied = true; } } switch (band.GetRasterColorInterpretation()) { case ColorInterp.GCI_AlphaBand: channelCount = 4; hasAlpha = true; bandMap[3] = i + 1; break; case ColorInterp.GCI_BlueBand: if (channelCount < 3) { channelCount = 3; } bandMap[0] = i + 1; break; case ColorInterp.GCI_RedBand: if (channelCount < 3) { channelCount = 3; } bandMap[2] = i + 1; break; case ColorInterp.GCI_GreenBand: if (channelCount < 3) { channelCount = 3; } bandMap[1] = i + 1; break; case ColorInterp.GCI_PaletteIndex: ct = band.GetRasterColorTable(); isIndexed = true; bandMap[0] = i + 1; break; case ColorInterp.GCI_GrayIndex: isIndexed = true; bandMap[0] = i + 1; break; default: // we create the bandmap using the dataset ordering by default if (i < 4 && bandMap[i] == 0) { if (channelCount < i) { channelCount = i; } bandMap[i] = i + 1; } break; } } // find out the pixel format based on the gathered information if (isIndexed) { pixelFormat = PixelFormat.Format8bppIndexed; dataType = DataType.GDT_Byte; pixelSpace = 1; } else { if (channelCount == 1) { if (channelSize > 8) { pixelFormat = PixelFormat.Format16bppGrayScale; dataType = DataType.GDT_Int16; pixelSpace = 2; } else { pixelFormat = PixelFormat.Format24bppRgb; channelCount = 3; dataType = DataType.GDT_Byte; pixelSpace = 3; } } else { if (hasAlpha) { if (channelSize > 8) { if (isPremultiplied) { pixelFormat = PixelFormat.Format64bppArgb; } else { pixelFormat = PixelFormat.Format64bppPArgb; } dataType = DataType.GDT_UInt16; pixelSpace = 8; } else { if (isPremultiplied) { pixelFormat = PixelFormat.Format32bppPArgb; } else { pixelFormat = PixelFormat.Format32bppArgb; } dataType = DataType.GDT_Byte; pixelSpace = 4; } channelCount = 4; } else { if (channelSize > 8) { pixelFormat = PixelFormat.Format48bppRgb; dataType = DataType.GDT_UInt16; pixelSpace = 6; } else { pixelFormat = PixelFormat.Format24bppRgb; dataType = DataType.GDT_Byte; pixelSpace = 3; } channelCount = 3; } } } // Create a Bitmap to store the GDAL image in return(new Bitmap(imageWidth, imageHeight, pixelFormat)); }
public static bool GetBandLimits(double freq, out Band outBand) { try { string sBand = ""; string f = freq.ToString("f6"); f = f.Replace(",", "."); DataRow[] rows = ds_band.Tables["BandLimits"].Select(f + ">=Low AND " + f + "<=High"); if (rows.Length == 0) // band not found { outBand = Band.B20M; return false; } else if (rows.Length == 1) // found band { outBand = Band.B20M; sBand = ((string)rows[0]["Name"]); switch (sBand) { case "B160M": outBand = Band.B160M; break; case "B80M": outBand = Band.B80M; break; case "B40M": outBand = Band.B40M; break; case "B30M": outBand = Band.B30M; break; case "B20M": outBand = Band.B20M; break; case "B17M": outBand = Band.B17M; break; case "B15M": outBand = Band.B15M; break; case "B12M": outBand = Band.B12M; break; case "B10M": outBand = Band.B10M; break; case "B6M": outBand = Band.B6M; break; } return true; } else if (rows.Length > 1) { MessageBox.Show("Error reading BandLimits table. Entries overlap!", "BandLimits Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); outBand = Band.B20M; return false; } else { outBand = Band.B20M; return false; } } catch (Exception e) { MessageBox.Show(e.Message + "\n\n\n" + e.StackTrace, "BandLimits Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); outBand = Band.B20M; return false; } }
private string BandToString(Band b) { string ret_val = ""; switch(b) { case Band.B160M: ret_val = "160m"; break; case Band.B80M: ret_val = "80m"; break; case Band.B60M: ret_val = "60m"; break; case Band.B40M: ret_val = "40m"; break; case Band.B30M: ret_val = "30m"; break; case Band.B20M: ret_val = "20m"; break; case Band.B17M: ret_val = "17m"; break; case Band.B15M: ret_val = "15m"; break; case Band.B12M: ret_val = "12m"; break; case Band.B10M: ret_val = "10m"; break; case Band.B6M: ret_val = "6m"; break; } return ret_val; }
private Band StringToBand(string s) { Band b = Band.GEN; switch (s) { case "GEN": b = Band.GEN; break; case "160m": b = Band.B160M; break; case "80m": b = Band.B80M; break; case "60m": b = Band.B60M; break; case "40m": b = Band.B40M; break; case "30m": b = Band.B30M; break; case "20m": b = Band.B20M; break; case "17m": b = Band.B17M; break; case "15m": b = Band.B15M; break; case "12m": b = Band.B12M; break; case "10m": b = Band.B10M; break; case "6m": b = Band.B6M; break; case "2m": b = Band.B2M; break; case "WWV": b = Band.WWV; break; case "VFO0": b = Band.VHF0; break; case "VFO1": b = Band.VHF1; break; case "VFO2": b = Band.VHF2; break; case "VFO3": b = Band.VHF3; break; case "VFO4": b = Band.VHF4; break; case "VFO5": b = Band.VHF5; break; case "VFO6": b = Band.VHF6; break; case "VFO7": b = Band.VHF7; break; case "VFO8": b = Band.VHF8; break; case "VFO9": b = Band.VHF9; break; case "VFO10": b = Band.VHF10; break; case "VFO11": b = Band.VHF11; break; case "VFO12": b = Band.VHF12; break; case "VFO13": b = Band.VHF13; break; } return(b); }
public void UpdateRelayState(out bool tx1, out bool tx2, out bool tx3) { bool t1 = false, t2 = false, t3 = false; bool power = console.PowerOn; Band band = console.TXBand; DSPMode mode = console.RX1DSPMode; for (int i = lstRules.Items.Count - 1; i >= 0; i--) { string s = (string)lstRules.Items[i]; string[] words = s.Split(' '); bool c1 = false, c2 = false; switch (words[4]) { case "Power": if ((words[5] == "Is" && ((words[6] == "On" && power) || (words[6] == "Off" && !power))) || (words[5] == "Is_Not" && ((words[6] == "On" && !power) || (words[6] == "Off" && power)))) { c1 = true; } break; case "Band": if ((words[5] == "Is" && StringToBand(words[6]) == band) || (words[5] == "Is_Not" && StringToBand(words[6]) != band)) { c1 = true; } break; case "Mode": if ((words[5] == "Is" && words[6] == mode.ToString()) || (words[5] == "Is_Not" && words[6] != mode.ToString())) { c1 = true; } break; } if (words.Length == 7) { c2 = true; } else if (words.Length == 11) { switch (words[8]) { case "Power": if ((words[9] == "Is" && ((words[10] == "On" && power) || (words[10] == "Off" && !power))) || (words[9] == "Is_Not" && ((words[10] == "On" && !power) || (words[10] == "Off" && power)))) { c2 = true; } break; case "Band": if ((words[9] == "Is" && StringToBand(words[10]) == band) || (words[9] == "Is_Not" && StringToBand(words[10]) != band)) { c2 = true; } break; case "Mode": if ((words[9] == "Is" && words[10] == mode.ToString()) || (words[9] == "Is_Not" && words[10] != mode.ToString())) { c2 = true; } break; } } if (c1 && c2) { if (words[1] == "On") { switch (words[2]) { case "TX1": t1 = true; break; case "TX2": t2 = true; break; case "TX3": t3 = true; break; } } else // words[1] == "Off" { switch (words[2]) { case "TX1": t1 = false; break; case "TX2": t2 = false; break; case "TX3": t3 = false; break; } } } else { if (words[1] == "On") { switch (words[2]) { case "TX1": t1 = false; break; case "TX2": t2 = false; break; case "TX3": t3 = false; break; } } else // words[1] == "Off" { switch (words[2]) { case "TX1": t1 = true; break; case "TX2": t2 = true; break; case "TX3": t3 = true; break; } } } } tx1 = t1; tx2 = t2; tx3 = t3; if (tx1) { btnTX1.BackColor = Color.Green; } else { btnTX1.BackColor = Color.Red; } if (tx2) { btnTX2.BackColor = Color.Green; } else { btnTX2.BackColor = Color.Red; } if (tx3) { btnTX3.BackColor = Color.Green; } else { btnTX3.BackColor = Color.Red; } }
static void Main(string[] args) { //verify gdal dlls are available; see: http://trac.osgeo.org/gdal/wiki/GdalOgrCsharpUsage string GDAL_HOME = @";c:\Program Files (x86)\FWTools2.4.7\bin"; string path = Environment.GetEnvironmentVariable("PATH"); path += ";" + GDAL_HOME; SetEnvironmentVariable("PATH", path); // string tifDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string tifDirectory = @"C:\dev\quito\For_Geoportal\For_Geoportal\Climate\"; string resultDirectory = tifDirectory + @"out\"; if (args.Length == 1) { tifDirectory = args[0]; } Gdal.AllRegister(); OSGeo.GDAL.Driver srcDrv = Gdal.GetDriverByName("GTiff"); //if app scales, or additional implementations made (e.g. database table), use DI for this dependency IColorRepository colorRepo = new ColorRepository(); //see: http://sharpmap.codeplex.com/discussions/421752 GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices(); Console.WriteLine(tifDirectory); DirectoryInfo di = new DirectoryInfo(tifDirectory); DirectoryInfo resultDir = new DirectoryInfo(resultDirectory); if (!resultDir.Exists) { resultDir.Create(); } Console.WriteLine("Processing {0} files matching '*.tif'"); foreach (FileInfo fi in di.GetFiles("*.tif")) { Console.WriteLine("Processing " + fi.Name + "..."); //read data from source raster Dataset src = Gdal.Open(fi.FullName, Access.GA_ReadOnly); Band band = src.GetRasterBand(1); float[] r = new float[band.XSize * band.YSize]; byte[] red = new byte[band.XSize * band.YSize]; byte[] green = new byte[band.XSize * band.YSize]; byte[] blue = new byte[band.XSize * band.YSize]; band.ReadRaster(0, 0, band.XSize, band.YSize, r, band.XSize, band.YSize, 0, 0); //assign values to rgb rasters to produce new raster with rgb bands matching color pattern for (int cell = 0; cell < r.Length; cell++) { RGBColors colors = colorRepo.ColorsOfValueInFile(fi.Name, r[cell]); red[cell] = (byte)colors.Red; green[cell] = (byte)colors.Green; blue[cell] = (byte)colors.Blue; } //write new output using (Dataset output = srcDrv.Create(resultDirectory + fi.Name, band.XSize, band.YSize, 3, DataType.GDT_Byte, null)) { if (output == null) { Console.WriteLine("Can't create " + args[0]); System.Environment.Exit(-1); } //set metadata output.SetProjection(src.GetProjection()); double[] geotransform = new double[0]; src.GetGeoTransform(geotransform); output.SetGeoTransform(geotransform); //prepare data for write int[] colorData = new int[red.Length * 3]; red.CopyTo(colorData, 0); green.CopyTo(colorData, red.Length); blue.CopyTo(colorData, red.Length + green.Length); //write data to disk output.WriteRaster(0, 0, band.XSize, band.YSize, colorData, band.XSize, band.YSize, 3, null, 0, 0, 0); output.FlushCache(); } } }
private string BandToString(Band b) { string ret_val = ""; switch (b) { case Band.GEN: ret_val = "GEN"; break; case Band.B160M: ret_val = "160m"; break; case Band.B80M: ret_val = "80m"; break; case Band.B60M: ret_val = "60m"; break; case Band.B40M: ret_val = "40m"; break; case Band.B30M: ret_val = "30m"; break; case Band.B20M: ret_val = "20m"; break; case Band.B17M: ret_val = "17m"; break; case Band.B15M: ret_val = "15m"; break; case Band.B12M: ret_val = "12m"; break; case Band.B10M: ret_val = "10m"; break; case Band.B6M: ret_val = "6m"; break; case Band.B2M: ret_val = "2m"; break; case Band.WWV: ret_val = "WWV"; break; case Band.VHF0: ret_val = "VHF0"; break; case Band.VHF1: ret_val = "VHF1"; break; case Band.VHF2: ret_val = "VHF2"; break; case Band.VHF3: ret_val = "VHF3"; break; case Band.VHF4: ret_val = "VHF4"; break; case Band.VHF5: ret_val = "VHF5"; break; case Band.VHF6: ret_val = "VHF6"; break; case Band.VHF7: ret_val = "VHF7"; break; case Band.VHF8: ret_val = "VHF8"; break; case Band.VHF9: ret_val = "VHF9"; break; case Band.VHF10: ret_val = "VHF10"; break; case Band.VHF11: ret_val = "VHF11"; break; case Band.VHF12: ret_val = "VHF12"; break; case Band.VHF13: ret_val = "VHF13"; break; } return(ret_val); }
public void GetAll_BandsEmptyAtFirst_0() { int result = Band.GetAll().Count; Assert.AreEqual(0, result); }
public void Dispose() { Venue.ClearAll(); Band.ClearAll(); }
/// <summary> /// Scans the specified path for music files. /// </summary> /// <param name="path"></param> /// <returns>A <see cref="Collection"/> with tag information.</returns> public static Collection ScanDirectory(string path) { Collection collection = new Collection(path); DirectoryInfo directory = new DirectoryInfo(path); foreach (var file in directory.EnumerateFiles("*.mp3", SearchOption.AllDirectories)) { var libFile = new TagLibFile(file); TagLib.File tagLibFile = null; try { tagLibFile = TagLib.File.Create(libFile); } catch (TagLib.CorruptFileException) { File.Move(file.FullName, file.FullName + "_corrrupt_"); continue; } catch (TagLib.UnsupportedFormatException) { continue; } catch (IOException) { continue; } using (tagLibFile) { Band band = null; Album album = null; Song song = null; TagLib.Tag tag = tagLibFile.Tag; TagInformation information = new TagInformation(tag); if (information.Title == null) { information.Title = file.Name; } if (information.Album == null) { information.Album = information.Title; } band = collection.Bands.FirstOrDefault(b => b.Name == information.Band); // If no band with that name found, make a new one if (band == null) { band = new Band(); band.Name = information.Band; collection.Bands.Add(band); } album = band.Albums.FirstOrDefault(a => a.Name == information.Album); // If no album with that name found, or its a new band if (album == null) { album = new Album(); album.Name = information.Album; album.Year = tag.Year; band.Albums.Add(album); } song = album.Songs.FirstOrDefault(s => s.Name == information.Title); // If that song exists, add the song suffixing with '_' if (song != null) { information.Title += "_"; } song = new Song(); album.Songs.Add(song); song.Name = information.Title; song.FilePath = file.FullName.Replace(path, ""); song.Duration = null; song.Track = information.Track; band.Albums.Add(album); } } return(collection); }
private static void GetBandsWithoutTimeSlot(ref List<Band> bands, bool asc) { try { // Get data DbDataReader reader; if (asc) reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description FROM band AS b LEFT OUTER JOIN timeslot AS ts ON b.ID = ts.bandID WHERE ts.bandID IS NULL ORDER BY Name ASC"); else reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description FROM band AS b LEFT OUTER JOIN timeslot AS ts ON b.ID = ts.bandID WHERE ts.bandID IS NULL ORDER BY Name DESC"); foreach (DbDataRecord record in reader) { Band band = new Band(); // Get ID if (DBNull.Value.Equals(record["ID"])) band.ID = -1; else band.ID = Convert.ToInt32(record["ID"]); // Get Name if (DBNull.Value.Equals(record["Name"])) band.Name = ""; else band.Name = record["Name"].ToString(); // Get Twitter if (DBNull.Value.Equals(record["Twitter"])) band.Twitter = ""; else band.Twitter = record["Twitter"].ToString(); // Get Facebook if (DBNull.Value.Equals(record["Facebook"])) band.Facebook = ""; else band.Facebook = record["Facebook"].ToString(); // Get Picture if (DBNull.Value.Equals(record["Picture"])) band.Picture = null; else band.Picture = (byte[])record["Picture"]; // Get Description if (DBNull.Value.Equals(record["Description"])) band.Description = ""; else band.Description = record["Description"].ToString(); // Get Genres band.Genres = GenreSQLRepository.GetGenresFromBand(band.ID); //Get Timeslots band.TimeSlots = null; bands.Add(band); } reader.Close(); } // Fail catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Initialize(ApplicationDbContext context) { context.Database.EnsureCreated(); if (context.Tours.Any()) { return; } // init seed data var managers = new Manager[] { new Manager { ManagerId = new Guid("fec0a4d6-5830-4eb8-8024-272bd5d6d2bb"), Name = "Kevin", CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Manager { ManagerId = new Guid("c3b7f625-c07f-4d7d-9be1-ddff8ff93b4d"), Name = "Sven", CreatedBy = "system", CreatedOn = DateTime.UtcNow } }; foreach (Manager manager in managers) { context.Managers.Add(manager); } context.SaveChanges(); var bands = new Band[] { new Band { BandId = new Guid("25320c5e-f58a-4b1f-b63a-8ee07a840bdf"), Name = "Queens of the Stone Age", CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Band { BandId = new Guid("83b126b9-d7bf-4f50-96dc-860884155f8b"), Name = "Nick Cave and the Bad Seeds", CreatedBy = "system", CreatedOn = DateTime.UtcNow } }; foreach (Band band in bands) { context.Bands.Add(band); } context.SaveChanges(); var tours = new Tour[] { new Tour { TourId = new Guid("c7ba6add-09c4-45f8-8dd0-eaca221e5d93"), BandId = new Guid("25320c5e-f58a-4b1f-b63a-8ee07a840bdf"), ManagerId = new Guid("fec0a4d6-5830-4eb8-8024-272bd5d6d2bb"), Title = "Villains World Tour", Description = "The Villains World Tour is a concert tour in support of the band's seventh studio album, Villains.", StartDate = new DateTimeOffset(2017, 6, 22, 0, 0, 0, new TimeSpan()), EndDate = new DateTimeOffset(2018, 3, 18, 0, 0, 0, new TimeSpan()), EstimatedProfits = 2500000, CreatedBy = "system", CreatedOn = DateTime.UtcNow, Shows = new Show[] { new Show { Venue = "The Rapids Theatre", City = "Niagara Falls", Country = "United States", Date = new DateTimeOffset(2017, 6, 22, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Marina de Montebello", City = "Montebello", Country = "Canada", Date = new DateTimeOffset(2017, 6, 24, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Ventura Theatre", City = "Venture", Country = "United States", Date = new DateTimeOffset(2017, 8, 10, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Golden Gate Park", City = "San Francisco", Country = "United States", Date = new DateTimeOffset(2017, 8, 12, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Capitol Theatre", City = "Port Chester", Country = "United States", Date = new DateTimeOffset(2017, 9, 6, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Festival Pier", City = "Philadelphia", Country = "United States", Date = new DateTimeOffset(2017, 9, 7, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Budweiser Stage", City = "Toronto", Country = "Canada", Date = new DateTimeOffset(2017, 9, 9, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow } } }, new Tour { TourId = new Guid("f67ba678-b6e0-4307-afd9-e804c23b3cd3"), BandId = new Guid("83b126b9-d7bf-4f50-96dc-860884155f8b"), ManagerId = new Guid("c3b7f625-c07f-4d7d-9be1-ddff8ff93b4d"), Title = "Skeleton Tree European Tour", Description = "Nick Cave and The Bad Seeds have announced an 8-week European tour kicking off in the UK at Bournemouth’s International Centre on 24th September. The tour will be the first time European audiences can experience live songs from new album Skeleton Tree alongside other Nick Cave & The Bad Seeds classics. The touring line up features Nick Cave, Warren Ellis, Martyn Casey, Thomas Wydler, Jim Sclavunos, Conway Savage, George Vjestica and Larry Mullins.", StartDate = new DateTimeOffset(2017, 9, 24, 0, 0, 0, new TimeSpan()), EndDate = new DateTimeOffset(2017, 11, 20, 0, 0, 0, new TimeSpan()), EstimatedProfits = 1200000, CreatedBy = "system", CreatedOn = DateTime.UtcNow, Shows = new Show[] { new Show { Venue = "Bournemouth International Centre", City = "Bournemouth", Country = "United Kingdom", Date = new DateTimeOffset(2017, 9, 24, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Arena", City = "Manchester", Country = "United Kingdom", Date = new DateTimeOffset(2017, 9, 25, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "The SSE Hydro", City = "Glasgow", Country = "United Kingdom", Date = new DateTimeOffset(2017, 9, 27, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Motorpoint Arena", City = "Nottingham", Country = "United Kingdom", Date = new DateTimeOffset(2017, 9, 28, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "The O2", City = "London", Country = "United Kingdom", Date = new DateTimeOffset(2017, 9, 30, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Zénith", City = "Paris", Country = "France", Date = new DateTimeOffset(2017, 10, 3, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Ziggo Dome", City = "Amsterdam", Country = "The Netherlands", Date = new DateTimeOffset(2017, 10, 6, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Jahrhunderthalle", City = "Frankfurt", Country = "Germany", Date = new DateTimeOffset(2017, 10, 7, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Sporthalle", City = "Hamburg", Country = "Germany", Date = new DateTimeOffset(2017, 10, 9, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Rockhal", City = "Luxembourg", Country = "Luxembourg", Date = new DateTimeOffset(2017, 10, 10, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Mitsubishi Electric Halle", City = "Düsseldorf", Country = "Germany", Date = new DateTimeOffset(2017, 10, 10, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow }, new Show { Venue = "Sportpaleis", City = "Antwerp", Country = "Belgium", Date = new DateTimeOffset(2017, 10, 13, 0, 0, 0, new TimeSpan()), CreatedBy = "system", CreatedOn = DateTime.UtcNow } } } }; foreach (Tour tour in tours) { context.Tours.Add(tour); } context.SaveChanges(); }
public IActionResult DeleteBand(int Id) { Band model = _context.Bands.Find(Id); return(View(model)); }
public static Bitmap LoadImage(string file) { lock (locker) { using (var ds = OSGeo.GDAL.Gdal.Open(file, OSGeo.GDAL.Access.GA_ReadOnly)) { // 8bit geotiff - single band if (ds.RasterCount == 1) { Band band = ds.GetRasterBand(1); if (band == null) { return(null); } ColorTable ct = band.GetRasterColorTable(); PixelFormat format = PixelFormat.Format8bppIndexed; // Create a Bitmap to store the GDAL image in Bitmap bitmap = new Bitmap(ds.RasterXSize, ds.RasterYSize, format); // Obtaining the bitmap buffer BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, ds.RasterXSize, ds.RasterYSize), ImageLockMode.ReadWrite, format); try { if (ct != null) { int iCol = ct.GetCount(); ColorPalette pal = bitmap.Palette; for (int i = 0; i < iCol; i++) { ColorEntry ce = ct.GetColorEntry(i); pal.Entries[i] = Color.FromArgb(ce.c4, ce.c1, ce.c2, ce.c3); } bitmap.Palette = pal; } else { } int stride = bitmapData.Stride; IntPtr buf = bitmapData.Scan0; band.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, buf, ds.RasterXSize, ds.RasterYSize, DataType.GDT_Byte, 1, stride); } finally { bitmap.UnlockBits(bitmapData); } return(bitmap); } { Bitmap bitmap = new Bitmap(ds.RasterXSize, ds.RasterYSize, PixelFormat.Format32bppArgb); if (ds.RasterCount == 3) { // when we load a 24bit bitmap, we need to set the alpha channel else we get nothing using (var tmp = Graphics.FromImage(bitmap)) { tmp.Clear(Color.White); } } for (int a = 1; a <= ds.RasterCount; a++) { // Get the GDAL Band objects from the Dataset Band band = ds.GetRasterBand(a); if (band == null) { return(null); } var cint = band.GetColorInterpretation(); // Obtaining the bitmap buffer BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, ds.RasterXSize, ds.RasterYSize), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); try { int stride = bitmapData.Stride; IntPtr buf = bitmapData.Scan0; var buffer = new byte[ds.RasterXSize * ds.RasterYSize]; band.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, buffer, ds.RasterXSize, ds.RasterYSize, 1, ds.RasterXSize); int c = 0; if (cint == ColorInterp.GCI_AlphaBand) { foreach (var b in buffer) { Marshal.WriteByte(buf, 3 + c * 4, (byte)b); c++; } } else if (cint == ColorInterp.GCI_RedBand) { foreach (var b in buffer) { Marshal.WriteByte(buf, 2 + c * 4, (byte)b); c++; } } else if (cint == ColorInterp.GCI_GreenBand) { foreach (var b in buffer) { Marshal.WriteByte(buf, 1 + c * 4, (byte)b); c++; } } else if (cint == ColorInterp.GCI_BlueBand) { foreach (var b in buffer) { Marshal.WriteByte(buf, 0 + c * 4, (byte)b); c++; } } else { } } finally { bitmap.UnlockBits(bitmapData); } } //bitmap.Save("gdal.png", ImageFormat.Png); return(bitmap); } } } return(null); }
public BandViewModel(Band band) { _band = band; InitSensors(); UpdateConnectedStatus(); _connectCmd = new Lazy<AsyncDelegateCommand<object>>(() => { return new AsyncDelegateCommand<object>(ConnectBand, CanConnect); }); }
public static VertexCollection getVersFromDEM(string imgpath) { VertexCollection vc = new VertexCollection(); //栅格范围:left,top,right,bottom //double dProjX = 138542.596197; //double dProjY = 177431.143484; //double dProjX1 = 141246.33321; //double dProjY1 = 173721.13817; _ds = Gdal.Open(imgpath, Access.GA_ReadOnly); srcWidth = _ds.RasterXSize; srcHeight = _ds.RasterYSize; int bandCount = _ds.RasterCount; int[] bandArray = new int[bandCount]; for (int i = 0; i < bandCount; i++) { bandArray[i] = i + 1; } double[] dataArray = new double[srcWidth * srcHeight * bandCount]; double[] dataArray1 = new double[srcWidth * srcHeight * bandCount]; double x, y; _ds.ReadRaster(0, 0, srcWidth, srcHeight, dataArray, srcWidth, srcHeight, bandCount, bandArray, 0, 0, 0); RasterWriter.writeFornixObj(dataArray, srcWidth, srcHeight, @"E:\Users\LiuXianyu\Documents\ExperimentData\myProject\FornixModelingGDAL\Data\LingYanShan\Export\Raster.txt"); //获取坐标变换系数 //0左上角x坐标 //1东西方向分辨率 //2旋转角度, 0表示图像 "北方朝上" //3左上角y坐标 //4旋转角度, 0表示图像 "北方朝上" //5南北方向分辨率 _ds.GetGeoTransform(_adfGeoTransform); Band band = _ds.GetRasterBand(1); band.ComputeRasterMinMax(lim, 0); //VIP法筛选DEM点 //getInnerPointsByVIP(dataArray, dataArray1); //固定步长法筛选DEM点 getInnerPointsByStep(dataArray, dataArray1); //根据矩阵数据生成点集 for (int i = 0; i < srcWidth; ++i) { for (int j = 0; j < srcHeight; ++j) { if (-1.0 != dataArray1[i * srcWidth + j]) { Vertex ver = new Vertex(); getCoordinateFromMatrix(dataArray1, i, j, out x, out y); ver.X(x); ver.Y(y); //ver.Z(dataArray1[i * srcWidth + j]); ver.Z(GetElevation(x, y)); ver.innerPoint = true; vc.addVer(ver); } } } return(vc); }
private string BandToString(Band b) { string ret_val = ""; switch(b) { case Band.GEN: ret_val = "GEN"; break; case Band.B160M: ret_val = "160m"; break; case Band.B80M: ret_val = "80m"; break; case Band.B60M: ret_val = "60m"; break; case Band.B40M: ret_val = "40m"; break; case Band.B30M: ret_val = "30m"; break; case Band.B20M: ret_val = "20m"; break; case Band.B17M: ret_val = "17m"; break; case Band.B15M: ret_val = "15m"; break; case Band.B12M: ret_val = "12m"; break; case Band.B10M: ret_val = "10m"; break; case Band.B6M: ret_val = "6m"; break; case Band.B2M: ret_val = "2m"; break; case Band.WWV: ret_val = "WWV"; break; case Band.VHF0: ret_val = "VHF0"; break; case Band.VHF1: ret_val = "VHF1"; break; case Band.VHF2: ret_val = "VHF2"; break; case Band.VHF3: ret_val = "VHF3"; break; case Band.VHF4: ret_val = "VHF4"; break; case Band.VHF5: ret_val = "VHF5"; break; case Band.VHF6: ret_val = "VHF6"; break; case Band.VHF7: ret_val = "VHF7"; break; case Band.VHF8: ret_val = "VHF8"; break; case Band.VHF9: ret_val = "VHF9"; break; case Band.VHF10: ret_val = "VHF10"; break; case Band.VHF11: ret_val = "VHF11"; break; case Band.VHF12: ret_val = "VHF12"; break; case Band.VHF13: ret_val = "VHF13"; break; } return ret_val; }
private List<XRControl> VisitBandChildren(Band band) { // Special Controls - Bands & Subreport Placeholders (which need additional event handlers) var childBands = band.Controls.OfType<Band>().ToList(); var subreportPlaceholders = band.Controls.OfType<XRSubreport>().ToList(); // Attach to Special Controls childBands.ForEach(AttachToControl); subreportPlaceholders.ForEach(AttachToControl); var ignore = childBands.Concat(subreportPlaceholders.Cast<XRControl>()); // Normal Controls return band.Controls.Cast<XRControl>().Except(ignore).ToList(); }
private void setBand(string bandName) { //Get the selected band var bands_query = bands.Where(b => b.getName() == bandName).ToArray(); if (bands_query.Length == 0) { //Set the page title bandPageLabel.Text = "Band doesn't exist"; return; } //Get the selected band selectedBand = bands_query[0]; //Make the add member button visible add.Visible = true; addShow.Visible = true; //If postback - we don't want to erase this data if (!IsPostBack) { //Set the page title bandPageLabel.Text = selectedBand.getName(); //Add members beneath band bandPageSubLabel.Visible = false; //selectedBand.addMember(new Member("Enter name", "Enter Instrument")); memberGrid.DataSource = selectedBand.getMembers().Select(m => new { Name = m.getName(), Instrument = m.getInstrument(), Joined = m.getJoinDate() }).ToList(); memberGrid.DataBind(); //bind show showGridView.DataSource = selectedBand.getShows().Select(s => new { venue = s.getVenue(), date = s.getDate() }).ToList(); showGridView.DataBind(); } }
public IActionResult AddBand(BandForm model) { if (ModelState.IsValid) { string[] permittedExtensions = { ".gif", ".jpg", ".jpeg", ".png" }; if (model.BandImage != null) { var tupleLarge = UploadedFileLarge(model); string uniqueFileNameLarge = tupleLarge.Item1; string fileExtLarge = tupleLarge.Item2; long fileSizeLarge = tupleLarge.Item3; // if file is greater than 5 MB if (fileSizeLarge > 5000000) { ViewBag.msg = "Image Large Too Big: " + fileSizeLarge.ToString(); return(View()); } // if file is not a whitelisted type if (!permittedExtensions.Contains(fileExtLarge)) { ViewBag.msg = "Wrong File type " + fileExtLarge; return(View()); } model.BandImageName = uniqueFileNameLarge; } if (model.BandImageMobile != null) { var tupleSmall = UploadedFileSmall(model); string uniqueFileNameSmall = tupleSmall.Item1; string fileExtSmall = tupleSmall.Item2; long fileSizeSmall = tupleSmall.Item3; // if file is greater than 5 MB if (fileSizeSmall > 5000000) { ViewBag.msg = "Image Small Too Big: " + fileSizeSmall.ToString(); return(View()); } // if file is not a whitelisted type if (!permittedExtensions.Contains(fileExtSmall)) { ViewBag.msg = "Wrong File type " + fileExtSmall; return(View()); } model.BandImageMobileName = uniqueFileNameSmall; } Band newBand = new Band { BandTitle = model.BandTitle, BandGenre = model.BandGenre, BandDescription = model.BandDescription, BandImage = model.BandImageName, BandImageMobile = model.BandImageMobileName, BandPrice = model.BandPrice, Stars = model.Stars, BandDate = model.BandDate, BandArea = model.BandArea }; _context.Add(newBand); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View()); }
protected override void SolveInstance(IGH_DataAccess DA) { List <Curve> boundary = new List <Curve>(); DA.GetDataList <Curve>(0, boundary); string IMG_file = string.Empty; DA.GetData <string>(1, ref IMG_file); RESTful.GdalConfiguration.ConfigureGdal(); OSGeo.GDAL.Gdal.AllRegister(); Dataset datasource = Gdal.Open(IMG_file, Access.GA_ReadOnly); OSGeo.GDAL.Driver drv = datasource.GetDriver(); if (datasource == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The vector datasource was unreadable by this component. It may not a valid file type for this component or otherwise null/empty."); return; } ///Get info about image string srcInfo = string.Empty; List <string> infoOptions = new List <string> { "-stats" }; srcInfo = Gdal.GDALInfo(datasource, new GDALInfoOptions(infoOptions.ToArray())); ///Get the spatial reference of the input raster file and set to WGS84 if not known ///Set up transform from source to WGS84 OSGeo.OSR.SpatialReference sr = new SpatialReference(Osr.SRS_WKT_WGS84); if (datasource.GetProjection() == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Coordinate Reference System (CRS) is missing. CRS set automatically set to WGS84."); } else { sr = new SpatialReference(datasource.GetProjection()); if (sr.Validate() != 0) { ///Check if SRS needs to be converted from ESRI format to WKT to avoid error: ///"No translation for Lambert_Conformal_Conic to PROJ.4 format is known." ///https://gis.stackexchange.com/questions/128266/qgis-error-6-no-translation-for-lambert-conformal-conic-to-proj-4-format-is-kn SpatialReference srEsri = sr; srEsri.MorphFromESRI(); string projEsri = string.Empty; srEsri.ExportToWkt(out projEsri); ///If no SRS exists, check Ground Control Points SRS SpatialReference srGCP = new SpatialReference(datasource.GetGCPProjection()); string projGCP = string.Empty; srGCP.ExportToWkt(out projGCP); if (!string.IsNullOrEmpty(projEsri)) { datasource.SetProjection(projEsri); sr = srEsri; AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Spatial Reference System (SRS) morphed form ESRI format."); } else if (!string.IsNullOrEmpty(projGCP)) { datasource.SetProjection(projGCP); sr = srGCP; AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Spatial Reference System (SRS) set from Ground Control Points (GCPs)."); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Spatial Reference System (SRS) is unknown or unsupported. SRS assumed to be WGS84." + "Try setting the SRS with the GdalWarp component using -t_srs EPSG:4326 for the option input."); sr.SetWellKnownGeogCS("WGS84"); } } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Data source SRS: EPSG:" + sr.GetAttrValue("AUTHORITY", 1)); } } //OSGeo.OSR.SpatialReference sr = new SpatialReference(ds.GetProjection()); OSGeo.OSR.SpatialReference dst = new OSGeo.OSR.SpatialReference(""); dst.SetWellKnownGeogCS("WGS84"); OSGeo.OSR.CoordinateTransformation coordTransform = new OSGeo.OSR.CoordinateTransformation(sr, dst); OSGeo.OSR.CoordinateTransformation revTransform = new OSGeo.OSR.CoordinateTransformation(dst, sr); double[] adfGeoTransform = new double[6]; double[] invTransform = new double[6]; datasource.GetGeoTransform(adfGeoTransform); Gdal.InvGeoTransform(adfGeoTransform, invTransform); int width = datasource.RasterXSize; int height = datasource.RasterYSize; ///Dataset bounding box double oX = adfGeoTransform[0] + adfGeoTransform[1] * 0 + adfGeoTransform[2] * 0; double oY = adfGeoTransform[3] + adfGeoTransform[4] * 0 + adfGeoTransform[5] * 0; double eX = adfGeoTransform[0] + adfGeoTransform[1] * width + adfGeoTransform[2] * height; double eY = adfGeoTransform[3] + adfGeoTransform[4] * width + adfGeoTransform[5] * height; ///Transform to WGS84 double[] extMinPT = new double[3] { oX, eY, 0 }; double[] extMaxPT = new double[3] { eX, oY, 0 }; coordTransform.TransformPoint(extMinPT); coordTransform.TransformPoint(extMaxPT); Point3d dsMin = new Point3d(extMinPT[0], extMinPT[1], extMinPT[2]); Point3d dsMax = new Point3d(extMaxPT[0], extMaxPT[1], extMaxPT[2]); Rectangle3d dsbox = new Rectangle3d(Plane.WorldXY, Heron.Convert.WGSToXYZ(dsMin), Heron.Convert.WGSToXYZ(dsMax)); double pixelWidth = dsbox.Width / width; double pixelHeight = dsbox.Height / height; ///Declare trees GH_Structure <GH_Point> pointcloud = new GH_Structure <GH_Point>(); GH_Structure <GH_Integer> rCount = new GH_Structure <GH_Integer>(); GH_Structure <GH_Integer> cCount = new GH_Structure <GH_Integer>(); GH_Structure <GH_Mesh> tMesh = new GH_Structure <GH_Mesh>(); for (int i = 0; i < boundary.Count; i++) { GH_Path path = new GH_Path(i); Curve clippingBoundary = boundary[i]; if (!clip) { clippingBoundary = dsbox.ToNurbsCurve(); } string clippedTopoFile = "/vsimem/topoclipped.tif"; if (!(dsbox.BoundingBox.Contains(clippingBoundary.GetBoundingBox(true).Min) && (dsbox.BoundingBox.Contains(clippingBoundary.GetBoundingBox(true).Max))) && clip) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "One or more boundaries may be outside the bounds of the topo dataset."); } ///Offsets to mesh/boundary based on pixel size Point3d clipperMinPreAdd = clippingBoundary.GetBoundingBox(true).Corner(true, false, true); Point3d clipperMinPostAdd = new Point3d(clipperMinPreAdd.X, clipperMinPreAdd.Y, clipperMinPreAdd.Z); Point3d clipperMin = Heron.Convert.XYZToWGS(clipperMinPostAdd); Point3d clipperMaxPreAdd = clippingBoundary.GetBoundingBox(true).Corner(false, true, true); ///add/subtract pixel width if desired to get closer to boundary Point3d clipperMaxPostAdd = new Point3d(); Point3d clipperMax = new Point3d(); if (clip) { clipperMaxPostAdd = new Point3d(clipperMaxPreAdd.X + pixelWidth, clipperMaxPreAdd.Y - pixelHeight, clipperMaxPreAdd.Z); clipperMax = Heron.Convert.XYZToWGS(clipperMaxPostAdd); } else { clipperMaxPostAdd = new Point3d(clipperMaxPreAdd.X, clipperMaxPreAdd.Y, clipperMaxPreAdd.Z); clipperMax = Heron.Convert.XYZToWGS(clipperMaxPostAdd); } double lonWest = clipperMin.X; double lonEast = clipperMax.X; double latNorth = clipperMin.Y; double latSouth = clipperMax.Y; var translateOptions = new[] { "-of", "GTiff", "-a_nodata", "0", "-projwin_srs", "WGS84", "-projwin", $"{lonWest}", $"{latNorth}", $"{lonEast}", $"{latSouth}" }; using (Dataset clippedDataset = Gdal.wrapper_GDALTranslate(clippedTopoFile, datasource, new GDALTranslateOptions(translateOptions), null, null)) { Band band = clippedDataset.GetRasterBand(1); width = clippedDataset.RasterXSize; height = clippedDataset.RasterYSize; clippedDataset.GetGeoTransform(adfGeoTransform); Gdal.InvGeoTransform(adfGeoTransform, invTransform); rCount.Append(new GH_Integer(height), path); cCount.Append(new GH_Integer(width), path); Mesh mesh = new Mesh(); List <Point3d> verts = new List <Point3d>(); //var vertsParallel = new System.Collections.Concurrent.ConcurrentDictionary<double[][], Point3d>(Environment.ProcessorCount, ((Urow - 1) * (Lrow - 1))); double[] bits = new double[width * height]; band.ReadRaster(0, 0, width, height, bits, width, height, 0, 0); for (int col = 0; col < width; col++) { for (int row = 0; row < height; row++) { // equivalent to bits[col][row] if bits is 2-dimension array double pixel = bits[col + row * width]; if (pixel < -10000) { pixel = 0; } double gcol = adfGeoTransform[0] + adfGeoTransform[1] * col + adfGeoTransform[2] * row; double grow = adfGeoTransform[3] + adfGeoTransform[4] * col + adfGeoTransform[5] * row; ///convert to WGS84 double[] wgsPT = new double[3] { gcol, grow, pixel }; coordTransform.TransformPoint(wgsPT); Point3d pt = new Point3d(wgsPT[0], wgsPT[1], wgsPT[2]); verts.Add(Heron.Convert.WGSToXYZ(pt)); } /*Parallel.For(Urow, Lrow - 1, rowP => * { * // equivalent to bits[col][row] if bits is 2-dimension array * double pixel = bits[col + rowP * width]; * if (pixel < -10000) * { * pixel = 0; * } * * double gcol = adfGeoTransform[0] + adfGeoTransform[1] * col + adfGeoTransform[2] * rowP; * double grow = adfGeoTransform[3] + adfGeoTransform[4] * col + adfGeoTransform[5] * rowP; * * Point3d pt = new Point3d(gcol, grow, pixel); * vertsParallel[] = Heron.Convert.ToXYZ(pt); * }); * */ } //Create meshes //non Parallel mesh.Vertices.AddVertices(verts); //Parallel //mesh.Vertices.AddVertices(vertsParallel.Values); for (int u = 1; u < cCount[path][0].Value; u++) { for (int v = 1; v < rCount[path][0].Value; v++) { mesh.Faces.AddFace(v - 1 + (u - 1) * (height), v - 1 + u * (height), v - 1 + u * (height) + 1, v - 1 + (u - 1) * (height) + 1); //(k - 1 + (j - 1) * num2, k - 1 + j * num2, k - 1 + j * num2 + 1, k - 1 + (j - 1) * num2 + 1) } } //mesh.Flip(true, true, true); tMesh.Append(new GH_Mesh(mesh), path); band.Dispose(); } Gdal.Unlink("/vsimem/topoclipped.tif"); } datasource.Dispose(); DA.SetDataTree(0, tMesh); DA.SetData(1, dsbox); DA.SetData(2, srcInfo); }
/// <inheritdoc /> public override int GetHashCode() { unchecked { return((Band.GetHashCode() * 397) ^ Gain.GetHashCode()); } }
public DefaultTerrainElevationFactory(string databaseRoot, double lat, double lon, uint maxLod) { if (databaseRoot == null) { throw new ArgumentNullException("databaseRoot"); } // Open the dataset. try { _DatabaseDataset = Gdal.OpenShared(databaseRoot, Access.GA_ReadOnly); if (_DatabaseDataset.RasterCount != 1) { throw new NotSupportedException(); } DatabaseRoot = databaseRoot; using (Band band = _DatabaseDataset.GetRasterBand(1)) { switch (band.GetColorInterpretation()) { case ColorInterp.GCI_Undefined: switch (_DatabaseDataset.GetDriver().ShortName) { case "SRTMHGT": case "VRT": break; default: throw new NotSupportedException("unknown GDAL driver"); } break; default: throw new NotSupportedException("unknown color interpretation"); } } // Determine current position double[] datasetTransform = new double[6], datasetInvTransform = new double[6]; _DatabaseDataset.GetGeoTransform(datasetTransform); Gdal.InvGeoTransform(datasetTransform, datasetInvTransform); double xCurrentPosition, yCurrentPosition; Gdal.ApplyGeoTransform(datasetInvTransform, lon, lat, out xCurrentPosition, out yCurrentPosition); // Let the higher levels to be pixel aligned int x = (int)Math.Floor(xCurrentPosition), y = (int)Math.Floor(yCurrentPosition); int maxLodStride = (int)Math.Pow(2.0, maxLod); x -= x % maxLodStride; y -= y % maxLodStride; x = Math.Max(x, 0); y = Math.Max(y, 0); Gdal.ApplyGeoTransform(datasetTransform, x, y, out lon, out lat); Latitude = lat; Longitude = lon; } catch { // Ensure GDAL object disposition if (_DatabaseDataset != null) { _DatabaseDataset.Dispose(); } // Exception throw; } }
public void UpdateBand(Band band) { //not implemented }
public static bool GetBandFilters(Model radio, double freq, out Band outBandFilter) { try { string sBand = ""; outBandFilter = Band.GEN; string f = freq.ToString("f6"); f = f.Replace(",", "."); DataRow[] rows = ds_band.Tables["G59BandFilters"].Select(f + ">=Low AND " + f + "<=High"); switch (radio) { case Model.GENESIS_G59USB: case Model.GENESIS_G59NET: rows = ds_band.Tables["G59BandFilters"].Select(f + ">=Low AND " + f + "<=High"); break; case Model.GENESIS_G11: rows = ds_band.Tables["G11BandFilters"].Select(f + ">=Low AND " + f + "<=High"); break; case Model.GENESIS_G6: rows = ds_band.Tables["G6BandFilters"].Select(f + ">=Low AND " + f + "<=High"); break; case Model.QRP2000: rows = ds_band.Tables["QRP2000BandFilters"].Select(f + ">=Low AND " + f + "<=High"); break; default: rows = ds_band.Tables["G59BandFilters"].Select(f + ">=Low AND " + f + "<=High"); break; } if (rows.Length == 0) // band not found { outBandFilter = Band.GEN; return false; } else if (rows.Length == 1) // found band { switch (radio) { case Model.GENESIS_G6: { outBandFilter = Band.B5; sBand = ((string)rows[0]["Filter"]); switch (sBand) { case "A1": outBandFilter = Band.A1; break; case "A2": outBandFilter = Band.A2; break; case "A3": outBandFilter = Band.A3; break; case "A4": outBandFilter = Band.A4; break; case "B1": outBandFilter = Band.B1; break; case "B2": outBandFilter = Band.B2; break; case "B3": outBandFilter = Band.B3; break; case "B4": outBandFilter = Band.B4; break; case "B5": outBandFilter = Band.B5; break; case "B6": outBandFilter = Band.B6; break; case "B7": outBandFilter = Band.B7; break; case "B8": outBandFilter = Band.B8; break; case "B9": outBandFilter = Band.B9; break; case "B10": outBandFilter = Band.B10; break; case "C1": outBandFilter = Band.C1; break; case "C2": outBandFilter = Band.C2; break; case "C3": outBandFilter = Band.C3; break; case "C4": outBandFilter = Band.C4; break; case "C5": outBandFilter = Band.C5; break; } break; } default: { outBandFilter = Band.GEN; sBand = ((string)rows[0]["Filter"]); switch (sBand) { case "B2190M": outBandFilter = Band.B2190M; break; case "B600M": outBandFilter = Band.B600M; break; case "B160M": outBandFilter = Band.B160M; break; case "B80M": outBandFilter = Band.B80M; break; case "B60M": outBandFilter = Band.B60M; break; case "B40M": outBandFilter = Band.B40M; break; case "B30M": outBandFilter = Band.B30M; break; case "B20M": outBandFilter = Band.B20M; break; case "B17M": outBandFilter = Band.B17M; break; case "B15M": outBandFilter = Band.B15M; break; case "B12M": outBandFilter = Band.B12M; break; case "B10M": outBandFilter = Band.B10M; break; case "B6M": outBandFilter = Band.B6M; break; case "B2M": outBandFilter = Band.B2M; break; case "WWV": outBandFilter = Band.WWV; break; } } break; } return true; } else if(rows.Length > 1) // this should never happen { MessageBox.Show("Error reading BandFilters table. Entries overlap!", "BandFilters Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); outBandFilter = Band.GEN; return false; } else { outBandFilter = Band.GEN; return false; } } catch (Exception e) { MessageBox.Show(e.Message + "\n\n\n" + e.StackTrace, "BandFilter Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); outBandFilter = Band.GEN; return false; } }
public void Dispose() { Venue.DeleteAll(); Band.DeleteAll(); }
public NeedMembersQueryViewModel(Band band, List<Instrument> instruments) { InstrumentSelectList = new SelectList(instruments, "Id", "Name"); Band = band; }
public void Dispose() { Band.DeleteAll(); Venue.DeleteAll(); Genre.DeleteAll(); }
public IActionResult DeleteBand(Band model) { _context.Bands.Remove(model); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Bands() { List <Band> allBands = Band.GetAll(); return(View(allBands)); }
private static void GetBandsWithTimeSlot(ref List<Band> bands, bool stage, bool asc) { try { // Get data DbDataReader reader; if (stage) { if (asc) reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StageName ASC, Name ASC, StartDate ASC"); else reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StageName DESC, Name DESC, StartDate DESC"); } else { if (asc) reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StartDate ASC, Name ASC, StageName ASC"); else reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StartDate DESC, Name DESC, StageName DESC"); } foreach (DbDataRecord record in reader) { Band band = new Band(); // Get ID if (DBNull.Value.Equals(record["ID"])) band.ID = -1; else band.ID = Convert.ToInt32(record["ID"]); // Get Name if (DBNull.Value.Equals(record["Name"])) band.Name = ""; else band.Name = record["Name"].ToString(); // Get Twitter if (DBNull.Value.Equals(record["Twitter"])) band.Twitter = ""; else band.Twitter = record["Twitter"].ToString(); // Get Facebook if (DBNull.Value.Equals(record["Facebook"])) band.Facebook = ""; else band.Facebook = record["Facebook"].ToString(); // Get Picture if (DBNull.Value.Equals(record["Picture"])) band.Picture = null; else band.Picture = (byte[])record["Picture"]; // Get Description if (DBNull.Value.Equals(record["Description"])) band.Description = ""; else band.Description = record["Description"].ToString(); // Get Genres band.Genres = GenreSQLRepository.GetGenresFromBand(band.ID); //Get Timeslot TimeSlot ts = new TimeSlot(); // Get TimeSlotID if (DBNull.Value.Equals(record["TimeSlotID"])) ts.ID = -1; else ts.ID = Convert.ToInt32(record["TimeSlotID"]); // Get BandID if (DBNull.Value.Equals(record["BandID"])) ts.BandID = -1; else ts.BandID = Convert.ToInt32(record["BandID"]); // Get StageID if (DBNull.Value.Equals(record["StageID"])) ts.StageID = -1; else ts.StageID = Convert.ToInt32(record["StageID"]); // Get StartDate if (DBNull.Value.Equals(record["StartDate"])) ts.StartDate = new DateTime(); else ts.StartDate = Convert.ToDateTime(record["StartDate"]); // Get EndDate if (DBNull.Value.Equals(record["EndDate"])) ts.EndDate = new DateTime(); else ts.EndDate = Convert.ToDateTime(record["EndDate"]); // Get Stage Stage s = new Stage(); // Get Stage_ID if (DBNull.Value.Equals(record["Stage_ID"])) s.ID = -1; else s.ID = Convert.ToInt32(record["Stage_ID"]); // Get Name if (DBNull.Value.Equals(record["StageName"])) s.Name = ""; else s.Name = record["StageName"].ToString(); ts.Stage = s; band.TimeSlots = new List<TimeSlot>(); band.TimeSlots.Add(ts); bands.Add(band); } reader.Close(); } // Fail catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void 无人机影像粗校正ToolStripMenuItem_Click(object sender, EventArgs e) { if (pictureBox1.Image != null) { //ds = Gdal.Open(_filePath, Access.GA_ReadOnly); Bitmap bitmap = (Bitmap)pictureBox1.Image; double pi = Math.PI; double[] can = new double[11]; double w = ds.RasterXSize; double h = ds.RasterYSize; ImageCorrection iC = new ImageCorrection(); iC.ShowDialog(); can = iC.returnCan(); if (can[0] == 0) { return; } //校正参数 double B = can[1], L = can[2], Zs = can[3], fai = can[4] / 180 * pi, w0 = can[5] / 180 * pi; double k = can[6] / 180 * pi, Iw = can[7] * 0.001, Ih = can[8] * 0.001, f = can[9] * 0.001, u = can[10]; double Xs = 0, Ys = 0; Foudation fd = new Foudation(); double[] xy = fd.GeoTransform(B, L); Xs = xy[0]; Ys = xy[1]; //旋转矩阵参数 double a1 = Math.Cos(fai) * Math.Cos(k) - Math.Sin(fai) * Math.Sin(w0) * Math.Sin(k); double a2 = -Math.Cos(fai) * Math.Sin(k) - Math.Sin(fai) * Math.Sin(w0) * Math.Cos(k); double a3 = -Math.Sin(fai) * Math.Cos(w0); double b1 = Math.Cos(w0) * Math.Sin(k); double b2 = Math.Cos(w0) * Math.Cos(k); double b3 = -Math.Sin(w0); double c1 = Math.Sin(fai) * Math.Cos(k) + Math.Cos(fai) * Math.Sin(w0) * Math.Sin(k); double c2 = -Math.Sin(fai) * Math.Sin(k) + Math.Cos(fai) * Math.Sin(w0) * Math.Cos(k); double c3 = Math.Cos(fai) * Math.Cos(k); //角点图像坐标 double[,] Ixy = new double[5, 3]; Ixy[1, 1] = 0; Ixy[1, 2] = 0; Ixy[2, 1] = Iw; Ixy[2, 2] = Ih; Ixy[3, 1] = 0; Ixy[3, 2] = Ih; Ixy[4, 1] = Iw; Ixy[4, 2] = 0; //图像像元大小 double pixelSize_x = Iw / w; double pixelSize_y = Ih / h; //角点地面坐标 double[,] XY = new double[5, 3]; double Zp = 750;//平均高程待定 for (int i = 1; i < 5; i++) { XY[i, 1] = Xs + (Zp - Zs) * (a1 * Ixy[i, 1] + a2 * Ixy[i, 2] - a3 * f) / (c1 * Ixy[i, 1] + c2 * Ixy[i, 2] - c3 * f); XY[i, 2] = Ys + (Zp - Zs) * (b1 * Ixy[i, 1] + b2 * Ixy[i, 2] - b3 * f) / (c1 * Ixy[i, 1] + c2 * Ixy[i, 2] - c3 * f); } //输出影像最小范围 double Xmin = (XY[1, 1] < XY[3, 1] ? XY[1, 1] : XY[3, 1]); double Xmax = (XY[2, 1] > XY[4, 1] ? XY[2, 1] : XY[4, 1]); double Ymin = (XY[3, 2] < XY[4, 2] ? XY[3, 2] : XY[4, 2]); double Ymax = (XY[1, 2] > XY[2, 2] ? XY[1, 2] : XY[2, 2]); int outwid = (int)((Xmax - Xmin) / u) + 10; int outhei = (int)((Ymax - Ymin) / u) + 10; //构建位图 double Xp, Yp; double x, y; Driver dryMemory = Gdal.GetDriverByName("MEM"); Dataset dsMemory = dryMemory.Create("", outwid, outhei, ds.RasterCount, DataType.GDT_CInt32, null); //dsMemory.SetProjection(ds.GetGCPProjection()); double[] GeoTrans = new double[6]; GeoTrans[0] = Xmin; GeoTrans[3] = Ymin; GeoTrans[1] = u; GeoTrans[5] = -u; GeoTrans[2] = 0; GeoTrans[4] = 0; dsMemory.SetGeoTransform(GeoTrans); dsMemory.SetProjection(" PROGCS[''G-K'']"); for (int i = 0; i < outhei; i++) { int[][] R = new int[ds.RasterCount][]; for (int bandindex = 0; bandindex < ds.RasterCount; bandindex++) { R[bandindex] = new int[outwid]; } for (int j = 0; j < outwid; j++) { //地面坐标 Xp = j * u + Xmin; Yp = (i) * u + Ymin; //解像点坐标 x = -f * (a1 * (Xp - Xs) + b1 * (Yp - Ys) + c1 * (Zp - Zs)) / (a3 * (Xp - Xs) + b3 * (Yp - Ys) + c3 * (Zp - Zs)); y = -f * (a2 * (Xp - Xs) + b2 * (Yp - Ys) + c2 * (Zp - Zs)) / (a3 * (Xp - Xs) + b3 * (Yp - Ys) + c3 * (Zp - Zs)); //对应原来图像的行列号 int i0 = (int)(x / pixelSize_x); int j0 = (int)(y / pixelSize_y); if (i0 >= 0 && i0 < ds.RasterXSize && j0 >= 0 && j0 < ds.RasterYSize) { for (int bandindex = 0; bandindex < ds.RasterCount; bandindex++) { int[] r_read = new int[1]; Band band = ds.GetRasterBand(bandindex + 1); band.ReadRaster(i0, j0, 1, 1, r_read, 1, 1, 0, 0); R[bandindex][j] = r_read[0]; } } else { for (int bandindex = 0; bandindex < ds.RasterCount; bandindex++) { R[bandindex][j] = 0; } } } for (int bandindex = 0; bandindex < ds.RasterCount; bandindex++) { Band memBand1 = dsMemory.GetRasterBand(bandindex + 1); memBand1.WriteRaster(0, i, R[bandindex].Length, 1, R[bandindex], R[bandindex].Length, 1, 0, 0); } } Driver drvJPG = Gdal.GetDriverByName("GTiff"); string dstFileName = @"E:\Correction.Tif";; //Dataset dstDs = drvJPG.Create(dstFileName, srcWidth, srcHeight, bandCount, DataType.GDT_Byte, null); drvJPG.CreateCopy(dstFileName, dsMemory, 1, null, null, null); ds = dsMemory; Rectangle pictureRect = new Rectangle(); pictureRect.X = 0; pictureRect.Y = 0; pictureRect.Width = this.pictureBox1.Width; pictureRect.Height = this.pictureBox1.Height; int[] disband = new int[3] { 1, 2, 3 }; Bitmap bitmap2 = fd.GetImage(this.ds, pictureRect, 3, disband); //遥感影像构建位图 pictureBox1.Image = bitmap2; MessageBox.Show("计算完成!"); } else { MessageBox.Show("没有图像!", "Error!"); } }
private float GainByBand(Band b) { float retval = 0; switch (b) { case Band.B160M: retval = SetupForm.PAGain160; break; case Band.B80M: retval = SetupForm.PAGain80; break; case Band.B40M: retval = SetupForm.PAGain40; break; case Band.B30M: retval = SetupForm.PAGain30; break; case Band.B20M: retval = SetupForm.PAGain20; break; case Band.B17M: retval = SetupForm.PAGain17; break; case Band.B15M: retval = SetupForm.PAGain15; break; case Band.B12M: retval = SetupForm.PAGain12; break; case Band.B10M: retval = SetupForm.PAGain10; break; case Band.B6M: retval = SetupForm.PAGain6; break; default: retval = 48.0f; break; } return retval; }
//http://www.gisremotesensing.com/2015/09/vector-to-raster-conversion-using-gdal-c.html public static void Rasterize(string inputFeature, string outRaster, string fieldName, int cellSize) { // Define pixel_size and NoData value of new raster int rasterCellSize = cellSize; const double noDataValue = -9999; string outputRasterFile = outRaster; //Register the vector drivers Ogr.RegisterAll(); //Reading the vector data DataSource dataSource = Ogr.Open(inputFeature, 0); var count = dataSource.GetLayerCount(); Layer layer = dataSource.GetLayerByIndex(0); var litems = layer.GetFeatureCount(0); var lname = layer.GetName(); Envelope envelope = new Envelope(); layer.GetExtent(envelope, 0); //Compute the out raster cell resolutions int x_res = Convert.ToInt32((envelope.MaxX - envelope.MinX) / rasterCellSize); int y_res = Convert.ToInt32((envelope.MaxY - envelope.MinY) / rasterCellSize); Console.WriteLine("Extent: " + envelope.MaxX + " " + envelope.MinX + " " + envelope.MaxY + " " + envelope.MinY); Console.WriteLine("X resolution: " + x_res); Console.WriteLine("X resolution: " + y_res); //Register the raster drivers Gdal.AllRegister(); //Check if output raster exists & delete (optional) if (File.Exists(outputRasterFile)) { File.Delete(outputRasterFile); } //Create new tiff OSGeo.GDAL.Driver outputDriver = Gdal.GetDriverByName("GTiff"); Dataset outputDataset = outputDriver.Create(outputRasterFile, x_res, y_res, 1, DataType.GDT_Float64, null); //Extrac srs from input feature string inputShapeSrs; SpatialReference spatialRefrence = layer.GetSpatialRef(); spatialRefrence.ExportToWkt(out inputShapeSrs); //Assign input feature srs to outpur raster outputDataset.SetProjection(inputShapeSrs); //Geotransform double[] argin = new double[] { envelope.MinX, rasterCellSize, 0, envelope.MaxY, 0, -rasterCellSize }; outputDataset.SetGeoTransform(argin); //Set no data Band band = outputDataset.GetRasterBand(1); band.SetNoDataValue(noDataValue); //close tiff outputDataset.FlushCache(); outputDataset.Dispose(); //Feature to raster rasterize layer options //No of bands (1) int[] bandlist = new int[] { 1 }; //Values to be burn on raster (10.0) double[] burnValues = new double[] { 10.0 }; Dataset myDataset = Gdal.Open(outputRasterFile, Access.GA_Update); //additional options string[] rasterizeOptions; //rasterizeOptions = new string[] { "ALL_TOUCHED=TRUE", "ATTRIBUTE=" + fieldName }; //To set all touched pixels into raster pixel rasterizeOptions = new string[] { "ATTRIBUTE=" + fieldName }; //Rasterize layer //Gdal.RasterizeLayer(myDataset, 1, bandlist, layer, IntPtr.Zero, IntPtr.Zero, 1, burnValues, null, null, null); // To burn the given burn values instead of feature attributes Gdal.RasterizeLayer(myDataset, 1, bandlist, layer, IntPtr.Zero, IntPtr.Zero, 1, burnValues, rasterizeOptions, new Gdal.GDALProgressFuncDelegate(ProgressFunc), "Raster conversion"); }
public ActionResult GoToBand(string id) { Band b = new Band(); b = Band.GetBands(id); return View(b); }
public ActionResult Bands() { return(View(Band.GetAll())); }
public AddMemberViewModel(Band band, ApplicationUser userToAdd, Instrument instrument) { Instrument = instrument; Band = band; UserToInvite = userToAdd; }
protected Task <(long, Pipeline)> LoadAsync(RecordSet layer) { Task <(long, Pipeline)> t1 = new Task <(long, Pipeline)>(() => { Dataset raster = Gdal.Open(layer.Source, Access.GA_ReadOnly); Band band1 = raster.GetRasterBand(1); double scalingFactor = 0; List <object> pipe = new List <object>(); pipe.Add(new { type = "readers.gdal", filename = layer.Source, header = layer.Properties.headerString }); // Get the size and pixel size of the raster // if the raster has more than 1,000,000 data points, using poisson sampling to down size long datapoints = raster.RasterXSize * raster.RasterYSize; if (datapoints > 1000000) { try { double[] geoTransform = new double[6]; raster.GetGeoTransform(geoTransform); if (geoTransform == null && geoTransform[1] == 0) { throw new Exception(); } scalingFactor = Math.Sqrt(datapoints / 1000000d * geoTransform[1]); } catch { scalingFactor = Math.Sqrt(datapoints / 1000000d); }; pipe.Add(new { type = "filters.sample", radius = scalingFactor }); } band1.FlushCache(); band1.Dispose(); raster.FlushCache(); raster.Dispose(); if (layer.Properties.Filter != null) { foreach (Dictionary <string, object> item in layer.Properties.Filter) { pipe.Add(item); } } if (layer.Properties.Dem != null) { pipe.Add(new { type = "filters.hag_dem", raster = layer.Properties.Dem }); pipe.Add(new { type = "filters.ferry", dimensions = "HeightAboveGround=>Z" }); } else { pipe.Add(new { type = "filters.ferry", dimensions = "=>Z" }); } if (layer.ContainsKey("Crs") && layer.Crs != null && layer.Crs != "") { string crs; AppState.instance.mapProj.ExportToProj4(out crs); pipe.Add(new { type = "filters.reprojection", in_srs = layer.Crs, out_srs = crs }); } pipe.Add(new { type = "filters.projpipeline", coord_op = "+proj=axisswap +order=1,-3,2" }); if (layer.Properties.ColorMode == ColorMode.SinglebandColor && layer.Properties.ColorInterp != null) { Dictionary <string, object> ci = new Dictionary <string, object>(layer.Properties.ColorInterp); ci.Add("type", "filters.colorinterp"); pipe.Add(ci); } string json = JsonConvert.SerializeObject(new { pipeline = pipe.ToArray() }); Pipeline pipeline = new Pipeline(json); if (pipeline.Valid == false) { Debug.LogError("Pipeline : " + json); throw new System.NotSupportedException("Layer : " + layer.Id + " - PDAL Pipeline is not valid - check Layer configuration"); } long pointCount = pipeline.Execute(); return(pointCount, pipeline); }); t1.Start(); return(t1); }
private static string BandText(Band b) { // TODO Oh, such a hack :-) return b.ToString().Substring(1); }
private static void SaveBitmapDirect(string filename, Dataset ds, int xOff, int yOff, int width, int height, int imageWidth, int imageHeight) { if (ds.RasterCount == 0) { return; } int[] bandMap = new int[4] { 1, 1, 1, 1 }; int channelCount = 1; bool hasAlpha = false; bool isIndexed = false; int channelSize = 8; ColorTable ct = null; // Evaluate the bands and find out a proper image transfer format for (int i = 0; i < ds.RasterCount; i++) { Band band = ds.GetRasterBand(i + 1); if (Gdal.GetDataTypeSize(band.DataType) > 8) { channelSize = 16; } switch (band.GetRasterColorInterpretation()) { case ColorInterp.GCI_AlphaBand: channelCount = 4; hasAlpha = true; bandMap[3] = i + 1; break; case ColorInterp.GCI_BlueBand: if (channelCount < 3) { channelCount = 3; } bandMap[0] = i + 1; break; case ColorInterp.GCI_RedBand: if (channelCount < 3) { channelCount = 3; } bandMap[2] = i + 1; break; case ColorInterp.GCI_GreenBand: if (channelCount < 3) { channelCount = 3; } bandMap[1] = i + 1; break; case ColorInterp.GCI_PaletteIndex: ct = band.GetRasterColorTable(); isIndexed = true; bandMap[0] = i + 1; break; case ColorInterp.GCI_GrayIndex: isIndexed = true; bandMap[0] = i + 1; break; default: // we create the bandmap using the dataset ordering by default if (i < 4 && bandMap[i] == 0) { if (channelCount < i) { channelCount = i; } bandMap[i] = i + 1; } break; } } // find out the pixel format based on the gathered information PixelFormat pixelFormat; DataType dataType; int pixelSpace; if (isIndexed) { pixelFormat = PixelFormat.Format8bppIndexed; dataType = DataType.GDT_Byte; pixelSpace = 1; } else { if (channelCount == 1) { if (channelSize > 8) { pixelFormat = PixelFormat.Format16bppGrayScale; dataType = DataType.GDT_Int16; pixelSpace = 2; } else { pixelFormat = PixelFormat.Format24bppRgb; channelCount = 3; dataType = DataType.GDT_Byte; pixelSpace = 3; } } else { if (hasAlpha) { if (channelSize > 8) { pixelFormat = PixelFormat.Format64bppArgb; dataType = DataType.GDT_UInt16; pixelSpace = 8; } else { pixelFormat = PixelFormat.Format32bppArgb; dataType = DataType.GDT_Byte; pixelSpace = 4; } channelCount = 4; } else { if (channelSize > 8) { pixelFormat = PixelFormat.Format48bppRgb; dataType = DataType.GDT_UInt16; pixelSpace = 6; } else { pixelFormat = PixelFormat.Format24bppRgb; dataType = DataType.GDT_Byte; pixelSpace = 3; } channelCount = 3; } } } // Create a Bitmap to store the GDAL image in Bitmap bitmap = new Bitmap(imageWidth, imageHeight, pixelFormat); if (isIndexed) { // setting up the color table if (ct != null) { int iCol = ct.GetCount(); ColorPalette pal = bitmap.Palette; for (int i = 0; i < iCol; i++) { ColorEntry ce = ct.GetColorEntry(i); pal.Entries[i] = Color.FromArgb(ce.c4, ce.c1, ce.c2, ce.c3); } bitmap.Palette = pal; } else { // grayscale ColorPalette pal = bitmap.Palette; for (int i = 0; i < 256; i++) { pal.Entries[i] = Color.FromArgb(255, i, i, i); } bitmap.Palette = pal; } } // Use GDAL raster reading methods to read the image data directly into the Bitmap BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, imageWidth, imageHeight), ImageLockMode.ReadWrite, pixelFormat); try { int stride = bitmapData.Stride; IntPtr buf = bitmapData.Scan0; ds.ReadRaster(xOff, yOff, width, height, buf, imageWidth, imageHeight, dataType, channelCount, bandMap, pixelSpace, stride, 1); } finally { bitmap.UnlockBits(bitmapData); } bitmap.Save(filename); }
private static Band Create(DbDataReader reader) { Band band = new Band(); band.Id = reader["Id"].ToString(); band.Name = reader["Name"].ToString(); band.Picture = reader["Picture"].ToString(); band.Description = reader["Description"].ToString(); band.Facebook = reader["Facebook"].ToString(); band.Twitter = reader["Twitter"].ToString(); return band; }
public bool IsNewSquare(string locator, Band band) { MySqlConnection conn = OpenConnection; lock (conn) { if (locator.Length > 4) locator = locator.Substring(0, 4); using (MySqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT COUNT(*) FROM log WHERE band LIKE ?band AND locator LIKE ?locator;"; cmd.Parameters.AddWithValue("?band", BandHelper.ToString(band)); cmd.Parameters.AddWithValue("?locator", locator.ToUpperInvariant() + "%"); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (!reader.Read()) return false; return reader.GetInt32(0) == 0; } } } }
public static string EditLineUp(Band SelectedBandAdd, string StartTime, string EndTime,Stage SelectedStage, DateTime SelectedDatum,string ID) { string error = ""; error = CheckTime(StartTime, EndTime, SelectedStage,SelectedDatum); if (error == null) { error = CheckBand(StartTime, EndTime, SelectedStage, SelectedBandAdd,SelectedDatum); if (error == null) { Database.ModifyData("UPDATE tbl_lineup SET DatePreformance=@date,FromTime=@from,UntilTime=@until,Stage=@stage,Band=@band WHERE ID=@id", Database.AddParameter("@date", SelectedDatum), Database.AddParameter("@from", StartTime), Database.AddParameter("@until", EndTime), Database.AddParameter("@stage", Convert.ToInt32(SelectedStage.ID)), Database.AddParameter("@id", Convert.ToInt32(ID)), Database.AddParameter("@band", Convert.ToInt32(SelectedBandAdd.ID)) ); } else { return error; } } return error; }
private static string CheckBand(string StartTime, string EndTime, Stage SelectedStage, Band SelectedBandAdd, DateTime SelectedDatum) { string[] strEndtime = EndTime.Split(':'); string EndTimecom = strEndtime[0] + strEndtime[1]; string[] strStarttime = StartTime.Split(':'); string StartTimecom = strStarttime[0] + strStarttime[1]; DbDataReader reader = Database.GetData("SELECT * FROM tbl_lineup WHERE Band=@band AND DatePreformance=@date", Database.AddParameter("@stage", Convert.ToInt32(SelectedStage.ID)), Database.AddParameter("@band", Convert.ToInt32(SelectedBandAdd.ID)), Database.AddParameter("@date", SelectedDatum) ); foreach (IDataRecord db in reader) { string[] strStartToCheck = db["FromTime"].ToString().Split(':'); string[] strEndToCheck = db["UntilTime"].ToString().Split(':'); if (Between(Convert.ToInt32(strStartToCheck[0] + strStartToCheck[1]), Convert.ToInt32(StartTimecom), Convert.ToInt32(EndTimecom)) || Between(Convert.ToInt32(strEndToCheck[0] + strEndToCheck[1]), Convert.ToInt32(StartTimecom), Convert.ToInt32(EndTimecom))) { return "Deze tijden voor deze band zijn al in gebruikt"; } } return null; }
public ActionResult BandsPost() { return(View("Bands", Band.GetAll())); }
public Band GetBandFromId(int bandId) { Band band = context.Bands.Where(b => b.BandId == bandId).FirstOrDefault(); return(band); }