def getMetadata(self): response = util.fetchJson("%s?key=%s" % (self.metadataPath, self.bingMapsKey)) if "errorDetails" not in response: data = response["resourceSets"][0]["resources"][0] self.tileWidth = data["imageWidth"] self.tileHeight = data["imageHeight"] self.imageUrl = data["imageUrl"] self.imageUrlSubdomains = data["imageUrlSubdomains"] self.zoomMax = data["zoomMax"] self.numSubdomains = len(self.imageUrlSubdomains) else: logging.error("Unknown response from the server") sys.exit(-1)
def getMaxZoom(self, bbox): (bottom, left) = util.toSphMercator(bbox[1], bbox[0]) (top, right) = util.toSphMercator(bbox[3], bbox[2]) (centerY, centerX) = util.toGeographic((top+bottom)/2, (left+right)/2) zoom = self.zoomMax while True: response = util.fetchJson("%s/%s,%s?zl=%s&key=%s" % (self.metadataPath, centerY, centerX, zoom, self.bingMapsKey)) if "errorDetails" not in response: data = response["resourceSets"][0]["resources"][0] if data["vintageEnd"]: break else: logging.error("Unknown response from the server") sys.exit(-1) zoom = zoom-1 return zoom