Ejemplo n.º 1
0
    def __init__(self, lon_lat, tile_index, path_to_scenery, magic):
        """Read all lines from stg to memory.
           Store our/other lines in two separate lists."""
        self.path_to_stg = calc_tile.construct_path_to_stg(
            path_to_scenery, lon_lat)
        self.file_name = self.path_to_stg + str(tile_index) + ".stg"
        self.other_list = []
        self.our_list = []
        self.magic = magic
        self.our_magic_start = delimiter_string(self.magic, True)
        self.our_magic_end = delimiter_string(self.magic, False)
        try:
            stg = open(self.file_name, 'r')
            lines = stg.readlines()
            stg.close()
        except IOError as reason:
            logger.warning("error reading %s: %s", self.file_name, reason)
            return

        try:
            ours_start = lines.index(self.our_magic_start)
        except ValueError:
            self.other_list = lines
            return

        try:
            ours_end = lines.index(self.our_magic_end)
        except ValueError:
            ours_end = len(lines)

        self.other_list = lines[:ours_start] + lines[ours_end + 1:]
        self.our_list = lines[ours_start + 1:ours_end]
Ejemplo n.º 2
0
def quick_stg_line(path_to_scenery, ac_fname, position, elevation, heading, show=True):
    """debug."""
    stg_path = calc_tile.construct_path_to_stg(path_to_scenery, position)
    stg_fname = calc_tile.construct_stg_file_name(position)
    stg_line = "OBJECT_STATIC %s %1.7f %1.7f %1.2f %g\n" % (ac_fname, position.lon, position.lat, elevation, heading)
    if show == 1 or show == 3:
        print stg_path + stg_fname
    if show == 2 or show == 3:
        print stg_line
    #        print "%s\n%s" % (stg_path + stg_fname, stg_line)
    return stg_path, stg_fname, stg_line
Ejemplo n.º 3
0
 def __init__(self, lon_lat, tile_index, path_to_scenery, magic):
     """Read all lines from stg to memory.
        Store our/other lines in two separate lists."""
     self.path_to_stg = calc_tile.construct_path_to_stg(path_to_scenery, lon_lat)
     self.file_name = self.path_to_stg + "%07i.stg" % tile_index
     self.other_list = []
     self.our_list = []
     self.magic = magic
     self.our_magic_start = delimiter_string(self.magic, True)
     self.our_magic_end = delimiter_string(self.magic, False)
     try:
         stg = open(self.file_name, "r")
         lines = stg.readlines()
         stg.close()
     except IOError, reason:
         logger.warning("error reading %s: %s", self.file_name, reason)
         return
Ejemplo n.º 4
0
 def __init__(self, lon_lat, tile_index, path_to_scenery, magic):
     """Read all lines from stg to memory.
        Store our/other lines in two separate lists."""
     self.path_to_stg = calc_tile.construct_path_to_stg(
         path_to_scenery, lon_lat)
     self.file_name = self.path_to_stg + "%07i.stg" % tile_index
     self.other_list = []
     self.our_list = []
     self.magic = magic
     self.our_magic_start = delimiter_string(self.magic, True)
     self.our_magic_end = delimiter_string(self.magic, False)
     try:
         stg = open(self.file_name, 'r')
         lines = stg.readlines()
         stg.close()
     except IOError, reason:
         logging.warning("error reading %s: %s", self.file_name, reason)
         return
Ejemplo n.º 5
0
def quick_stg_line(path_to_scenery,
                   ac_fname,
                   position,
                   elevation,
                   heading,
                   show=True):
    """debug."""
    stg_path = calc_tile.construct_path_to_stg(path_to_scenery, position)
    stg_fname = calc_tile.construct_stg_file_name(position)
    stg_line = "OBJECT_STATIC %s %1.7f %1.7f %1.2f %g\n" % (
        ac_fname, position.lon, position.lat, elevation, heading)
    if show == 1 or show == 3:
        print(stg_path + stg_fname)
    if show == 2 or show == 3:
        print(stg_line)


#        print ("%s\n%s" % (stg_path + stg_fname, stg_line))
    return stg_path, stg_fname, stg_line
Ejemplo n.º 6
0
logging.info("probing elevation")
ac_file_list = []
ac_object_list = []
for o in objects:
    if o.msl == None:
        if not args.no_elev: 
            o.msl = elev_prober(o.pos)
        else:
            o.msl = 0.1
        #logging.debug("object %s: elev probed %s" % (o.file, str(o.msl)))
    else:
        logging.debug("object %s: using provided MSL=%g" % (o.file, o.msl))

    stg_file_name = calc_tile.construct_stg_file_name(o.pos)
    stg_path = calc_tile.construct_path_to_stg(path_to_fg_out, o.pos)
    #print stg_file_name, stg_path
    # -- build list of objects to be converted
    full_path = get_source_path(o)
    full_path = "/tmp"
    if full_path != False:
        path_to_stg = stg_manager.add_object_shared(o.prefix + o.file + ".ac", o.pos, o.msl, 90-o.hdg)
        mk_dirs(path_to_stg + o.prefix)
        o.path_to_ac = path_to_stg + o.prefix + o.file + '.ac'
        if o.path_to_ac not in ac_file_list:
            ac_file_list.append(o.path_to_ac)
            ac_object_list.append(o)
            if os.path.exists(o.path_to_ac):
                print "EX ", o
            else:
                s = "convert('%s', '%s')\n" % (full_path, o.path_to_ac)
Ejemplo n.º 7
0
logging.info("probing elevation")
ac_file_list = []
ac_object_list = []
for o in objects:
    if o.msl == None:
        if not args.no_elev:
            o.msl = elev_prober(o.pos)
        else:
            o.msl = 0.1
        #logging.debug("object %s: elev probed %s" % (o.file, str(o.msl)))
    else:
        logging.debug("object %s: using provided MSL=%g" % (o.file, o.msl))

    stg_file_name = calc_tile.construct_stg_file_name(o.pos)
    stg_path = calc_tile.construct_path_to_stg(path_to_fg_out, o.pos)
    #print stg_file_name, stg_path
    # -- build list of objects to be converted
    full_path = get_source_path(o)
    full_path = "/tmp"
    if full_path != False:
        path_to_stg = stg_manager.add_object_shared(o.prefix + o.file + ".ac",
                                                    o.pos, o.msl, 90 - o.hdg)
        mk_dirs(path_to_stg + o.prefix)
        o.path_to_ac = path_to_stg + o.prefix + o.file + '.ac'
        if o.path_to_ac not in ac_file_list:
            ac_file_list.append(o.path_to_ac)
            ac_object_list.append(o)
            if os.path.exists(o.path_to_ac):
                print "EX ", o
            else: