Esempio n. 1
0
    def testLabel(self):

        # Create a new label
        l = czml.Label()
        l.text = 'test label'
        l.show = False
        self.assertEqual(l.data(), {'text': 'test label', 'show': False})

        # Modify an existing label
        l.show = True
        self.assertEqual(l.data(), {'text': 'test label', 'show': True})

        # Create a new label from an existing label
        l2 = czml.Label()
        l2.loads(l.dumps())
        self.assertEqual(l.data(), l2.data())

        # Add a label toa CZML packet
        packet = czml.CZMLPacket(id='abc')
        packet.label = l2
        self.assertEqual(packet.data(), {
            'id': 'abc',
            'label': {
                'text': 'test label',
                'show': True
            },
        })
Esempio n. 2
0
 def testLabel(self):
     l = czml.Label()
     l.text = 'test label'
     l.show = False
     self.assertEqual(l.data(), {'text': 'test label', 'show': False})
     l.show = True
     self.assertEqual(l.data(), {'text': 'test label', 'show': True})
     l2 = czml.Label()
     l2.loads(l.dumps())
     self.assertEqual(l.data(), l2.data())
Esempio n. 3
0
def create(ICAO, longitude, latitude, height):
    packet2 = czml.CZMLPacket(id=ICAO)
    lb = czml.Label(text=ICAO, show=True)
    lb.scale = 0.5
    lb.pixelOffset = {'cartesian2': [30, -20]}
    packet2.label = lb
    packet2.position = {"cartographicDegrees": [longitude, latitude, height]}
    md = czml.Model()
    md.gltf = "../../Models/b737.glb"
    md.maximumScale = 20000
    md.minimumPixelSize = 64
    packet2.model = md
    doc.packets.append(packet2)
Esempio n. 4
0
def create(obj_id, longitude, latitude, height):
    packet2 = czml.CZMLPacket(id=obj_id)
    packet2.name = "BEIDOU1"
    lb = czml.Label(text="北斗卫星", show=True)
    lb.scale = 0.5
    lb.pixelOffset = {'cartesian2': [50, -30]}
    packet2.label = lb
    packet2.position = {"cartographicDegrees": [longitude, latitude, height]}
    md = czml.Model()
    md.gltf = "../../Models/a2100.gltf"
    md.maximumScale = 20000
    md.minimumPixelSize = 64
    packet2.model = md
    doc.packets.append(packet2)
Esempio n. 5
0
    def testDocument(self):

        # Create a new document packet
        doc_packet1 = czml.CZMLPacket(id='document', version='1.0')
        self.assertEqual(doc_packet1.data(), {
            'id': 'document',
            'version': '1.0'
        })

        # Modify an existing document packet
        doc_packet1.version = '1.1'
        self.assertEqual(doc_packet1.data(), {
            'id': 'document',
            'version': '1.1'
        })

        # Create a new document packet from an existing document packet
        doc_packet2 = czml.CZMLPacket()
        doc_packet2.loads(doc_packet1.dumps())
        self.assertEqual(doc_packet1.data(), doc_packet2.data())

        # Test that version can only be added to the document packet (id='document')
        with self.assertRaises(Exception):
            doc_packet1 = czml.CZMLPacket(id='foo', version='1.0')
        doc_packet1 = czml.CZMLPacket(id='foo')
        self.assertRaises(Exception, setattr, doc_packet1, 'version', '1.0')

        # Test the writing of CZML using the write() method and the reading of that CZML using the loads() method
        doc = czml.CZML()
        doc.packets.append(doc_packet2)
        label_packet = czml.CZMLPacket(id='label')
        label = czml.Label()
        label.text = 'test label'
        label.show = True
        label_packet.label = label
        doc.packets.append(label_packet)
        test_filename = 'test.czml'
        doc.write(test_filename)
        with open(test_filename, 'r') as test_file:
            doc2 = czml.CZML()
            doc2.loads(test_file.read())
            self.assertEqual(doc.dumps(), doc2.dumps())
        os.remove(test_filename)
Esempio n. 6
0
    def testCZMLPacket(self):
        p = czml.CZMLPacket(id='abc')
        self.assertEqual(p.dumps(), '{"id": "abc"}')
        bb = czml.Billboard()
        bb.image = 'http://localhost/img.png'
        bb.scale = 0.7
        bb.show = True
        p.billboard = bb
        self.assertEqual(p.data(),
            {'billboard': {'image': 'http://localhost/img.png',
            'scale': 0.7, 'show': True}, 'id': 'abc'})
        p2 = czml.CZMLPacket(id='abc')
        p2.loads(p.dumps())
        self.assertEqual(p.data(), p2.data())
        pos = czml.Position()
        coords = [7.0, 0.0, 1.0, 2.0, 6.0, 3.0, 4.0, 5.0]
        pos.cartesian = coords
        p.position = pos
        l = czml.Label()
        l.text = 'test label'
        l.show = False
        p.label = l
        self.assertEqual(p.data(),
            {'billboard': {'image': 'http://localhost/img.png',
            'scale': 0.7, 'show': True}, 'id': 'abc',
            'label': {'show': False, 'text': 'test label'},
            'position': {'cartesian': [7.0, 0.0, 1.0, 2.0, 6.0, 3.0, 4.0, 5.0]},
            })
        p2.loads(p.dumps())
        self.assertEqual(p.data(), p2.data())
        p3 = czml.CZMLPacket(id='cde')
        p3.point = {'color':
                    {'rgba': [0, 255, 127, 55]},
                    'show': True}
        self.assertEqual(p3.data(), {'id': 'cde',
                                    'point': {'color':
                                        {'rgba': [0, 255, 127, 55]},
                                        'show': True}})
        p32 = czml.CZMLPacket(id='abc')
        p32.loads(p3.dumps())
        self.assertEqual(p3.data(), p32.data())
        p4 = czml.CZMLPacket(id='defg')

        pl = czml.Polyline()
        pl.color = {'rgba': [0, 255, 127, 55]}
        pl.width = 10
        pl.outlineWidth = 2
        pl.show = True
        v = czml.VertexPositions()
        v.cartographicDegrees = [0.0, 0.0, .0, 1.0, 1.0, 1.0]
        p4.vertexPositions = v
        p4.polyline = pl
        self.assertEqual(p4.data(),
             {'polyline':
                {'color': {'rgba': [0, 255, 127, 55]},
                'width': 10,
                'outlineWidth': 2,
                'show': True},
            'id': 'defg',
            'vertexPositions':
                {'cartographicDegrees':
                    [0.0, 0.0, 0.0, 1.0, 1.0, 1.0]}
            })
        p42 = czml.CZMLPacket(id='abc')
        p42.loads(p4.dumps())
        self.assertEqual(p4.data(), p42.data())
        p5 = czml.CZMLPacket(id='efgh')
        p5.vertexPositions = v
        poly = czml.Polygon(color={'rgba': [0, 255, 127, 55]})
        p5.polygon = poly
        self.assertEqual(p5.data(),
            {'polygon':
                {'material':
                    {'solidColor':
                        {'color':
                            {'rgba': [0, 255, 127, 55]}}}},
                    'id': 'efgh',
                    'vertexPositions':
                        {'cartographicDegrees':
                            [0.0, 0.0, 0.0, 1.0, 1.0, 1.0]}})
        p52 = czml.CZMLPacket(id='abc')
        p52.loads(p5.dumps())
        self.assertEqual(p5.data(), p52.data())
        return p