Exemplo n.º 1
0
    def testMaterial(self):
        red = czml.Color(rgba=(255, 0, 0, 64))
        mat = czml.Material(solidColor={'color': red})
        mat.solidColor = {'color': red}
        mat_dict = {'solidColor': {'color': {'rgba': [255, 0, 0, 64]}}}
        self.assertEqual(mat.data(), mat_dict)

        mat2 = czml.Material(**mat_dict)
        self.assertEqual(mat.data(), mat2.data())
Exemplo n.º 2
0
    def testCone(self):
        sc = czml.SolidColor(color={'rgba': [0, 255, 127, 55]})
        mat = czml.Material(solidColor=sc)

        c = czml.Cone(show=True,
                      innerMaterial=mat,
                      outerMaterial=mat,
                      capMaterial=mat,
                      showIntersection=True,
                      outerHalfAngle=1,
                      innerHalfAngle=2.0,
                      )

        czml_dict = {'outerHalfAngle': 1,
                     'innerHalfAngle': 2.0,
                     'outerMaterial': {'solidColor': {'color': {'rgba': [0, 255, 127, 55]}}},
                     'show': True,
                     'showIntersection': True,
                     'capMaterial': {'solidColor': {'color': {'rgba': [0, 255, 127, 55]}}},
                     'innerMaterial': {'solidColor': {'color': {'rgba': [0, 255, 127, 55]}}}
                     }

        self.assertEqual(czml_dict, c.data())

        # Passing in an unknown value raises a ValueError
        #with self.assertRaises(ValueError):
        #    czml.Cone(bad_data=None, **czml_dict)
        self.assertRaises(ValueError, czml.Cone, bad_data=None, **czml_dict)
Exemplo n.º 3
0
    def testEllipsoid(self):
        ellipsoid_value = {'radii': {'cartesian': [1000.0, 2000.0, 3000.0]},
                           'material': {},
                           'show': True,
                           }
        e = czml.Ellipsoid()
        e.show = True
        e.radii = czml.Radii(cartesian=[1000, 2000, 3000])
        e.material = czml.Material()
        self.assertEqual(e.data(), ellipsoid_value)
        e2 = czml.Ellipsoid(**ellipsoid_value)
        self.assertEqual(e.data(), ellipsoid_value)

        # You can't create an ellipsoid with a nonsensical value for material.
        ellipsoid_value['material'] = 2
        #with self.assertRaises(TypeError):
        #    czml.Ellipsoid(**ellipsoid_value)
        self.assertRaises(TypeError, czml.Ellipsoid, **ellipsoid_value)

        ellipsoid_value['material'] = {}
        ellipsoid_value['radii'] = 5
        # Can't create ellipsoids with nonsensical radii
        #with self.assertRaises(TypeError):
        #    czml.Ellipsoid(**ellipsoid_value)
        self.assertRaises(TypeError, czml.Ellipsoid, **ellipsoid_value)
Exemplo n.º 4
0
    def testMaterial(self):

        # Create a new material
        red = czml.Color(rgba=(255, 0, 0, 64))
        mat = czml.Material()
        mat.solidColor = {'color': red}
        self.assertEqual(mat.data(),
                         {'solidColor': {
                             'color': {
                                 'rgba': [255, 0, 0, 64]
                             }
                         }})

        # Create a new material from an existing material
        mat2 = czml.Material()
        mat2.loads(mat.dumps())
        self.assertEqual(mat.data(), mat2.data())
