/*
--- zoomTo ( PinRange ) method ---

This method zoom to a pin

Parameter :
PinRange : the position in the pins collection

return: a reference to the pin
355977
function ( PinRange ) {
				var Pin = _Pins [ PinRange ];
				Pin.options.map.setView ( Pin.getLatLng ( ), 17);
				
				return Pin;
			}
303326
public void setZoom(int zoom)
    {
        zoomChanging = true;
        mainMap.setZoom(zoom);
        miniMap.setZoom(mainMap.getZoom() + 4);
        if (sliderReversed)
        {
            zoomSlider.setValue(zoomSlider.getMaximum() - zoom);
        }
        else
        {
            zoomSlider.setValue(zoom);
        }
        zoomChanging = false;
    }
303880
function zoomTo(geom) {
                // when the view is ready
                return self.view.when(function() {
                    // zoom to the buffer geometry
                    return self.view.goTo({
                        target: geom,
                        scale: 24000,
                        tilt: 0,
                        heading: 0
                    }).then(function() {
                        // resolve the promises with the input geometry
                        return geom;
                    });
                });
            }
1275781
function zoomTo(ratio, pivot, _originalEvent) {
    var options = this.options,
        canvasData = this.canvasData;
    var width = canvasData.width,
        height = canvasData.height,
        naturalWidth = canvasData.naturalWidth,
        naturalHeight = canvasData.naturalHeight;


    ratio = Number(ratio);

    if (ratio >= 0 && this.ready && !this.disabled && options.zoomable) {
      var newWidth = naturalWidth * ratio;
      var newHeight = naturalHeight * ratio;

      if (dispatchEvent(this.element, EVENT_ZOOM, {
        originalEvent: _originalEvent,
        oldRatio: width / naturalWidth,
        ratio: newWidth / naturalWidth
      }) === false) {
        return this;
      }

      if (_originalEvent) {
        var pointers = this.pointers;

        var offset = getOffset(this.cropper);
        var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
          pageX: _originalEvent.pageX,
          pageY: _originalEvent.pageY
        };

        // Zoom from the triggering point of the event
        canvasData.left -= (newWidth - width) * ((center.pageX - offset.left - canvasData.left) / width);
        canvasData.top -= (newHeight - height) * ((center.pageY - offset.top - canvasData.top) / height);
      } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
        canvasData.left -= (newWidth - width) * ((pivot.x - canvasData.left) / width);
        canvasData.top -= (newHeight - height) * ((pivot.y - canvasData.top) / height);
      } else {
        // Zoom from the center of the canvas
        canvasData.left -= (newWidth - width) / 2;
        canvasData.top -= (newHeight - height) / 2;
      }

      canvasData.width = newWidth;
      canvasData.height = newHeight;
      this.renderCanvas(true);
    }

    return this;
  }
867110
function ( ) {
				var _Translator;
				if ( typeof module !== 'undefined' && module.exports ) {
					_Translator = require ('./L.Marker.Pin.Translator' );
				}
				else {
					_Translator = L.marker.pin.translator ( );
				}
				var HtmlText = this.options.pinCategory.CategoryName + '<br />';
				if ( this.options.text && 0 < this.options.text.length ) {
					HtmlText += this.options.text + '<br />';
				}
				if ( this.options.address && 0 < this.options.address.length ) {
					HtmlText += 
						_Translator.getText ( 'L.Marker.Pin.Address' ) +
						'&nbsp;: ' +
						this.options.address +
						'<br />';
				}
				if ( this.options.phone && 0 < this.options.phone.length ) {
					HtmlText += 
						_Translator.getText ( 'L.Marker.Pin.Phone' ) +
						'&nbsp;: ' +
						this.options.phone + 
						'<br />';
				}
				if ( this.options.url && 0 < this.options.url.length ) {
					HtmlText += 
						_Translator.getText ( 'L.Marker.Pin.Link' ) +
						'&nbsp: <a href="' +
						this.options.url + '" target="_blank">' +
						this.options.url.slice ( 0, 30 ) +
						'...</a>' +
						'<br />';
				}
				if ( this.options.distance && 0 < this.options.distance ) {
					HtmlText += 
						_Translator.getText ( 'L.Marker.Pin.Distance' ) +
						'&nbsp;: ' +
						this.options.distance.toFixed ( 3 );
				}
				
				return HtmlText;
			}
1059293
public void pointTo(Object baseObject, long baseOffset, int sizeInBytes) {
    // Read the number of elements from the first 8 bytes.
    final long numElements = Platform.getLong(baseObject, baseOffset);
    assert numElements >= 0 : "numElements (" + numElements + ") should >= 0";
    assert numElements <= Integer.MAX_VALUE :
      "numElements (" + numElements + ") should <= Integer.MAX_VALUE";

    this.numElements = (int)numElements;
    this.baseObject = baseObject;
    this.baseOffset = baseOffset;
    this.sizeInBytes = sizeInBytes;
    this.elementOffset = baseOffset + calculateHeaderPortionInBytes(this.numElements);
  }
1364611
function(bounds, zoomChanged, dragging) {
        OpenLayers.Layer.prototype.moveTo.apply(this, arguments);

        if (this.mapObject != null) {

            var newCenter = this.map.getCenter();
            var newZoom = this.map.getZoom();

            if (newCenter != null) {

                var moOldCenter = this.getMapObjectCenter();
                var oldCenter = this.getOLLonLatFromMapObjectLonLat(moOldCenter);

                var moOldZoom = this.getMapObjectZoom();
                var oldZoom= this.getOLZoomFromMapObjectZoom(moOldZoom);

                if (!(newCenter.equals(oldCenter)) || newZoom != oldZoom) {

                    if (!zoomChanged && oldCenter && this.dragPanMapObject && 
                        this.smoothDragPan) {
                        var oldPx = this.map.getViewPortPxFromLonLat(oldCenter);
                        var newPx = this.map.getViewPortPxFromLonLat(newCenter);
                        this.dragPanMapObject(newPx.x-oldPx.x, oldPx.y-newPx.y);
                    } else {
                        var center = this.getMapObjectLonLatFromOLLonLat(newCenter);
                        var zoom = this.getMapObjectZoomFromOLZoom(newZoom);
                        this.setMapObjectCenter(center, zoom, dragging);
                    }
                }
            }
        }
    }
967661
def get_pinned_object(pinned_id):
    """"""

    from ray import ObjectID

    return _from_pinnable(
        ray.get(
            ObjectID(base64.b64decode(pinned_id[len(PINNED_OBJECT_PREFIX):]))))
580610
def for_point(cls, point, zoom):
        """"""
        latitude, longitude = point.latitude_longitude
        return cls.for_latitude_longitude(latitude=latitude, longitude=longitude, zoom=zoom)
1346277
function ( Pin ) {
				for ( var Counter = 0; Counter < _Pins.length ; Counter++ )
				{
					if ( _Pins [ Counter ].options.pinId === Pin.options.pinId ) {
						_Pins.splice ( Counter, 1 );
						this.CallbackFunction ( );
						_updateControl ( );
						
						return Counter;
					}
				}
				
				return -1;
			}
1302853
function _attachPanZoom(container, g, element) {
  var SCALE_TUNER = 1 / 700,
      MIN_SCALE = 0.5,
      MAX_SCALE = 2;

  var prevX = 0,
      prevY = 0,

      panX = PADDING,
      panY = PADDING,
      scale = 1,

      scheduleId = 0;

  /**
   * Transform g to current panX, panY and scale.
   * @param animate {Boolean} Animate the transformation in DURATION time.
   */
  function transform(animate) {
    var base = animate ? g.transition().duration(DURATION) : g;
    base.attr('transform', `translate(${panX}, ${panY}) scale(${scale})`);
  }

  /**
   * Check if the item have moved out of the visible area, and reset if required
   */
  function visibilityCheck() {
    var graphBound = g.node().getBoundingClientRect(),
        containerBound = container[0].getBoundingClientRect();

    if(graphBound.right < containerBound.left ||
      graphBound.bottom < containerBound.top ||
      graphBound.left > containerBound.right ||
      graphBound.top > containerBound.bottom) {
        panX = PADDING;
        panY = PADDING;
        scale = 1;
        transform(true);
    }
  }

  /**
   * Schedule a visibility check and reset if required
   */
  function scheduleVisibilityCheck() {
    if(scheduleId) {
      clearTimeout(scheduleId);
      scheduleId = 0;
    }
    scheduleId = setTimeout(visibilityCheck, 100);
  }

  /**
   * Set pan values
   */
  function onMouseMove(event) {
    panX += event.pageX - prevX;
    panY += event.pageY - prevY;

    transform();

    prevX = event.pageX;
    prevY = event.pageY;
  }
  /**
   * Set zoom values, pan also would change as we are zooming with mouse position as pivote.
   */
  function onWheel(event) {
    var prevScale = scale,

        offset = container.offset(),
        mouseX = event.pageX - offset.left,
        mouseY = event.pageY - offset.top,
        factor = 0;

    scale += event.deltaY * SCALE_TUNER;
    if(scale < MIN_SCALE) {
      scale = MIN_SCALE;
    }
    else if(scale > MAX_SCALE) {
      scale = MAX_SCALE;
    }

    factor = 1 - scale / prevScale;
    panX += (mouseX - panX) * factor;
    panY += (mouseY - panY) * factor;

    transform();
    scheduleVisibilityCheck();

    _tip.reposition();
    event.preventDefault();
  }

  Ember.$(element).on('mousewheel', onWheel);

  container
  .mousedown(function (event){
    prevX = event.pageX;
    prevY = event.pageY;

    container.on('mousemove', onMouseMove);
    container.parent().addClass('panning');
  })
  .mouseup(function (){
    container.off('mousemove', onMouseMove);
    container.parent().removeClass('panning');

    scheduleVisibilityCheck();
  });

  /**
   * A closure to reset/modify panZoom based on an external event
   * @param newPanX {Number}
   * @param newPanY {Number}
   * @param newScale {Number}
   */
  return function(newPanX, newPanY, newScale) {
    var values = {
      panX: panX,
      panY: panY,
      scale: scale
    };

    panX = newPanX === undefined ? panX : newPanX;
    panY = newPanY === undefined ? panY : newPanY;
    scale = newScale === undefined ? scale : newScale;

    transform(true);

    return values;
  };
}
1049555
def zoom_pinch_cb(self, fitsimage, event):
        
        chviewer = self.fv.getfocus_viewer()
        bd = chviewer.get_bindings()

        if hasattr(bd, 'pi_zoom'):
            return bd.pi_zoom(chviewer, event)

        return False
