2007-12-23

Map API Updates

A bunch of internal cleanup and refactoring, which will hopefully have no noticeable impact on the site, and three subtle changes to the Poster API:
  • Extra-sector worlds no longer rendered - borders and routes will be shown, but the worlds themselves will not be.
  • Added an optional subsector=X argument where X is the A...P index of the subsector. If specified, only that subsector is rendered.
  • If no render options are specified, by default a sector poster elides the sector grid lines and a subsector poster elides the subsector grid lines as well.
This should make it easier to use the site as an API for static navigation. For example, the following image is embedded in the blog via the following markup:

<img src="http://www.travellermap.com/Poster.aspx?sector=Spinward+Marches&subsector=C&options=2928&scale=64" border="4" />



The API documentation in the last post was incomplete, so here's another shot:

/Coordinates.aspx?sector=SECTORNAME[&hex=XXYY]
  • Maps a sector name (and optional hex coordinate) into sector/hex coordinates
  • Results are in XML, or JSON if Accept: application/json is specified
  • example
/Credits.aspx?x=XCOORD&y=YCOORD
  • Looks up the data and credits for a given location, including UWP if available
  • Coordinates are in tile-space coordinates (optimized for tile rendering, not navigation); conversion functions are in the script
  • Results are in XML, or JSON if Accept: application/json is specified
  • example
/MSEC.aspx?sector=SECTORNAME
/Poster.aspx?sector=SECTORNAME[&scale=N][&subsector=X][&options=O]
  • Generate a GIF or JPEG image of the specified sector (or just subsector). Scale (pixels/parsec) and options can be included
  • Image format depends on selected options ("Candy" produces JPEG, otherwise GIF)
  • Options are defined in the script
  • example
/Search.aspx?q=QUERY
  • Perform a free-text search of names for matching sectors, subsectors and worlds
  • Results are in XML, or JSON if Accept: application/json is specified
  • example
/Tile.aspx?x=XCOORD&y=YCOORD&scale=N&options=O[&w=WIDTH&h=HEIGHT]
  • Generate a GIF or JPEG image of the specified region.
  • Coordinates are in tile-space coordinates (optimized for tile rendering, not navigation); conversion functions are in the script
  • Image format depends on selected options ("Candy" produces JPEG, otherwise GIF)
  • Options are defined in the script
  • example
In case it isn't obvious, the map page itself works by calling these APIs from JavaScript (primarily Tile, but also Coordinates and Search depending on user actions; use of Credits is still "in beta")

Please feel free to make use of any of these APIs. If you encounter any issues with them, let me know! Ω

1 comment:

Jim said...

Josh, this is really incredibly cool. I love the MSEC addition. Any plans on generating a sector data file (in whatever format) from the web service?