def _from_db(self): if not self.coords: geodb = PostgreSQLConnector(WOC['GEODB']) geodb.connect() query = """SELECT centr_x AS x, centr_y AS y FROM planet_osm_{type} WHERE osm_id = {osm_id} """.format(type=self.item.osm_type, osm_id=self.item.osm_id) logger.debug(query) res = geodb.query(query) logger.debug(res) geodb.close() if not (res is None) and len(res) != 0: lat=res[0][1] lon=res[0][0] self.coords = (lat,lon)
logger.info("CURR_DIR: %s" %CURR_DIR) # ***** ***** # ***** OSM2Wiki ***** geodb = PostgreSQLConnector(WOC['GEODB']) osmres = list() try: osm_input = open('osm_query.txt','r') osmlist = osm_input.readlines() osmlist = [tuple(line.strip().split(',')) for line in osmlist] except: osm_input = None if not osm_input: geodb.connect() query="""SELECT osm_id, name, tags -> 'wikipedia' AS "wikipedia", 'point' AS "type" FROM planet_osm_point WHERE (tags ? 'wikipedia') AND ((amenity = 'place_of_worship') OR (building = 'church') OR (building = 'cathedral') OR (building = 'chapel')) UNION SELECT osm_id, name, tags -> 'wikipedia' AS "wikipedia",'line' AS "type" FROM planet_osm_line WHERE (tags ? 'wikipedia') AND ((amenity = 'place_of_worship') OR (building = 'church') OR (building = 'cathedral') OR (building = 'chapel')) UNION SELECT osm_id, name, tags -> 'wikipedia' AS "wikipedia", 'polygon' AS "type" FROM planet_osm_polygon WHERE (tags ? 'wikipedia') AND ((amenity = 'place_of_worship') OR (building = 'church') OR (building = 'cathedral') OR (building = 'chapel')) UNION