Ejemplo n.º 1
0
 private static object GetRasterTemplateByArray(string templateName)
 {
     string[] rasterNames = RasterDictionaryTemplateFactory.RasterTemplateNames;
     foreach (string name in rasterNames)
     {
         if (name == templateName)
         {
             return(RasterDictionaryTemplateFactory.CreateRasterTemplate(templateName));
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
        private StatResultItem[] CountByLandRaster(IRasterDataProvider raster, Func <T, int, int> weight)
        {
            IRasterDictionaryTemplate <byte> temp  = RasterDictionaryTemplateFactory.CreateLandRasterTemplate();
            Dictionary <byte, string>        paris = temp.CodeNameParis;

            if (paris == null)
            {
                return(null);
            }
            double lon = raster.CoordEnvelope.Center.X;
            double lat = raster.CoordEnvelope.Center.Y;
            IRasterOperator <T>   oper  = new RasterOperator <T>();
            List <StatResultItem> items = new List <StatResultItem>();

            int[] aoi;
            int   count;

            foreach (string value in paris.Values)
            {
                aoi = temp.GetAOI(value, raster.CoordEnvelope.MinX, raster.CoordEnvelope.MaxX, raster.CoordEnvelope.MinY, raster.CoordEnvelope.MaxY, new Size(raster.Width, raster.Height));
                if (aoi == null)
                {
                    continue;
                }
                count = oper.Count(raster, aoi, weight);
                if (count == 0)
                {
                    continue;
                }
                StatResultItem it = new StatResultItem();
                it.Name  = value;
                it.Value = count;
                double d = AreaCountHelper.CalcArea(lon, lat, raster.ResolutionX, raster.ResolutionY) * count * Math.Pow(10, -6);
                it.Value = Math.Round(d, 3);
                items.Add(it);
            }
            return(items != null?items.ToArray() : null);
        }