Determines the index in the array (1D or 2D) where the
    lat/lon point is
421691
def _get_lat_lon_indices(lsm_lat_array, lsm_lon_array, lat, lon):
    
    if lsm_lat_array.ndim == 2 and lsm_lon_array.ndim == 2:
        lsm_lat_indices_from_lat, lsm_lon_indices_from_lat = \
            np.where((lsm_lat_array == lat))
        lsm_lat_indices_from_lon, lsm_lon_indices_from_lon = \
            np.where((lsm_lon_array == lon))

        index_lsm_grid_lat = np.intersect1d(lsm_lat_indices_from_lat,
                                            lsm_lat_indices_from_lon)[0]
        index_lsm_grid_lon = np.intersect1d(lsm_lon_indices_from_lat,
                                            lsm_lon_indices_from_lon)[0]

    elif lsm_lat_array.ndim == 1 and lsm_lon_array.ndim == 1:
        index_lsm_grid_lon = np.where(lsm_lon_array == lon)[0][0]
        index_lsm_grid_lat = np.where(lsm_lat_array == lat)[0][0]
    else:
        raise IndexError("Lat/Lon lists have invalid dimensions. "
                         "Only 1D or 2D arrays allowed ...")

    return index_lsm_grid_lat, index_lsm_grid_lon
31656
def _first_fill_value_loc(self):
        
        if len(self) == 0 or self.sp_index.npoints == len(self):
            return -1

        indices = self.sp_index.to_int_index().indices
        if not len(indices) or indices[0] > 0:
            return 0

        diff = indices[1:] - indices[:-1]
        return np.searchsorted(diff, 2) + 1
781267
function findLastCommonIndex(xs, ys) {
    for (let i = Math.min(xs.length, ys.length) - 1; i >= 0; --i) {
        if (xs[i] === ys[i]) {
            return i
        }
    }
    return -1
}
34842
private void locate(double[] array, int left, int right, int index) {

        int mid = (left + right) / 2;
        //System.out.println(left+" to "+right+" ("+mid+")");

        if (right == left) {
            //System.out.println("* "+array[targetIndex]);
            //result=array[targetIndex];
            return;
        }

        if (left < right) {
            double s = array[mid];
            int i = left - 1;
            int j = right + 1;

            while (true) {
                while (array[++i] < s);
                while (array[--j] > s);
                if (i >= j)
                    break;
                swap(array, i, j);
            }

            //System.out.println("2 parts: "+left+"-"+(i-1)+" and "+(j+1)+"-"+right);

            if (i > index) {
                // the target index in the left partition
                //System.out.println("left partition");
                locate(array, left, i - 1, index);
            } else {
                // the target index in the right partition
                //System.out.println("right partition");
                locate(array, j + 1, right, index);
            }
        }
    }
1228047
def _get_indexers_coords_and_indexes(self, indexers):
        
        from .dataarray import DataArray

        coord_list = []
        indexes = OrderedDict()
        for k, v in indexers.items():
            if isinstance(v, DataArray):
                v_coords = v.coords
                if v.dtype.kind == 'b':
                    if v.ndim != 1:  # we only support 1-d boolean array
                        raise ValueError(
                            '{:d}d-boolean array is used for indexing along '
                            'dimension {!r}, but only 1d boolean arrays are '
                            'supported.'.format(v.ndim, k))
                    # Make sure in case of boolean DataArray, its
                    # coordinate also should be indexed.
                    v_coords = v[v.values.nonzero()[0]].coords

                coord_list.append({d: v_coords[d].variable for d in v.coords})
                indexes.update(v.indexes)

        # we don't need to call align() explicitly or check indexes for
        # alignment, because merge_variables already checks for exact alignment
        # between dimension coordinates
        coords = merge_variables(coord_list)
        assert_coordinate_consistent(self, coords)

        # silently drop the conflicted variables.
        attached_coords = OrderedDict(
            (k, v) for k, v in coords.items() if k not in self._variables
        )
        attached_indexes = OrderedDict(
            (k, v) for k, v in indexes.items() if k not in self._variables
        )
        return attached_coords, attached_indexes
1293483
function findIndex (array, predicate) {
  for (let i = 0; i < array.length; i++) {
    if (predicate(array[i])) return i
  }
  return -1
}
621647
function locationToPoint(loc) {
  var lat, lng, radius, cosLat, sinLat, cosLng, sinLng, x, y, z;

  lat = loc.lat * Math.PI / 180.0;
  lng = loc.lng * Math.PI / 180.0;
  radius = loc.elv + getRadius(lat);
  cosLng = Math.cos(lng);
  sinLng = Math.sin(lng);
  cosLat = Math.cos(lat);
  sinLat = Math.sin(lat);
  x = cosLng * cosLat * radius;
  y = sinLng * cosLat * radius;
  z = sinLat * radius;

  return { x: x, y: y, z: z, radius: radius };
}
1108291
void getXY(int cluster, Point2D pt) {
		int vindex = getClusterVertexIndex_(cluster);
		m_shape.getXYWithIndex(vindex, pt);
	}
1366565
def coord(self, offset=(0,0)):
		''''''
		(tilex, tiley) = self.tile
		(offsetx, offsety) = offset
		world_tiles = 1<<self.zoom
		x = ( tilex + 1.0*offsetx/TILES_WIDTH ) / (world_tiles/2.) - 1
		y = ( tiley + 1.0*offsety/TILES_HEIGHT) / (world_tiles/2.) - 1
		lon = x * 180.0
		y = math.exp(-y*2*math.pi)
		e = (y-1)/(y+1)
		lat = 180.0/math.pi * math.asin(e)
		return (lat, lon)
1092386
def coords(self):
        
        x, y = ("lat", "lng") if self.order == "lat" else ("lng", "lat")
        try:
            return (self["location"][x], self["location"][y])

        except KeyError:
            return None
4822
function pos2index(pos, prelen, linelen) {
  return Number(prelen) + Number(pos) -1 + Math.floor( (pos -1)/linelen );
}
572333
def lon_lat(value):
    
    lon, lat = value.split()
    return longitude(lon), latitude(lat)
835715
def coordinates_to_index(self, x, y, x_shift=0, y_shift=0):
        
        target_x = x + x_shift
        target_y = y + y_shift
        self.validate_coordinates(target_x, target_y)
        index = (target_y * self.length) + target_x
        return index
149106
protected void determineCoordinates(){
		for (int i=0; i<numPoints; i++){
			coordinates.set(i, getPointCoordinate(i));
		}
	}
771048
def get_sets_index(self):
        
        index = []
        for i, place in enumerate(self):
            index.append(np.ones(place.set_of_points.shape[0])*i)
        return np.concatenate(index).astype(int)
1351087
function findClosestPointIndexWithinRadius(points, x, y, radiusThreshold) {
    let closestIdx;
    let closestDist = Number.MAX_VALUE;
    points.forEach((d, idx) => {
      let distSqrd = Math.pow(d.x - x, 2) + Math.pow(d.y - y, 2); // changeto: (d.x - x)**2 + (d.y - y)**2;
      if (distSqrd < closestDist && distSqrd < radiusThreshold) {
        closestIdx = idx;
        closestDist = distSqrd;
      }
    });
    return closestIdx;
  }
1107311
def get_position():
    
    e = Quartz.CGEventCreate(None)
    point = Quartz.CGEventGetLocation(e)
    return (point.x, point.y)