420427
def read(pin):
    '''
    '''
    f = _open[pin].value
    out = int(_read(f))
    log.debug("Read {0}: {1}".format(pin, out))
    return out
1220177
private static boolean closerToZoomIn(double[] lengths, double length,
			int lengthIndex) {

		// Zoom level distance to the zoomed in length
		double zoomInDistance = Math.log(length / lengths[lengthIndex - 1])
				/ Math.log(2);

		// Zoom level distance to the zoomed out length
		double zoomOutDistance = Math.log(length / lengths[lengthIndex])
				/ Math.log(.5);

		boolean zoomIn = zoomInDistance < zoomOutDistance;

		return zoomIn;
	}
992180
function ( Map ) {
				_Map = Map;
				
				var MainDiv = L.DomUtil.create ( 'div', 'PinControl-MainDiv' );
				MainDiv.id = 'PinControl-MainDiv';
				var PinsDiv;
				
				if ( _ButtonsOnTop ){
					_createButtonsDiv ( MainDiv, 0 === _Pins.length );
					PinsDiv = _createPinsDiv ( MainDiv );
				}
				else{
					PinsDiv = _createPinsDiv ( MainDiv );
					_createButtonsDiv ( MainDiv, 0 === _Pins.length );
				}

				if ( 0 === _Pins.length  ) {
					PinsDiv.setAttribute("style", "visibility : hidden; width: 0; min-width: 0; height: 0; margin: 0.5em;" );
					PinsDiv.dataset.minimized = 'yes';
				}
				
				return MainDiv;
			}
