示例#1
0
 def test_switch_2D_3D_2D(self):
     """Test switch between: 2D => 3D => 2D"""
     point = Point()
     self.assertIsNone(point.z)
     self.assertTrue(point.is2D)
     point.z = 1
     self.assertFalse(point.is2D)
     point.z = None
     self.assertTrue(point.is2D, True)
示例#2
0
 def test_switch_2D_3D_2D(self):
     """Test switch between: 2D => 3D => 2D"""
     point = Point()
     self.assertIsNone(point.z)
     self.assertTrue(point.is2D)
     point.z = 1
     self.assertFalse(point.is2D)
     point.z = None
     self.assertTrue(point.is2D, True)
示例#3
0
 def test_distance(self):
     """Test distance method"""
     point0 = Point(0, 0, 0)
     point1 = Point(1, 0)
     self.assertEqual(point0.distance(point1), 1.0)
     point1.z = 1
     self.assertAlmostEqual(point0.distance(point1), np.sqrt(2.0))
示例#4
0
 def test_distance(self):
     """Test distance method"""
     point0 = Point(0, 0, 0)
     point1 = Point(1, 0)
     self.assertEqual(point0.distance(point1), 1.0)
     point1.z = 1
     self.assertAlmostEqual(point0.distance(point1), np.sqrt(2.))
示例#5
0
    def uppoints(self):
        """Return"""
        name_map = self.name_map + "__Topo"
        topo = VectorTopo(name_map)
        topo.open("r", layer=1)

        pts_org = []
        pts_chg = []
        attrs = []
        for i in range(1, len(topo) + 1):
            act = topo.read(i).attrs["action"]
            if act != "":
                cat = topo.read(i).attrs["cat"]
                pto_org = topo.cat(cat, "points", 1)[0]
                pto_chg = Point(pto_org.x, pto_org.y, pto_org.z)
                if topo.read(i).attrs["x"] is not None:
                    pto_chg.x = float(topo.read(i).attrs["x"])
                if topo.read(i).attrs["y"] is not None:
                    pto_chg.y = float(topo.read(i).attrs["y"])
                if topo.read(i).attrs["z"] is not None:
                    pto_chg.z = float(topo.read(i).attrs["z"])

                pts_org.append(pto_org)
                pts_chg.append(pto_chg)
                attrs.append(
                    [
                        cat,
                        topo.read(i).attrs["pk"],
                        topo.read(i).attrs["name"],
                        topo.read(i).attrs["azi"],
                        topo.read(i).attrs["p_type"],
                        topo.read(i).attrs["align"],
                        topo.read(i).attrs["vparam"],
                        topo.read(i).attrs["v_type"],
                        topo.read(i).attrs["terr"],
                        topo.read(i).attrs["t_type"],
                        topo.read(i).attrs["dist_d"],
                        pto_chg.x,
                        pto_chg.y,
                        pto_chg.z,
                        "",
                    ]
                )
        topo.close()
        if pts_org != []:
            topo.open("rw", 1, with_z=True)
            for i, pto in enumerate(pts_org):
                topo.rewrite(pto, pts_chg[i], attrs[i][1:])
            topo.table.conn.commit()
            topo.close()
    def uppoints(self):
        """ Return
        """
        name_map = self.name_map + '__Topo'
        topo = VectorTopo(name_map)
        topo.open('r', layer=1)

        pts_org = []
        pts_chg = []
        attrs = []
        for i in range(1, len(topo) + 1):
            act = topo.read(i).attrs['action']
            if act != '':
                cat = topo.read(i).attrs['cat']
                pto_org = topo.cat(cat, 'points', 1)[0]
                pto_chg = Point(pto_org.x, pto_org.y, pto_org.z)
                if topo.read(i).attrs['x'] is not None:
                    pto_chg.x = float(topo.read(i).attrs['x'])
                if topo.read(i).attrs['y'] is not None:
                    pto_chg.y = float(topo.read(i).attrs['y'])
                if topo.read(i).attrs['z'] is not None:
                    pto_chg.z = float(topo.read(i).attrs['z'])

                pts_org.append(pto_org)
                pts_chg.append(pto_chg)
                attrs.append([
                    cat,
                    topo.read(i).attrs['pk'],
                    topo.read(i).attrs['name'],
                    topo.read(i).attrs['azi'],
                    topo.read(i).attrs['p_type'],
                    topo.read(i).attrs['align'],
                    topo.read(i).attrs['vparam'],
                    topo.read(i).attrs['v_type'],
                    topo.read(i).attrs['terr'],
                    topo.read(i).attrs['t_type'],
                    topo.read(i).attrs['dist_d'], pto_chg.x, pto_chg.y,
                    pto_chg.z, ''
                ])
        topo.close()
        if pts_org != []:
            topo.open('rw', 1, with_z=True)
            for i, pto in enumerate(pts_org):
                topo.rewrite(pto, pts_chg[i], attrs[i][1:])
            topo.table.conn.commit()
            topo.close()