Esempio n. 1
0
    def test_selection_combinaison_constraint(self):

        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        chemin = os.path.join(self.resource_path, './data/trace1.dat')
        trace = FileReader.readFromFile(chemin, 2, 3, -1, 4, separator=",")
        trace.plot()

        t1 = TimeConstraint(begin=GPSTime('2018-07-31 14:00:00'))
        t3 = TimeConstraint(begin=GPSTime('2018-07-25 14:00:00'))

        center = trace.getObs(int(trace.size() / 2)).position
        radius = 91000
        circle1 = Geometrics.Circle(center, radius)
        circle1.plot('b-')

        pt = trace.getObs(int(trace.size() / 2)).position
        ll = ENUCoords(pt.getX() + 1000, pt.getY() + 15000)
        ur = ENUCoords(pt.getX() + 10000, pt.getY() + 40000)
        rect1 = Geometrics.Rectangle(ll, ur)
        rect1.plot()

        # =====================================================================
        c1 = Constraint(shape=circle1, time=t1, mode=MODE_CROSSES)
        s1 = Selector([c1])
        c2 = Constraint(shape=rect1, time=t3, mode=MODE_CROSSES)
        s2 = Selector([c2])

        selector = GlobalSelector([s1, s2])
        isSelection = selector.contains(trace)
        self.assertFalse(isSelection)

        selector = GlobalSelector([s1, s2], combination=COMBINATION_OR)
        isSelection = selector.contains(trace)
        self.assertTrue(isSelection)
Esempio n. 2
0
    def test_generate(self):
        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        #track = core_Track.Track.generate(TestOperateurMethods.x2, TestOperateurMethods.y2)
        track = synth.generate(TestOperateurMethods.x2,
                               TestOperateurMethods.y2)

        track.createAnalyticalFeature("a")
        track.operate(Operator.RANDOM, "a", prob, "randx")
        track.operate(Operator.RANDOM, "a", prob, "randy")

        track.operate(Operator.INTEGRATOR, "randx", "randx")
        track.operate(Operator.INTEGRATOR, "randy", "randy")

        track.operate(Operator.SCALAR_MULTIPLIER, "randx", 0.5, "noisex")
        track.operate(Operator.SCALAR_MULTIPLIER, "randx", 0.5, "noisey")

        track.operate(Operator.ADDER, "x", "noisex", "x_noised")
        track.operate(Operator.ADDER, "y", "noisey", "y_noised")

        kernel = GaussianKernel(31)

        track.operate(Operator.FILTER, "x_noised", kernel, "x_filtered")
        track.operate(Operator.FILTER, "y_noised", kernel, "y_filtered")

        plt.plot(track.getAnalyticalFeature("x"),
                 track.getAnalyticalFeature("y"), 'k--')
        plt.plot(track.getAnalyticalFeature("x_noised"),
                 track.getAnalyticalFeature("y_noised"), 'b-')
        plt.plot(track.getAnalyticalFeature("x_filtered"),
                 track.getAnalyticalFeature("y_filtered"), 'r-')

        plt.show()
Esempio n. 3
0
	def test_visvalingam(self):
		GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
		chemin = './data/trace1.dat'
		track = FileReader.readFromFile(chemin, 2, 3, -1, 4, separator=",")
		track.simplify(5, MODE_SIMPLIFY_VISVALINGAM)
		
		self.assertTrue((1.289 - 1.28) < 0.01)
Esempio n. 4
0
    def test_random(self):
        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        #track = core_Track.Track.generate(TestOperateurMethods.x, TestOperateurMethods.y)
        track = synth.generate(x, y)

        track.createAnalyticalFeature("a")

        track.operate(Operator.RANDOM, ("a", "a"), prob,
                      ("x_noised", "y_noised"))
        track.operate(Operator.INTEGRATOR, ("x_noised", "y_noised"))
        track.operate(Operator.SCALAR_MULTIPLIER, ("x_noised", "y_noised"),
                      0.02)
        track.operate(Operator.ADDER, ("x_noised", "y_noised"), ("x", "y"))

        kernel = GaussianKernel(21)
        kernel.setFilterBoundary(True)

        track.operate(Operator.FILTER, ("x_noised", "y_noised"), kernel,
                      ("x_filtered", "y_filtered"))

        plt.plot(track.getX(), track.getY(), 'k--')
        plt.plot(track.getAnalyticalFeature("x_noised"),
                 track.getAnalyticalFeature("y_noised"), 'b-')
        plt.plot(track.getAnalyticalFeature("x_filtered"),
                 track.getAnalyticalFeature("y_filtered"), 'r-')
        plt.show()
Esempio n. 5
0
    def test_tableau_af_rmse_2(self):

        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        chemin = os.path.join(self.resource_path, './data/trace0.gps')
        track = FileReader.readFromFile(chemin, 2, 3, -1, 1, separator=",")

        track.estimate_speed()

        track.operate(Operator.DIFFERENTIATOR, "x", "dx")
        track.operate(Operator.DIFFERENTIATOR, "y", "dy")
        track.operate(Operator.SQUARE, "dx", "dx2")
        track.operate(Operator.SQUARE, "dy", "dy2")
        track.operate(Operator.ADDER, "dx2", "dy2", "dx2+dy2")
        track.operate(Operator.SQRT, "dx2+dy2", "ds")

        track.operate(Operator.SHIFT_RIGHT, "t", "t1")
        track.operate(Operator.SUBSTRACTER, "t", "t1", "dt")
        track.operate(Operator.DIVIDER, "ds", "dt", "ds/dt")

        self.assertEqual(len(track.getListAnalyticalFeatures()), 10)
        L = [
            'speed', 'dx', 'dy', 'dx2', 'dy2', 'dx2+dy2', 'ds', 't1', 'dt',
            'ds/dt'
        ]
        L.sort()
        T = track.getListAnalyticalFeatures()
        T.sort()
        self.assertEqual(T, L)

        track.operate(Operator.SUBSTRACTER, "speed", "ds/dt", "err")
        track.operate(Operator.SQUARE, "err", "err2")
        mse = track.operate(Operator.AVERAGER, "err2", "merr2")
        rmse = math.sqrt(mse)
        # print("RMSE =", math.sqrt(mse), "m/s")
        self.assertTrue((rmse - 2.36) < 0.01)
