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); } }
public static ORSPlanetaryResourcePixel getResourceAvailability(int body, string resourcename, double lat, double lng) { if (body != current_body) { loadPlanetaryResourceData(body); } if (body_resource_maps.ContainsKey(resourcename)) { ORSPlanetaryResourceInfo resource_info = body_resource_maps[resourcename]; double resource_val = resource_info.getLatLongAbundanceValue(lat, lng); 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); } }