Пример #1
0
 def _add_features(self, features):
     # add all features (as features are rendered on top of each other in the
     # order we provide it to mapnik, make sure markers are on top)
     types = ['Polygon', 'LineString', 'Point']
     getter = lambda x: types.index(x['geometry']['type'])
     entries = sorted([strip(f) for f in features], key=getter)
     collection = json.dumps(FeatureCollection(entries))
     xml_str = get_xml("styles/features.xml").format(collection).encode()
     load_map_from_string(self._map, xml_str)
Пример #2
0
 def _get_features(self):
     # add all features (as features are rendered on top of each other in the
     # order we provide it to mapnik, make sure markers are on top)
     features = []
     if len(self.obj['features']) > 0:
         types = ['GeometryCollection', 'Polygon', 'LineString', 'Point']
         getter = lambda x: types.index(x['geometry']['type'])
         features = sorted([strip(f) for f in self.obj['features']],
                           key=getter)
     return geojson.FeatureCollection(features)
Пример #3
0
def betdsi_nhl_extractor(page):
    tp = TableParser()
    tp.feed(strip(page))
    tables = tp.get_tables()

    # Get rid of garbage rows
    tables = [t for t in tables if len(t) == 2]

    # Find team names and moneylines
    pairs = []
    for table in tables:
        name1 = table[0][1].strip()
        name2 = table[1][0]
        moneyline1 = table[0][-1].strip()
        moneyline2 = table[1][-1].strip()
        pairs.append(((name1, moneyline1), (name2, moneyline2)))
    return pairs
Пример #4
0
def bodog_nhl_extractor(page):
    tp = TableParser()
    tp.feed(strip(page))
    tables = tp.get_tables()

    # Get rid of garbage rows
    rows = [r for t in tables for r in t if len(r) > 3][1:]

    # Find team names and moneylines
    pairs = []
    for i in range(len(rows)/2):
        name1 = rows[i*2][2].strip()
        name2 = rows[i*2+1][1].strip()
        moneyline1 = rows[i*2][4].strip()
        moneyline2 = rows[i*2+1][3].strip()
        pairs.append(((name1, moneyline1), (name2, moneyline2)))
    return pairs
Пример #5
0
def betdsi_nhl_extractor(page):
    tp = TableParser()
    tp.feed(strip(page))
    tables = tp.get_tables()

    # Get rid of garbage rows
    tables = [t for t in tables if len(t) == 2]

    # Find team names and moneylines
    pairs = []
    for table in tables:
        name1 = table[0][1].strip()
        name2 = table[1][0]
        moneyline1 = table[0][-1].strip()
        moneyline2 = table[1][-1].strip()
        pairs.append(((name1, moneyline1), (name2, moneyline2)))
    return pairs
Пример #6
0
def bovada_nhl_extractor(page):
    tp = TableParser()
    tp.feed(strip(page))
    tables = tp.get_tables()

    # Get rid of garbage lines in the table
    tables = tables[1:]
    for i, t in enumerate(tables):
        tables[i] = max(t, key=lambda x: len(x))

    # Find the team names and moneylines
    pairs = []
    for i in range(len(tables) / 2):
        name1 = tables[i * 2][2].strip()
        name2 = tables[i * 2 + 1][1].strip()
        moneyline1 = tables[i * 2][4].strip()
        moneyline2 = tables[i * 2 + 1][3].strip()
        pairs.append(((name1, moneyline1), (name2, moneyline2)))
    return pairs