Exemplo n.º 5
0
    def testEllipsoid(self):

        # Create a new ellipsoid
        ellipsoid_value = {
            'radii': {
                'cartesian': [1000.0, 2000.0, 3000.0]
            },
            'material': {},
            'show': True,
        }
        e = czml.Ellipsoid()
        e.show = True
        e.radii = czml.Radii(cartesian=[1000, 2000, 3000])
        e.material = czml.Material()
        self.assertEqual(e.data(), ellipsoid_value)

        # Create a new ellipsoid from an existing ellipsoid
        e2 = czml.Ellipsoid(**ellipsoid_value)
        self.assertEqual(e.data(), ellipsoid_value)

        # Verify you can't create an ellipsoid with a nonsensical value for material.
        ellipsoid_value['material'] = 2
        with self.assertRaises(TypeError):
            czml.Ellipsoid(**ellipsoid_value)
        self.assertRaises(TypeError, czml.Ellipsoid, **ellipsoid_value)

        # Verify you can't create ellipsoids with nonsensical radii
        ellipsoid_value['material'] = {}
        ellipsoid_value['radii'] = 5
        with self.assertRaises(TypeError):
            czml.Ellipsoid(**ellipsoid_value)
        self.assertRaises(TypeError, czml.Ellipsoid, **ellipsoid_value)

        # Add an ellipsoid to a CZML packet
        packet = czml.CZMLPacket(id='abc')
        packet.ellipsoid = e
        self.assertEqual(
            packet.data(), {
                'id': 'abc',
                'ellipsoid': {
                    'radii': {
                        'cartesian': [1000.0, 2000.0, 3000.0]
                    },
                    'material': {},
                    'show': True,
                },
            })
Exemplo n.º 6
0
 def testPolygon(self):
     p = czml.Polygon()
     m = czml.Material()
     sc = czml.SolidColor(color={'rgba': [0, 255, 127, 55]})
     m.solidColor = sc
     p.material = m
     self.assertEqual(p.data(),
         {'material':
             {'solidColor':
                 {'color': {'rgba': [0, 255, 127, 55]}}
         }   }
         )
     p2 = czml.Polygon()
     p2.loads(p.dumps())
     self.assertEqual(p.data(), p2.data())
     p3 = czml.Polygon(color={'rgba': [0, 255, 127, 55]})
     self.assertEqual(p.data(), p3.data())
Exemplo n.º 7
0
    packet._description = DummyObject(rail['segment'])

    props = list(packet._properties)
    props.append("status")
    packet._properties = props
    #print(packet._properties)
    packet.status = DummyObject(rail['new_track'])
    #packet._description = "t"#str(rail['new_track'])

    positions = czml.Positions(cartographicDegrees=positions)

    pl = czml.Polyline(positions=positions)
    if rail['new_track'].lower() == "new":
        color = {'rgba': [255, 0, 0, 255]}
    else:
        color = {'rgba': [0, 0, 255, 255]}
    pl.material = czml.Material(solidColor=czml.SolidColor(color=color))
    pl.width = 5
    pl.clampToGround = True
    # https://icons-for-free.com/iconfiles/png/512/express+harry+hogwarts+potter+train+icon-1320183591487406864.png

    packet.polyline = pl
    doc.packets.append(packet)

    # time packet

filename = "../wwwroot/test/rails.czml"
doc.write(filename)

