/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } if (lc == this.Value) { this.Status = "Pass"; this.Comment = "Constant " + Constant + " is set to [" + this.Value + "]"; return; } if (lc.ToUpper() == this.Value.ToUpper()) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " is set to [" + lc + "] but [" + this.Value + "] is required."; return; } this.Status = Severity; this.Comment = "Constant " + Constant + " is set to [" + lc + "] but [" + this.Value + "] is required."; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { FileInfo fi = new FileInfo(las.FileName); string filename = fi.Name; StringBuilder sb = new StringBuilder(); foreach (string s in Values) { string lc = las.GetConstant(s); if (lc.Length <= 0) { lc = las.GetParameter(s); } if (lc.Length > 0) { sb.Append(lc); } else { sb.Append(s); } } string mask = (Capitals == "YES")? sb.ToString().ToUpper(): sb.ToString(); if (Underscore == "YES") { mask = mask.Replace(' ', '_'); } if (filename.StartsWith(mask)) { if (Underscore == "YES" && filename.Contains(" ")) { this.Status = "Warning"; this.Comment = "File name should not contain spaces: " + filename; return; } this.Status = "Pass"; this.Comment = "Naming convention is followed in " + filename; return; } if (Capitals == "YES" && filename.ToUpper().StartsWith(mask)) { this.Status = "Warning"; this.Comment = "File name must be in capitals: " + filename; return; } this.Status = Severity; this.Comment = "Naming convention is not followed in file " + filename + ". Should start with [" + mask + "]"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " is set to [" + lc + "]"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } Longitude lon = null; try { lon = new Longitude(ReplaceFunnyChars(lc)); } catch (Exception ex) { this.Status = Severity; this.Comment = "Constant " + Constant + " with value [" + lc + "] could not be read. " + ex.Message; return; } double val = lon.AngleD; if (Double.IsNaN(val)) { this.Status = Severity; this.Comment = "Constant " + Constant + " has incorrect value [" + lc + "]"; return; } if (val < MinValueError || MaxValueError < val) { this.Status = Severity; this.Comment = "Constant " + Constant + " [" + val.ToString("0.0000") + "] is set outside of range [" + MinValueError.ToString() + ", " + MaxValueError.ToString() + "]"; return; } if (val < MinValueWarning || MaxValueWarning < val) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " [" + val.ToString("0.0000") + "] is set outside of range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " [" + val.ToString("0.0000") + "] is within range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } double val = Double.NaN; try { val = Convert.ToDouble(lc); } catch (Exception) { }; if (Double.IsNaN(val)) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not set to numeric value, but to [" + lc + "]"; return; } if (val == las.MissingValue) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " is set to missing value [" + lc + "]"; return; } if (val < MinValueError || MaxValueError < val) { this.Status = Severity; this.Comment = "Constant " + Constant + " is set outside of range [" + MinValueError.ToString() + ", " + MaxValueError.ToString() + "]"; return; } if (val < MinValueWarning || MaxValueWarning < val) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " is set outside of range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " is within range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } string ret = FindValue(lc); if (ret.Length > 0) { this.Status = "Pass"; this.Comment = "Constant " + Constant + " is set to [" + lc + "]"; return; } ret = FindValueUpper(lc.ToUpper()); if (ret.Length > 0) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " is set to [" + lc + "] but [" + ret + "] within is required."; return; } this.Status = Severity; StringBuilder sb = new StringBuilder(); sb.Append("Constant " + Constant + " is set to [" + lc + "], but should contain one of ["); for (int i = 0; i < Values.Count; i++) { sb.Append(Values[i]); if (i < Values.Count - 1) { sb.Append(", "); } } sb.Append("]."); Comment = sb.ToString(); return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc2 = las.GetConstant(Constant); if (lc2.Length <= 0) { lc2 = las.GetParameter(Constant); } if (lc2.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } double val2 = Double.NaN; try { val2 = Convert.ToDouble(lc2); } catch (Exception) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not numeric"; return; } if (val2 == -999.25) { this.Status = Severity; this.Comment = "Constant " + Constant + " is set to missing value"; return; } Shift = val2; LAS_Channel lc = (LAS_Channel)las.GetChannel(Channel); if (lc == null) { this.Status = "NA"; this.Comment = "Channel " + Channel + " is not defined"; return; } if (!lc.IsLoaded) { this.Status = Severity; this.Comment = "Channel " + Channel + " contains no data"; return; } LAS_Channel index = (LAS_Channel)las.GetIndex(); if (Hole != "OPEN" && Hole != "CASED") { EnforceInRange(lc, index, Double.MinValue, Double.MaxValue); return; } string csgString = las.GetParameter("CSGL"); if (csgString.Length <= 0) { csgString = las.GetParameter("CSGD"); } double csg = Double.NaN; try { csg = Convert.ToDouble(csgString); } catch (Exception) { } if (Double.IsNaN(csg)) { EnforceInRange(lc, index, Double.MinValue, Double.MaxValue); return; } if (Hole == "OPEN") { EnforceInRange(lc, index, csg + SkipBelowCasing, Double.MaxValue); } else { EnforceInRange(lc, index, Double.MinValue, csg); } }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } string lc2 = las.GetConstant(CompareWith); if (lc2.Length <= 0) { lc2 = las.GetParameter(CompareWith); } if (lc2.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + CompareWith + " is not defined"; return; } double val = Double.NaN; double val2 = Double.NaN; try { val = Convert.ToDouble(lc); val2 = Convert.ToDouble(lc2); } catch (Exception) { this.Status = Severity; this.Comment = "Constants " + Constant + " and/or " + CompareWith + " are not numeric"; return; } if (val == -999.25 || val2 == -999.25) { this.Status = Severity; this.Comment = "Constants " + Constant + " and/or " + CompareWith + " are set to missing"; return; } if (Comparison == "LESS" && val >= val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is more or equal to " + CompareWith + " [" + val + ">=" + val2 + "]"; return; } if (Comparison == "LESS_OR_EQUAL" && val > val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is more than " + CompareWith + " [" + val + ">" + val2 + "]"; return; } if (Comparison == "EQUAL" && val != val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not equal to " + CompareWith + " [" + val + "!=" + val2 + "]"; return; } if (Comparison == "MORE_OR_EQUAL" && val < val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is less than " + CompareWith + " [" + val + "<" + val2 + "]"; return; } if (Comparison == "MORE" && val <= val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is less or equal to " + CompareWith + " [" + val + "<=" + val2 + "]"; return; } if (Comparison == "NOT_EQUAL" && val == val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is equal to " + CompareWith + " [" + val + "==" + val2 + "]"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " is " + Comparison + " than/to " + CompareWith; return; }