Esempio n. 1
0
def make_thing_map(query, symbols, filename, legend=False):
    global lat, lng
    # symbols: [(uri, color, name), ...]

    themap = config.make_map_from_cli_args()
    symbols = {
        uri: (themap.add_symbol(random_id(),
                                color,
                                '#000000',
                                1,
                                title=pick_name(name)), pick_name(name))
        for (uri, color, name) in symbols
    }
    other = themap.add_symbol(random_id(),
                              '#000000',
                              '#000000',
                              1,
                              title='Other')

    unclassified = {}
    for (s, title, thing, lat, lng) in sparqllib.query_for_rows(query):
        try:
            (symbol, name) = symbols[thing]
        except KeyError:
            unclassified[thing] = unclassified.get(thing, 0) + 1
            symbol = other
            name = thing

        themap.add_marker(lat, lng, title + ': ' + name, symbol)

    for (thing, count) in unclassified.items():
        print 'Unclassified: %s %s' % (thing, count)

    themap.set_legend(legend)
    themap.render_to(config.get_file() or filename)
Esempio n. 2
0
    def __init__(self, recent_projects, directory_callback, parent=None):
        super(ExistingProjectDialog, self).__init__(parent)
        self.setWindowTitle('Open Project Folder')
        self.setWindowIcon(
            QtGui.QIcon(config.get_file('files/images/icon.png')))
        self.setMinimumWidth(500)

        group_box = QtGui.QGroupBox('Existing Projects')
        gbox_layout = QtGui.QVBoxLayout()
        self.project_list = QtGui.QListWidget()

        gbox_layout.addWidget(self.project_list)
        group_box.setLayout(gbox_layout)

        self.callback = directory_callback

        self.projects = recent_projects

        for project in recent_projects:
            text = '{} - {}'.format(os.path.basename(project), project)
            self.project_list.addItem(text)

        self.project_list.itemClicked.connect(self.project_clicked)

        self.cancel = QtGui.QPushButton('Cancel')
        self.open = QtGui.QPushButton('Open Selected')
        self.open_readonly = QtGui.QPushButton('Open Read-only')
        self.browse = QtGui.QPushButton('Browse...')

        self.open.setEnabled(False)
        self.open.clicked.connect(self.open_clicked)

        self.open_readonly.setEnabled(False)
        self.open_readonly.clicked.connect(self.open_readonly_clicked)

        self.browse.clicked.connect(self.browse_clicked)

        buttons = QtGui.QWidget()

        button_layout = QtGui.QHBoxLayout()
        button_layout.addWidget(self.cancel)
        button_layout.addWidget(QtGui.QWidget())
        button_layout.addWidget(self.browse)
        button_layout.addWidget(self.open_readonly)
        button_layout.addWidget(self.open)

        buttons.setLayout(button_layout)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(group_box)
        layout.addWidget(buttons)

        self.setLayout(layout)
        self.cancel.clicked.connect(self.cancelled)
Esempio n. 3
0
    def __init__(self, recent_projects, directory_callback, parent=None):
        super(ExistingProjectDialog, self).__init__(parent)
        self.setWindowTitle('Open Project Folder')
        self.setWindowIcon(QtGui.QIcon(config.get_file('files/images/icon.png')))
        self.setMinimumWidth(500)

        group_box = QtGui.QGroupBox('Existing Projects')
        gbox_layout = QtGui.QVBoxLayout()
        self.project_list = QtGui.QListWidget()

        gbox_layout.addWidget(self.project_list)
        group_box.setLayout(gbox_layout)

        self.callback = directory_callback

        self.projects = recent_projects

        for project in recent_projects:
            text = '{} - {}'.format(os.path.basename(project), project)
            self.project_list.addItem(text)

        self.project_list.itemClicked.connect(self.project_clicked)

        self.cancel = QtGui.QPushButton('Cancel')
        self.open = QtGui.QPushButton('Open Selected')
        self.open_readonly = QtGui.QPushButton('Open Read-only')
        self.browse = QtGui.QPushButton('Browse...')

        self.open.setEnabled(False)
        self.open.clicked.connect(self.open_clicked)

        self.open_readonly.setEnabled(False)
        self.open_readonly.clicked.connect(self.open_readonly_clicked)

        self.browse.clicked.connect(self.browse_clicked)

        buttons = QtGui.QWidget()

        button_layout = QtGui.QHBoxLayout()
        button_layout.addWidget(self.cancel)
        button_layout.addWidget(QtGui.QWidget())
        button_layout.addWidget(self.browse)
        button_layout.addWidget(self.open_readonly)
        button_layout.addWidget(self.open)

        buttons.setLayout(button_layout)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(group_box)
        layout.addWidget(buttons)

        self.setLayout(layout)
        self.cancel.clicked.connect(self.cancelled)