Esempio n. 6
0
def example0():

    path_cam = "../data/hybridation_gnss_camera.dat"
    path_gps = "../data/hybridation_gnss_camera.pos"

    GPSTime.setReadFormat("2D/2M/4Y-2h:2m:2s.3z")
    track_cam = FileReader.readFromFile(path_cam,
                                        1,
                                        2,
                                        3,
                                        0,
                                        " ",
                                        srid="ENUCoords")
    track_gps = FileReader.readFromFile(path_gps,
                                        1,
                                        2,
                                        3,
                                        0,
                                        " ",
                                        srid="ENUCoords")
    track_cam.incrementTime(0, 18 - 3600)

    ini_time = GPSTime("06/06/2021-16:02:00.000")
    fin_time = GPSTime("06/06/2021-16:12:12.000")
    track_cam = track_cam.extractSpanTime(ini_time, fin_time)
    track_gps = track_gps.extractSpanTime(ini_time, fin_time)
    track_gps = track_gps // track_cam

    track_cam.rotate(0.2)
    Mapping.mapOn(track_cam, track_gps)

    track_cam.plot('r-')
    track_gps.plot('b+')
    plt.show()
Esempio n. 7
0
 def __str__(self):
     """TODO"""
     output = "Temporal constraint: \n"
     if self.minTimestamp - GPSTime(0, 0, 0, 0, 0, 0) != 0:
         if self.maxTimestamp - GPSTime(2100, 0, 0, 0, 0, 0) != 0:
             output += "    -" + str(self.minTimestamp) + " <= t <= "
             output += str(self.maxTimestamp) + "\n"
     if not self.pattern is None:
         output += "    - timestamp pattern: " + self.pattern
     return output
Esempio n. 8
0
	def test_gaussien(self):
		GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
		chemin = './data/trace1.dat'
		track = FileReader.readFromFile(chemin, 2, 3, -1, 4, separator=",")
		kernel = GaussianKernel(201)
		track.operate(Operator.FILTER, "x", kernel, "x2")
		track.operate(Operator.FILTER, "y", kernel, "y2")
		plt.plot(track.getT(), track.getAnalyticalFeature("y"), 'b-', markersize=1.5)
		plt.plot(track.getT(), track.getAnalyticalFeature("y2"), 'r-')
		plt.show()
Esempio n. 9
0
 def __init__(self, begin=None, end=None, pattern=None):
     """TODO"""
     if begin is None:
         self.minTimestamp = GPSTime(0, 0, 0, 0, 0, 0)
     else:
         self.minTimestamp = begin
     if end is None:
         self.maxTimestamp = GPSTime(2100, 0, 0, 0, 0, 0)
     else:
         self.maxTimestamp = end
     self.pattern = pattern
Esempio n. 10
0
 def test_create_index_collection2(self):
     
     GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
             
     track = Track()
     p1 = Obs(ENUCoords(0, 0), GPSTime.readTimestamp('2020-01-01 10:00:00'))
     track.addObs(p1)
     p2 = Obs(ENUCoords(3.1, 3), GPSTime.readTimestamp('2020-01-01 10:08:00'))
     track.addObs(p2)
     p3 = Obs(ENUCoords(3.1, 4.5), GPSTime.readTimestamp('2020-01-01 10:17:00'))
     track.addObs(p3)
     
     p4 = Obs(ENUCoords(4.5, 4.5), GPSTime.readTimestamp('2020-01-01 10:21:00'))
     track.addObs(p4)
     p5 = Obs(ENUCoords(6, 5.5), GPSTime.readTimestamp('2020-01-01 10:21:00'))
     track.addObs(p5)
     
     p6 = Obs(ENUCoords(7, 4.5), GPSTime.readTimestamp('2020-01-01 10:21:00'))
     track.addObs(p6)
     p7 = Obs(ENUCoords(11, 5.5), GPSTime.readTimestamp('2020-01-01 10:21:00'))
     track.addObs(p7)
     p8 = Obs(ENUCoords(13, 10), GPSTime.readTimestamp('2020-01-01 10:25:00'))
     track.addObs(p8)
             #track.plot()
             #track.plotAsMarkers()
             
     TRACES = []
     TRACES.append(track)
     collection = TrackCollection(TRACES)
             
     index = SpatialIndex(collection, (2, 2))
     index.plot()
     
     # =====================================================================
     # =====================================================================
     self.assertEqual(index.request(0, 0), [0])
     self.assertEqual(index.request(1, 0), [0])
     self.assertEqual(index.request(0, 1), [])
     self.assertEqual(index.request(1, 1), [0])
     self.assertEqual(index.request(2, 0), [])
     self.assertEqual(index.request(2, 1), [])
     self.assertEqual(index.request(1, 2), [0])
     self.assertEqual(index.request(2, 2), [0])
     self.assertEqual(index.request(3, 2), [0])
     self.assertEqual(index.request(3, 3), [])
     self.assertEqual(index.request(4, 2), [0])
     self.assertEqual(index.request(4, 3), [])
     self.assertEqual(index.request(4, 4), [])
     self.assertEqual(index.request(5, 2), [0])
     self.assertEqual(index.request(5, 3), [0])
     self.assertEqual(index.request(5, 4), [])
Esempio n. 11
0
    def test_abs_curv1(self):
        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        chemin = os.path.join(self.resource_path, 'data/trace1.dat')

        track = FileReader.readFromFile(chemin,
                                        2,
                                        3,
                                        -1,
                                        4,
                                        separator=",",
                                        DateIni=-1,
                                        h=0,
                                        com="#",
                                        no_data_value=-999999,
                                        srid="ENUCoords")

        track.addAnalyticalFeature(algo.diffJourAnneeTrace)
        track.operate(Operator.INVERTER, "diffJourAnneeTrace",
                      "rando_jour_neg")
        #track.segmentation(["rando_jour_neg"], "rando_jour", [-1])
        seg.segmentation(track, ["rando_jour_neg"], "rando_jour", [-1])
        self.mafonct(track, "rando_jour")

        TRACES = seg.split(track, "rando_jour")

        self.assertTrue(len(TRACES) == 4)

        if len(TRACES) > 0:
            trace = TRACES[1]
            # trace.summary()
            trace.compute_abscurv()

            trace.resample(3, interpolation.MODE_SPATIAL)
            Sigma = trace.compute_abscurv()
            trace.estimate_speed()
            Speed = trace.getAnalyticalFeature('speed')
            #print (Speed)
            #print (trace.getListAnalyticalFeatures())
            tabAF = trace.getListAnalyticalFeatures()
            self.assertEqual(2, len(tabAF))
            self.assertEqual('abs_curv', tabAF[0])
            self.assertEqual('speed', tabAF[1])

            # =============================================================================
            # ============================================================================
            #
            fig, ax1 = plt.subplots(figsize=(15, 3))
            #plt.plot(trace.getAnalyticalFeature("sigma"), trace.getAnalyticalFeature("speed2"), '-', color='gold')
            plt.plot(Sigma, Speed, '-', color='skyblue')
            plt.show()
