コード例 #1
0
def setup_trajectory_source(filename, args):
    if args.domain == 'terrestrial':
        from tracktable.domain.terrestrial import TrajectoryReader
    else:
        from tracktable.domain.cartesian2d import TrajectoryReader

    infile = open(filename, 'rb')
    return TrajectoryReader(infile)
def read_trajectories_from_string(text):
    input = version_appropriate_string_buffer(text)
    reader = TrajectoryReader(input)
    points = list(reader)
    return points
コード例 #3
0
def read_trajectories_from_string(text):
    input = StringIO(text)
    reader = TrajectoryReader(input)
    points = list(reader)
    return points
コード例 #4
0
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Purpose: Demonstrate how to create and use a Trajectory Reader    
# If you have a file of already formed trajectories, you can use the Trajectory 
# Reader to read them from file. Like the point reader, you can iterate over the 
# trajectories you have and access the properties of the points in each trajectory.

from tracktable.domain.terrestrial import TrajectoryReader

# The trajectory reader is set up in a similar way as a point reader. In the 
# example below, we give it a file containing trajectories and we use the default 
# which is the terrestrial point reader. Terrestrial is typically used on real data. 
# In order to access the trajectories, iterate over the reader.

inFile = open("data/SampleTrajectories.traj")
reader = TrajectoryReader()
reader.input = inFile
i = 1
for x in reader:                                 #Each object in the reader is an iterator pointer here
    print(*x)
    print("\n")
    i -= 1
    if i <= 0:
        break

# Note that by iterating over the reader, you get a collection of points together as 
# trajectories. Just like the point reader, you can edit the delimiting character and 
# comment character as well as the column properties.