Exemple #1
0
        public void GetPixelAsBoundingBoxString_ValidInput_ReturnsExpected()
        {
            // Arrange
            var    sut      = new PointToPolygonConverter();
            string expected = "[[-118.67213507701905,45.71042895488162],[-118.67213507701905,45.74640181911838],[-118.62060247098096,45.74640181911838],[-118.62060247098096,45.71042895488162],[-118.67213507701905,45.71042895488162]]";

            // Act
            string actual = sut.GetPixelAsBoundingBoxString(
                45.72841538700,
                -118.64636877400,
                4);

            // Assert
            Assert.Equal(expected, actual);
        }
        public async Task <bool> Run(
            string inputFilePath,
            string outputFilePath,
            int delay = 100)
        {
            List <CsipLocation> locations = new List <CsipLocation>();

            // Read file with FlexCropping locations
            List <FlexCroppingLocation> points =
                fileHandler.ReadFlexCroppingLocationFile(inputFilePath);

            // For each point, get cokey
            foreach (var point in points)
            {
                string polygonString = converter.GetPixelAsBoundingBoxString(
                    point.Latitude, point.Longitude, 4);

                string resultJson = await serviceHandler.Post(polygonString);

                WweSoilParamsResponseV2_0 result =
                    serviceHandler.ParseResultsJson(resultJson);

                //string cokey = cokeyChooser.GetDominateCokey(result);
                Component component = cokeyChooser.GetDominateComponent(result);
                string    muname    = cokeyChooser.GetDominateMapUnitName(result);

                CsipLocation location = new CsipLocation()
                {
                    Latitude         = point.Latitude,
                    Longitude        = point.Longitude,
                    AnthromeKey      = point.Anthrome,
                    Cokey            = component.Cokey,
                    Slope            = component.Slope,
                    SlopeLength      = component.SlopeLength,
                    PercentOfMapUnit = component.PercentOfMapUnit,
                    MapUnitName      = muname
                };

                locations.Add(location);

                Thread.Sleep(delay);
            }

            // Write file
            fileHandler.WriteCsipLocationFile(outputFilePath, locations);

            return(true);
        }