Esempio n. 12
0
    def test_compare_calculs_vitesse(self):
        '''
        '''

        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        chemin = os.path.join(self.resource_path, './data/trace0.gps')
        track = FileReader.readFromFile(chemin, 2, 3, -1, 1, separator=",")

        # 1ère méthode
        track.estimate_speed()
        # print (track.getListAnalyticalFeatures())
        self.assertEqual(len(track.getListAnalyticalFeatures()), 1)
        L = ['speed']
        self.assertEqual(track.getListAnalyticalFeatures(), L)

        #2ème méthode
        track.operate(Operator.SHIFT_RIGHT, "x", "x1")
        track.operate(Operator.SHIFT_LEFT, "x", "x2")
        track.operate(Operator.SUBSTRACTER, "x2", "x1", "dx")

        track.operate(Operator.SHIFT_RIGHT, "y", "y1")
        track.operate(Operator.SHIFT_LEFT, "y", "y2")
        track.operate(Operator.SUBSTRACTER, "y2", "y1", "dy")

        track.operate(Operator.SQUARE, "dx", "dx2")
        track.operate(Operator.SQUARE, "dy", "dy2")
        track.operate(Operator.ADDER, "dx2", "dy2", "dx2+dy2")
        track.operate(Operator.SQRT, "dx2+dy2", "ds")

        track.operate(Operator.SHIFT_RIGHT, "t", "t1")
        track.operate(Operator.SHIFT_LEFT, "t", "t2")
        track.operate(Operator.SUBSTRACTER, "t2", "t1", "dt")
        track.operate(Operator.DIVIDER, "ds", "dt", "ds/dt")

        #print (track.getListAnalyticalFeatures())

        #print (track.getObsAnalyticalFeature('speed', 10))
        #print (track.getObsAnalyticalFeature('ds/dt', 10))

        VM1 = track.getAnalyticalFeature("speed")
        #print (VM1[0:10])
        VM2 = track.getAnalyticalFeature("ds/dt")
        #print (VM2[0:10])
        self.assertEqual(VM1[1:len(VM1) - 1], VM2[1:len(VM2) - 1])

        track.operate(Operator.SUBSTRACTER, "speed", "ds/dt", "err")
        track.operate(Operator.SQUARE, "err", "err2")
        mse = track.operate(Operator.AVERAGER, "err2", "merr2")
        # print("RMSE =", math.sqrt(mse), "m/s")
        self.assertTrue(math.sqrt(mse) < 0.000001)
Esempio n. 13
0
    def test_selection_one_shape_time_constraint(self):

        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        chemin = os.path.join(self.resource_path, './data/trace1.dat')
        trace = FileReader.readFromFile(chemin, 2, 3, -1, 4, separator=",")
        trace.plot()

        t1 = TimeConstraint(begin=GPSTime('2018-07-31 14:00:00'))
        t2 = TimeConstraint(begin=GPSTime('2019-07-31 14:00:00'))
        t3 = TimeConstraint(begin=GPSTime('2018-07-25 14:00:00'))

        center = trace.getObs(int(trace.size() / 2)).position
        radius = 91000
        circle1 = Geometrics.Circle(center, radius)
        #circle1.plot()
        #plt.show()

        pt = trace.getObs(int(trace.size() / 2)).position
        center = ENUCoords(pt.getX() + 10000, pt.getY() + 30000)
        radius = 10000
        circle4 = Geometrics.Circle(center, radius)

        # =====================================================================
        c1 = Constraint(shape=circle1, time=t1, mode=MODE_CROSSES)
        s = Selector([c1])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertTrue(isSelection)

        # =====================================================================
        c1 = Constraint(shape=circle1, time=t2, mode=MODE_CROSSES)
        s = Selector([c1])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertFalse(isSelection)

        # =====================================================================
        c1 = Constraint(shape=circle1, time=t3, mode=MODE_CROSSES)
        s = Selector([c1])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertTrue(isSelection)

        # =====================================================================
        c1 = Constraint(shape=circle4, time=t1, mode=MODE_CROSSES)
        s = Selector([c1])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertFalse(isSelection)
Esempio n. 14
0
    def writeToGpx(tracks, path, af=False):
        """
        Transforms track into Gpx string
        # path: file to write gpx (gpx returned in standard output if empty)
        af: AF exported in gpx file
        """
        f = open(path, "w")

        # Time output management
        fmt_save = GPSTime.getPrintFormat()
        GPSTime.setPrintFormat("4Y-2M-2DT2h:2m:2s")

        if isinstance(tracks, Track):
            collection = TrackCollection()
            collection.addTrack(tracks)
            tracks = collection

        f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
        f.write("<gpx>\n")
        f.write(
            "<author>File generated by Tracklib: https://github.com/umrlastig/tracklib</author>\n"
        )
        for i in range(len(tracks)):
            track = tracks.getTrack(i)
            f.write("    <trk>\n")
            f.write("        <trkseg>\n")
            for i in range(len(track)):
                x = "{:3.8f}".format(track[i].position.getX())
                y = "{:3.8f}".format(track[i].position.getY())
                z = "{:3.8f}".format(track[i].position.getZ())
                f.write('            <trkpt lat="' + y + '" lon="' + x +
                        '">\n')
                f.write("                <ele>" + z + "</ele>\n")
                f.write("                <time>" + str(track[i].timestamp) +
                        track[i].timestamp.printZone() + "</time>\n")
                if af:
                    f.write("                <extensions>\n")
                    for af_name in track.getListAnalyticalFeatures():
                        f.write("                    <" + af_name + ">")
                        f.write(str(track.getObsAnalyticalFeature(af_name, i)))
                        f.write("</" + af_name + ">\n")
                    f.write("                </extensions>\n")
                f.write("            </trkpt>\n")
            f.write("        </trkseg>\n")
            f.write("    </trk>\n")
        f.write("</gpx>\n")

        f.close()
        GPSTime.setPrintFormat(fmt_save)
