diff options
author | ttt | 2017-05-13 00:29:47 +0530 |
---|---|---|
committer | ttt | 2017-05-13 00:29:47 +0530 |
commit | abf599be33b383a6a5baf9493093b2126a622ac8 (patch) | |
tree | 4c5ab6e0d935d5e65fabcf0258e4a00dd20a5afa /lib/python2.7/site-packages/django/contrib/gis/tests/geoapp/feeds.py | |
download | SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.tar.gz SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.tar.bz2 SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.zip |
added all server files
Diffstat (limited to 'lib/python2.7/site-packages/django/contrib/gis/tests/geoapp/feeds.py')
-rw-r--r-- | lib/python2.7/site-packages/django/contrib/gis/tests/geoapp/feeds.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/python2.7/site-packages/django/contrib/gis/tests/geoapp/feeds.py b/lib/python2.7/site-packages/django/contrib/gis/tests/geoapp/feeds.py new file mode 100644 index 0000000..f53431c --- /dev/null +++ b/lib/python2.7/site-packages/django/contrib/gis/tests/geoapp/feeds.py @@ -0,0 +1,66 @@ +from __future__ import absolute_import + +from django.contrib.gis import feeds + +from .models import City + + +class TestGeoRSS1(feeds.Feed): + link = '/city/' + title = 'Test GeoDjango Cities' + + def items(self): + return City.objects.all() + + def item_link(self, item): + return '/city/%s/' % item.pk + + def item_geometry(self, item): + return item.point + +class TestGeoRSS2(TestGeoRSS1): + def geometry(self, obj): + # This should attach a <georss:box> element for the extent of + # of the cities in the database. This tuple came from + # calling `City.objects.extent()` -- we can't do that call here + # because `extent` is not implemented for MySQL/Oracle. + return (-123.30, -41.32, 174.78, 48.46) + + def item_geometry(self, item): + # Returning a simple tuple for the geometry. + return item.point.x, item.point.y + +class TestGeoAtom1(TestGeoRSS1): + feed_type = feeds.GeoAtom1Feed + +class TestGeoAtom2(TestGeoRSS2): + feed_type = feeds.GeoAtom1Feed + + def geometry(self, obj): + # This time we'll use a 2-tuple of coordinates for the box. + return ((-123.30, -41.32), (174.78, 48.46)) + +class TestW3CGeo1(TestGeoRSS1): + feed_type = feeds.W3CGeoFeed + +# The following feeds are invalid, and will raise exceptions. +class TestW3CGeo2(TestGeoRSS2): + feed_type = feeds.W3CGeoFeed + +class TestW3CGeo3(TestGeoRSS1): + feed_type = feeds.W3CGeoFeed + + def item_geometry(self, item): + from django.contrib.gis.geos import Polygon + return Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0))) + +# The feed dictionary to use for URLs. +feed_dict = { + 'rss1' : TestGeoRSS1, + 'rss2' : TestGeoRSS2, + 'atom1' : TestGeoAtom1, + 'atom2' : TestGeoAtom2, + 'w3cgeo1' : TestW3CGeo1, + 'w3cgeo2' : TestW3CGeo2, + 'w3cgeo3' : TestW3CGeo3, +} |