def _load_parser(self): if self.config.src.endswith(".pbf"): from modules.OsmPbf import OsmPbfReader self.parser = OsmPbfReader(self.config.src, getattr(self.config, 'src_state', None), self.logger.sub()) self.parsing_change_file = False elif (self.config.src.endswith(".osc") or self.config.src.endswith(".osc.gz") or self.config.src.endswith(".osc.bz2")): from modules.OsmSax import OscSaxReader self.parser = OscSaxReader(self.config.src, getattr(self.config, 'src_state', None), self.logger.sub()) self.parsing_change_file = True elif (self.config.src.endswith(".osm") or self.config.src.endswith(".osm.gz") or self.config.src.endswith(".osm.bz2")): from modules.OsmSax import OsmSaxReader self.parser = OsmSaxReader(self.config.src, getattr(self.config, 'src_state', None), self.logger.sub()) self.parsing_change_file = False else: raise Exception("File extension '%s' is not recognized" % self.config.src)
def update_metainfo(self, conf): # Fill metainfo table gisconn = psycopg2.connect(self.db_string) giscurs = gisconn.cursor() try: diff_path = conf.download["diff_path"] osm_state = OsmState(os.path.join(diff_path, "state.txt")).timestamp() except: from modules.OsmPbf import OsmPbfReader osm_state = OsmPbfReader(conf.download["dst"], None).timestamp() giscurs.execute("UPDATE metainfo SET tstamp = %s", [osm_state]) gisconn.commit() giscurs.close() gisconn.close()
def update_metainfo(self, conf): # Fill metainfo table gisconn = self.osmosis().conn() giscurs = gisconn.cursor() diff_path = conf.download["diff_path"] state_file = os.path.join(diff_path, "state.txt") dst_pbf = conf.download.get("dst") from modules.OsmPbf import OsmPbfReader osm_state = OsmPbfReader(dst_pbf, state_file=state_file).timestamp() giscurs.execute("UPDATE metainfo SET tstamp = %s", [osm_state]) self.logger.sub().log("OSM data timestamp: {}".format(osm_state)) gisconn.commit() giscurs.close() self.osmosis_close()