Example #1
0
 def kmlGetSessionResponse(self, request, quotedId, method):
     sessionId = urllib.unquote_plus(quotedId)
     #print 'sessionId:', sessionId
     #print 'method:', method
     if method == 'initial':
         return KmlUtil.wrapKmlDjango(self.kmlGetInitialKml(request, sessionId))
     elif method == 'update':
         return KmlUtil.wrapKmlDjango(self.kmlGetUpdateKml(request, sessionId))
     else:
         raise Exception('method must be "initial" or "update"')
Example #2
0
 def kmlGetSessionResponse(self, request, quotedId, method):
     sessionId = urllib.unquote_plus(quotedId)
     #print 'sessionId:', sessionId
     #print 'method:', method
     if method == 'initial':
         return KmlUtil.wrapKmlDjango(
             self.kmlGetInitialKml(request, sessionId))
     elif method == 'update':
         return KmlUtil.wrapKmlDjango(
             self.kmlGetUpdateKml(request, sessionId))
     else:
         raise Exception('method must be "initial" or "update"')
Example #3
0
def feed_messages_kml(request, author_username=None):
    messages, _message_count = get_messages(request, author_username)
    out = StringIO()
    iconHref = request.build_absolute_uri(settings.MEDIA_URL + 'geocamMemo/icons/note.png')
    out.write("""
<Document>
  <Style id="memoMarker">
    <IconStyle>
      <Icon>
        <href>%(iconHref)s</href>
      </Icon>
    </IconStyle>
  </Style>
    """ % dict(iconHref=iconHref))
    for msg in messages:
        out.write(msg.getKml())
    out.write("</Document>")
    return KmlUtil.wrapKmlDjango(out.getvalue())
Example #4
0
def feed_messages_kml(request, recipient_username=None, author_username=None):
    _timestamp, messages, _message_count = get_messages(request, recipient_username, author_username)
    out = StringIO()
    iconHref = request.build_absolute_uri(settings.MEDIA_URL + 'geocamTalk/icons/word_bubble.png')
    out.write("""
<Document>
  <Style id="talkMarker">
    <IconStyle>
      <Icon>
        <href>%(iconHref)s</href>
      </Icon>
    </IconStyle>
  </Style>
    """ % dict(iconHref=iconHref))
    for msg in messages:
        out.write(msg.getKml())
    out.write("</Document>")
    return KmlUtil.wrapKmlDjango(out.getvalue())
Example #5
0
 def kmlStartSession(self, request):
     searchQuery = request.REQUEST.get('q', None)
     sessionId = GoogleEarthSession.getSessionId(searchQuery)
     print >> sys.stderr, "ViewKml: started session %s" % sessionId
     return KmlUtil.wrapKmlDjango(
         self.kmlGetStartSessionKml(request, sessionId))
Example #6
0
 def kmlFeed(self, request):
     return KmlUtil.wrapKmlDjango(self.kmlGetInitialKml(request))
Example #7
0
 def kmlStartSession(self, request):
     searchQuery = request.REQUEST.get('q', None)
     sessionId = GoogleEarthSession.getSessionId(searchQuery)
     print >>sys.stderr, "ViewKml: started session %s" % sessionId
     return KmlUtil.wrapKmlDjango(self.kmlGetStartSessionKml(request, sessionId))
