public static FNPlanetaryResourcePixel getResourceAvailabilityByRealResourceName(int body, string resourcename, double lat, double lng)
 {
     if (body != current_body) {
         loadPlanetaryResourceData(body);
     }
     try{
         FNPlanetaryResourceInfo resource_info = body_resource_maps.Where(ri => ri.Value.getResourceName() == resourcename).FirstOrDefault().Value;
         return getResourceAvailability(body, resource_info.getName(),lat,lng);
     }catch(Exception ex) {
         FNPlanetaryResourcePixel resource_pixel = new FNPlanetaryResourcePixel(resourcename, 0, body);
         return resource_pixel;
     }
 }
        public static FNPlanetaryResourcePixel 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)) {
                FNPlanetaryResourceInfo 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);

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

                return resource_pixel;
            }else {
                FNPlanetaryResourcePixel resource_pixel = new FNPlanetaryResourcePixel(resourcename, 0, body);
                return resource_pixel;
            }
        }