/gdata/geo/data.py

http://radioappz.googlecode.com/ · Python · 92 lines · 34 code · 31 blank · 27 comment · 0 complexity · d587ea0ff49af727cb6d63d65759ac52 MD5 · raw file

  1. #!/usr/bin/python
  2. #
  3. # Copyright (C) 2009 Google Inc.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. """Contains the data classes of the Geography Extension"""
  17. __author__ = 'j.s@google.com (Jeff Scudder)'
  18. import atom.core
  19. GEORSS_TEMPLATE = '{http://www.georss.org/georss/}%s'
  20. GML_TEMPLATE = '{http://www.opengis.net/gml/}%s'
  21. GEO_TEMPLATE = '{http://www.w3.org/2003/01/geo/wgs84_pos#/}%s'
  22. class GeoLat(atom.core.XmlElement):
  23. """Describes a W3C latitude."""
  24. _qname = GEO_TEMPLATE % 'lat'
  25. class GeoLong(atom.core.XmlElement):
  26. """Describes a W3C longitude."""
  27. _qname = GEO_TEMPLATE % 'long'
  28. class GeoRssBox(atom.core.XmlElement):
  29. """Describes a geographical region."""
  30. _qname = GEORSS_TEMPLATE % 'box'
  31. class GeoRssPoint(atom.core.XmlElement):
  32. """Describes a geographical location."""
  33. _qname = GEORSS_TEMPLATE % 'point'
  34. class GmlLowerCorner(atom.core.XmlElement):
  35. """Describes a lower corner of a region."""
  36. _qname = GML_TEMPLATE % 'lowerCorner'
  37. class GmlPos(atom.core.XmlElement):
  38. """Describes a latitude and longitude."""
  39. _qname = GML_TEMPLATE % 'pos'
  40. class GmlPoint(atom.core.XmlElement):
  41. """Describes a particular geographical point."""
  42. _qname = GML_TEMPLATE % 'Point'
  43. pos = GmlPos
  44. class GmlUpperCorner(atom.core.XmlElement):
  45. """Describes an upper corner of a region."""
  46. _qname = GML_TEMPLATE % 'upperCorner'
  47. class GmlEnvelope(atom.core.XmlElement):
  48. """Describes a Gml geographical region."""
  49. _qname = GML_TEMPLATE % 'Envelope'
  50. lower_corner = GmlLowerCorner
  51. upper_corner = GmlUpperCorner
  52. class GeoRssWhere(atom.core.XmlElement):
  53. """Describes a geographical location or region."""
  54. _qname = GEORSS_TEMPLATE % 'where'
  55. Point = GmlPoint
  56. Envelope = GmlEnvelope
  57. class W3CPoint(atom.core.XmlElement):
  58. """Describes a W3C geographical location."""
  59. _qname = GEO_TEMPLATE % 'Point'
  60. long = GeoLong
  61. lat = GeoLat