filename = "rails.czml"
doc.write(filename)
Exemplo n.º 8
0
    def testPolygon(self):

        # Create a new polygon
        img = czml.Image(image='http://localhost/img.png', repeat=2)
        mat = czml.Material(image=img)
        pts = geometry.LineString([(50, 20, 2), (60, 30, 3), (50, 30, 4),
                                   (60, 20, 5)])
        pos = czml.Positions(cartographicDegrees=pts)
        col = {'rgba': [0, 255, 127, 55]}
        pol = czml.Polygon(show=True,
                           material=mat,
                           positions=pos,
                           perPositionHeight=True,
                           fill=True,
                           outline=True,
                           outlineColor=col)
        self.assertEqual(
            pol.data(), {
                'show': True,
                'fill': True,
                'outline': True,
                'perPositionHeight': True,
                'outlineColor': {
                    'rgba': [0, 255, 127, 55]
                },
                'material': {
                    'image': {
                        'image': 'http://localhost/img.png',
                        'repeat': 2
                    },
                },
                'positions': {
                    'cartographicDegrees':
                    [50, 20, 2, 60, 30, 3, 50, 30, 4, 60, 20, 5]
                },
            })

        # Create a new polygon from an existing polygon
        pol2 = czml.Polygon()
        pol2.loads(pol.dumps())
        self.assertEqual(pol2.data(), pol.data())

        # Modify an existing polygon
        grid = czml.Grid(color={'rgba': [0, 55, 127, 255]},
                         cellAlpha=0.4,
                         lineCount=5,
                         lineThickness=2,
                         lineOffset=0.3)
        mat2 = czml.Material(grid=grid)
        pts2 = geometry.LineString([(1.5, 1.2, 0), (1.6, 1.3, 0),
                                    (1.5, 1.3, 0), (1.6, 1.2, 0)])
        pos2 = czml.Positions(cartographicRadians=pts2)
        pol2.material = mat2
        pol2.positions = pos2
        pol2.perPositionHeight = False
        pol2.height = 7
        pol2.extrudedHeight = 30
        self.assertEqual(
            pol2.data(), {
                'show': True,
                'fill': True,
                'outline': True,
                'perPositionHeight': False,
                'height': 7,
                'extrudedHeight': 30,
                'outlineColor': {
                    'rgba': [0, 255, 127, 55]
                },
                'material': {
                    'grid': {
                        'color': {
                            'rgba': [0, 55, 127, 255]
                        },
                        'cellAlpha': 0.4,
                        'lineCount': 5,
                        'lineThickness': 2,
                        'lineOffset': 0.3
                    },
                },
                'positions': {
                    'cartographicRadians':
                    [1.5, 1.2, 0, 1.6, 1.3, 0, 1.5, 1.3, 0, 1.6, 1.2, 0]
                },
            })

        # Add a polygon to a CZML packet
        packet = czml.CZMLPacket(id='abc')
        packet.polygon = pol2
        self.assertEqual(
            packet.data(), {
                'id': 'abc',
                'polygon': {
                    'show': True,
                    'fill': True,
                    'outline': True,
                    'perPositionHeight': False,
                    'height': 7,
                    'extrudedHeight': 30,
                    'outlineColor': {
                        'rgba': [0, 255, 127, 55]
                    },
                    'material': {
                        'grid': {
                            'color': {
                                'rgba': [0, 55, 127, 255]
                            },
                            'cellAlpha': 0.4,
                            'lineCount': 5,
                            'lineThickness': 2,
                            'lineOffset': 0.3
                        },
                    },
                    'positions': {
                        'cartographicRadians':
                        [1.5, 1.2, 0, 1.6, 1.3, 0, 1.5, 1.3, 0, 1.6, 1.2, 0]
                    },
                },
            })
Exemplo n.º 9
0
    def testPolyline(self):

        # Create a new polyline
        sc = czml.SolidColor(color={'rgba': [0, 255, 127, 55]})
        m1 = czml.Material(solidColor=sc)
        c1 = geometry.LineString([(-162, 41, 0), (-151, 43, 0), (-140, 45, 0)])
        v1 = czml.Positions(cartographicDegrees=c1)
        p1 = czml.Polyline(show=True,
                           width=5,
                           followSurface=False,
                           material=m1,
                           positions=v1)
        self.assertEqual(
            p1.data(), {
                'show': True,
                'width': 5,
                'followSurface': False,
                'material': {
                    'solidColor': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        }
                    },
                },
                'positions': {
                    'cartographicDegrees':
                    [-162, 41, 0, -151, 43, 0, -140, 45, 0]
                },
            })

        # Create a new polyline
        pg = czml.PolylineGlow(color={'rgba': [0, 255, 127, 55]},
                               glowPower=0.25)
        m2 = czml.Material(polylineGlow=pg)
        c2 = geometry.LineString([(1.6, 5.3, 10), (2.4, 4.2, 20),
                                  (3.8, 3.1, 30)])
        v2 = czml.Positions(cartographicRadians=c2)
        p2 = czml.Polyline(show=False,
                           width=7,
                           followSurface=True,
                           material=m2,
                           positions=v2)
        self.assertEqual(
            p2.data(), {
                'show': False,
                'width': 7,
                'followSurface': True,
                'material': {
                    'polylineGlow': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        },
                        'glowPower': 0.25
                    },
                },
                'positions': {
                    'cartographicRadians':
                    [1.6, 5.3, 10, 2.4, 4.2, 20, 3.8, 3.1, 30]
                },
            })

        # Create a polyline from an existing polyline
        p3 = czml.Polyline()
        p3.loads(p2.dumps())
        self.assertEqual(p3.data(), p2.data())

        # Modify an existing polyline
        po = czml.PolylineOutline(color={'rgba': [0, 255, 127, 55]},
                                  outlineColor={'rgba': [0, 55, 127, 255]},
                                  outlineWidth=4)
        m3 = czml.Material(polylineOutline=po)
        c3 = geometry.LineString([(1000, 7500, 90), (2000, 6500, 50),
                                  (3000, 5500, 20)])
        v3 = czml.Positions(cartesian=c3)
        p3.material = m3
        p3.positions = v3
        self.assertEqual(
            p3.data(), {
                'show': False,
                'width': 7,
                'followSurface': True,
                'material': {
                    'polylineOutline': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        },
                        'outlineColor': {
                            'rgba': [0, 55, 127, 255]
                        },
                        'outlineWidth': 4
                    },
                },
                'positions': {
                    'cartesian':
                    [1000, 7500, 90, 2000, 6500, 50, 3000, 5500, 20]
                },
            })

        # Add a polyline to a CZML packet
        packet = czml.CZMLPacket(id='abc')
        packet.polyline = p3
        self.assertEqual(
            packet.data(), {
                'id': 'abc',
                'polyline': {
                    'show': False,
                    'width': 7,
                    'followSurface': True,
                    'material': {
                        'polylineOutline': {
                            'color': {
                                'rgba': [0, 255, 127, 55]
                            },
                            'outlineColor': {
                                'rgba': [0, 55, 127, 255]
                            },
                            'outlineWidth': 4
                        },
                    },
                    'positions': {
                        'cartesian':
                        [1000, 7500, 90, 2000, 6500, 50, 3000, 5500, 20]
                    },
                },
            })
