Skip to content

Commit

Permalink
Fixed inverted z coordinate in systemvis.html.
Browse files Browse the repository at this point in the history
Added sectorvis.html which shows the distribution of system names.
Added coordinates to sysinfo.html.
TGC interface now ignores duplicate distances.
  • Loading branch information
SteveHodge committed Mar 15, 2015
1 parent 301b44f commit e735c82
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 55 deletions.
91 changes: 51 additions & 40 deletions entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@

function getRegionTable(trilat) {
var table = document.createElement('table');
if (!trilat.regions);
var row = document.createElement('tr');
$('<th data-sort="string">Corner 1</th>').appendTo(row);
$('<th data-sort="string">Corner 2</th>').appendTo(row);
Expand Down Expand Up @@ -723,6 +724,14 @@
$('<td>').text(this.best.length).appendTo(row);
$('<td>').text(this.nextBest).appendTo(row);
tbody.appendChild(row);

if (this.minx <= 25.21875 && this.maxx >= 25.21875
&& this.miny <= -20.90625 && this.maxy >= -20.90625
&& this.minz <= 25899.96875 && this.maxz >= 25899.96875) {
row.className = 'error';
console.log(row.className);
}

});

$(table).stupidtable().bind('aftertablesort', updateSortArrow);
Expand Down Expand Up @@ -846,46 +855,48 @@ <h3>Nearby Systems</h3>
</table>
</div>

<h3>Distances</h3>
<table id="distances">
<thead>
<tr>
<th data-sort="string-ins" data-sort-desc="string-ins">System</th>
<th>Distance</th>
<th data-sort="optfloat">Calculated</th>
<th data-sort="optfloat" style="width:20em">Status</th>
</tr>
</thead>
<tbody>
<tr><td><input class="system-name" value="Sirius"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Privir"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Arug"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Nuwach"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Blende"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Zhuar"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Bastana"></td><td><input class="distance"></td><td/><td/></tr>
</tbody>
</table>
<div id="ref-warning" class="ui-state-error ui-corner-all" style="margin: 0.5em; display:none">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
<strong>Warning:</strong> Need more distances to reference systems!</p>
</div>

<h3>Calculated</h3>
<div id="output" style="clear:both"></div>
<button id="tgc-button" disabled="true">Submit to TGC</button>
<button id="done-button" disabled="true">Add to output only</button>
<button id="cancel-button">Cancel</button>
<br>

<div style="float:clear">
<h3>Output</h3>
<button id="toggle-log">Hide Log</button><button id="toggle-json">Show JSON</button><button id="toggle-sql">Show SQL</button>
<button id="toggle-tgc">Show TGC Response</button>
<pre id="log-output" style="height: 180px; overflow: auto"></pre>
<pre id="sql-output" style="display:none"></pre>
<pre id="json-output" style="display:none"></pre>
<pre id="tgc-output" style="display:none"></pre>
<div style="float: left">
<h3>Distances</h3>
<table id="distances">
<thead>
<tr>
<th data-sort="string-ins" data-sort-desc="string-ins">System</th>
<th>Distance</th>
<th data-sort="optfloat">Calculated</th>
<th data-sort="optfloat" style="width:20em">Status</th>
</tr>
</thead>
<tbody>
<tr><td><input class="system-name" value="Sirius"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Privir"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Arug"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Nuwach"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Blende"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Zhuar"></td><td><input class="distance"></td><td/><td/></tr>
<tr><td><input class="system-name" value="Bastana"></td><td><input class="distance"></td><td/><td/></tr>
</tbody>
</table>
<div id="ref-warning" class="ui-state-error ui-corner-all" style="margin: 0.5em; display:none">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
<strong>Warning:</strong> Need more distances to reference systems!</p>
</div>

<h3>Calculated</h3>
<div id="output" style="clear:both"></div>
<button id="tgc-button" disabled="true">Submit to TGC</button>
<button id="done-button" disabled="true">Add to output only</button>
<button id="cancel-button">Cancel</button>
<br>