Esempio n. 4
0
  ?type rdfs:subClassOf tb:Account.
}''' # tb:pitch-temperature ?pt;

years = []
for (s, title, y) in sparqllib.query_for_rows(query):
    #print s, title, y
    if int(y) < 0:
        print s, title
    years.append(int(y))

years.sort()
print years[0], '-', years[-1]

from matplotlib import pyplot

pyplot.style.use(config.get_plot_style())

(n, bins, patches) = pyplot.hist(years,
                                 BINS,
                                 alpha=0.5,
                                 label='Accounts by year')
pyplot.title('Accounts by year')
pyplot.xlabel('Year')
pyplot.ylabel('Number of accounts')

if not config.get_file():
    pyplot.show()
else:
    pyplot.savefig(config.get_file())
    pyplot.close()
Esempio n. 5
0
    NEG + 'either' : EITHER,
    NEG + 'both' : EITHER
}

query = '''
prefix dc: <http://purl.org/dc/elements/1.1/>
prefix neg: <http://www.garshol.priv.no/2014/neg/>
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix tb: <http://www.garshol.priv.no/2014/trad-beer/>
prefix eu: <http://www.garshol.priv.no/2017/eu/>
prefix r: <http://www.garshol.priv.no/2014/trad-beer/recipe/>

SELECT DISTINCT ?s ?lat ?lng ?title ?harvest
WHERE {
  ?s
    dc:title ?title;
    geo:lat ?lat;
    geo:long ?lng;
    tb:yeast-harvest ?harvest.
}'''
for (s, lat, lng, title, harvest) in sparqllib.query_for_rows(query):
    try:
        symbol = symbols[harvest]
    except KeyError:
        print 'KeyError:', s, harvest
        raise
    themap.add_marker(lat, lng, title, symbol)

themap.set_legend(True)
themap.render_to(config.get_file() or 'yeast-harvest')
Esempio n. 6
0
labels = {
    'en': {
        'true': 'Juniper infusion',
        'false': 'No infusion',
        'borderline': 'Borderline',
    },
    'no': {
        'true': u'Einerlåg',
        'false': u'Ikke einerlåg',
        'borderline': u'Både og',
    }
}

query = '''
prefix dc: <http://purl.org/dc/elements/1.1/>
prefix neg: <http://www.garshol.priv.no/2014/neg/>
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix tb: <http://www.garshol.priv.no/2014/trad-beer/>

SELECT DISTINCT ?s ?lat ?lng ?title ?mead
WHERE {
  ?s
    dc:title ?title;
    geo:lat ?lat;
    geo:long ?lng;
    tb:juniper-infusion ?mead.
}'''
maputils.make_boolean_map(query,
                          config.get_file() or 'juniper-infusion-map',
                          labels[LANG])
Esempio n. 7
0
                         title=l['either'])
blue = themap.add_symbol('blue',
                         '#0000FF',
                         '#000000',
                         strokeweight=1,
                         title=l['men'])

NEG = 'http://www.garshol.priv.no/2014/neg/'
MALE = NEG + 'male'
FEMALE = NEG + 'female'
BOTH = NEG + 'both'
symbol_map = {MALE: blue, FEMALE: red, BOTH: pink}

query = '''
prefix tb: <http://www.garshol.priv.no/2014/trad-beer/>
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?s ?lat ?lng ?sex ?title
WHERE {
  ?s
    dc:title ?title;
    geo:lat ?lat;
    geo:long ?lng;
    tb:malter-sex ?sex.
}'''
for (s, lat, lng, sex, title) in sparqllib.query_for_rows(query):
    symbol = symbol_map[sex]
    themap.add_marker(lat, lng, title, symbol)

themap.set_legend(True)
themap.render_to(config.get_file() or 'malter-sex-map')
Esempio n. 8
0
    'From bottom of beer cask': green,
}

query = '''
prefix dc: <http://purl.org/dc/elements/1.1/>
prefix neg: <http://www.garshol.priv.no/2014/neg/>
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix tb: <http://www.garshol.priv.no/2014/trad-beer/>
prefix yeast: <http://www.garshol.priv.no/2017/trad-beer/yeast-keeping/>

SELECT DISTINCT ?s ?lat ?lng ?proc ?procname ?title
WHERE {
  ?s
    dc:title ?title;
    geo:lat ?lat;
    geo:long ?lng;
    tb:yeast-keeping ?proc.

  ?proc rdfs:label ?procname.
}'''# FILTER( ?proc in (yeast:log, yeast:yeast-ring))

for (s, lat, lng, proc, procname, title) in sparqllib.query_for_rows(query):
    symbol = symbols.get(procname, black)
    if symbol == black:
        print 'UNMAPPED', repr(procname)

    themap.add_marker(lat, lng, title, symbol, procname)

themap.set_legend(True)
themap.render_to(config.get_file() or 'yeast-keeping-map')
Esempio n. 9
0
    'en': {
        'true': 'Cold mash',
        'false': 'No cold mash',
        'borderline': 'Borderline',
    },
    'no': {
        'true': u'Kaldmesk',
        'false': u'Ikke kaldmesk',
        'borderline': u'Både og',
    }
}

query = '''
prefix dc: <http://purl.org/dc/elements/1.1/>
prefix neg: <http://www.garshol.priv.no/2014/neg/>
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix tb: <http://www.garshol.priv.no/2014/trad-beer/>