Esempio n. 15
0
    def __init__(self, position: ENUCoords, timestamp: GPSTime = None):
        """Constructor of :class:`Obs` class

        :param position: A point coordinate
        :param timestamp: The time stamp of acquisition (Default timestamp is 1970/01/01 00:00:00)
        """

        if timestamp is None:
            timestamp = GPSTime()

        self.position = position
        self.timestamp = timestamp

        self.features = []

        self.gdop = 0
        self.pdop = 0
        self.vdop = 0
        self.hdop = 0
        self.tdop = 0

        self.nb_sats = 0
        self.mask = 0
        self.code = 0

        self.azimut = 0
        self.elevation = 0
Esempio n. 16
0
 def test_write_csv_2AF_desordre(self):
     
     GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
     track = Track()
     p1 = Obs(ENUCoords(0, 0), GPSTime.readTimestamp('2020-01-01 10:00:00'))
     track.addObs(p1)
     p2 = Obs(ENUCoords(0, 1), GPSTime.readTimestamp('2020-01-01 10:00:01'))
     track.addObs(p2)
     p3 = Obs(ENUCoords(1, 1), GPSTime.readTimestamp('2020-01-01 10:00:02'))
     track.addObs(p3)
     p4 = Obs(ENUCoords(1, 2), GPSTime.readTimestamp('2020-01-01 10:00:03'))
     track.addObs(p4)
     p5 = Obs(ENUCoords(2, 2), GPSTime.readTimestamp('2020-01-01 10:00:04'))
     track.addObs(p5)
     
     track.addAnalyticalFeature(Analytics.speed)
     track.compute_abscurv()
     
     csvpath = os.path.join(self.resource_path, 'data/test/test_write_csv_2AF_desordre.wkt')
     af_names = ['speed', 'abs_curv']
     FileWriter.writeToFile(track, csvpath, id_E=3, id_N=2, id_U=0, id_T=1, h=1, 
                            separator=";", af_names=af_names)
     contents = open(csvpath).read()
     
     txt  = "#srid: ENU\n"
     txt += "#U;time;N;E;speed;abs_curv\n"
     txt += "0.000;01/01/2020 10:00:00;0.000;0.000;1.0;0\n"
     txt += "0.000;01/01/2020 10:00:01;1.000;0.000;0.7071067811865476;1.0\n"
     txt += "0.000;01/01/2020 10:00:02;1.000;1.000;0.7071067811865476;2.0\n"
     txt += "0.000;01/01/2020 10:00:03;2.000;1.000;0.7071067811865476;3.0\n"
     txt += "0.000;01/01/2020 10:00:04;2.000;2.000;1.0;4.0\n"
     self.assertEqual(contents.strip(), txt.strip())
Esempio n. 17
0
 def test_create_index(self):
     
     GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
     
     track = Track()
     p1 = Obs(ENUCoords(550, 320), GPSTime.readTimestamp('2020-01-01 10:00:00'))
     track.addObs(p1)
     p2 = Obs(ENUCoords(610, 325), GPSTime.readTimestamp('2020-01-01 10:08:00'))
     track.addObs(p2)
     p3 = Obs(ENUCoords(610, 330), GPSTime.readTimestamp('2020-01-01 10:17:00'))
     track.addObs(p3)
     p4 = Obs(ENUCoords(650, 330), GPSTime.readTimestamp('2020-01-01 10:21:00'))
     track.addObs(p4)
     p5 = Obs(ENUCoords(675, 340), GPSTime.readTimestamp('2020-01-01 10:25:00'))
     track.addObs(p5)
     #track.plot()
     #track.plotAsMarkers()
     
     TRACES = []
     TRACES.append(track)
     collection = TrackCollection(TRACES)
     
     res = (25, 4)
     index = SpatialIndex(collection, res, 0.05, True)
     index.plot()
     
     
     # =====================================================================
     self.assertEqual(index.request(0, 0), [0])
     self.assertEqual(index.request(1, 0), [0])
     self.assertEqual(index.request(0, 1), [])
     self.assertEqual(index.request(1, 1), [0])
     self.assertEqual(index.request(2, 0), [])
     self.assertEqual(index.request(2, 1), [0])
Esempio n. 18
0
 def test_write_csv_path(self):
     
     GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
     track = Track()
     p1 = Obs(ENUCoords(0, 0), GPSTime.readTimestamp('2020-01-01 10:00:00'))
     track.addObs(p1)
     p2 = Obs(ENUCoords(0, 1), GPSTime.readTimestamp('2020-01-01 10:00:01'))
     track.addObs(p2)
     p3 = Obs(ENUCoords(1, 1), GPSTime.readTimestamp('2020-01-01 10:00:02'))
     track.addObs(p3)
     p4 = Obs(ENUCoords(1, 2), GPSTime.readTimestamp('2020-01-01 10:00:03'))
     track.addObs(p4)
     p5 = Obs(ENUCoords(2, 2), GPSTime.readTimestamp('2020-01-01 10:00:04'))
     track.addObs(p5)
     
     csvpath = os.path.join(self.resource_path, 'data/test/test_write_csv_path.wkt')
     FileWriter.writeToFile(track, csvpath)
     contents = open(csvpath).read()
     
     txt  = "0.000,0.000,0.000,01/01/2020 10:00:00\n"
     txt += "0.000,1.000,0.000,01/01/2020 10:00:01\n"
     txt += "1.000,1.000,0.000,01/01/2020 10:00:02\n"
     txt += "1.000,2.000,0.000,01/01/2020 10:00:03\n"
     txt += "2.000,2.000,0.000,01/01/2020 10:00:04\n"
     self.assertEqual(contents.strip(), txt.strip())
