Compass

class visigoth.map_layers.compass.Compass(radius=40, fill='lightgrey', stroke='black', stroke_width=2)

Create a compass layer showing the user device heading (if available on the user device)

Arguments:

Keyword Arguments
  • radius (int) – radius of compass in pixels

  • fill (str) – fill colour

  • stroke (str) – stroke color for circumference of compass and text

  • stroke_width (int) – stroke width for circumference of compass

Notes:

Example

Screenshot (Link to open SVG for interactive features):

../_images/example24.png

Source Code (Link to Github):



import os.path
import sys
import argparse


from visigoth.diagram import Diagram
from visigoth.containers.map import Map
from visigoth.containers.box import Box
from visigoth.map_layers.compass import Compass
from visigoth.map_layers.wms import WMS
from visigoth.utils.mapping.projections import Projections
from visigoth.common.text import Text

if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("--outpath", help="path for output SVG", default="example.svg")
    parser.add_argument("--iterations", help="number of iterations to run", default=200,type=int)

    args = parser.parse_args()

    d = Diagram()

    bounds  = ((-180,-70),(180,70))
    m = Map(512,bounds)
    
    m.addLayer(WMS())
    m.addLayer(Compass())
    d.add(Box(Text("Compass Test",text_attributes={"font-style":"italic"})))
    d.add(Box(m))
    
    svg = d.draw()

    f = open(args.outpath, "wb")
    f.write(svg)
    f.close()