SELECT DISTINCT ?s ?lat ?lng ?title ?yeast
WHERE {
  ?s
    dc:title ?title;
    geo:lat ?lat;
    geo:long ?lng;
    tb:process ?proc.

  ?proc neg:cold-mash ?yeast.
}'''
maputils.make_boolean_map(query,
                          config.get_file() or 'cold-mash-map', labels[LANG])
Esempio n. 10
0
}
'''

labels = {
    'en': {
        'party': u'Oppskåke',
        'house-tasting': 'House tasting',
        'skokubolle': 'Skokubolle',
        'none': 'Nothing',
    },
    'no': {
        'party': u'Oppskåke',
        'house-tasting': 'Husstanden smaker',
        'skokubolle': 'Skokubolle',
        'none': 'Ingen markering',
    }
}

LANG = config.get_language()
PREFIX = 'http://www.garshol.priv.no/2014/neg/'
symbols = [
    (PREFIX + 'party', '#FFFF00', labels[LANG]['party']),
    (PREFIX + 'house-tasting', '#AAAAAA', labels[LANG]['house-tasting']),
    (PREFIX + 'skokubolle', '#00FF00', labels[LANG]['skokubolle']),
    (PREFIX + 'none', '#000000', labels[LANG]['none']),
]
maputils.make_thing_map(query,
                        symbols,
                        config.get_file() or 'oppskake-map',
                        legend=True)
Esempio n. 11
0
#encoding=utf-8

import re
import config
import maputils

KORNOL = re.compile(u'k((orn)|(ønnj))øl')
HEIMABRYGG = re.compile('heim(a|e)br(y|u)gg')
MALTOL = re.compile(u'malt(ø|ö)l')
DRICKA = re.compile(u'dr(i|e)(c|k)?k(a|e)?')

symbols = [
    (KORNOL, '#FFFFFF', u'Kornøl'),
    (HEIMABRYGG, '#0000FF', u'Heimabrygg'),
    (MALTOL, '#00FF00', u'Maltøl'),
    (DRICKA, '#FF0000', u'Dricka'),
]
maputils.make_term_map('tb:beer-name',
                       symbols,
                       config.get_file() or 'beer-name-map',
                       language=config.get_language())
Esempio n. 12
0
import maplib
import sparqllib

themap = config.make_map_from_cli_args()

alive = themap.add_symbol('yellow', '#FFFF00', '#000000')

query = '''
prefix tb: <http://www.garshol.priv.no/2014/trad-beer/>
prefix neg: <http://www.garshol.priv.no/2014/neg/>

select ?title ?place ?lat ?lng where {
  ?s dc:title ?title;
    tb:year ?year;
    tb:place-of-origin ?p;
    tb:brewing-ended false.

  ?p rdfs:label ?place;
    geo:lat ?lat;
    geo:long ?lng.

  FILTER ( ?year >= 2000 )
}
'''
for (title, place, lat, lng) in sparqllib.query_for_rows(query):
    themap.add_marker(lat, lng, title, alive)

# ===== RENDER

themap.render_to(config.get_file() or 'now-map')
Esempio n. 13
0
}

l = labels[LANG]
red = themap.add_symbol('red', '#FF0000', '#000000', title=l['women'])
pink = themap.add_symbol('pink', '#FF00FF', '#000000', title=l['either'])
blue = themap.add_symbol('blue', '#0000FF', '#000000', title=l['men'])

NEG = 'http://www.garshol.priv.no/2014/neg/'
MALE = NEG + 'male'
FEMALE = NEG + 'female'
BOTH = NEG + 'both'
symbol_map = {MALE: blue, FEMALE: red, BOTH: pink}

query = '''
prefix tb: <http://www.garshol.priv.no/2014/trad-beer/>
prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?s ?lat ?lng ?sex ?title
WHERE {
  ?s
    dc:title ?title;
    geo:lat ?lat;
    geo:long ?lng;
    tb:brewer-sex ?sex.
}'''
for (s, lat, lng, sex, title) in sparqllib.query_for_rows(query):
    symbol = symbol_map[sex]
    themap.add_marker(lat, lng, title, symbol)

themap.set_legend(True)
themap.render_to(config.get_file() or 'sex-map')