コード例 #1
0
        //public void Tally(string species, Double midValue)
        //{
        //    var tallyPopulation = TallyPopulations.Where(x => x.Species == species).First();

        //    var bucket = tallyPopulation.Buckets.Where(x => x.Value == midValue).Single();

        //    Tally(bucket);
        //}

        public void UnTally(FixCNTTallyBucket tallyBucket)
        {
            var tallyPop = tallyBucket.TallyPopulation;

            FixCNTDataservice.DecrementFixCNTTreeCount(
                Unit,
                PlotNumber,
                tallyPop.StratumCode,
                tallyPop.SampleGroupCode,
                tallyPop.SpeciesCode,
                tallyPop.LiveDead,
                tallyPop.FieldName,
                tallyBucket.Value);

            tallyBucket.TreeCount = Math.Max(0, tallyBucket.TreeCount - 1);
        }
コード例 #2
0
        public void IncrementFixCNTTreeCount()
        {
            var unitCode   = Units.First();
            var plotNumber = 1;
            var fieldName  = "DBH";
            var value      = 10;

            var subpop = Subpops.First();

            var sgCode = subpop.SampleGroupCode;
            var stCode = subpop.StratumCode;
            var sp     = subpop.SpeciesCode;
            var ld     = subpop.LiveDead;

            using (var database = CreateDatabase())
            {
                var plotds = new CuttingUnitDatastore(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID));

                var plotID = plotds.AddNewPlot(unitCode);

                var ds = new FixCNTDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID);

                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(0);

                // after incrementing once, tree count should be 1
                // and there shold only be one tree in the tree table
                ds.IncrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(1);
                database.ExecuteScalar <int>("SELECT count(*) FROM Tree;").Should().Be(1);

                // after incrementing a second time, tree count should be 2
                // and there shold still only be one tree in the tree table
                ds.IncrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(2);

                database.ExecuteScalar <int>("SELECT count(*) FROM Tree;").Should().Be(1);

                var plotTrees = plotds.GetPlotTreeProxies(unitCode, plotNumber);
                plotTrees.Should().HaveCount(1);
            }
        }
コード例 #3
0
        public void DecrementFixCNTTreeCount()
        {
            var unitCode   = Units.First();
            var plotNumber = 1;
            var fieldName  = "DBH";
            var value      = 10;

            var subpop = Subpops.First();

            var sgCode = subpop.SampleGroupCode;
            var stCode = subpop.StratumCode;
            var sp     = subpop.SpeciesCode;
            var ld     = subpop.LiveDead;

            using (var database = CreateDatabase())
            {
                var plotds = new CuttingUnitDatastore(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID));

                var plotID = plotds.AddNewPlot(unitCode);

                var ds = new FixCNTDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID);

                // check initial state
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(0);

                // increment once
                ds.IncrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(1);

                // decrement back to zero
                ds.DecrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(0);

                // try to decrement past zero should only result in count of zero
                ds.DecrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(0);
            }
        }
コード例 #4
0
        protected override void Load(IParameters parameters)
        {
            if (parameters is null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var unit        = Unit = parameters.GetValue <string>(NavParams.UNIT);
            var plotNumber  = PlotNumber = parameters.GetValue <int>(NavParams.PLOT_NUMBER);
            var stratumCode = parameters.GetValue <string>(NavParams.STRATUM);

            //read fixcount tally populations
            var tallyPopulations = FixCNTDataservice.GetFixCNTTallyPopulations(stratumCode).ToArray();

            //foreach tally population calculate and itterate through interval values
            foreach (var tp in tallyPopulations)
            {
                var buckets  = new List <FixCNTTallyBucket>();
                var interval = tp.Min + tp.IntervalSize / 2;

                //foreach interval value try to read a tree
                do
                {
                    var treeCount = FixCNTDataservice.GetTreeCount(unit, plotNumber, stratumCode, tp.SampleGroupCode, tp.SpeciesCode, tp.LiveDead, tp.FieldName, interval);

                    buckets.Add(new FixCNTTallyBucket(tp, interval, treeCount));

                    interval += tp.IntervalSize;
                } while (interval <= tp.Max);

                tp.Buckets = buckets;
            }

            TallyPopulations = tallyPopulations;
            RaisePropertyChanged(nameof(TallyPopulations));
        }