This commit is contained in:
2012-02-05 11:08:43 +00:00
parent a6e5364a9d
commit 3b122460d5
4 changed files with 784 additions and 775 deletions

4
.gitignore vendored
View File

@@ -1,3 +1,3 @@
*.pyc
*.db
*.pyc
*.db
*.sqlite3

33
app.py
View File

@@ -1,13 +1,20 @@
from flask import Flask, Response
from map import CynoMap
app = Flask(__name__)
@app.route('/cynos.svg')
def cynos():
map = CynoMap(jumprange=13, keyid=525316, vcode="8jIZ4pjpLQOKQsUPY4cSpIy0Rtd4AcBh6HzOOzDC4qFlI0UO7dtJUVSkh7G7NhST").svg.standalone_xml()
return Response(mimetype='image/svg+xml', response=map)
if __name__ == '__main__':
app.run()
import logging
from flask import Flask, Response
from map import CynoMap
app = Flask(__name__)
@app.route('/cynos.svg')
@app.route('/cynos-<range>.svg')
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)
@app.route('/')
def index():
return """<iframe src="/cynos.svg" width="600px" height="600px" scrolling="yes"></iframe>"""
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
app.run(host='0.0.0.0')

14
map.py
View File

@@ -55,7 +55,7 @@ class CynoMap(object):
@staticmethod
def calc_distance(sys1, sys2):
"""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
def systems(self):
@@ -142,15 +142,15 @@ class CynoMap(object):
if not self.keyid or not self.vcode: return {}
if not hasattr(self, '_cynochars'):
auth = EVEAPIConnection(cacheHandler=DbCacheHandler()).auth(keyID=self.keyid, vCode=self.vcode)
chars = auth.account.Characters()
members = auth.corp.MemberTracking(characterID=chars.characters[0].characterID)
#chars = auth.account.APIKeyInfo()
members = auth.corp.MemberTracking(extended=1)
self._cynochars = {}
for member in members.members:
loc = self.get_system_location(member.locationID)
if not loc: continue
info = {'name': member.name }
info = member.name
if not int(loc) in self._cynochars:
self._cynochars[loc] = [info]
else:
@@ -194,12 +194,14 @@ class CynoMap(object):
if sys['id'] in self.get_cyno_locations():
fill = 'red'
radius = 5
title = "%s (%s)" % (sys['name'], ', '.join(self.get_cyno_locations()[sys['id']]))
else:
fill = 'gray'
for loc in self.get_cyno_locations():
if self.calc_distance(sys, self.systems[loc]) < self.jumprange:
fill = 'blue'
radius = 2
title = sys['name']
@@ -207,7 +209,7 @@ class CynoMap(object):
if lowz > sys['cz']: lowz = sys['cz']
if highx < sys['cx']: highx = sys['cx']
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)
sysgroup.append(svg)
@@ -232,4 +234,4 @@ class CynoMap(object):
c = canvas()
c.attr.update({'viewBox': '-1000 -1100 2000 2000', 'height': '2000', 'width': '2000'})
c.extend([jumpgroup, sysgroup, cynos])
return c
return c

1508
svgfig.py

File diff suppressed because it is too large Load Diff