예제 #1
0
파일: analyze_map.py 프로젝트: bhenne/MoSP
def main():
    """This tool helps to analyze the map data after having been loaded into mosp.
    This can help to find mistakes in maps and map usage in the simulator.
    This tool can be used to show and remove partitioned graphs. To do this,
    count the partitions, then output map as osm data, open it in JOSM, search
    for partition:1, partition:2, ... open the original map and fix it."""
    
    map = '../data/kl0.osm'
    s = Simulation(geo=osm.OSMModel(map), rel_speed=30, seed=200)
    print '\n Analysing map %s' % map
    print '\n  number of nodes: %5d (all)' % len(s.geo.way_nodes)
    print '  number of nodes: %5d (no border)' % len([n for n in s.geo.way_nodes if "border" not in n.tags])
    print '  number of nodes: %5d (border)' % len([n for n in s.geo.way_nodes if "border" in n.tags])
    print '  number of nodes: %5d (no out_of_bb)' % len([n for n in s.geo.way_nodes if not s.geo.out_of_bb(n)])
    print '  number of nodes: %5d (out_of_bb)' % len([n for n in s.geo.way_nodes if s.geo.out_of_bb(n)])
    print '  number of nodes: %5d (no border/out_of_bb)' % len([m for m in [n for n in s.geo.way_nodes if not s.geo.out_of_bb(n)] if "border" not in m.tags])
    print '  number of nodes: %5d (border/out_of_bb)' % len([m for m in [n for n in s.geo.way_nodes if s.geo.out_of_bb(n)] if "border" in m.tags])
    print '\n  number of neighbors:'
    count_neighbors(s.geo.way_nodes)
    print '\n  graph partitions:'
    p, n = count_partitions(s.geo.way_nodes)
    print ''
    for i in xrange(1,n+1):
        print_partition(s.geo.way_nodes, p, i)
    print_osm(s.geo, p)
    for node in s.geo.way_nodes:
        print node.id, node.lon, node.lat, utm.utm_to_latlong(node.x, node.y, node.z)
예제 #2
0
파일: test_utm.py 프로젝트: bhenne/MoSP
 def test_utm_latlong(self):
     """Test utm to latlong and latlong to utm by trying 100 coordinates
     in both functions. What about southern hemisphere?!??"""
     for lat in xrange(10):
         for lon in xrange(10):
             zone = utm.long_to_zone(lon)
             coords = utm.latlong_to_utm(lat, lon, zone)
             coords = utm.utm_to_latlong(coords[0], coords[1], zone, False)
             self.assertEqual(round_utm_coord(coords[0]), lat)
             self.assertEqual(round_utm_coord(coords[1]), lon)
예제 #3
0
파일: node_finder.py 프로젝트: bhenne/MoSP
    def update(self):
        """Update GUI and stderr output."""
        s = select.select([sys.stdin], [], [], 0.0)
        while s[0]:
            t, id, x, y = [int(i) for i in sys.stdin.readline().split(' ')]
            coords = utm_to_latlong(x, y, self.zone)
            self.markers[id].set_position(coords[1], coords[0])
            print id, t, x, y
            print coords
            s = select.select([sys.stdin], [], [], 0.0)

        gobject.timeout_add(200, self.update)                
예제 #4
0
    def update(self):
        """On update, get new marker positions, update colors, ..."""
        try:
            s = select.select([sys.stdin], [], [], 0.0)
        except IOError:
            print 'assuming end of simulation'
            return
        while s[0]:
            type = sys.stdin.read(1)
            if type == '\x00':
                data = sys.stdin.read(PipePlayerMonitor.FORMAT_LEN)
                color, id, x, y = struct.unpack(PipePlayerMonitor.FORMAT, data)
                coords = utm_to_latlong(x, y, self.zone)
                self.markers[id].set_position(coords[1], coords[0])
                self.markers[id].change_color(color)
                # print id, t, x, y
                # print coords
            elif type == '\x01':
                t = struct.unpack('I', sys.stdin.read(4))[0]
                self.date.set_text(str(t))
                t %= 24000
                op = None
                if 4000 <= t <= 8000:
                    op = 120 - (t - 4000.0) / 4000 * 120
                if 16000 <= t <= 20000:
                    op = (t - 16000.0) / 4000 * 120

                if not op is None:
                    self.night.set_opacity(int(op))

            s = select.select([sys.stdin], [], [], 0.0)

            s = select.select([sys.stdin], [], [], 0.0)

        # TODO
        # self.night.set_opacity(self.night.get_opacity() + 1)
        gobject.timeout_add(50, self.update)
예제 #5
0
파일: test_utm.py 프로젝트: bhenne/MoSP
 def test_utm_to_latlong(self):
     """Tests utm_to_latlong()"""
     coords = utm.utm_to_latlong(410943.6064656443, 5653928.43291308, 33, False)
     self.assertEqual(round(coords[0], 2), 13.73)
     self.assertEqual(round(coords[1], 2), 51.03)