Download height-map
436615
function downloadHeightMap() {
    console.log('downloadHeightMap:', file.name);
    var heightMapFile = new Blob([heightMap], { type: 'text/plain;charset=utf-8' });
    saveAs(heightMapFile, file.name + '.height-map.txt');
}
605576
def js_map_loader(url):
    

    hdr = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7'}
    req = urllib.request.Request(url, headers=hdr)
    page = urlopen(req)
    result = page.read().decode('utf-8')
    result = result[len(re.search(r'^.* = ', result).group()):]

    return json.loads(result)
965739
function getDownloadlink(map,title){
	var url = decodeURIComponent(map.url),
		sig = (map.s || map.sig)? '&signature='+(map.s || map.sig) : '',
		tit = '&title='+title;
	return url+sig+tit;
}
982357
function getNaturalHeight(elementList, factor) {
    var q = {'$position': 'absolute', '$visibility': 'hidden', '$display': 'block', '$height': _null};
    var oldStyles = elementList['get'](q);
    var h = elementList['set'](q)['get']('clientHeight');
    elementList['set'](oldStyles);
    return h*factor + 'px';
  }
1356818
def _get_ui_content(self, cli, width, height):
        
        def get_content():
            return self.content.create_content(cli, width=width, height=height)

        key = (cli.render_counter, width, height)
        return self._ui_content_cache.get(key, get_content)
1089539
def _get_topMargin(self):
        
        bounds = self.bounds
        if bounds is None:
            return None
        xMin, yMin, xMax, yMax = bounds
        return self.height - yMax
509613
function() {
        var res = this.map.getResolution();
        if (!res) {
            return;
        }

        var curMapUnits = this.map.getUnits();
        var inches = OpenLayers.INCHES_PER_UNIT;

        // convert maxWidth to map units
        var maxSizeData = this.maxWidth * res * inches[curMapUnits];
        var geodesicRatio = 1;
        if(this.geodesic === true) {
            var maxSizeGeodesic = (this.map.getGeodesicPixelSize().w ||
                0.000001) * this.maxWidth;
            var maxSizeKilometers = maxSizeData / inches["km"];
            geodesicRatio = maxSizeGeodesic / maxSizeKilometers;
            maxSizeData *= geodesicRatio;
        }

        // decide whether to use large or small scale units     
        var topUnits;
        var bottomUnits;
        if(maxSizeData > 100000) {
            topUnits = this.topOutUnits;
            bottomUnits = this.bottomOutUnits;
        } else {
            topUnits = this.topInUnits;
            bottomUnits = this.bottomInUnits;
        }

        // and to map units units
        var topMax = maxSizeData / inches[topUnits];
        var bottomMax = maxSizeData / inches[bottomUnits];

        // now trim this down to useful block length
        var topRounded = this.getBarLen(topMax);
        var bottomRounded = this.getBarLen(bottomMax);

        // and back to display units
        topMax = topRounded / inches[curMapUnits] * inches[topUnits];
        bottomMax = bottomRounded / inches[curMapUnits] * inches[bottomUnits];

        // and to pixel units
        var topPx = topMax / res / geodesicRatio;
        var bottomPx = bottomMax / res / geodesicRatio;
        
        // now set the pixel widths
        // and the values inside them
        
        if (this.eBottom.style.visibility == "visible"){
            this.eBottom.style.width = Math.round(bottomPx) + "px"; 
            this.eBottom.innerHTML = bottomRounded + " " + bottomUnits ;
        }
            
        if (this.eTop.style.visibility == "visible"){
            this.eTop.style.width = Math.round(topPx) + "px";
            this.eTop.innerHTML = topRounded + " " + topUnits;
        }
        
    }
490005
def area_to_image(self, lat, lon, width, height, ground_width, zoom=None, ordered=True):
        ''''''

        img = np.zeros((height,width,3), np.uint8)

        tlist = self.area_to_tile_list(lat, lon, width, height, ground_width, zoom)

        # order the display by distance from the middle, so the download happens
        # close to the middle of the image first
        if ordered:
            (midlat, midlon) = self.coord_from_area(width/2, height/2, lat, lon, width, ground_width)
            tlist.sort(key=lambda d: d.distance(midlat, midlon), reverse=True)

        for t in tlist:
            scaled_tile = self.scaled_tile(t)

            w = min(width - t.dstx, scaled_tile.shape[1] - t.srcx)
            h = min(height - t.dsty, scaled_tile.shape[0] - t.srcy)
            if w > 0 and h > 0:
                scaled_tile_roi = scaled_tile[t.srcy:t.srcy+h, t.srcx:t.srcx+w]
                img[t.dsty:t.dsty+h, t.dstx:t.dstx+w] = scaled_tile_roi.copy()

        # return as an RGB image
        img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        return img
40928
function() {
        var style = this.getTile().style,
            size = this.frame ? this.size :
                this.layer.getImageSize(this.bounds),
            ratio = 1;
        if (this.layer instanceof OpenLayers.Layer.Grid) {
            ratio = this.layer.getServerResolution() / this.layer.map.getResolution();
        }
        style.left = this.position.x + "px";
        style.top = this.position.y + "px";
        style.width = Math.round(ratio * size.w) + "px";
        style.height = Math.round(ratio * size.h) + "px";
    }