Esempio n. 19
0
 def test_write_csv_minim(self):
     
     GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
     track = Track()
     p1 = Obs(ENUCoords(0, 0), GPSTime.readTimestamp('2020-01-01 10:00:00'))
     track.addObs(p1)
     p2 = Obs(ENUCoords(0, 1), GPSTime.readTimestamp('2020-01-01 10:00:01'))
     track.addObs(p2)
     
     csvpath = os.path.join(self.resource_path, 'data/test/test_write_csv_minim.wkt')
     FileWriter.writeToFile(track, csvpath, id_E=0,id_N=1,id_U=2,id_T=3,h=1, separator=";")
     contents = open(csvpath).read()
     
     txt  = "#srid: ENU\n"
     txt += "#E;N;U;time\n"
     txt += "0.000;0.000;0.000;01/01/2020 10:00:00\n"
     txt += "0.000;1.000;0.000;01/01/2020 10:00:01\n"
     self.assertEqual(contents.strip(), txt.strip())
Esempio n. 20
0
    def __init__(self, arg, ext=-1):
        """TODO"""

        if ext >= 0:

            fields = FileFormat.__search_fmt_from_ext_or_name(
                FileFormat.TRACK_FILE_FORMAT, arg, ext)

            self.name = fields[0].strip()
            self.id_E = int(fields[2].strip())
            self.id_N = int(fields[3].strip())
            self.id_U = int(fields[4].strip())
            self.id_T = int(fields[5].strip())
            self.DateIni = fields[6].strip()
            self.separator = fields[7].strip()
            self.h = int(fields[8].strip())
            self.com = fields[9].strip()
            self.no_data_value = float(fields[10].strip())
            self.srid = fields[11].strip()
            self.read_all = fields[13].strip().upper() == "TRUE"

            self.time_fmt = fields[12].strip()

            self.separator = self.separator.replace("b", " ")
            self.separator = self.separator.replace("c", ",")
            self.separator = self.separator.replace("s", ";")

            if self.DateIni == "-1":
                self.DateIni = -1
            else:
                fmt_temp = GPSTime.getReadFormat()
                GPSTime.setReadFormat(self.time_fmt)
                self.DateIni = GPSTime(self.DateIni)
                GPSTime.setReadFormat(fmt_temp)
        else:

            self.id_E = -1
            self.id_N = -1
            self.id_U = -1
            self.id_T = -1
            self.DateIni = -1
            self.separator = ","
            self.h = 0
            self.com = "#"
            self.no_data_value = -999999
            self.srid = "ENUCoords"
            self.read_all = False

            self.time_fmt = GPSTime.getReadFormat()
Esempio n. 21
0
def wktLineStringToObs(wkt, srid):
    """
    Une polyligne de n points est modélisée par une Track (timestamp = 1970/01/01 00 :00 :00)
        Cas LINESTRING()
    """

    # Creation d'une liste vide
    TAB_OBS = list()

    # Separation de la chaine
    coords_string = wkt.split("(")
    coords_string = coords_string[1]
    coords_string = coords_string.split(")")[0]

    coords = coords_string.split(",")

    for i in range(0, len(coords)):
        sl = coords[i].strip().split(" ")
        x = float(sl[0])
        y = float(sl[1])
        if len(sl) == 3:
            z = float(sl[2])
        else:
            z = 0.0

        if not srid.upper() in [
                "ENUCOORDS",
                "ENU",
                "GEOCOORDS",
                "GEO",
                "ECEFCOORDS",
                "ECEF",
        ]:
            print("Error: unknown coordinate type [" + str(srid) + "]")
            exit()

        if srid.upper() in ["ENUCOORDS", "ENU"]:
            point = ENUCoords(x, y, z)
        if srid.upper() in ["GEOCOORDS", "GEO"]:
            point = GeoCoords(x, y, z)
        if srid.upper() in ["ECEFCOORDS", "ECEF"]:
            point = ECEFCoords(x, y, z)

        TAB_OBS.append(Obs(point, GPSTime()))

    return TAB_OBS
Esempio n. 22
0
    def readFromGpx(path, srid="GEO"):
        """
        Reads (multiple) tracks in .gpx file
        """

        tracks = TrackCollection()

        format_old = GPSTime.getReadFormat()
        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")

        doc = minidom.parse(path)

        trks = doc.getElementsByTagName("trk")

        for trk in trks:
            trace = t.Track()
            trkpts = trk.getElementsByTagName("trkpt")
            for trkpt in trkpts:
                lon = float(trkpt.attributes["lon"].value)
                lat = float(trkpt.attributes["lat"].value)

                hgt = utils.NAN
                eles = trkpt.getElementsByTagName("ele")
                if eles.length > 0:
                    hgt = float(eles[0].firstChild.data)

                time = ""
                times = trkpt.getElementsByTagName("time")
                if times.length > 0:
                    time = GPSTime(times[0].firstChild.data)
                else:
                    time = GPSTime()

                point = Obs(utils.makeCoords(lon, lat, hgt, srid), time)
                trace.addObs(point)

            tracks.addTrack(trace)

        # pourquoi ?
        # --> pour remettre le format comme il etait avant la lectre :)   
        GPSTime.setReadFormat(format_old)

        collection = TrackCollection(tracks)
        return collection
Esempio n. 23
0
    def test_format_time(self):

        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        madate = '2018-01-31 13:21:46'
        t = GPSTime.readTimestamp(madate)
        self.assertEqual("31/01/2018 13:21:46", str(t))

        GPSTime.setReadFormat("4Y-2M-2DT2h:2m:2s1Z")
        madate = '2018-01-31T11:17:46Z'
        t = GPSTime.readTimestamp(madate)
        self.assertEqual("31/01/2018 11:17:46", str(t))

        d = GPSTime.readUnixTime(1550941038.0)
        self.assertIsInstance(d, GPSTime)
        self.assertEqual('23/02/2019 16:57:18', str(d))
        self.assertEqual(23, d.day)
        self.assertEqual(2, d.month)
        self.assertEqual(2019, d.year)
        self.assertEqual(16, d.hour)
        self.assertEqual(57, d.min)
        self.assertEqual(18, d.sec)
