mirror of
https://github.com/nikdoof/cynomap.git
synced 2025-12-13 13:12:17 +00:00
Fix CRLF
This commit is contained in:
13
app.py
13
app.py
@@ -1,13 +1,20 @@
|
|||||||
|
import logging
|
||||||
from flask import Flask, Response
|
from flask import Flask, Response
|
||||||
from map import CynoMap
|
from map import CynoMap
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/cynos.svg')
|
@app.route('/cynos.svg')
|
||||||
def cynos():
|
@app.route('/cynos-<range>.svg')
|
||||||
map = CynoMap(jumprange=13, keyid=525316, vcode="8jIZ4pjpLQOKQsUPY4cSpIy0Rtd4AcBh6HzOOzDC4qFlI0UO7dtJUVSkh7G7NhST").svg.standalone_xml()
|
def cynos(range=13):
|
||||||
|
logging.info('Range %s' % range)
|
||||||
|
map = CynoMap(jumprange=float(range), keyid=525316, vcode="8jIZ4pjpLQOKQsUPY4cSpIy0Rtd4AcBh6HzOOzDC4qFlI0UO7dtJUVSkh7G7NhST").svg.standalone_xml()
|
||||||
return Response(mimetype='image/svg+xml', response=map)
|
return Response(mimetype='image/svg+xml', response=map)
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
return """<iframe src="/cynos.svg" width="600px" height="600px" scrolling="yes"></iframe>"""
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
app.run(host='0.0.0.0')
|
||||||
|
|||||||
12
map.py
12
map.py
@@ -55,7 +55,7 @@ class CynoMap(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def calc_distance(sys1, sys2):
|
def calc_distance(sys1, sys2):
|
||||||
"""Calculate the distance between two sets of 3d coordinates"""
|
"""Calculate the distance between two sets of 3d coordinates"""
|
||||||
return sqrt((sys1['x']-sys2['x'])**2+(sys1['y']-sys2['y'])**2+(sys1['z']-sys2['z'])**2) / 10000000000000000
|
return sqrt((sys1['x']-sys2['x'])**2+(sys1['y']-sys2['y'])**2+(sys1['z']-sys2['z'])**2) / 9460000000000000.0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def systems(self):
|
def systems(self):
|
||||||
@@ -142,15 +142,15 @@ class CynoMap(object):
|
|||||||
if not self.keyid or not self.vcode: return {}
|
if not self.keyid or not self.vcode: return {}
|
||||||
if not hasattr(self, '_cynochars'):
|
if not hasattr(self, '_cynochars'):
|
||||||
auth = EVEAPIConnection(cacheHandler=DbCacheHandler()).auth(keyID=self.keyid, vCode=self.vcode)
|
auth = EVEAPIConnection(cacheHandler=DbCacheHandler()).auth(keyID=self.keyid, vCode=self.vcode)
|
||||||
chars = auth.account.Characters()
|
#chars = auth.account.APIKeyInfo()
|
||||||
members = auth.corp.MemberTracking(characterID=chars.characters[0].characterID)
|
members = auth.corp.MemberTracking(extended=1)
|
||||||
|
|
||||||
self._cynochars = {}
|
self._cynochars = {}
|
||||||
for member in members.members:
|
for member in members.members:
|
||||||
loc = self.get_system_location(member.locationID)
|
loc = self.get_system_location(member.locationID)
|
||||||
if not loc: continue
|
if not loc: continue
|
||||||
|
|
||||||
info = {'name': member.name }
|
info = member.name
|
||||||
if not int(loc) in self._cynochars:
|
if not int(loc) in self._cynochars:
|
||||||
self._cynochars[loc] = [info]
|
self._cynochars[loc] = [info]
|
||||||
else:
|
else:
|
||||||
@@ -194,12 +194,14 @@ class CynoMap(object):
|
|||||||
if sys['id'] in self.get_cyno_locations():
|
if sys['id'] in self.get_cyno_locations():
|
||||||
fill = 'red'
|
fill = 'red'
|
||||||
radius = 5
|
radius = 5
|
||||||
|
title = "%s (%s)" % (sys['name'], ', '.join(self.get_cyno_locations()[sys['id']]))
|
||||||
else:
|
else:
|
||||||
fill = 'gray'
|
fill = 'gray'
|
||||||
for loc in self.get_cyno_locations():
|
for loc in self.get_cyno_locations():
|
||||||
if self.calc_distance(sys, self.systems[loc]) < self.jumprange:
|
if self.calc_distance(sys, self.systems[loc]) < self.jumprange:
|
||||||
fill = 'blue'
|
fill = 'blue'
|
||||||
radius = 2
|
radius = 2
|
||||||
|
title = sys['name']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -207,7 +209,7 @@ class CynoMap(object):
|
|||||||
if lowz > sys['cz']: lowz = sys['cz']
|
if lowz > sys['cz']: lowz = sys['cz']
|
||||||
if highx < sys['cx']: highx = sys['cx']
|
if highx < sys['cx']: highx = sys['cx']
|
||||||
if highz < sys['cz']: highz = sys['cz']
|
if highz < sys['cz']: highz = sys['cz']
|
||||||
attrs = {'cx': sys['cx'], 'cy': -sys['cz'], 'r': radius, 'id': 'system-%s' % sys['id'], 'class': 'system', 'fill': fill, 'stroke-width': 0}
|
attrs = {'cx': sys['cx'], 'cy': -sys['cz'], 'r': radius, 'id': 'system-%s' % sys['id'], 'class': 'system', 'fill': fill, 'stroke-width': 0, 'title': title}
|
||||||
svg = SVG('circle', **attrs)
|
svg = SVG('circle', **attrs)
|
||||||
sysgroup.append(svg)
|
sysgroup.append(svg)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user