private void RedrawMap() { map = new SCANmap(); map.setProjection(SCANmap.MapProjection.Rectangular); orbitingBody = vessel.mainBody; map.setBody(vessel.mainBody); map.setSize(screenWidth, screenHeight); map.mapscale *= (zoomLevel * zoomLevel + zoomModifier); mapCenterLong = vessel.longitude; mapCenterLat = vessel.latitude; // That's really just sweeping the problem under the carpet instead of fixing it, but meh. if (zoomLevel == 0) { mapCenterLat = 0; } map.centerAround(mapCenterLong, mapCenterLat); map.resetMap(mapMode); // Compute and store the map scale factors in mapSizeScale. We // use these values for every segment when drawing trails, so it // makes sense to compute it only when it changes. mapSizeScale = new Vector2d(360.0 * map.mapscale / map.mapwidth, 180.0 * map.mapscale / map.mapheight); redrawDeviation = redrawEdge * 180 / (zoomLevel * zoomLevel + zoomModifier); try { localAnomalies = SCANcontroller.controller.getData(vessel.mainBody).getAnomalies(); } catch { Debug.Log("JSISCANsatRPM: Could not get a list of anomalies, what happened?"); } // MATH! double kmPerDegreeLon = (2 * Math.PI * (orbitingBody.Radius / 1000d)) / 360d; double pixelsPerDegree = Math.Abs(longitudeToPixels(mapCenterLong + (((mapCenterLong + 1) > 360) ? -1 : 1), mapCenterLat) - longitudeToPixels(mapCenterLong, mapCenterLat)); pixelsPerKm = pixelsPerDegree / kmPerDegreeLon; }
public void setMapCenter(double lat, double lon, SCANmap big) { Visible = true; bigmap = big; SCANcontroller.controller.TargetSelecting = false; SCANcontroller.controller.TargetSelectingActive = false; if (bigmap.Projection == MapProjection.Polar) { spotmap.setProjection(MapProjection.Polar); } else { spotmap.setProjection(MapProjection.Rectangular); } if (bigmap.Body != b) { SCANdata dat = SCANUtil.getData(bigmap.Body); if (dat == null) { dat = new SCANdata(bigmap.Body); } data = dat; b = data.Body; spotmap.setBody(b); } if (SCANconfigLoader.GlobalResource && narrowBand) { spotmap.Resource = bigmap.Resource; spotmap.Resource.CurrentBodyConfig(b.name); } spotmap.MapScale = 10; spotmap.centerAround(lon, lat); if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay) { checkForScanners(); } spotmap.resetMap(bigmap.MType, false, narrowBand); }