geolucidate.links.tools – Utility functions for map link generators

Convenience class for generating links to maps.

>>> ml = MapLink("58147N/07720W", "58.235278", "-77.333333")
>>> ml
<MapLink 58.235278, -77.333333>
coordinates(separator='')[source]

Return the coordinates stored by this MapLink, separated by optional separator character separator.

lat_str

Latitude value, converted to a string. Automatically quantized according to input precision.

long_str

Longitude value, converted to a string. Automatically quantized according to input precision.

Calls the link generator function passed as link_generator to generate a link to the URL baseurl, with parameters params.

The link text is set to the original string, while the link title is set to the original string followed by the parsed coordinates in parentheses.

Parameters:
  • baseurl – Base URL to pass to link generator; should end in ‘?’
  • params – Dictionary of parameters to be URL-encoded with urlencode() and appended to the base URL
  • link_generator – Link-generating function; should take as parameters the URL, text, and title, and return generated HTML link
>>> ml = MapLink("ABC123", "-10.0", "20.0")
>>> ml.make_link("http://www.example.com/?",
...              {'foo': 'bar',
...               'lat': ml.lat_str,
...               'lon': ml.long_str},
...              default_link)
u'<a href="http://www.example.com/?lat=-10.0&foo=bar&lon=20.0" title="ABC123 (-10.0, 20.0)">ABC123</a>'
original_string

Original string contaning parsed coordinates.

The default link generating function, for generating HTML links as strings. To generate links as Genshi elements, lxml elements, etc., supply an alternate link-generating function which takes the same parameters.

>>> default_link("http://www.google.com", "Google")
u'<a href="http://www.google.com">Google</a>'
>>> default_link("http://www.google.com", "Google", "Google")
u'<a href="http://www.google.com" title="Google">Google</a>'

Previous topic

geolucidate.links.yahoo – Yahoo Maps link generator

Next topic

Notes on input formats

This Page