From 846e5e38863d31cf9da13bd129e58b89f77cf4ce Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 10 Jan 2017 03:22:02 -0500 Subject: [PATCH] Fix security status calculation. --- calefaction/eve/universe.py | 4 ++-- calefaction/format.py | 4 ++-- calefaction/modules/map.py | 10 +++++++++- static/map.js | 10 +++++----- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/calefaction/eve/universe.py b/calefaction/eve/universe.py index 6c14060..38d7fc8 100644 --- a/calefaction/eve/universe.py +++ b/calefaction/eve/universe.py @@ -84,12 +84,12 @@ class _SolarSystem(_UniqueObject): @property def is_nullsec(self): """Whether the solar system is in nullsec.""" - return self.security < 0.05 + return self.security <= 0.0 @property def is_lowsec(self): """Whether the solar system is in nullsec.""" - return self.security >= 0.05 and self.security < 0.45 + return self.security > 0.0 and self.security < 0.45 @property def is_highsec(self): diff --git a/calefaction/format.py b/calefaction/format.py index 5a6e42c..c8dfa9c 100644 --- a/calefaction/format.py +++ b/calefaction/format.py @@ -79,6 +79,6 @@ def format_security(value): def get_security_class(value): """Given a system security status, return the corresponding CSS class.""" - if value < 0.05: + if value <= 0.0: return "sec-null" - return "sec-" + str(round(value, 1)).replace(".", "_") + return "sec-" + str(round(max(value, 0.1), 1)).replace(".", "_") diff --git a/calefaction/modules/map.py b/calefaction/modules/map.py index 4b6e343..a081263 100644 --- a/calefaction/modules/map.py +++ b/calefaction/modules/map.py @@ -22,9 +22,10 @@ def map(): def mapdata(): """Render and return the map data as a JSON object.""" payload = { - "galaxy": { + "systems": { system.id: { "name": system.name, + "region": system.region.id, "security": system.security, "coords": system.coords, "gates": [dest.id for dest in system.gates], @@ -32,6 +33,13 @@ def mapdata(): } for system in g.eve.universe.systems() if not system.is_whspace }, + "regions": { + region.id: { + "name": region.name, + "faction": region.faction.id if region.faction else -1 + } + for region in g.eve.universe.regions() if not region.is_whspace + }, "factions": { faction.id: { "name": faction.name diff --git a/static/map.js b/static/map.js index 70fba1f..2ef3bb5 100644 --- a/static/map.js +++ b/static/map.js @@ -21,7 +21,7 @@ var get_bounds = function(galaxy) { $(function() { $("#map .preload").append($("

").text("Loading map data...")); $.getJSON( "map/data.json", data => { - var galaxy = data["galaxy"]; + var galaxy = data["systems"]; var systems = Object.values(galaxy); var jumps = [].concat .apply([], Object.keys(galaxy) @@ -67,8 +67,8 @@ $(function() { .attr("r", 2) .attr("class", d => { var sec = d["security"]; - var klass = sec < 0.05 ? "null" : - Number(sec).toFixed(1).replace(".", "_"); + var klass = sec <= 0.0 ? "null" : + Number(Math.max(sec, 0.1)).toFixed(1).replace(".", "_"); return "system sec-" + klass; }); @@ -82,13 +82,13 @@ $(function() { trans.x = Math.max(Math.min(trans.x, clamp), -clamp); trans.y = Math.max(Math.min(trans.y, clamp), -clamp); stars.attr("transform", trans); + $("#map-scale").val(Math.log2(trans.k + 1)); - if (trans.k != lastk) { + if (Math.abs((trans.k - lastk) / lastk) > 0.1) { stars.selectAll("circle") .attr("r", 6 / (trans.k + 2)); stars.selectAll("line") .style("stroke-width", 2 / (trans.k + 1)); - $("#map-scale").val(Math.log2(trans.k + 1)); lastk = trans.k; } });