374474
function(index, height) {
      var currentPos = (this.dimensions[index] || {}).primaryPos || 0;
      this.currentIndex = index;

      this.hasPrevIndex = index > 0;
      if (this.hasPrevIndex) {
        this.previousPos = Math.max(
          currentPos - this.dimensions[index - 1].primarySize,
          this.dimensions[index - 1].primaryPos
        );
      }
      this.hasNextIndex = index + 1 < this.dataSource.getLength();
      if (this.hasNextIndex) {
        this.nextPos = Math.min(
          currentPos + this.dimensions[index + 1].primarySize,
          this.dimensions[index + 1].primaryPos
        );
      }
    }
1071964
function (data, width, height, normalize, colorFunc, isInRange) {
        var brush = this._getBrush();
        var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
        var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
        var r = this.pointSize + this.blurSize;

        var canvas = this.canvas;
        var ctx = canvas.getContext('2d');
        var len = data.length;
        canvas.width = width;
        canvas.height = height;
        for (var i = 0; i < len; ++i) {
            var p = data[i];
            var x = p[0];
            var y = p[1];
            var value = p[2];

            // calculate alpha using value
            var alpha = normalize(value);

            // draw with the circle brush with alpha
            ctx.globalAlpha = alpha;
            ctx.drawImage(brush, x - r, y - r);
        }

        if (!canvas.width || !canvas.height) {
            // Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
            // 'CanvasRenderingContext2D': The source height is 0."
            return canvas;
        }

        // colorize the canvas using alpha value and set with gradient
        var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);

        var pixels = imageData.data;
        var offset = 0;
        var pixelLen = pixels.length;
        var minOpacity = this.minOpacity;
        var maxOpacity = this.maxOpacity;
        var diffOpacity = maxOpacity - minOpacity;

        while (offset < pixelLen) {
            var alpha = pixels[offset + 3] / 256;
            var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
            // Simple optimize to ignore the empty data
            if (alpha > 0) {
                var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
                // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
                alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
                pixels[offset++] = gradient[gradientOffset];
                pixels[offset++] = gradient[gradientOffset + 1];
                pixels[offset++] = gradient[gradientOffset + 2];
                pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
            }
            else {
                offset += 4;
            }
        }
        ctx.putImageData(imageData, 0, 0);

        return canvas;
    }
76140
function(r) {
			geo.origin.size.height = r.height,
				geo.origin.windowOffset.left = r.left,
				geo.origin.windowOffset.top = r.top,
				geo.origin.size.width = r.width
		}
47318
function(height, angle, dist) {
    var z = dist * Math.cos(angle);
    var wallH = this.height * height / z;
    var bottom = this.height / 2 * (1 + 1 / z);

    return {
      top: bottom - wallH,
      height: wallH
    };
  }
227149
def parse_map_Ns(self):
        """"""
        Kd = os.path.join(self.dir, " ".join(self.values[1:]))
        self.this_material.set_texture_specular_highlight(Kd)
774300
function() {
        if (arguments.length > 0) {
            var bounds = this.adjustBounds(arguments[0]);
            var res = this.getServerResolution();
            var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
            var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h));
            var z = this.getZoomForResolution( res );
            var w = this.standardTileSize;
            var h = this.standardTileSize;
            if (x == this.tierSizeInTiles[z].w -1 ) {
                var w = this.tierImageSize[z].w % this.standardTileSize;
            }
            if (y == this.tierSizeInTiles[z].h -1 ) {
                var h = this.tierImageSize[z].h % this.standardTileSize;
            }
            return (new OpenLayers.Size(w, h));
        } else {
            return this.tileSize;
        }
    }
200733
function measure() {
			if (!tw || !th) {
				var wrapper = $('.plupload_file:eq(0)', self.filelist);
				tw = wrapper.outerWidth(true);
				th = wrapper.outerHeight(true);
			}

			var aw = self.content.width(), ah = self.content.height();
			cols = Math.floor(aw / tw);
			num =  cols * (Math.ceil(ah / th) + 1);
		}
18793
def map(self, width, height):
        
        template = ti.load(os.path.join(script_dir, 'assets', 'template.tmx'))['map0']
        #template.set_view(0, 0, template.px_width, template.px_height)
        template.set_view(0, 0, width*template.tw, height*template.th)

        # TODO: Save the generated map.
        #epoch = int(time.time())
        #filename = 'map_' + str(epoch) + '.tmx'

        # Draw borders
        border_x = template.cells[width]
        for y in xrange(0,height+1):
            border_x[y].tile = template.cells[0][0].tile

        for x in xrange(0,width):
            template.cells[x][height].tile = template.cells[0][0].tile

        # Start within borders
        #self.recursive_division(template.cells, 3, (template.px_width/template.tw)-1, (template.px_height/template.th)-1, 0, 0)
        self.recursive_division(template.cells, 3, width, height, 0, 0)

        return template