Exemplo n.º 10
0
    def testPath(self):

        # Create a new path
        sc = czml.SolidColor(color={'rgba': [0, 255, 127, 55]})
        m1 = czml.Material(solidColor=sc)
        c1 = [0, -62, 141, 0, 2, -51, 143, 0, 4, -40, 145, 0]
        v1 = czml.Position(cartographicDegrees=c1)
        p1 = czml.Path(show=True,
                       width=5,
                       leadTime=2,
                       trailTime=6,
                       resolution=3,
                       material=m1,
                       position=v1)
        self.assertEqual(
            p1.data(), {
                'show': True,
                'width': 5,
                'leadTime': 2,
                'trailTime': 6,
                'resolution': 3,
                'material': {
                    'solidColor': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        }
                    },
                },
                'position': {
                    'cartographicDegrees':
                    [0, -62, 141, 0, 2, -51, 143, 0, 4, -40, 145, 0]
                },
            })

        # Create a new path from an existing path
        p2 = czml.Path()
        p2.loads(p1.dumps())
        self.assertEqual(p2.data(), p1.data())

        # Modify an existing path
        po = czml.PolylineOutline(color={'rgba': [0, 255, 127, 55]},
                                  outlineColor={'rgba': [0, 55, 127, 255]},
                                  outlineWidth=4)
        m2 = czml.Material(polylineOutline=po)
        c2 = [0, 1000, 7500, 90, 4, 2000, 6500, 50, 8, 3000, 5500, 20]
        v2 = czml.Position(cartesian=c2)
        p2.show = False
        p2.material = m2
        p2.position = v2
        self.assertEqual(
            p2.data(), {
                'show': False,
                'width': 5,
                'leadTime': 2,
                'trailTime': 6,
                'resolution': 3,
                'material': {
                    'polylineOutline': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        },
                        'outlineColor': {
                            'rgba': [0, 55, 127, 255]
                        },
                        'outlineWidth': 4
                    },
                },
                'position': {
                    'cartesian':
                    [0, 1000, 7500, 90, 4, 2000, 6500, 50, 8, 3000, 5500, 20]
                },
            })

        # Add a path to a CZML packet
        packet = czml.CZMLPacket(id='abc')
        packet.path = p2
        self.assertEqual(
            packet.data(), {
                'id': 'abc',
                'path': {
                    'show': False,
                    'width': 5,
                    'leadTime': 2,
                    'trailTime': 6,
                    'resolution': 3,
                    'material': {
                        'polylineOutline': {
                            'color': {
                                'rgba': [0, 255, 127, 55]
                            },
                            'outlineColor': {
                                'rgba': [0, 55, 127, 255]
                            },
                            'outlineWidth': 4
                        },
                    },
                    'position': {
                        'cartesian': [
                            0, 1000, 7500, 90, 4, 2000, 6500, 50, 8, 3000,
                            5500, 20
                        ]
                    },
                },
            })
