public void AddReaderStamp(LightStamp stamp, float crownRadiusInMeters) { float rest = (crownRadiusInMeters % 1.0F) + 0.0001F; int hdClass = (int)(10.0F * rest); // 0 .. 9.99999999 if (hdClass >= Constant.Stamp.HeightDiameterClassCount) { hdClass = Constant.Stamp.HeightDiameterClassCount - 1; } int diameterClass = (int)crownRadiusInMeters; //Debug.WriteLine("Readerstamp r="<< crown_radius_m<<" index dbh hd:" << cls_dbh << cls_hd; stamp.SetCrownRadiusAndArea(crownRadiusInMeters); // prepare special keys for reader stamps this.AddStamp(stamp, diameterClass, hdClass, crownRadiusInMeters, 0.0F, 0.0F); // set crownradius, but not dbh/hd }
private void AddStamp(LightStamp stamp, int diameterClass, int hdClass, float crownRadiusInM, float dbh, float hdRatio) { //if (this.UseLookup) //{ if (diameterClass < 0 || diameterClass >= Constant.Stamp.DbhClassCount || hdClass < 0 || hdClass >= Constant.Stamp.HeightDiameterClassCount) { throw new NotSupportedException(String.Format("addStamp: Stamp out of range. dbh={0} hd={1}.", dbh, hdRatio)); } lightStampsByDbhAndHDRatio[diameterClass, hdClass] = stamp; // save address in look up table //} // if (useLookup) stamp.SetCrownRadiusAndArea(crownRadiusInM); LightStampWithTreeSize si = new() { Dbh = dbh, HDratio = hdRatio, CrownRadius = crownRadiusInM, Stamp = stamp }; lightStampsWithTreeSizes.Add(si); // store entry in list of stamps }