Permalink
Browse files

fixed kml feed

  • Loading branch information...
1 parent a9f22c8 commit 73c0c6c4fa00d4fbc59a13cf98194acd6dbd1c5c @trey0 trey0 committed Aug 23, 2011
Showing with 32 additions and 20 deletions.
  1. +16 −10 geocamLens/ViewKml.py
  2. +13 −8 geocamLens/models.py
  3. +3 −2 geocamLens/urls.py
View
@@ -8,6 +8,8 @@
import datetime
import sys
+from django.core import urlresolvers
+
from geocamUtil import KmlUtil
from geocamCore.models import Feature
@@ -20,8 +22,9 @@ def build_absolute_uri(self, text):
class ViewKml(object):
def kmlGetStartSessionKml(self, request, sessionId):
- quotedId = urllib.quote_plus(sessionId)
- absUrl = request.build_absolute_uri('%skml/%s/initial.kml' % (settings.SCRIPT_NAME, quotedId))
+ urlPath = urlresolvers.reverse('geocamLens_kmlGetSessionResponse',
+ args=[sessionId, 'initial'])
+ absUrl = request.build_absolute_uri(urlPath)
if settings.GEOCAM_LENS_KML_FLY_TO_VIEW:
flyToView = '<flyToView>1</flyToView>'
else:
@@ -68,12 +71,14 @@ def kmlGetInitialKml(self, request, sessionId):
allFeaturesFolder = self.kmlGetAllFeaturesFolder(request,
session.getSearchQuery(),
newUtime)
- quotedId = urllib.quote_plus(sessionId)
- updateUrl = request.build_absolute_uri('%skml/%s/update.kml' % (settings.SCRIPT_NAME, quotedId))
- return ("""
+ result = ("""
<Document id="allFeatures">
<name>%(GEOCAM_CORE_SITE_TITLE)s</name>
-
+""" % dict(GEOCAM_CORE_SITE_TITLE=settings.GEOCAM_CORE_SITE_TITLE))
+ if 0:
+ quotedId = urllib.quote_plus(sessionId)
+ updateUrl = request.build_absolute_uri('%skml/%s/update.kml' % (settings.SCRIPT_NAME, quotedId))
+ result += ("""
<NetworkLink>
<name>Update</name>
<Link>
@@ -82,13 +87,14 @@ def kmlGetInitialKml(self, request, sessionId):
<refreshInterval>30</refreshInterval>
</Link>
</NetworkLink>
-
+""" % dict(updateUrl=updateUrl))
+
+ result += ("""
%(allFeaturesFolder)s
</Document>
-""" % dict(GEOCAM_CORE_SITE_TITLE=settings.GEOCAM_CORE_SITE_TITLE,
- updateUrl=updateUrl,
- allFeaturesFolder=allFeaturesFolder))
+""" % dict(allFeaturesFolder=allFeaturesFolder))
+ return result
def kmlGetUpdateKml(self, request, sessionId):
# FIX: implement me -- can use old version of geocam for reference
View
@@ -216,12 +216,13 @@ def getCaptionHtml(self):
return ''
def getBalloonHtml(self, request):
- dw, dh = self.getThumbSize(settings.GEOCAM_CORE_DESC_THUMB_SIZE[0])
+ result = ['<div>\n']
+
viewerUrl = request.build_absolute_uri(self.getViewerUrl())
- thumbnailUrl = request.build_absolute_uri(self.getThumbnailUrl(settings.GEOCAM_CORE_DESC_THUMB_SIZE[0]))
- captionHtml = self.getCaptionHtml()
- return ("""
-<div>
+ if self.widthPixels != 0:
+ dw, dh = self.getThumbSize(settings.GEOCAM_CORE_DESC_THUMB_SIZE[0])
+ thumbnailUrl = request.build_absolute_uri(self.getThumbnailUrl(settings.GEOCAM_CORE_DESC_THUMB_SIZE[0]))
+ result.append("""
<a href="%(viewerUrl)s"
title="Show high-res view">
<img
@@ -231,13 +232,17 @@ def getBalloonHtml(self, request):
border="0"
/>
</a>
- %(captionHtml)s
-</div>
""" % dict(viewerUrl=viewerUrl,
thumbnailUrl=thumbnailUrl,
- captionHtml=captionHtml,
dw=dw,
dh=dh))
+ else:
+ result.append("""
+<div><a href="%(viewerUrl)s">Show detail view</a></div>
+""" % dict(viewerUrl=viewerUrl))
+ result.append(self.getCaptionHtml())
+ result.append('</div>\n')
+ return ''.join(result)
def getXmpVals(self, storePath):
xmp = Xmp(storePath)
View
@@ -17,11 +17,12 @@
# kml
(r'^kml/startSession.kml(?:\?[^/]*)?$', views.kmlStartSession,
- {'readOnly': True}),
+ {'readOnly': True}, 'geocamLens_kmlStartSession'),
(r'^kml/([^/]+)/([^/]+)\.kml$', views.kmlGetSessionResponse,
# google earth can't handle django challenge
{'challenge': 'digest',
- 'readOnly': True}),
+ 'readOnly': True},
+ 'geocamLens_kmlGetSessionResponse'),
# features
(r'^features.json', views.featuresJson, {'readOnly': True}),

0 comments on commit 73c0c6c

Please sign in to comment.