984604
function getPinsFromBoard(board, paginate, callback) {
        var pins = [];
        var pinDateMap = {};

        async.parallel([
            function (asyncCallback) {
                getCache(board, true, function (cacheData) {
                    if (cacheData === null) {
                        // Get data and put it in the cache
                        get('https://api.pinterest.com/v3/pidgets/boards/' + username + '/' + board.replace(/#/g, '') + '/pins/', true, function (response) {
                            putCache(board, JSON.stringify(response));
                            pins = response.data ? response.data.pins : [];
                            asyncCallback();
                        });
                    } else {
                        pins = cacheData.data ? cacheData.data.pins : [];
                        asyncCallback();
                    }
                });
            },
            function (asyncCallback) {
                if (!obtainDates) {
                    asyncCallback();
                    return;
                }

                getDatesForBoardPinsFromRss(username, board, function (dates) {
                    pinDateMap = dates;
                    asyncCallback();
                    return;
                });
            }],
            function (err) {
                if (err) { throw err; }
                var pinIdsThatNeedDates = [];
                for (var i = 0; i < pins.length; i++) {
                    pins[i].created_at = null;
                    pins[i].created_at_source = null;
                    if (pinDateMap[pins[i].id]) {
                        pins[i].created_at = pinDateMap[pins[i].id];
                        pins[i].created_at_source = 'rss';
                    } else {
                        pinIdsThatNeedDates.push(pins[i].id);
                    }
                }

                if (obtainDates) {
                    getDatesForPinsFromScraping(pinIdsThatNeedDates, null, function (scrapedPinDateMap) {
                        for (var i = 0; i < pins.length; i++) {
                            if (scrapedPinDateMap[pins[i].id] && scrapedPinDateMap[pins[i].id].date) {
                                pins[i].created_at = scrapedPinDateMap[pins[i].id].date;
                                pins[i].created_at_source = scrapedPinDateMap[pins[i].id].source;
                            }
                        }
                        if (paginate) {
                            pins = buildResponse(pins);
                        }

                        callback(pins);
                        return;
                    });
                } else {
                    if (paginate) {
                        pins = buildResponse(pins);
                    }

                    callback(pins);
                    return;
                }
            }
        );
    }
687773
function ( ) {
			if ( ! options.exist ) {
				// http request to Nominatim to performs the Geocoding of the pin.
				// To avoid to much call to Nominatim with the same position,
				// the call is only performed when it's a new pin
				var NominatimUrl = 
					'http://nominatim.openstreetmap.org/reverse?format=json&lat=' +
					latlng.lat +
					'&lon=' +
					latlng.lng +
					'&zoom=' +
					Map.getZoom ( ) +
					'&addressdetails=1&accept-language=' +
					_Translator.UserLanguage +
					'&osm_type=W';
				var XmlHttpRequest = new XMLHttpRequest ( );
				XmlHttpRequest.onreadystatechange = function ( ) { 
					if ( XmlHttpRequest.readyState == 4 && XmlHttpRequest.status == 200 ) {
						_NominatimCallback ( XmlHttpRequest.responseText );
					}
				};  
				XmlHttpRequest.open ( "GET", NominatimUrl, true );
				XmlHttpRequest.send ( null );
			}
		}