<div>
<h3>Output</h3>
<button id="toggle-log">Hide Log</button><button id="toggle-json">Show JSON</button><button id="toggle-sql">Show SQL</button>
<button id="toggle-tgc">Show TGC Response</button>
<pre id="log-output" style="height: 180px; overflow: auto"></pre>
<pre id="sql-output" style="display:none"></pre>
<pre id="json-output" style="display:none"></pre>
<pre id="tgc-output" style="display:none"></pre>
</div>
</div>
</div>
</body>
Expand Down
210 changes: 210 additions & 0 deletions sectorvis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Systems Visualisation</title>
<script src="external/jquery-2.1.1.js" type="text/javascript"></script>
<script src="external/three.js" type="text/javascript"></script>
<script src="external/TrackballControls.js" type="text/javascript"></script>
<script src="tgc.js" type="text/javascript"></script>
<style>
body {
color: #ffffff;
font-family:Monospace;
font-size:13px;
text-align:center;
font-weight: bold;

background-color: #000000;
margin: 0px;
overflow: hidden;
}
td {
text-align:left;
}
</style>
<script>
var renderer, scene, camera, pointCloud;
var axes;

var systems = [];
var validSectors = [];

var sectorColors = ['white', 'gray', 'aqua', 'teal', 'red', 'maroon', 'blue', 'navy', 'lime', 'green', 'fuchsia', 'purple', 'orange', 'yellow', 'olive','white'];
var sectorColorMap = {};

$(document).ready(function () {
getTGCData(function() {
$.getJSON('validsectors.json', function(data) {
validSectors = data;

var sectorMap = {};

$.each(systemsMap, function(k, s) {
if (!('x' in s) || s.x == null) return;

var matches;
if (matches = s.name.match(/^(.*)\s+([a-z][a-z]-[a-z])\s+([a-g]\d+)(-\d+)?$/i)) {
var sector;
// find the sector, if any:
$.each(validSectors, function(i, sect) {
if (sect.toLowerCase() === matches[1].toLowerCase()) {
sector = sect;
return false;
}
});
if (!sector) return;

s.sector = sector;
systems.push(s);
if (sector in sectorMap) {
sectorMap[sector]++;
} else {
sectorMap[sector] = 1;
}
}
});

var sectorCount = [];
$.each(sectorMap, function(sect, count) {
sectorCount.push({sector: sect, count: count});
});
sectorCount.sort(function(a,b) {
if (b.count !== a.count) return b.count-a.count;
if (a.sector) return a.sector.localeCompare(b.sector);
return b.sector ? -1 : 0;
});

var i = 0;
var rest = 0, restNames = 0;
$.each(sectorCount, function() {
if (i < sectorColors.length-1 && this.sector !== '(unknown)') {
$('<tr>')
.append($('<td>').width('1.5em').css('background',sectorColors[i]))
.append($('<td>').text(this.sector+': '+this.count))
.appendTo('#legend tbody');
sectorColorMap[this.sector] = sectorColors[i];
i++;
}
});

init();
});
});
});

function init() {
var container = document.getElementById('container');

renderer = new THREE.WebGLRenderer({ clearColor: 0x000000, clearAlpha: 1 });
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);

scene = new THREE.Scene();

camera = new THREE.PerspectiveCamera(
45,
window.innerWidth / window.innerHeight,
1,
20000);
camera.position.z = 2500;

controls = new THREE.TrackballControls( camera );
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.2;
controls.panSpeed = 0.8;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;
controls.keys = [ 65, 83, 68 ];
controls.addEventListener( 'change', render );

var refMaterial = new THREE.PointCloudMaterial({
color: sectorColors[0],
// vertexColors: THREE.VertexColors,
size: 4,
sizeAttenuation: false,
opacity: 1,
map: THREE.ImageUtils.loadTexture("external/images/ball.png"),
transparent: true
});
var refGeometry = new THREE.Geometry();

var material = new THREE.PointCloudMaterial({
color: 0xffffff,
vertexColors: THREE.VertexColors,
size: 4,
sizeAttenuation: false,
opacity: 1,
map: THREE.ImageUtils.loadTexture("external/images/ball.png"),
transparent: true
});
var geometry = new THREE.Geometry();

$.each(systems, function(i,s){
if (s.sector in sectorColorMap) {
geometry.vertices.push(new THREE.Vector3( s.x, s.y, -s.z ));
geometry.colors.push(new THREE.Color(sectorColorMap[s.sector]));
}
});

pointCloud = new THREE.PointCloud(geometry, material);
pointCloud.sortParticles = true;
scene.add(pointCloud);

material = new THREE.LineBasicMaterial({
color: 0x0000ff
});