Esempio n. 24
0
def tabCoordsLineStringToObs(coords, srid):
    """TODO"""

    # Creation d'une liste vide
    TAB_OBS = list()

    for i in range(0, len(coords)):
        sl = coords[i]
        x = float(sl[0])
        y = float(sl[1])
        if len(sl) == 3:
            z = float(sl[2])
        else:
            z = 0.0

        if not srid.upper() in [
                "ENUCOORDS",
                "ENU",
                "GEOCOORDS",
                "GEO",
                "ECEFCOORDS",
                "ECEF",
        ]:
            print("Error: unknown coordinate type [" + str(srid) + "]")
            exit()

        if srid.upper() in ["ENUCOORDS", "ENU"]:
            point = ENUCoords(x, y, z)
        if srid.upper() in ["GEOCOORDS", "GEO"]:
            point = GeoCoords(x, y, z)
        if srid.upper() in ["ECEFCOORDS", "ECEF"]:
            point = ECEFCoords(x, y, z)

        TAB_OBS.append(Obs(point, GPSTime()))

    return TAB_OBS
Esempio n. 25
0
from tracklib.core.GPSTime import GPSTime
from tracklib.io.GpxReader import GpxReader
from tracklib.core.Operator import Operator

import tracklib.algo.Analytics as algo
import tracklib.algo.Interpolation as interp
import tracklib.algo.Segmentation as segmentation

import tracklib.core.Grid as grid
import tracklib.core.TrackCollection as trackCollection
import tracklib.algo.Summarising as summ

# ---------------------------------------------------
# Lecture des donnees
# ---------------------------------------------------
GPSTime.setReadFormat("4Y-2M-2DT2h:2m:2sZ")
tracks = GpxReader.readFromGpx("./data/activity_5807084803.gpx")
trace = tracks.getTrack(0)

# Transformation GEO coordinates to ENU
trace.toENUCoords()

# Display
trace.plot()
#trace.plot('POINT')

# ================================================
# SPEED : different
trace.estimate_speed()

trace.plotAnalyticalFeature('speed', 'BOXPLOT')
Esempio n. 26
0
    def test_selection_track_constraint(self):

        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
        chemin = os.path.join(self.resource_path, './data/trace1.dat')
        trace = FileReader.readFromFile(chemin, 2, 3, -1, 4, separator=",")
        trace.plot()

        # =====================================================================
        trace1 = Track()
        c1 = trace.getObs(1350).position
        c0 = ENUCoords(c1.getX() + 5000, c1.getY())
        c2 = ENUCoords(c1.getX() - 5000, c1.getY())
        p1 = Obs(c0, GPSTime.readTimestamp("2018-07-31 14:00:00"))
        p2 = Obs(c1, GPSTime.readTimestamp("2018-07-31 14:01:00"))
        p3 = Obs(c2, GPSTime.readTimestamp("2018-07-31 14:02:00"))
        trace1.addObs(p1)
        trace1.addObs(p2)
        trace1.addObs(p3)
        plt.plot(trace1.getX(), trace1.getY(), 'r-')
        plt.show()

        c3 = TrackConstraint(trace1, mode=MODE_PARALLEL)
        s = Selector([c3])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertFalse(isSelection)

        c4 = TrackConstraint(trace1, mode=MODE_CROSSES)
        s = Selector([c4])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertTrue(isSelection)

        # =====================================================================
        trace1 = Track()
        c0 = ENUCoords(
            trace.getObs(1349).position.getX(),
            trace.getObs(1349).position.getY())
        c1 = ENUCoords(
            trace.getObs(1350).position.getX(),
            trace.getObs(1350).position.getY())
        c2 = ENUCoords(
            trace.getObs(1351).position.getX(),
            trace.getObs(1351).position.getY())
        p1 = Obs(c0, GPSTime.readTimestamp("2018-07-31 14:00:00"))
        p2 = Obs(c1, GPSTime.readTimestamp("2018-07-31 14:01:00"))
        p3 = Obs(c2, GPSTime.readTimestamp("2018-07-31 14:02:00"))
        trace1.addObs(p1)
        trace1.addObs(p2)
        trace1.addObs(p3)
        trace.plot()
        plt.plot(trace1.getX(), trace1.getY(), 'r-')
        plt.show()

        c3 = TrackConstraint(trace1, mode=MODE_PARALLEL)
        s = Selector([c3])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertTrue(isSelection)

        c4 = TrackConstraint(trace1, mode=MODE_CROSSES)
        s = Selector([c4])
        selector = GlobalSelector([s])
        isSelection = selector.contains(trace)
        self.assertTrue(isSelection)
Esempio n. 27
0
    def setUp(self):

        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")

        self.track = Track()
        p1 = Obs(ENUCoords(0, 0), GPSTime.readTimestamp('2020-01-01 10:00:00'))
        self.track.addObs(p1)
        p2 = Obs(ENUCoords(0, 1), GPSTime.readTimestamp('2020-01-01 10:00:01'))
        self.track.addObs(p2)
        p3 = Obs(ENUCoords(1, 1), GPSTime.readTimestamp('2020-01-01 10:00:02'))
        self.track.addObs(p3)
        p4 = Obs(ENUCoords(1, 2), GPSTime.readTimestamp('2020-01-01 10:00:03'))
        self.track.addObs(p4)
        p5 = Obs(ENUCoords(2, 2), GPSTime.readTimestamp('2020-01-01 10:00:04'))
        self.track.addObs(p5)
        p6 = Obs(ENUCoords(2, 3), GPSTime.readTimestamp('2020-01-01 10:00:06'))
        self.track.addObs(p6)
        p7 = Obs(ENUCoords(3, 3), GPSTime.readTimestamp('2020-01-01 10:00:08'))
        self.track.addObs(p7)
        p8 = Obs(ENUCoords(3, 4), GPSTime.readTimestamp('2020-01-01 10:00:10'))
        self.track.addObs(p8)
        p9 = Obs(ENUCoords(4, 4), GPSTime.readTimestamp('2020-01-01 10:00:12'))
        self.track.addObs(p9)
Esempio n. 28
0
 def testFindStopsLocal(self):
     GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
     chemin = os.path.join(self.resource_path, './data/trace1.dat')
     trace = FileReader.readFromFile(chemin, 2, 3, -1, 4, separator=",")
     stops = findStopsLocal(trace)
     self.assertLessEqual(3, 5)
