Example #1
0
 def execute_write_pnts(self, content):
     pnts_writer.run(self.skt, content[2], content[1], self.folder,
                     self.write_rgb)
Example #2
0
def zmq_process(activity_graph, srs_out_wkt, srs_in_wkt, node_store,
                octree_metadata, folder, write_rgb, verbosity):
    transformer = None
    if srs_out_wkt is not None:
        crs_out = CRS(srs_out_wkt)
        crs_in = CRS(srs_in_wkt)
        transformer = Transformer.from_crs(crs_in, crs_out)
    context = zmq.Context()

    # Socket to receive messages on
    skt = context.socket(zmq.DEALER)
    skt.connect('ipc:///tmp/py3dtiles1')

    startup_time = time.time()
    idle_time = 0

    if activity_graph:
        activity = open('activity.{}.csv'.format(os.getpid()), 'w')

    # notify we're ready
    skt.send_multipart([b''])

    while True:
        before = time.time() - startup_time

        skt.poll()

        after = time.time() - startup_time

        idle_time += after - before
        command = skt.recv_multipart()
        delta = time.time() - pickle.loads(command[0])
        if delta > 0.01 and verbosity >= 1:
            print('{} / {} : Delta time: {}'.format(os.getpid(),
                                                    round(after, 2),
                                                    round(delta, 3)))
        command = command[1:]

        if len(command) == 1:
            command = pickle.loads(command[0])
            command_type = 1

            if command == b'shutdown':
                # ack
                break

            _, ext = os.path.splitext(command['filename'])
            init_reader_fn = las_reader.run if ext == '.las' else xyz_reader.run
            init_reader_fn(command['id'], command['filename'],
                           command['offset_scale'], command['portion'], skt,
                           transformer, verbosity)
        elif command[0] == b'pnts':
            command_type = 3
            pnts_writer.run(skt, command[2], command[1], folder, write_rgb)
            skt.send_multipart([b''])
        else:
            command_type = 2
            node_process.run(command, octree_metadata, skt, verbosity)

        if activity_graph:
            print('{before}, {command_type}'.format(**locals()), file=activity)
            print('{before}, 0'.format(**locals()), file=activity)
            print('{after}, 0'.format(**locals()), file=activity)
            print('{after}, {command_type}'.format(**locals()), file=activity)

    if activity_graph:
        activity.close()

    if verbosity >= 1:
        print('total: {} sec, idle: {}'.format(
            round(time.time() - startup_time, 1), round(idle_time, 1)))

    skt.send_multipart([b'halted'])
Example #3
0
def zmq_process(activity_graph, projection, node_store, octree_metadata,
                folder, write_rgb, verbosity):
    context = zmq.Context()

    # Socket to receive messages on
    skt = context.socket(zmq.DEALER)
    skt.connect('tcp://127.0.0.1:1234')

    startup_time = time.time()
    idle_time = 0

    if activity_graph:
        activity = open('activity.{}.csv'.format(os.getpid()), 'w')

    # notify we're ready
    skt.send_multipart([b''])

    while True:
        before = time.time() - startup_time

        skt.poll()

        after = time.time() - startup_time

        idle_time += after - before
        command = skt.recv_multipart()
        delta = time.time() - pickle.loads(command[0])
        if delta > 0.01 and verbosity >= 1:
            print('{} / {} : Delta time: {}'.format(os.getpid(),
                                                    round(after, 2),
                                                    round(delta, 3)))
        command = command[1:]

        if len(command) == 1:
            command = pickle.loads(command[0])
            command_type = 1

            if command == b'shutdown':
                # ack
                break

            las_reader.run(command['id'], command['filename'],
                           command['offset_scale'], command['portion'], skt,
                           projection, verbosity)
        elif command[0] == b'pnts':
            command_type = 3
            pnts_writer.run(skt, command[2], command[1], folder, write_rgb)
            skt.send_multipart([b''])
        else:
            command_type = 2
            node_process.run(command, octree_metadata, skt, verbosity)

        if activity_graph:
            print('{before}, {command_type}'.format(**locals()), file=activity)
            print('{before}, 0'.format(**locals()), file=activity)
            print('{after}, 0'.format(**locals()), file=activity)
            print('{after}, {command_type}'.format(**locals()), file=activity)

    if activity_graph:
        activity.close()

    if verbosity >= 1:
        print('total: {} sec, idle: {}'.format(
            round(time.time() - startup_time, 1), round(idle_time, 1)))

    skt.send_multipart([b'halted'])