geometry = new THREE.Geometry();
geometry.vertices.push(
new THREE.Vector3(-100, 0, 0),
new THREE.Vector3(100, 0, 0),
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, -100, 0),
new THREE.Vector3(0, 100, 0),
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 0, -100),
new THREE.Vector3(0, 0, 100)
);

axes = new THREE.Line(geometry, material);
scene.add(axes);

animate();
}

function animate() {
requestAnimationFrame(animate);
controls.update();
render();
}

function render() {
if ($('#autorotate').prop('checked')){
pointCloud.rotation.x += 0.005;
pointCloud.rotation.y += 0.005;

axes.rotation.x += 0.005;
axes.rotation.y += 0.005;
}

renderer.render(scene, camera);
}

</script>
</head>
<body>
<div id="info">ED Known Sectors<br>Left mouse: rotate - Right mouse: pan - Mouse wheel: zoom<br>
<input type="checkbox" id="autorotate">Animate
<!--<input type="button" value="Switch" id="switch-button">-->
</div>
<div id="legend" style="position: absolute">
<table><tbody>
</tbody></table>
</div>
<div id="container"></div>

</body>
</html>
27 changes: 19 additions & 8 deletions sysinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}

function addSystemRow() {
var tr = $('<tr><td><input class="system-name"></td><td><input class="distance" size="8"></td><td/><td/><td/><td/></tr>')
var tr = $('<tr><td><input class="system-name"></td><td/><td/><td/><td><input class="distance" size="8"></td><td/><td/><td/><td/></tr>')
.appendTo('#distances tbody');
tr.find('input').change(updateCoords);
tr.find('input.system-name')
Expand All @@ -146,8 +146,8 @@
var $tr = addSystemRow();
$tr.find('input.system-name').val(this.system);
$tr.find('input.distance').val(this.distance);
$tr.children("td:nth-child(5)").text(this.created);
$tr.children("td:nth-child(6)").text(this.creator);
$tr.children("td:nth-child(8)").text(this.created);
$tr.children("td:nth-child(9)").text(this.creator);
});

updateCoords();
Expand All @@ -163,8 +163,16 @@
$("#distances input.system-name").each(function() {
var n = nameKey(this.value);
if (n.length > 0) {
$(this).parentsUntil('table','tr').attr('system', n);
if ((n in systemsMap) && systemsMap[n].name !== this.value) $(this).val(systemsMap[n].name);
var $tr = $(this).parentsUntil('table','tr');
$tr.attr('system', n);
if (n in systemsMap) {
var s = systemsMap[n];
if (s.name !== this.value) $(this).val(s.name); // update name if the capitalisation is different
// update coords:
$tr.children("td:nth-child(2)").text(s.x);
$tr.children("td:nth-child(3)").text(s.y);
$tr.children("td:nth-child(4)").text(s.z);
}
}
});

Expand All @@ -185,7 +193,7 @@
});

// reset the calculated distances and errors.
$("#distances tr:has(input.system-name) td:nth-child(3)").text("").next().text("");
$("#distances tr:has(input.system-name) td:nth-child(6)").text("").next().text("");
$("#output").html("");

// TODO trilateration needs to be moved to timer callback
Expand Down Expand Up @@ -217,7 +225,7 @@
if (enteredDist.length > 0) {
var nameKey = this.getAttribute('system');
if (!(nameKey in systemsMap)) {
$(this).children("td:nth-child(3)").text("")
$(this).children("td:nth-child(6)").text("")
.next().html('<span class="ui-icon ui-icon-alert inline-alert"></span>Unknown system');
return;
}
Expand All @@ -239,7 +247,7 @@
}
if (!sys.calculated) status += " (ref)";

$(this).children("td:nth-child(3)").text(sys.x == null ? '' : calcDist.toFixed(2)).next().html(status);
$(this).children("td:nth-child(6)").text(sys.x == null ? '' : calcDist.toFixed(2)).next().html(status);
}
});

Expand Down Expand Up @@ -383,6 +391,9 @@ <h3>Trilateration</h3>
<thead>
<tr>
<th data-sort="string-ins">System</th>
<th data-sort="float">X</th>
<th data-sort="float">Y</th>
<th data-sort="float">Z</th>
<th data-sort="optfloat">Distance</th>
<th data-sort="optfloat">Calculated</th>
<th data-sort="string-ins" style="width:12em">Status</th>
Expand Down
Loading

0 comments on commit e735c82

Please sign in to comment.