Esempio n. 29
0
def intersection(track1, track2, withTime=-1):

    if not (track1.getSRID() == track2.getSRID()):
        print("Error: tracks must have same SRID to compute intersections")
        exit()

    I = Track()
    TMP_I = []
    TMP_J = []
    TMP_TPS2 = []

    for i in range(len(track1) - 1):

        x11 = track1[i].position.getX()
        y11 = track1[i].position.getY()
        x12 = track1[i + 1].position.getX()
        y12 = track1[i + 1].position.getY()
        seg1 = [x11, y11, x12, y12]

        for j in range(len(track2) - 1):

            x21 = track2[j].position.getX()
            y21 = track2[j].position.getY()
            x22 = track2[j + 1].position.getX()
            y22 = track2[j + 1].position.getY()
            seg2 = [x21, y21, x22, y22]

            if isSegmentIntersects(seg1, seg2):
                P1 = cartesienne(seg1)
                P2 = cartesienne(seg2)
                A = np.zeros((2, 2))
                B = np.zeros((2, 1))
                A[0, 0] = P1[0]
                A[0, 1] = P1[1]
                B[0, 0] = -P1[2]
                A[1, 0] = P2[0]
                A[1, 1] = P2[1]
                B[1, 0] = -P2[2]

                X = np.linalg.solve(A, B)

                x = X[0, 0]
                y = X[1, 0]
                p = Utils.makeCoords(x, y, 0, track1.getSRID())

                # Linear interpolation on track 1
                w1 = p.distance2DTo(track1[i].position)
                w2 = p.distance2DTo(track1[i + 1].position)
                p.setZ((w1 * track1[i + 1].position.getZ() +
                        w2 * track1[i].position.getZ()) / (w1 + w2))
                t1 = track1[i].timestamp.toAbsTime()
                t2 = track1[i].timestamp.toAbsTime()
                ta = (w1 * t2 + w2 * t1) / (w1 + w2)

                # Linear interpolation on track 2
                w1 = p.distance2DTo(track2[j].position)
                w2 = p.distance2DTo(track2[j + 1].position)
                t1 = track2[i].timestamp.toAbsTime()
                t2 = track2[i].timestamp.toAbsTime()
                tb = (w1 * t2 + w2 * t1) / (w1 + w2)

                # Add intersection
                if (withTime == -1) or (abs(tb - ta) < withTime):
                    I.addObs(Obs(p, GPSTime.readUnixTime(ta)))
                    TMP_TPS2.append(GPSTime.readUnixTime(tb))
                    TMP_I.append(i)
                    TMP_J.append(j)

    if I.size() > 0:
        I.createAnalyticalFeature("timestamp2", TMP_TPS2)
        I.createAnalyticalFeature("id1", TMP_I)
        I.createAnalyticalFeature("id2", TMP_J)

    return I
