Skip to content

Instantly share code, notes, and snippets.

@soypunk
Created March 7, 2020 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soypunk/df5de4153a5d3bf277ba36a4f7c21cca to your computer and use it in GitHub Desktop.
Save soypunk/df5de4153a5d3bf277ba36a4f7c21cca to your computer and use it in GitHub Desktop.
"""
Proof of Concept: Generate a Travellermap Subsector Poster from Legacy SEC data using Python and the Requests lib
"""
import requests
# I'm hard coding this for demostration purposes but ideally this data comes from the CLWorldGen
# Also note that API allows you to generate an entire sector or just a subsector.
# for our purposes we'll just generate subsector A
SUBSECTOR_DATA = """@SUB-SECTOR: Laorre SECTOR: Esge
#
#--------1---------2---------3---------4---------5-------
#PlanetName Loc. UPP Code B Notes Z PBG Al
#---------- ---- --------- - --------------- - --- --
Usorenla 0101 C727411-7 S Ni X 113 Im
Xeenla 0103 E300330-7 Lo Va X 310 Im
Atriqu 0105 E332751-7 Na X 511 Im
Soama 0109 X677230-5 Lo Lt X 520 Im
Anveve 0201 E538214-7 Lo X 601 Im
Arsogela 0202 C658875-3 Ga Lt X 411 Im
Enri 0207 X110110-7 Lo X 500 Im
Bicere 0208 X100200-7 Lo Va X 600 Im
Isdion 0209 X454541-1 Ag Ga Lt Ni X 412 Im
Atbire 0302 E540567-5 De Lt Ni X 421 Im
Tilece 0305 X533433-7 Ni X 210 Im
Bimain 0306 X525410-7 Ni X 511 Im
Digediri 0310 X421300-7 Lo X 211 Im
Onedla 0406 X676210-5 Lo Lt X 411 Im
Edxeorra 0410 E252655-4 Lt Ni X 301 Im
Isso 0501 C400685-9 Na Ni Va X 510 Im
Edvetear 0503 X120200-7 De Lo X 312 Im
Orusti 0507 D350432-4 De Lt Ni X 611 Im
Laorza 0510 D310232-7 Lo X 311 Im
Xeatqu 0602 E350310-6 De Lo X 713 Im
Tiusis 0603 E100310-A Lo Va X 513 Im
Esrigear 0604 D434672-7 Ni X 310 Im
Edbe 0608 X220446-7 De Ni X 221 Im
Rivear 0704 X400200-7 Lo Va X 611 Im
Riaar 0708 C535533-7 Ni X 512 Im
Zaar 0709 X100353-7 Lo Va X 420 Im
Ralaesbe 0802 C443586-8 Ni X 620 Im
Cedi 0806 A856976-C Hi Ht X 710 Im
Onongexe 0807 X30158A-7 Ic Ni Va X 713 Im
Matiso 0808 X300210-7 Lo Va X 711 Im
Atenve 0809 X000231-7 As Lo Va X 713 Im
Bisoxeer 0810 B565AB9-9 Hi A 411 Im
"""
TRAVELLERMAP_POSTER_API_URL = "https://travellermap.com/api/poster"
def render_poster(
subsector_data,
scale=64,
subsector_index="A"):
url = "%s?scale=%d&subsector=%s" % (
TRAVELLERMAP_POSTER_API_URL,
scale,
subsector_index)
form_data = {
'data': subsector_data
}
response = requests.post(
url = url,
data = form_data)
# raise any HTTP errors
response.raise_for_status()
if response.headers['Content-Type'] == 'image/png':
file = open("poster.png", "wb")
file.write(response.content)
file.close()
render_poster(SUBSECTOR_DATA)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment