Next Previous Up Contents
Next: VO
Up: General Functions
Previous: TrigDegrees

### B.1.23 URLs

Functions that construct URLs for external services. Most of the functions here just do string manipulation to build up URL strings, using knowledge of the parameters required for various services.

`urlEncode( txt )`
  Performs necessary quoting of a string for it to be included safely in the data part of a URL. Alphanumeric characters and the characters underscore ("`_`"), minus sign ("`-`"), period ("`.`") and tilde ("`~`") are passed through unchanged, and any other 7-bit ASCII character is represented by a percent sign ("`%`") followed by its 2-digit hexadecimal code. Characters with values of 128 or greater are simply dropped.

  - Parameters:
    - `txt` (String): input (unencoded) string
  - Return value
    - (String): output (encoded) string
  - Example:
    - `urlEncode("RR Lyr") = "RR%20Lyr"`
  - See Also:
    - RFC 3986
`urlDecode( txt )`
  Reverses the quoting performed by `urlEncode`. Percent-encoded sequences (`%xx`) are replaced by the ASCII character with the hexadecimal code `xx`.

  - Parameters:
    - `txt` (String): input (encoded) string
  - Return value
    - (String): output (unencoded) string
  - Example:
    - `urlDecode("RR%20Lyr") = "RR Lyr"`
  - See Also:
    - RFC 3986
`paramsUrl( baseUrl, nameValuePairs, ... )`
  Builds a query-type URL string given a base URL and a list of name, value pairs.

  The parameters are encoded on the command line according to the "`application/x-www-form-urlencoded`" convention, which appends a "?" to the base URL, and then adds name=value pairs separated by "&" characters, with percent-encoding of non-URL-friendly characters. This format is used by many services that require a list of parameters to be conveyed on the URL.

  - Parameters:
    - `baseUrl` (String): basic URL (may or may not already contain a "?")
    - `nameValuePairs` (String, one or more): an even number of arguments (or an even-length string array) giving parameter name1,value1,name2,value2,...nameN,valueN
  - Return value
    - (String): form-encoded URL
  - Example:
    - `paramsUrl("http://x.org/", "a", "1", "b", "two", "c", "3&4") = "http://x.org/?a=1&b=two&c=3%264"`
`bibcodeUrl( bibcode )`
  Maps a bibcode to the URL that will display the relevant entry in ADS. If the supplied string does not appear to be a bibcode, null will be returned.

  If the supplied string appears to be a bibcode, it just prepends the string "`https://ui.adsabs.harvard.edu/abs/`" and performs any character escaping that is required.

  - Parameters:
    - `bibcode` (String): ADS-style bibcode string
  - Return value
    - (String): display URL pointing at bibcode record, or null if it doesn't look like a bibcode
  - Example:
    - `bibcodeUrl("2018A&A...616A...2L") = "https://ui.adsabs.harvard.edu/abs/2018A%26A...616A...2L"`
  - See Also:
    - http://adsabs.harvard.edu/abs_doc/help_pages/data.html
`doiUrl( doi )`
  Maps a DOI (Digital Object Identifier) to its display URL. If the supplied string does not appear to be a DOI, null will be returned.

  If the supplied string appears to be a DOI, it strips any "`doi:`" prefix if present, prepends the string "`https://doi.org/`", and performs any character escaping that is required.

  - Parameters:
    - `doi` (String): DOI string, with or without "doi:" prefix
  - Return value
    - (String): display URL pointing at DOI content, or null if it doesn't look like a DOI
  - Example:
    - `doiUrl("10.3390/informatics4030018") = "https://doi.org/10.3390/informatics4030018"`
  - See Also:
    - https://www.doi.org/
`arxivUrl( arxivId )`
  Maps an arXiv identifier to the URL that will display its arXiv web page. If the supplied string does not appear to be an arXiv identifier, null will be returned.

  If the supplied string appears to be an arXiv identifier, it strips any "`arXiv:` prefix and prepends the string "`https://arxiv.org/abs/`".

  - Parameters:
    - `arxivId` (String): arXiv identifier, with or without "arXiv:" prefix
  - Return value
    - (String): display URL pointing at bibcode record, or null if it doesn't look like a bibcode
  - Example:
    - `arxivUrl("arXiv:1804.09379") = "https://arxiv.org/abs/1804.09381"`
  - See Also:
    - https://arxiv.org/help/arxiv_identifier
`simbadUrl( sourceId )`
  Maps a source identifier to the URL of its SIMBAD web page. SIMBAD is the astronomical source information service run by the Centre de Données astronomiques de Strasbourg.

  The string "`http://simbad.u-strasbg.fr/simbad/sim-id?Ident=`" is prepended to the given id string, and any necessary character escaping is applied. No attempt is made to validate whether the supplied string is a real source identifier, so there is no guarantee that the returned URL will contain actual results.

  - Parameters:
    - `sourceId` (String): free text assumed to represent a source identifier known by SIMBAD
  - Return value
    - (String): URL of the Simbad web page describing the identified source
  - Example:
    - `simbadUrl("Beta Pictoris") = "http://simbad.u-strasbg.fr/simbad/sim-id?Ident=Beta%20Pictoris"`
`nedUrl( sourceId )`
  Maps a source identifier to the URL of its NED web page. NED is the NASA/IPAC Extragalactic Database.

  The string "`http://ned.ipac.caltech.edu/byname?objname=`" is prepended to the given id string, and any necessary character escaping is applied. No attempt is made to validate whether the supplied string is a real source identifier, so there is no guarantee that the returned URL will contain actual results.

  - Parameters:
    - `sourceId` (String): free text assumed to represent a source identifier known by NED
  - Return value
    - (String): URL of the NED web page describing the identified source
  - Example:
    - `nedUrl("NGC 3952") = "http://ned.ipac.caltech.edu/byname?objname=NGC%203952"`
`hips2fitsUrl( hipsId, fmt, raDeg, decDeg, fovDeg, npix )`
  Returns the URL of a cutout from the Hips2Fits service operated by CDS. The result will be the URL of a FITS or image file resampled to order from one of the HiPS surveys available at CDS.

  This function requests a square cutout using the SIN projection, which is suitable for small cutouts. If the details of this function don't suit your purposes, you can construct the URL yourself.

  - Parameters:
    - `hipsId` (String): identifier or partial identifier for the HiPS survey
    - `fmt` (String): required output format, for instance "`fits`", "`png`", "`jpg`"
    - `raDeg` (floating point): central Right Ascension (longitude) in degrees
    - `decDeg` (floating point): central Declination (latitude) in degrees
    - `fovDeg` (floating point): field of view; extent of the cutout in degrees
    - `npix` (integer): extent of the cutout in pixels (width=height=npix)
  - Return value
    - (String): URL of the required cutout
  - See Also:
    - http://alasky.u-strasbg.fr/hips-image-services/hips2fits

Next Previous Up Contents
Next: VO
Up: General Functions
Previous: TrigDegrees

TOPCAT - Tool for OPerations on Catalogues And Tables
Starlink User Note253
TOPCAT web page: http://www.starlink.ac.uk/topcat/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@jiscmail.ac.uk