Esempio n. 30
0
    def test_create_index_collection1(self):
        
        GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
                
        track = Track()
        p1 = Obs(ENUCoords(0, 0), GPSTime.readTimestamp('2020-01-01 10:00:00'))
        track.addObs(p1)
        p2 = Obs(ENUCoords(2.5, 3), GPSTime.readTimestamp('2020-01-01 10:08:00'))
        track.addObs(p2)
        p3 = Obs(ENUCoords(2.5, 5), GPSTime.readTimestamp('2020-01-01 10:17:00'))
        track.addObs(p3)
        p4 = Obs(ENUCoords(7, 5), GPSTime.readTimestamp('2020-01-01 10:21:00'))
        track.addObs(p4)
        p5 = Obs(ENUCoords(10, 10), GPSTime.readTimestamp('2020-01-01 10:25:00'))
        track.addObs(p5)
                #track.plot()
                #track.plotAsMarkers()
                
        TRACES = []
        TRACES.append(track)
        collection = TrackCollection(TRACES)
                
        index = SpatialIndex(collection, (2, 2))
        index.plot()
        
        # =====================================================================
        # =====================================================================
        self.assertEqual(index.request(0, 0), [0])
        self.assertEqual(index.request(1, 0), [])
        self.assertEqual(index.request(0, 1), [0])
        self.assertEqual(index.request(1, 1), [0])
        self.assertEqual(index.request(2, 0), [])
        self.assertEqual(index.request(2, 1), [])
        self.assertEqual(index.request(1, 2), [0])
        self.assertEqual(index.request(2, 2), [0])
        self.assertEqual(index.request(3, 2), [0])
        self.assertEqual(index.request(3, 3), [0])
        self.assertEqual(index.request(4, 3), [0])
        self.assertEqual(index.request(4, 4), [0])
        
        
        # # =====================================================================
        self.assertEqual(index.request(ENUCoords(0, 0)), [0])
        self.assertEqual(index.request(ENUCoords(2.5, 3)), [0])
        self.assertEqual(index.request(ENUCoords(2.5, 5)), [0])
        self.assertEqual(index.request(ENUCoords(7, 5)), [0])
        self.assertEqual(index.request(ENUCoords(10, 10)), [0])
        self.assertEqual(index.request(ENUCoords(0.5, 2.5)), [0])
        self.assertEqual(index.request(ENUCoords(4.2, 5.8)), [0])

        
        # # =====================================================================
        self.assertEqual(index.request([ENUCoords(2.1, 0.5), ENUCoords(1.1, 1.1)]), [0])
        self.assertEqual(index.request([ENUCoords(2.1, 0.5), ENUCoords(7.1, 3.5)]), [])
        self.assertEqual(index.request([ENUCoords(5.8, 5.8), ENUCoords(2.1, 1.1)]), [0])
        
        
        # # =====================================================================
        self.assertEqual(index.request(track), [0])
 
        track2 = Track()
        p6 = Obs(ENUCoords(2.2, 0), GPSTime.readTimestamp('2020-01-01 10:00:00'))
        track2.addObs(p6)
        p7 = Obs(ENUCoords(2.2, 3.8), GPSTime.readTimestamp('2020-01-01 10:08:00'))
        track2.addObs(p7)
        p8 = Obs(ENUCoords(6.5, 3.8), GPSTime.readTimestamp('2020-01-01 10:08:00'))
        track2.addObs(p8)
        self.assertEqual(index.request(track2), [0])
        
        
        track3 = Track()
        p9 = Obs(ENUCoords(6.5, 3.8), GPSTime.readTimestamp('2020-01-01 10:00:00'))
        track3.addObs(p9)
        p10 = Obs(ENUCoords(6.5, 7), GPSTime.readTimestamp('2020-01-01 10:08:00'))
        track3.addObs(p10)
        p11 = Obs(ENUCoords(10, 7), GPSTime.readTimestamp('2020-01-01 10:08:00'))
        track3.addObs(p11)
        self.assertEqual(index.request(track3), [0])


        # # =====================================================================
        # # =====================================================================
        self.assertCountEqual(index.neighborhood(0, 4, 0), [])
        self.assertCountEqual(index.neighborhood(0, 4, 1), [])
        self.assertCountEqual(index.neighborhood(0, 4, 2), [0])
        self.assertCountEqual(index.neighborhood(0, 4, 3), [0])
    
        self.assertCountEqual(index.neighborhood(3, 0, 0), [])
        self.assertCountEqual(index.neighborhood(3, 0, 1), [])
        self.assertCountEqual(index.neighborhood(3, 0, 2), [0])
        self.assertCountEqual(index.neighborhood(3, 0, 3), [0])
    
        self.assertCountEqual(index.neighborhood(2, 2, 0), [0])
        self.assertCountEqual(index.neighborhood(2, 2, 1), [0])
        self.assertCountEqual(index.neighborhood(2, 2, 2), [0])
        #self.assertCountEqual(index.neighborhood(2, 2, 3), [0])
    
        # # UNIT = -1
        self.assertCountEqual(index.neighborhood(2, 1, -1), [0])
        self.assertCountEqual(index.neighborhood(2, 0, -1), [0])
        self.assertCountEqual(index.neighborhood(0, 1, -1), [0])
        self.assertCountEqual(index.neighborhood(1, 1, -1), [0])
        self.assertCountEqual(index.neighborhood(0, 4, -1), [0])
        self.assertCountEqual(index.neighborhood(3, 4, -1), [0])
        self.assertCountEqual(index.neighborhood(4, 4, -1), [0])
        self.assertCountEqual(index.neighborhood(2, 4, -1), [0])
        
        
        # # =====================================================================
        self.assertCountEqual(index.neighborhood(ENUCoords(0, 0.1)), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.5, 3)), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.5, 5)), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(7, 5)), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(10, 10)), [0])
        
        self.assertCountEqual(index.neighborhood(ENUCoords(6.5, 3.8), None, 0), [])
        self.assertCountEqual(index.neighborhood(ENUCoords(6.5, 3.8), None, 1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(6.5, 3.8), None, 2), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(6.5, 3.8), None, 3), [0])

        self.assertCountEqual(index.neighborhood(ENUCoords(2.2, 3.8), None, 0), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.2, 3.8), None, 1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.2, 3.8), None, 2), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.2, 3.8), None, 3), [0])
        
        self.assertCountEqual(index.neighborhood(ENUCoords(9.9, 7), None, 0), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(9.9, 7), None, 1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(9.9, 7), None, 2), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(9.9, 7), None, 3), [0])
       
        #  # UNIT = -1
        self.assertCountEqual(index.neighborhood(ENUCoords(0, 0), None, -1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.5, 3), None, -1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.5, 5), None, -1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(7, 5), None, -1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(10, 10), None, -1), [0])
        
        self.assertCountEqual(index.neighborhood(ENUCoords(6.5, 3.8), None, -1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(2.2, 3.8), None, -1), [0])
        self.assertCountEqual(index.neighborhood(ENUCoords(9.9, 7), None, -1), [0])
  
    
        # # =====================================================================
        self.assertEqual(index.neighborhood([ENUCoords(2.1, 0.5), ENUCoords(0.1, 2.1)], None, 0), [0])
        self.assertEqual(index.neighborhood([ENUCoords(2.1, 0.5), ENUCoords(0.1, 2.1)], None, 1), [0])
        self.assertEqual(index.neighborhood([ENUCoords(2.1, 0.5), ENUCoords(0.1, 2.1)], None, 2), [0])
        self.assertEqual(index.neighborhood([ENUCoords(2.1, 0.5), ENUCoords(0.1, 2.1)], None, -1), [0])

        self.assertEqual(index.neighborhood([ENUCoords(2.1, 0.5), ENUCoords(7.1, 3.5)]), [])
        self.assertEqual(index.neighborhood([ENUCoords(2.1, 0.5), ENUCoords(7.1, 3.5)], None, 2), [0])
        self.assertEqual(index.neighborhood([ENUCoords(2.1, 0.5), ENUCoords(7.1, 3.5)], None, -1), [0])
        
        self.assertEqual(index.neighborhood([ENUCoords(5.8, 5.8), ENUCoords(2.1, 1.1)]), [0])
        self.assertEqual(index.neighborhood([ENUCoords(5.8, 5.8), ENUCoords(2.1, 1.1)], None, 1), [0])
        self.assertEqual(index.neighborhood([ENUCoords(5.8, 5.8), ENUCoords(2.1, 1.1)], None, 2), [0])
        self.assertEqual(index.neighborhood([ENUCoords(5.8, 5.8), ENUCoords(2.1, 1.1)], None, -1), [0])
        
        
        # # =====================================================================
        self.assertEqual(index.neighborhood(track), [0])
        self.assertEqual(index.neighborhood(track, None, 1), [0])
        self.assertEqual(index.neighborhood(track, None, 3), [0])
        self.assertEqual(index.neighborhood(track, None, -1), [0])
 
        self.assertEqual(index.neighborhood(track2), [0])
        self.assertEqual(index.neighborhood(track2, None, 0), [0])
        self.assertEqual(index.neighborhood(track2, None, 1), [0])
        self.assertEqual(index.neighborhood(track2, None, 3), [0])
        self.assertEqual(index.neighborhood(track2, None, -1), [0])
        
        self.assertEqual(index.neighborhood(track3), [0])
        self.assertEqual(index.neighborhood(track3, None, 0), [0])
        self.assertEqual(index.neighborhood(track3, None, 1), [0])
        self.assertEqual(index.neighborhood(track3, None, 2), [0])
        self.assertEqual(index.neighborhood(track3, None, 3), [0])
        self.assertEqual(index.neighborhood(track3, None, -1), [0])