Format latitude to fit the image name
546623
def _format_lat(self, lat):
        '''  '''

        if self.ppd in [4, 8, 16, 32, 64]:
            latcenter = '000N'
        elif self.ppd in [128]:
            if lat < 0:
                latcenter = '450S'
            else:
                latcenter = '450N'

        return latcenter
177476
def calculate_dimensions(image, long_side, short_side):
    """"""
    if image.width >= image.height:
        return '{0}x{1}'.format(long_side, short_side)
    return '{0}x{1}'.format(short_side, long_side)
1296003
def namer(cls, imageUrl, pageUrl):
        """"""
        imgname = imageUrl.split('/')[-1]
        imgbase = imgname.rsplit('-', 1)[0]
        imgext = imgname.rsplit('.', 1)[1]
        return '%s.%s' % (imgbase, imgext)
1083191
def _format_lat(self, lat):
        '''  '''
        if self.ppd in [4, 16, 64, 128]:
            return None
        else:
            if lat < 0:
                return map(lambda x: "{0:0>2}"
                           .format(int(np.abs(x))) + 'S', self._map_center('lat', lat))
            else:
                return map(lambda x: "{0:0>2}"
                           .format(int(x)) + 'N', self._map_center('lat', lat))
579806
function formatNumberToGeoLocation(number) {
    // work out minutes and seconds for this input
    var locationMinutes = Math.floor((number % 1) * 60);
    var locationSeconds = (((number * 60) % 1) * 60).toFixed(2);

    // return formatted string
    return `${Math.floor(number)}\u00B0${locationMinutes}\u2032${locationSeconds}\u2033`;
}
155523
function getLetterDesignator(lat) {
        //This is here as an error flag to show that the Latitude is
        //outside MGRS limits
        var LetterDesignator = 'Z';

        if ((84 >= lat) && (lat >= 72)) {
            LetterDesignator = 'X';
        }
        else if ((72 > lat) && (lat >= 64)) {
            LetterDesignator = 'W';
        }
        else if ((64 > lat) && (lat >= 56)) {
            LetterDesignator = 'V';
        }
        else if ((56 > lat) && (lat >= 48)) {
            LetterDesignator = 'U';
        }
        else if ((48 > lat) && (lat >= 40)) {
            LetterDesignator = 'T';
        }
        else if ((40 > lat) && (lat >= 32)) {
            LetterDesignator = 'S';
        }
        else if ((32 > lat) && (lat >= 24)) {
            LetterDesignator = 'R';
        }
        else if ((24 > lat) && (lat >= 16)) {
            LetterDesignator = 'Q';
        }
        else if ((16 > lat) && (lat >= 8)) {
            LetterDesignator = 'P';
        }
        else if ((8 > lat) && (lat >= 0)) {
            LetterDesignator = 'N';
        }
        else if ((0 > lat) && (lat >= -8)) {
            LetterDesignator = 'M';
        }
        else if ((-8 > lat) && (lat >= -16)) {
            LetterDesignator = 'L';
        }
        else if ((-16 > lat) && (lat >= -24)) {
            LetterDesignator = 'K';
        }
        else if ((-24 > lat) && (lat >= -32)) {
            LetterDesignator = 'J';
        }
        else if ((-32 > lat) && (lat >= -40)) {
            LetterDesignator = 'H';
        }
        else if ((-40 > lat) && (lat >= -48)) {
            LetterDesignator = 'G';
        }
        else if ((-48 > lat) && (lat >= -56)) {
            LetterDesignator = 'F';
        }
        else if ((-56 > lat) && (lat >= -64)) {
            LetterDesignator = 'E';
        }
        else if ((-64 > lat) && (lat >= -72)) {
            LetterDesignator = 'D';
        }
        else if ((-72 > lat) && (lat >= -80)) {
            LetterDesignator = 'C';
        }
        return LetterDesignator;
    }
694741
def ang2pix(nside, theta, phi, nest=False, lonlat=False):
    """"""
    lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
    return lonlat_to_healpix(lon, lat, nside, order='nested' if nest else 'ring')
