Skip to content

Commit

Permalink
first beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigma88 committed Feb 10, 2018
1 parent 2aaaf6c commit 033e5b8
Show file tree
Hide file tree
Showing 10 changed files with 769 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**v0.1.0**

First Beta Release
25 changes: 25 additions & 0 deletions GameData/Sigma/Cartographer/Sigma-Cartographer.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"NAME": "<b><color=#9B59B6>Sigma Cartographer</color></b>",
"URL": "https://raw.githubusercontent.com/Sigma88/Sigma-Cartographer/master/GameData/Sigma/Cartographer/Sigma-Cartographer.version",
"DOWNLOAD": "https://github.com/Sigma88/Sigma-Cartographer/releases/latest",
"CHANGE_LOG_URL": "https://raw.githubusercontent.com/Sigma88/Sigma-Cartographer/master/Changelog.txt",
"GITHUB":
{
"USERNAME": "Sigma88",
"REPOSITORY": "Sigma-Cartographer",
"ALLOW_PRE_RELEASE": false
},
"VERSION":
{
"MAJOR": 0,
"MINOR": 1,
"PATCH": 0,
"BUILD": 0
},
"KSP_VERSION":
{
"MAJOR": 1,
"MINOR": 3,
"PATCH": 1
}
}
Binary file not shown.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Sigma-Cartographer
Map exporting tool for KSP
# Sigma Cartographer

**Map exporting tool for KSP**
Binary file added [Source]/Distribution/SigmaCartographer.dll
Binary file not shown.
121 changes: 121 additions & 0 deletions [Source]/SigmaCartographer/BodyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using System.Linq;
using System.IO;
using UnityEngine;


namespace SigmaRandomPlugin
{
[KSPAddon(KSPAddon.Startup.MainMenu, false)]
class BodyInfo : MonoBehaviour
{
static string[] info = new string[9];

void Start()
{
UrlDir.UrlConfig[] nodes = GameDatabase.Instance?.GetConfigs("SigmaCartographer");

foreach (var node in nodes)
{
foreach (var bodyInfo in node.config.GetNodes("Info"))
{
foreach (var bodyName in bodyInfo.GetValues("body"))
{
CelestialBody body = FlightGlobals.Bodies.FirstOrDefault(p => p.transform.name == bodyName);
if (body?.pqsController != null)
{
FirstPass(body);
}
}
}
}
}

void FirstPass(CelestialBody body)
{
double lowest = double.MaxValue;
double highest = double.MinValue;

Vector2d LatLonLo = new Vector2d();
Vector2d LatLonHi = new Vector2d();

for (double LON = -180; LON < 180; LON += 0.1)
{
for (double LAT = -90; LAT <= 90; LAT += 0.1)
{
double ALT = body.TerrainAltitude(LAT, LON, true);

if (ALT < lowest)
{
lowest = ALT;
LatLonLo = new Vector2d(LAT, LON);
}
if (ALT > highest)
{
highest = ALT;
LatLonHi = new Vector2d(LAT, LON);
}
}
}
Lowest(body, LatLonLo);
Highest(body, LatLonHi);
}

void Lowest(CelestialBody body, Vector2d LatLon)
{
double altitude = double.MaxValue;
double latitude = LatLon.x;
double longitude = LatLon.y;

for (double LON = LatLon.y - 0.1; LON <= LatLon.y + 0.1; LON += 0.001)
{
for (double LAT = LatLon.x - 0.1; LAT <= LatLon.x + 0.1; LAT += 0.001)
{
double ALT = body.TerrainAltitude(LAT, LON, true);
if (ALT < altitude)
{
latitude = LAT;
longitude = LON;
altitude = ALT;
}
}
}

info[0] = "Lowest Point";
info[1] = "LAT = " + latitude;
info[2] = "LON = " + longitude;
info[3] = "ALT = " + altitude;
info[4] = "";
}

void Highest(CelestialBody body, Vector2d LatLon)
{
double altitude = double.MinValue;
double latitude = LatLon.x;
double longitude = LatLon.y;

for (double LON = LatLon.y - 0.1; LON <= LatLon.y + 0.1; LON += 0.001)
{
for (double LAT = LatLon.x - 0.1; LAT <= LatLon.x + 0.1; LAT += 0.001)
{
double ALT = body.TerrainAltitude(LAT, LON, true);
if (ALT > altitude)
{
latitude = LAT;
longitude = LON;
altitude = ALT;
}
}
}

info[5] = "Highest Point";
info[6] = "LAT = " + latitude;
info[7] = "LON = " + longitude;
info[8] = "ALT = " + altitude;

string path = "GameData/Sigma/Cartographer/PluginData/" + body.transform.name + "/";

Directory.CreateDirectory(path);
File.WriteAllLines(path + "Info.txt", info);
}
}
}
Loading

0 comments on commit 033e5b8

Please sign in to comment.