Example #8
0
def mapTileKml(request, layerId, dayCode, level, x, y):
    level = int(level)
    x = int(x)
    y = int(y)

    # make links to sub-tiles if necessary
    if level < settings.XGDS_PLOT_MAP_ZOOM_RANGE[1] - 1:
        linkList = []
        subLevel = level + 1
        for offset in ((0, 0), (0, 1), (1, 0), (1, 1)):
            subX = 2 * x + offset[0]
            subY = 2 * y + offset[1]
            subUrl = (request.build_absolute_uri(
                reverse('xgds_plot_mapTileKml',
                        args=[layerId, dayCode, subLevel, subX, subY])))
            linkList.append("""
<NetworkLink>
  <Region>
    %(box)s
    <Lod>
      <minLodPixels>%(minLodPixels)s</minLodPixels>
      <maxLodPixels>-1</maxLodPixels>
    </Lod>
  </Region>
  <Link>
    <href>%(subUrl)s</href>
    <viewRefreshMode>onRegion</viewRefreshMode>
  </Link>
</NetworkLink>
""" % dict(box=tile.getLatLonAltBox(tile.getTileBounds(subLevel, subX, subY)),
            subUrl=subUrl,
            minLodPixels=settings.XGDS_PLOT_MAP_PIXELS_PER_TILE // 2))
        netLinks = '\n'.join(linkList)
    else:
        netLinks = ''

    #tileUrl = request.build_absolute_uri(reverse('mapTileImage', args=[level, x, y]))
    tileUrl = request.build_absolute_uri(
        '%s/%s/%s/%d/%d/%d.png' %
        (MAP_DATA_PATH, layerId, dayCode, level, x, y))
    bounds = tile.getTileBounds(level, x, y)
    minZoom, maxZoom = settings.XGDS_PLOT_MAP_ZOOM_RANGE
    if level < maxZoom - 1:
        maxLodPixels = settings.XGDS_PLOT_MAP_PIXELS_PER_TILE * 2
    else:
        maxLodPixels = -1
    if level > minZoom:
        minLodPixels = settings.XGDS_PLOT_MAP_PIXELS_PER_TILE // 2
    else:
        minLodPixels = -1
    return KmlUtil.wrapKmlDjango("""
<Folder>
  %(netLinks)s
  <GroundOverlay>
    <Icon>
      <href>%(tileUrl)s</href>
      <refreshMode>onInterval</refreshMode>
      <refreshInterval>5</refreshInterval>
    </Icon>
    %(llBox)s
    <drawOrder>%(level)s</drawOrder>
    <Region>
      %(llaBox)s
      <Lod>
        <minLodPixels>%(minLodPixels)s</minLodPixels>
        <maxLodPixels>%(maxLodPixels)s</maxLodPixels>
      </Lod>
    </Region>
  </GroundOverlay>
  <Style>
    <ListStyle>
      <listItemType>checkHideChildren</listItemType>
    </ListStyle>
  </Style>
</Folder>
""" % dict(netLinks=netLinks,
           llBox=tile.getLatLonBox(bounds),
           llaBox=tile.getLatLonAltBox(bounds),
           tileUrl=tileUrl,
           level=level,
           minLodPixels=minLodPixels,
           maxLodPixels=maxLodPixels))
Example #9
0
def mapIndexKml(request):
    out = StringIO()
    writeMapIndexKml(request, out)
    return KmlUtil.wrapKmlDjango(out.getvalue())
Example #10
0
 def kmlFeed(self, request):
     return KmlUtil.wrapKmlDjango(self.kmlGetInitialKml(request))
Example #11
0
def mapTileKml(request, layerId, dayCode, level, x, y):
    level = int(level)
    x = int(x)
    y = int(y)

    # make links to sub-tiles if necessary
    if level < settings.XGDS_PLOT_MAP_ZOOM_RANGE[1] - 1:
        linkList = []
        subLevel = level + 1
        for offset in ((0, 0), (0, 1), (1, 0), (1, 1)):
            subX = 2 * x + offset[0]
            subY = 2 * y + offset[1]
            subUrl = (request.build_absolute_uri
                      (reverse
                       ('xgds_plot_mapTileKml',
                        args=[layerId, dayCode, subLevel, subX, subY])))
            linkList.append("""
<NetworkLink>
  <Region>
    %(box)s
    <Lod>
      <minLodPixels>%(minLodPixels)s</minLodPixels>
      <maxLodPixels>-1</maxLodPixels>
    </Lod>
  </Region>
  <Link>
    <href>%(subUrl)s</href>
    <viewRefreshMode>onRegion</viewRefreshMode>
  </Link>
</NetworkLink>
""" %
                            dict(box=tile.getLatLonAltBox(tile.getTileBounds(subLevel, subX, subY)),
                                 subUrl=subUrl,
                                 minLodPixels=settings.XGDS_PLOT_MAP_PIXELS_PER_TILE // 2))
        netLinks = '\n'.join(linkList)
    else:
        netLinks = ''

    #tileUrl = request.build_absolute_uri(reverse('mapTileImage', args=[level, x, y]))
    tileUrl = request.build_absolute_uri('%s/%s/%s/%d/%d/%d.png'
                                         % (MAP_DATA_PATH,
                                            layerId,
                                            dayCode,
                                            level, x, y))
    bounds = tile.getTileBounds(level, x, y)
    minZoom, maxZoom = settings.XGDS_PLOT_MAP_ZOOM_RANGE
    if level < maxZoom - 1:
        maxLodPixels = settings.XGDS_PLOT_MAP_PIXELS_PER_TILE * 2
    else:
        maxLodPixels = -1
    if level > minZoom:
        minLodPixels = settings.XGDS_PLOT_MAP_PIXELS_PER_TILE // 2
    else:
        minLodPixels = -1
    return KmlUtil.wrapKmlDjango("""
<Folder>
  %(netLinks)s
  <GroundOverlay>
    <Icon>
      <href>%(tileUrl)s</href>
      <refreshMode>onInterval</refreshMode>
      <refreshInterval>5</refreshInterval>
    </Icon>
    %(llBox)s
    <drawOrder>%(level)s</drawOrder>
    <Region>
      %(llaBox)s
      <Lod>
        <minLodPixels>%(minLodPixels)s</minLodPixels>
        <maxLodPixels>%(maxLodPixels)s</maxLodPixels>
      </Lod>
    </Region>
  </GroundOverlay>
  <Style>
    <ListStyle>
      <listItemType>checkHideChildren</listItemType>
    </ListStyle>
  </Style>
</Folder>
""" % dict(netLinks=netLinks,
           llBox=tile.getLatLonBox(bounds),
           llaBox=tile.getLatLonAltBox(bounds),
           tileUrl=tileUrl,
           level=level,
           minLodPixels=minLodPixels,
           maxLodPixels=maxLodPixels))
Example #12
0
def mapIndexKml(request):
    out = StringIO()
    writeMapIndexKml(request, out)
    return KmlUtil.wrapKmlDjango(out.getvalue())