Beispiel #1
0
    def test_askml(self):
        # Should throw a TypeError when trying to obtain KML from a
        # non-geometry field.
        with self.assertRaises(TypeError):
            City.objects.annotate(kml=functions.AsKML('name'))

        # Ensuring the KML is as expected.
        ptown = City.objects.annotate(kml=functions.AsKML('point', precision=9)).get(name='Pueblo')
        self.assertEqual('<Point><coordinates>-104.609252,38.255001</coordinates></Point>', ptown.kml)
 def test_kml_response(self):
     response = self.client.get(self.url, {
         'format': 'kml',
         'precision': self.precision
     })
     part = self.qs.annotate(
         kml=sqlfn.AsKML('geom', precision=self.precision))[0].kml
     self.assertInHTML(part, response.content.decode('utf-8'), count=1)
Beispiel #3
0
 def test_simplify_kml(self):
     fn = functions.AsKML(query.Simplify('geom', self.radius))
     sqs = self.qs.all().annotate(kml=fn)
     self.assertTrue(sqs[0].kml.startswith('<Polygon>'))
     self.assertNotIn('<coordinates></coordinates>', sqs[0].kml)
     self.assertXMLNotEqual(sqs[0].kml, self.qs[0].geom.kml)