Пример #1
0
        private Point ConvertTernaryToCartesianCoordinates(TernaryCoordinate coord)
        {
            double xCoord = (1.0D / 2.0D) * ((2.0D * coord.Silt + coord.Clay) / (coord.Sand + coord.Silt + coord.Clay));
            double yCoord = (Math.Sqrt(3.0D) / 2.0D) * (coord.Clay / (coord.Sand + coord.Silt + coord.Clay));

            return(new Point()
            {
                x = xCoord, y = yCoord
            });
        }
Пример #2
0
        public string GetSoilType(TernaryCoordinate coord)
        {
            var samplePoint = ConvertTernaryToCartesianCoordinates(coord);

            foreach (var soilType in SoilTypeValues.SoilTypes)
            {
                var poly = soilType.GetPolygon();
                if (samplePoint.InsidePolygon(poly, poly.Length) == 0)
                {
                    return(soilType.Name);
                }
            }

            return("N/A");
        }