기존 RSS에 geo 네임스페이스를 붙여 좌표를 줄 수 있게 한다. http://georss.org/ 라는 사이트가 있어서 마치 대표 사이트인 것처럼 보이는데, 정작 airpolmap에 쓰인 야후 지도에는 다른 형식으로 줘야 인식한다. 클라이언트 단에서 뭘 복잡하게 하려면 아무래도 부하나 시간 때문에 무리가 있는데 미리 서버단에서 다 준비하고 파일로 한 번에 전달할 수 있다는 점에서, 완전히 실시간일 필요가 없다면 쓸만하다. 다만 네이버 지도에서는 지원하지 않고 구글과 야후에서만 된다. ---- PyRSS2Gen에 지원이 없어서 확장을 해줬다.# coding: utf-8# GeoRSS.pyfrom PyRSS2Gen import RSSItem, Guid, RSS2, _opt_elementclass GeoRSS(RSS2): rss_attrs = { "version": "2.0", "xmlns:geo": "http://www.w3.org/2003/01/geo/wgs84_pos#", "xmlns:ymaps": "http://api.maps.yahoo.com/Maps/V2/AnnotatedMaps.xsd" } def publish_extensions(self, handler): if hasattr(self, 'geo_lat'): _opt_element(handler, "geo:lat", self.geo_lat) if hasattr(self, 'geo_long'): _opt_element(handler, "geo:long", self.geo_long) if hasattr(self, 'ymaps_ZoomLevel'): _opt_element(handler, "ymaps:ZoomLevel", self.ymaps_ZoomLevel) if hasattr(self, 'ymaps_IntlCode'): _opt_element(handler, "ymaps:IntlCode", self.ymaps_IntlCode) if hasattr(self, 'ymaps_Groups'): _opt_element(handler, "ymaps:Groups", self.ymaps_Groups)class GeoRSSItem(RSSItem): def publish_extensions(self, handler): if hasattr(self, 'geo_lat'): _opt_element(handler, "geo:lat", self.geo_lat) if hasattr(self, 'geo_long'): _opt_element(handler, "geo:long", self.geo_long) if hasattr(self, 'georss_point'): _opt_element(handler, "georss:point", self.georss_point) if hasattr(self, 'georss_line'): _opt_element(handler, "georss:line", self.georss_line) if hasattr(self, 'georss_polygon'): _opt_element(handler, "georss:polygon", self.georss_polygon)<?xml version="1.0" encoding="UTF-8"?><rss xmlns:ymaps="http://api.maps.yahoo.com/Maps/V2/AnnotatedMaps.xsd" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" version="2.0"> <channel> <title>대기 오염 측정소 정보</title> <link>http://www.airkorea.or.kr/airkorea/information/main.jsp?action=station</link> <description/> <geo:lat>37.566661</geo:lat> <geo:long>126.978003</geo:long> <ymaps:ZoomLevel>2</ymaps:ZoomLevel> |