Ejemplo n.º 1
0
        public static ORSPlanetaryResourcePixel getResourceAvailability(int body, string resourcename, double lat, double lng)
        {
            if (body != current_body)
            {
                loadPlanetaryResourceData(body);
            }
            int lng_s = ((int)Math.Ceiling(Math.Abs(lng / 180)) % 2);

            lng = lng % 180;
            if (lng_s == 0)
            {
                lng = (180 * Math.Sign(lng) - lng) * (-1);
            }
            int lat_s = ((int)Math.Ceiling(Math.Abs(lat / 90)) % 2);

            lat = lat % 90;
            if (lat_s == 0)
            {
                lat = (90 * Math.Sign(lat) - lat) * (-1);
            }
            if (body_resource_maps.ContainsKey(resourcename))
            {
                ORSPlanetaryResourceInfo resource_info = body_resource_maps[resourcename];
                Texture2D map      = resource_info.getResourceMap();
                double    len_x    = map.width;
                double    len_y    = map.height;
                double    origin_x = map.width / 2.0;
                double    origin_y = map.height / 2.0;

                double map_x = (lng * len_x / 2 / 180 + origin_x);
                double map_y = (lat * len_y / 2 / 90 + origin_y);

                int pix_x = (int)Math.Round(map_x);
                int pix_y = (int)Math.Round(map_y);

                double resource_val = getPixelAbundanceValue(pix_x, pix_y, resource_info);

                ORSPlanetaryResourcePixel resource_pixel = new ORSPlanetaryResourcePixel(resource_info.getName(), resource_val, resource_info.getBody());
                resource_pixel.setResourceName(resource_info.getResourceName());

                return(resource_pixel);
            }
            else
            {
                ORSPlanetaryResourcePixel resource_pixel = new ORSPlanetaryResourcePixel(resourcename, 0, body);
                return(resource_pixel);
            }
        }
Ejemplo n.º 2
0
        protected static double getPixelAbundanceValue(int pix_x, int pix_y, ORSPlanetaryResourceInfo resource_info)
        {
            Texture2D map              = resource_info.getResourceMap();
            Color     pix_color        = map.GetPixel(pix_x, pix_y);
            double    resource_val     = 0;
            double    scale_factor     = resource_info.getScaleFactor();
            double    scale_multiplier = resource_info.getScaleMultiplier();

            if (resource_info.getResourceScale() == ORSPlanetaryResourceInfo.LOG_SCALE)
            {
                resource_val = Math.Pow(scale_factor, pix_color.grayscale * 255.0) / 1000000 * scale_multiplier;
            }
            else if (resource_info.getResourceScale() == ORSPlanetaryResourceInfo.LINEAR_SCALE)
            {
                resource_val = pix_color.grayscale * scale_multiplier;
            }
            return(resource_val);
        }
 protected static double getPixelAbundanceValue(int pix_x, int pix_y, ORSPlanetaryResourceInfo resource_info)
 {
     Texture2D map = resource_info.getResourceMap();
     Color pix_color = map.GetPixel(pix_x, pix_y);
     double resource_val = 0;
     double scale_factor = resource_info.getScaleFactor();
     double scale_multiplier = resource_info.getScaleMultiplier();
     if (resource_info.getResourceScale() == ORSPlanetaryResourceInfo.LOG_SCALE)
     {
         resource_val = Math.Pow(scale_factor, pix_color.grayscale * 255.0) / 1000000 * scale_multiplier;
     }
     else if (resource_info.getResourceScale() == ORSPlanetaryResourceInfo.LINEAR_SCALE)
     {
         resource_val = pix_color.grayscale * scale_multiplier;
     }
     return resource_val;
 }