It's live. (Be gentle!)
The API docs have been updated, but here's the short version:
For Poster.aspx, Tile.aspx or JumpMap.aspx, either pass an HTTP "Accept" header with "application/pdf" or include "accept=application/pdf" in either the query string (GET) or form data (POST).
Since it took a whopping 10 seconds, I also added a checkbox to the post example if you want to generate PDFs from your custom data.
Once any bugs are shaken out of this update I plan to add a link to the bottom of the main map page which offers "give me a printable version" of whatever you're looking at. I could make it either "smart" and offer Charted Space, Domain, Sector, Quadrant or Subsector depending on scale, or "dumb" and spew out exactly what you see on screen but in PDF form. I lean towards "smart".
Ω
2009-08-17
2009-08-16
PDF Generation, Continued [SNEAK PEEK]
I have almost everything functional again under the PdfSharp code. The time consuming bit is that I was using GDI+ TexturedBrushes for a couple of things and PdfSharp (wisely) doesn't provide this, so you have to implement this manually. This actually ended up simplifying the code in several places. The only gotcha is that I was using it in a somewhat complicated way for rendering pseudo-random stars within the galactic arms at certain scales.
The old algorithm went like this:
The new code looks like this:
Simpler, huh? Well, yes, but it turns out that (1) it's a whopping huge path with lots of curves and segments (and I reduced it as much as I could), (2) bitmap-based clipping is heavily optimized, and (3) it's a single clip against a region, rather than once per star.
After pondering the importance of this (i.e. not very) I decided to simply ditch the pseudo-random stars away from charted space, and turn on the pretty galaxy image instead if you zoom out.
So... I'm pretty close to flipping the switch on this to make it live, but want to double check all of the changes first. But to whet your appetites, here are few more previews:
Spinward Marches - Eye-Candy - this one is a bit big (1MB) due to all the images
Charted Space
Enjoy! Ω
The old algorithm went like this:
if (inside charted space)
draw a bunch of pseudo-random stars on the tile
else if (inside the galactic bounds)
construct a tile-sized bitmap
draw a bunch of pseudo-random stars on the bitmap
load a path describing the galactic arms
on the tile, fill the path using the bitmap as a brush
The new code looks like this:
if (inside charted space)
draw a bunch of pseudo-random stars on the tile
else if (inside the galactic bounds)
load a path describing the galactic arms
use the path as a "clipping" region
draw a bunch of pseudo-random stars on the tile
Simpler, huh? Well, yes, but it turns out that (1) it's a whopping huge path with lots of curves and segments (and I reduced it as much as I could), (2) bitmap-based clipping is heavily optimized, and (3) it's a single clip against a region, rather than once per star.
After pondering the importance of this (i.e. not very) I decided to simply ditch the pseudo-random stars away from charted space, and turn on the pretty galaxy image instead if you zoom out.
So... I'm pretty close to flipping the switch on this to make it live, but want to double check all of the changes first. But to whet your appetites, here are few more previews:
Spinward Marches - Eye-Candy - this one is a bit big (1MB) due to all the images
Charted Space
Enjoy! Ω
2009-08-15
PDF Generation [SNEAK PEEK]
I'm playing with the PDFSharp library which provides PDF generation capabilities for C# with a liberal license and can be used with ASP.NET handily enough. The library nicely supports using the same rendering primitives to output via GDI+ or PDF, so I can actually just convert the site's entire rendering stack onto PDFSharp (which looks a lot like System.Drawing anyway) and then simply pass it either a bitmap or a PDF into which to render.
After a couple of hours of playing, here's sample output from the Poster API:
http://www.travellermap.com/tmp/spinward_demo.pdf
Warning: don't blithely hit "print" - I'm not doing anything clever with units yet, so I don't know how many pages it will try and span. Examine the print options carefully. :)
This is not live yet - there are several things not working yet and I'm concerned about performance when suddenly have the main map site running through this code. But so far, it looks promising.
When it is live, you'll be able to use the Tile, Poster and JumpMap APIs to generate PDFs by specifying either a Content-Type HTTP header or a query string parameter in the URI (since we can't always control header generation). Ω
After a couple of hours of playing, here's sample output from the Poster API:
http://www.travellermap.com/tmp/spinward_demo.pdf
Warning: don't blithely hit "print" - I'm not doing anything clever with units yet, so I don't know how many pages it will try and span. Examine the print options carefully. :)
This is not live yet - there are several things not working yet and I'm concerned about performance when suddenly have the main map site running through this code. But so far, it looks promising.
When it is live, you'll be able to use the Tile, Poster and JumpMap APIs to generate PDFs by specifying either a Content-Type HTTP header or a query string parameter in the URI (since we can't always control header generation). Ω
2009-08-14
Scale and Content Fixes
A handful of bug fixes
Fix ParsecScaleX constant from 0.868 to cos(30°). (Reported by Joachim Pfaff)
This has been wrong since the site was created - I must have estimated the number (or it was a typo - it's closer to 0.866) and never corrected it. This unfortunately means that permalinks - which encode a non-scaled x/y - are now slightly off. Given that the coordinate system starts at Reference, this means the farther you get from the center of the Imperium the more the old permalinks will be off.
Fortunately, this isn't far - compare Regina - new permalink, old permalink. Since it's less than a parsec, I'm not going to call on Plan B, which would be to honor old permalinks and tag new permalinks in some way (additional argument, changed coordinate names, etc.).
Fix erroneous inclusion of invalid neighbor subsector labels. (Reported by BeRKA.)
Stupid logic glitch on my part - I was allowing the "neighbor subsector" calculation to wrap around.
Fix subsector name for Zhodane (from Zhdant to Gaval) per Supplement 11. (Reported by Thomas Jones-Low.)
Dunno where "Zhdant" came from as the subsector name - probably an older sector file. But it's now corrected, per Supp 11. Ω
Fix ParsecScaleX constant from 0.868 to cos(30°). (Reported by Joachim Pfaff)
This has been wrong since the site was created - I must have estimated the number (or it was a typo - it's closer to 0.866) and never corrected it. This unfortunately means that permalinks - which encode a non-scaled x/y - are now slightly off. Given that the coordinate system starts at Reference, this means the farther you get from the center of the Imperium the more the old permalinks will be off.
Fortunately, this isn't far - compare Regina - new permalink, old permalink. Since it's less than a parsec, I'm not going to call on Plan B, which would be to honor old permalinks and tag new permalinks in some way (additional argument, changed coordinate names, etc.).
Fix erroneous inclusion of invalid neighbor subsector labels. (Reported by BeRKA.)
Stupid logic glitch on my part - I was allowing the "neighbor subsector" calculation to wrap around.
Fix subsector name for Zhodane (from Zhdant to Gaval) per Supplement 11. (Reported by Thomas Jones-Low.)
Dunno where "Zhdant" came from as the subsector name - probably an older sector file. But it's now corrected, per Supp 11. Ω
Subscribe to:
Posts (Atom)