Exemplo n.º 11
0
    def testCone(self):

        # Create a new cone
        sc = czml.SolidColor(color={'rgba': [0, 255, 127, 55]})
        mat = czml.Material(solidColor=sc)
        c = czml.Cone(
            show=True,
            innerMaterial=mat,
            outerMaterial=mat,
            capMaterial=mat,
            showIntersection=True,
            outerHalfAngle=1,
            innerHalfAngle=2.0,
        )
        self.assertEqual(
            c.data(), {
                'outerHalfAngle': 1,
                'innerHalfAngle': 2.0,
                'outerMaterial': {
                    'solidColor': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        }
                    }
                },
                'show': True,
                'showIntersection': True,
                'capMaterial': {
                    'solidColor': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        }
                    }
                },
                'innerMaterial': {
                    'solidColor': {
                        'color': {
                            'rgba': [0, 255, 127, 55]
                        }
                    }
                }
            })

        # Create a new cone from an existing cone
        c2 = czml.Cone()
        c2.loads(c.dumps())
        self.assertEqual(c2.data(), c.data())

        # Verify passing in an unknown value raises a ValueError
        with self.assertRaises(ValueError):
            c3 = czml.Cone(bad_data=None)

        # Add a cone to a CZML packet
        packet = czml.CZMLPacket(id='abc')
        packet.cone = c2
        self.assertEqual(
            packet.data(), {
                'id': 'abc',
                'cone': {
                    'outerHalfAngle': 1,
                    'innerHalfAngle': 2.0,
                    'outerMaterial': {
                        'solidColor': {
                            'color': {
                                'rgba': [0, 255, 127, 55]
                            }
                        }
                    },
                    'show': True,
                    'showIntersection': True,
                    'capMaterial': {
                        'solidColor': {
                            'color': {
                                'rgba': [0, 255, 127, 55]
                            }
                        }
                    },
                    'innerMaterial': {
                        'solidColor': {
                            'color': {
                                'rgba': [0, 255, 127, 55]
                            }
                        }
                    }
                },
            })
Exemplo n.º 12
0
    def testEllipse(self):

        # Create a new ellipse
        sc = czml.SolidColor(color={'rgba': [127, 127, 127, 255]})
        mat1 = czml.Material(solidColor=sc)
        pts1 = [50, 20, 2]
        pos1 = czml.Position(cartographicDegrees=pts1)
        ell1 = czml.Ellipse(show=True,
                            fill=True,
                            height=50,
                            extrudedHeight=200,
                            outline=True,
                            outlineColor={'rgba': [0, 255, 127, 55]},
                            semiMajorAxis=150,
                            semiMinorAxis=75,
                            numberOfVerticalLines=800,
                            rotation=1.2,
                            material=mat1,
                            position=pos1)

        self.assertEqual(
            ell1.data(), {
                'show': True,
                'fill': True,
                'outline': True,
                'height': 50,
                'extrudedHeight': 200,
                'rotation': 1.2,
                'semiMajorAxis': 150,
                'semiMinorAxis': 75,
                'numberOfVerticalLines': 800,
                'outlineColor': {
                    'rgba': [0, 255, 127, 55]
                },
                'material': {
                    'solidColor': {
                        'color': {
                            'rgba': [127, 127, 127, 255]
                        }
                    },
                },
                'position': {
                    'cartographicDegrees': [50, 20, 2]
                },
            })

        # Create a new ellipse from an existing ellipse
        ell2 = czml.Ellipse()
        ell2.loads(ell1.dumps())
        self.assertEqual(ell2.data(), ell1.data())

        # Modify an existing ellipse
        strp = czml.Stripe(evenColor={'rgba': [127, 55, 255, 255]},
                           oddColor={'rgba': [127, 255, 55, 127]},
                           offset=1.3,
                           repeat=64,
                           orientation='VERTICAL')
        mat2 = czml.Material(stripe=strp)
        pts2 = [0, 1.5, 1.2, 0, 2, 1.6, 1.3, 0, 4, 1.5, 1.3, 0, 6, 1.6, 1.2, 0]
        pos2 = czml.Position(cartographicRadians=pts2)
        ell2.material = mat2
        ell2.position = pos2
        ell2.perPositionHeight = False
        ell2.height = 7
        ell2.extrudedHeight = 30
        ell2.semiMajorAxis = 600
        ell2.semiMinorAxis = 400
        self.assertEqual(
            ell2.data(), {
                'show': True,
                'fill': True,
                'outline': True,
                'height': 7,
                'extrudedHeight': 30,
                'rotation': 1.2,
                'semiMajorAxis': 600,
                'semiMinorAxis': 400,
                'numberOfVerticalLines': 800,
                'outlineColor': {
                    'rgba': [0, 255, 127, 55]
                },
                'material': {
                    'stripe': {
                        'evenColor': {
                            'rgba': [127, 55, 255, 255]
                        },
                        'oddColor': {
                            'rgba': [127, 255, 55, 127]
                        },
                        'offset': 1.3,
                        'repeat': 64,
                        'orientation': 'VERTICAL'
                    },
                },
                'position': {
                    'cartographicRadians': [
                        0, 1.5, 1.2, 0, 2, 1.6, 1.3, 0, 4, 1.5, 1.3, 0, 6, 1.6,
                        1.2, 0
                    ]
                },
            })

        # Add an ellipse to a CZML packet
        packet = czml.CZMLPacket(id='abc')
        packet.ellipse = ell2
        self.assertEqual(
            packet.data(), {
                'id': 'abc',
                'ellipse': {
                    'show': True,
                    'fill': True,
                    'outline': True,
                    'height': 7,
                    'extrudedHeight': 30,
                    'rotation': 1.2,
                    'semiMajorAxis': 600,
                    'semiMinorAxis': 400,
                    'numberOfVerticalLines': 800,
                    'outlineColor': {
                        'rgba': [0, 255, 127, 55]
                    },
                    'material': {
                        'stripe': {
                            'evenColor': {
                                'rgba': [127, 55, 255, 255]
                            },
                            'oddColor': {
                                'rgba': [127, 255, 55, 127]
                            },
                            'offset': 1.3,
                            'repeat': 64,
                            'orientation': 'VERTICAL'
                        },
                    },
                    'position': {
                        'cartographicRadians': [
                            0, 1.5, 1.2, 0, 2, 1.6, 1.3, 0, 4, 1.5, 1.3, 0, 6,
                            1.6, 1.2, 0
                        ]
                    },
                },
            })