536671
def convertLatLngToPixelXY(self, lat, lng, level):
        '''
        
        '''
        mapSize = self.getMapDimensionsByZoomLevel(level)

        lat = self.clipValue(lat, self.min_lat, self.max_lat)
        lng = self.clipValue(lng, self.min_lng, self.max_lng)

        x = (lng + 180) / 360
        sinlat = math.sin(lat * math.pi / 180)
        y = 0.5 - math.log((1 + sinlat) / (1 - sinlat)) / (4 * math.pi)

        pixelX = int(self.clipValue(x * mapSize + 0.5, 0, mapSize - 1))
        pixelY = int(self.clipValue(y * mapSize + 0.5, 0, mapSize - 1))
        return (pixelX, pixelY)
779660
public static void formatLatitude(Appendable out, double latitude, UnitType unit)
    {
        formatLatitude(out, Locale.getDefault(), latitude, unit);
    }
386976
function formatPct(sign, pct) {
  var rendered = (sign ? pct : Math.abs (pct)).toLocaleString ('en', {
    minimumIntegerDigits: 3,
    minimumFractionDigits: 1,
    maximumFractionDigits: 1,
    useGrouping: false
  });
  return (sign && pct >= 0 ? '+' + rendered : rendered) + '%';
}
373164
def aitoffSphereToImage(lon, lat):
    
    lon = lon - 360.*(lon>180)
    lon = np.radians(lon)
    lat = np.radians(lat)

    half_lon = lon/2.
    cos_lat = np.cos(lat)
     
    gamma = (180. / np.pi) * np.sqrt(2. / (1. + (cos_lat * np.cos(half_lon))))
    x = 2. * gamma * cos_lat * np.sin(half_lon)
    y = gamma * np.sin(lat)
    return x, y
197218
private String guessImageFormat(String contentType, String imagePath) throws IOException {

        String format = "png";

        if (contentType == null) {
            contentType = URLConnection.guessContentTypeFromName(imagePath);
        }

        if (contentType != null) {
            format = contentType.replaceFirst("^image/([^;]+)[;]?.*$", "$1");
        }
        else {
            int queryStringIndex = imagePath.indexOf('?');

            if (queryStringIndex != -1) {
                imagePath = imagePath.substring(0, queryStringIndex);
            }

            String[] pathTokens = imagePath.split("\\.");

            if (pathTokens.length > 1) {
                format = pathTokens[pathTokens.length - 1];
            }
        }

        return format;
    }
837560
function getLetterDesignator(latitude) {
  if (latitude <= 84 && latitude >= 72) {
    // the X band is 12 degrees high
    return 'X';
  } else if (latitude < 72 || latitude >= -80) {
    // Latitude bands are lettered C through X, excluding I and O
    const bandLetters = 'CDEFGHJKLMNPQRSTUVWX';
    const bandHeight = 8;
    const minLatitude = -80;
    const index = Math.floor((latitude - minLatitude) / bandHeight);
    return bandLetters[index];
  } else if (latitude > 84 || latitude < -80) {
    //This is here as an error flag to show that the Latitude is
    //outside MGRS limits
    return 'Z';
  }
}
807089
def namer(cls, imageUrl, pageUrl):
        """"""
        start = ''
        tsmatch = compile(r'/(\d+)-').search(imageUrl)
        if tsmatch:
            start = datetime.utcfromtimestamp(int(tsmatch.group(1))).strftime("%Y-%m-%d")
        else:
            # There were only chapter 1, page 4 and 5 not matching when writing
            # this...
            start = '2015-04-11x'
        return start + "-" + pageUrl.rsplit('/', 1)[-1]
1143935
function (format) {
        return function (data) {
            var el = makeElement("img", [ "image-output" ]);
            el.src = "data:image/" + format + ";base64," + joinText(data).replace(/\n/g, "");
            return el;
        };
    }
647177
function prettifyProjection(
  longitude,
  latitude,
  proj4Projection,
  proj4longlat,
  projectionUnits
) {
  const zone = 1 + Math.floor((longitude + 180) / 6);

  const projection =
    proj4Projection + " +zone=" + zone + (latitude < 0 ? " +south" : "");

  const projPoint = proj4(proj4longlat, projection, [longitude, latitude]);

  return {
    utmZone: zone + (latitude < 0.0 ? "S" : "N"),
    north: projPoint[1].toFixed(2) + projectionUnits,
    east: projPoint[0].toFixed(2) + projectionUnits
  };
}
419965
public static void formatLatitude(Appendable out, Locale locale, double latitude, UnitType unit)
    {
        format(out, locale, latitude, unit, NS);
    }