def create_table_dict(self): self.metadata.info['srid'] = CONFIG.srid self.metadata.info['num_threads'] = self.get_option('numthreads') tables = OrderedDict() # first the update table: stores all modified routes, points uptable = UpdatedGeometriesTable(self.metadata, CONFIG.change_table) tables['updates'] = uptable # First we filter all route relations into an extra table. rfilt = FilteredTable(self.metadata, CONFIG.route_filter_table, self.osmdata.relation, text("(%s)" % CONFIG.relation_subset)) tables['relfilter'] = rfilt # Then we create the connection between ways and relations. # This also adds geometries. relway = RelationWayTable(self.metadata, CONFIG.way_relation_table, self.osmdata.way, rfilt, osmdata=self.osmdata) tables['relway'] = relway # From that create the segmented table. segments = SegmentsTable(self.metadata, CONFIG.segment_table, relway, (relway.c.rels,)) tables['segments'] = segments # hierarchy table for super relations rtree = RelationHierarchy(self.metadata, CONFIG.hierarchy_table, rfilt) tables['hierarchy'] = rtree # routes table: information about each route routes = self.routeinfo_class(self.metadata, CONFIG.route_table, rfilt, relway, rtree, CountryGrid(MetaData(), CONFIG.country_table)) tables['routes'] = routes # finally the style table for rendering style = StyleTable(self.metadata, routes, segments, rtree, conf.get('DEFSTYLE'), uptable) tables['style'] = style # optional table for guide posts if conf.isdef('GUIDEPOSTS'): cfg = conf.get('GUIDEPOSTS') filt = FilteredTable(self.metadata, cfg.table_name + '_view', self.osmdata.node, text(cfg.node_subset), view_only=True) tables['gp_filter'] = filt tables['guideposts'] = GuidePosts(self.metadata, filt) # optional table for network nodes if conf.isdef('NETWORKNODES'): cfg = conf.get('NETWORKNODES') filt = FilteredTable(self.metadata, cfg.table_name + '_view', self.osmdata.node, self.osmdata.node.c.tags.has_key(cfg.node_tag), view_only=True) tables['nnodes_filter'] = filt tables['networknodes'] = NetworkNodes(self.metadata, filt) return tables
def create_mapdb(site_config, options): # all the route stuff we take from the RoutesDB implmentation setattr(options, 'schema', site_config.DB_SCHEMA) db = SlopesMapDB(options, site_config) setup_tables(db, PisteRoutes) # now create the additional joined ways tabname = site_config.DB_TABLES subset = and_(text(site_config.DB_WAY_SUBSET), column('id').notin_(select([db.tables.relway.c.id]))) filt = db.add_table('norelway_filter', FilteredTable(db.metadata, tabname.way_table + '_view', db.osmdata.way, subset)) ways = db.add_table('ways', PisteWayInfo(db.metadata, tabname.way_table, filt, db.osmdata, db.tables.updates, site_config.ROUTES, db.tables.routes.shield_fab)) cols = ('name', 'symbol', 'difficulty', 'piste') db.add_table('joined_ways', GroupedWayTable(db.metadata, tabname.joinedway, ways, cols)) return db
def create_tables(self): symbol_factory = ShieldFactory(self.site_config.ROUTES.symbols, self.site_config.SYMBOLS) # all the route stuff we take from the RoutesDB implmentation tables = self.create_table_dict(symbol_factory, PisteRoutes) # now create the additional joined ways tabname = self.site_config.DB_TABLES subset = and_(text(self.site_config.DB_WAY_SUBSET), column('id').notin_(select([tables['relway'].c.id]))) filt = FilteredTable(self.metadata, tabname.way_table + '_view', self.osmdata.way, subset) tables['norelway_filter'] = filt ways = PisteWayInfo(self.metadata, tabname.way_table, filt, self.osmdata, self.site_config.ROUTES, symbol_factory) tables['ways'] = ways cols = ('name', 'symbol', 'difficulty', 'piste') joins = GroupedWayTable(self.metadata, tabname.joinedway, ways, cols) tables['joined_ways'] = joins _RouteTables = namedtuple('_RouteTables', tables.keys()) return _RouteTables(**tables)
def create_tables(self): # all the route stuff we take from the RoutesDB implmentation tables = self.create_table_dict() # now create the additional joined ways subset = and_(text(CONF.way_subset), column('id').notin_(select([tables['relway'].c.id]))) filt = FilteredTable(self.metadata, PISTE_CONF.way_table_name + '_view', self.osmdata.way, subset) tables['norelway_filter'] = filt ways = PisteWayInfo(self.metadata, PISTE_CONF.way_table_name, filt, self.osmdata, tables['updates']) tables['ways'] = ways cols = ('name', 'symbol', 'difficulty', 'piste') joins = GroupedWayTable(self.metadata, CONF.joinedway_table, ways, cols) tables['joined_ways'] = joins _RouteTables = namedtuple('_RouteTables', tables.keys()) return _RouteTables(**tables)
def create_table_dict(self, symbol_factory, route_class=Routes): self.metadata.info['srid'] = self.site_config.DB_SRID self.metadata.info['num_threads'] = self.get_option('numthreads') tabname = self.site_config.DB_TABLES tables = OrderedDict() # first the update table: stores all modified routes, points uptable = UpdatedGeometriesTable(self.metadata, tabname.change) tables['updates'] = uptable # First we filter all route relations into an extra table. rfilt = FilteredTable(self.metadata, tabname.route_filter, self.osmdata.relation, text("(%s)" % self.site_config.DB_ROUTE_SUBSET)) tables['relfilter'] = rfilt # Then we create the connection between ways and relations. # This also adds geometries. relway = RelationWayTable(self.metadata, tabname.way_relation, self.osmdata.way, rfilt, osmdata=self.osmdata) tables['relway'] = relway # From that create the segmented table. segments = SegmentsTable(self.metadata, tabname.segment, relway, (relway.c.rels, )) tables['segments'] = segments # hierarchy table for super relations rtree = RelationHierarchy(self.metadata, tabname.hierarchy, rfilt) tables['hierarchy'] = rtree # routes table: information about each route routes = route_class(self.metadata, rfilt, relway, rtree, CountryGrid(MetaData(), tabname.country), self.site_config.ROUTES, symbol_factory) tables['routes'] = routes # finally the style table for rendering style = StyleTable(self.metadata, routes, segments, rtree, self.site_config.DEFSTYLE, uptable) tables['style'] = style # optional table for guide posts if self.site_config.GUIDEPOSTS is not None: cfg = self.site_config.GUIDEPOSTS filt = FilteredTable(self.metadata, cfg.table_name + '_view', self.osmdata.node, text(cfg.node_subset), view_only=True) tables['gp_filter'] = filt tables['guideposts'] = GuidePosts(self.metadata, filt, cfg) # optional table for network nodes if self.site_config.NETWORKNODES is not None: cfg = self.site_config.NETWORKNODES filt = FilteredTable(self.metadata, cfg.table_name + '_view', self.osmdata.node, self.osmdata.node.c.tags.has_key( cfg.node_tag), view_only=True) tables['nnodes_filter'] = filt tables['networknodes'] = NetworkNodes(self.metadata, filt, cfg) return tables
def setup_tables(db, route_class=Routes): if not db.get_option('no_engine'): country = CountryGrid(MetaData(), db.site_config.DB_TABLES.country) if not country.data.exists(db.engine): raise RuntimeError("No country table found.") db.set_metadata('srid', db.site_config.DB_SRID) db.set_metadata('num_threads', db.get_option('numthreads')) tabname = db.site_config.DB_TABLES # first the update table: stores all modified routes, points uptable = db.add_table('updates', UpdatedGeometriesTable(db.metadata, tabname.change)) # First we filter all route relations into an extra table. rfilt = db.add_table( 'relfilter', FilteredTable(db.metadata, tabname.route_filter, db.osmdata.relation, text(f"({db.site_config.DB_ROUTE_SUBSET})"))) # Then we create the connection between ways and relations. # This also adds geometries. relway = db.add_table( 'relway', RelationWayTable(db.metadata, tabname.way_relation, db.osmdata.way, rfilt, osmdata=db.osmdata)) # From that create the segmented table. segments = db.add_table( 'segments', SegmentsTable(db.metadata, tabname.segment, relway, (relway.c.rels, ))) # hierarchy table for super relations rtree = db.add_table( 'hierarchy', RelationHierarchy(db.metadata, tabname.hierarchy, rfilt)) # routes table: information about each route routes = db.add_table( 'routes', route_class( db.metadata, rfilt, relway, rtree, CountryGrid(MetaData(), tabname.country), db.site_config.ROUTES, ShieldFactory(db.site_config.ROUTES.symbols, db.site_config.SYMBOLS))) # finally the style table for rendering db.add_table( 'style', StyleTable(db.metadata, routes, segments, rtree, db.site_config.DEFSTYLE, uptable)) # optional table for guide posts if db.site_config.GUIDEPOSTS is not None: cfg = db.site_config.GUIDEPOSTS filt = db.add_table( 'gp_filter', FilteredTable(db.metadata, cfg.table_name + '_view', db.osmdata.node, text(cfg.node_subset), view_only=True)) db.add_table('guideposts', GuidePosts(db.metadata, filt, cfg))\ .set_update_table(uptable) # optional table for network nodes if db.site_config.NETWORKNODES is not None: cfg = db.site_config.NETWORKNODES filt = db.add_table( 'nnodes_filter', FilteredTable(db.metadata, cfg.table_name + '_view', db.osmdata.node, db.osmdata.node.c.tags.has_key(cfg.node_tag), view_only=True)) db.add_table('networknodes', NetworkNodes(db.metadata, filt, cfg))
def create_tables(self, db): return [ FilteredTable(db.metadata, "test", db.osmdata.relation, sqla.text("tags ? 'foo'")) ]
def create_tables(self, db): t = FilteredTable(db.metadata, "test", db.osmdata.relation, sqla.text("tags ? 'foo'")) t.view_only = True return (t, )