Exemplo n.º 13
0
    def czml(self):

        doc = czml.CZML();
        iso = self.date.isoformat()

        # Generate time-specific lists for various objects
        central_polyline_degrees = []
        north_polyline_degrees = []
        south_polyline_degrees = []
        ellipse_position = []
        ellipse_semiMajorAxis = []
        ellipse_semiMinorAxis = []
        ellipse_rotation = []

        for t in range(len(self.time)):

            time = iso + "T" + self.time[t] + ":00Z"

            # Define polyline waypoints only where data exist
            if self.position['north'][t] != None:
                north_polyline_degrees += [self.position['north'][t][0], self.position['north'][t][1], 0.0]
            if self.position['central'][t] != None:
                central_polyline_degrees += [self.position['central'][t][0], self.position['central'][t][1], 0.0]
            if self.position['south'][t] != None:
                south_polyline_degrees += [self.position['south'][t][0], self.position['south'][t][1], 0.0]

            # Define ellipse positions and attributes for every time in the interval, using limits where necessary
            use_limit = min(int(math.floor(t/(len(self.time)/2))),1)
            if self.position['north'][t] == None:
                north = self.limits['north'][use_limit]
            else:
                north = self.position['north'][t]
            if self.position['central'][t] == None:
                central = self.limits['central'][use_limit]
            else:
                central = self.position['central'][t]
            if self.position['south'][t] == None:
                south = self.limits['south'][use_limit]
            else:
                south = self.position['south'][t]

            # Approximate ellipse semiMajorAxis from vincenty distance between limit polylines
            north2 = (north[1], north[0])
            south2 = (south[1], south[0])
            semi_major_axis = vincenty(north2, south2).meters / 2

            # Approximate elipse semiMinorAxis from sun altitude (probably way wrong!)
            ellipse_axis_ratio = self.sun_altitude[t] / 90
            semi_minor_axis = semi_major_axis * ellipse_axis_ratio

            # Approximate ellipse rotation using basic spheroid (TODO: replace with WGS-84)
            # Calculate bearing in both directions and average them
            nlat = north[1]/180 * math.pi;
            nlon = north[0]/180 * math.pi;
            clat = central[1]/180 * math.pi;
            clon = central[0]/180 * math.pi;
            slat = south[1]/180 * math.pi;
            slon = south[0]/180 * math.pi;

            y = math.sin(slon-nlon) * math.cos(slat);
            x = math.cos(nlat) * math.sin(slat) - math.sin(nlat) * math.cos(slat) * math.cos(slon-nlon);
            initial_bearing = math.atan2(y, x)
            if (initial_bearing < 0):
                initial_bearing += math.pi * 2

            y = math.sin(nlon-slon) * math.cos(nlat);
            x = math.cos(slat) * math.sin(nlat) - math.sin(slat) * math.cos(nlat) * math.cos(nlon-slon);
            final_bearing = math.atan2(y, x) - math.pi
            if (final_bearing < 0):
                final_bearing += math.pi * 2

            rotation = -1 * ((initial_bearing + final_bearing) / 2 - (math.pi / 2))

            ellipse_position += [time, central[0], central[1], 0.0]
            ellipse_semiMajorAxis += [time, round(semi_major_axis, 3)]
            ellipse_semiMinorAxis += [time, round(semi_minor_axis, 3)]
            ellipse_rotation += [time, round(rotation, 3)]        

        # Generate document packet with clock
        start_time = iso + "T" + self.time[0] + ":00Z"
        end_time = iso + "T" + self.time[-1] + ":00Z"
        packet = czml.CZMLPacket(id='document',version='1.0')
        c = czml.Clock()
        c.multiplier = 300
        c.range = "LOOP_STOP"
        c.step = "SYSTEM_CLOCK_MULTIPLIER"
        c.currentTime = start_time
        c.interval = start_time + "/" + end_time
        packet.clock = c
        doc.packets.append(packet)

        # Generate a polyline packet for the north and south polylines, connected and filled
        limit_polyline_degrees = list(north_polyline_degrees)
        point = len(south_polyline_degrees)/3
        while (point > 0):
            offset = (point-1) * 3
            limit_polyline_degrees += [ south_polyline_degrees[offset],
                                        south_polyline_degrees[offset+1],
                                        south_polyline_degrees[offset+2] ]
            point -= 1
        packet_id = iso + '_bounds_polygon'
        packet = czml.CZMLPacket(id=packet_id)
        boc = czml.Color(rgba=(232, 72, 68, 255))
        bsc = czml.SolidColor(color=czml.Color(rgba=(0, 0, 0, 66)))
        bmat = czml.Material(solidColor=bsc)
        bdeg = limit_polyline_degrees
        bpos = czml.Positions(cartographicDegrees=bdeg)
        bpg = czml.Polygon(show=True, height=0, outline=True, outlineColor=boc, outlineWidth=2, material=bmat, positions=bpos)
        packet.polygon = bpg
        doc.packets.append(packet)

        # Generate central polyline packet
        packet_id = iso + '_central_polyline'
        packet = czml.CZMLPacket(id=packet_id)
        csc = czml.SolidColor(color=czml.Color(rgba=(241, 226, 57, 255)))
        cmat = czml.Material(solidColor=csc)
        cpos = czml.Positions(cartographicDegrees=central_polyline_degrees)
        cpl = czml.Polyline(show=True, width=4, followSurface=True, material=cmat, positions=cpos)
        packet.polyline = cpl
        doc.packets.append(packet)

        # Generate ellipse shadow packet
        packet_id = iso + '_shadow_ellipse'
        packet = czml.CZMLPacket(id=packet_id)
        esc = czml.SolidColor(color=czml.Color(rgba=(0, 0, 0, 160)))
        emat = czml.Material(solidColor=esc)
        xmaj = czml.Number(ellipse_semiMajorAxis)
        xmin = czml.Number(ellipse_semiMinorAxis)
        rot = czml.Number(ellipse_rotation)
        ell = czml.Ellipse(show=True, fill=True, granularity=0.002, material=emat, semiMajorAxis=xmaj, semiMinorAxis=xmin, rotation=rot)
        packet.ellipse = ell
        packet.position = czml.Position(cartographicDegrees=ellipse_position)
        doc.packets.append(packet)

        return list(doc.data())