select * from spatial_ref_sys where srid in (4301, 4326)
結果を要約すると、
4301 → Tokyo (いわゆる日本測地系。日本の地図でけっこう使われている)
4326 → WGS 84 (いわゆる世界測地系。Google Maps等で使われている)
参考:Bubble://ちずろぐ/別巻/ SRIDList
select * from spatial_ref_sys where srid in (4301, 4326)
4301 → Tokyo (いわゆる日本測地系。日本の地図でけっこう使われている)
4326 → WGS 84 (いわゆる世界測地系。Google Maps等で使われている)
+proj=longlat +ellps=bessel +no_defs
+proj=longlat +ellps=bessel +towgs84=-147.54,507.26,680.47,0,0,0,0 +no_defs
<?php
$string = 'こんにちはこんにちは!';
$fontSize = 12;
$padSize = 10;
$angle = 0; //角度を指定できる
$fontPath = 'C:/WINDOWS/Fonts/MSGOTHIC.TTC'; //Windowsの場合
try {
//文字列の大きさを取得 http://jp2.php.net/imageTtfBBox
$box = imageTtfBBox($fontSize, $angle, $fontPath, $string);
if ($box === false) {
throw new Exception('imageTtfBBox()失敗');
}
$boxWidth = abs($box[2] - $box[0]);
$boxHeight = abs($box[7] - $box[1]);
//キャンバス生成 http://jp2.php.net/imageCreateTrueColor
$width = $boxWidth + $padSize * 2;
$height = $boxHeight + $padSize * 2;
$img = imageCreateTrueColor($width, $height);
if ($img === false) {
throw new Exception('imageCreateTrueColor()失敗');
}
//背景色と文字色をそれぞれ造る
// http://jp2.php.net/imageColorAllocate
// http://jp2.php.net/imageColorAllocateAlpha (透過の場合)
$red = 0xFF;
$green = 0x00;
$blue = 0x00;
$bgColor = imageColorAllocate($img, $red, $green, $blue);
if ($bgColor === false) {
throw new Exception('imageColorAllocate()失敗');
}
$red = 0xFF;
$green = 0xFF;
$blue = 0xFF;
$alpha = 20; //0~127。127は完全に透明
$textColor = imageColorAllocateAlpha($img, $red, $green, $blue, $alpha);
if ($textColor === false) {
throw new Exception('imageColorAllocate()失敗');
}
//キャンバスに色を塗る http://jp2.php.net/imageFill
$startX = 0;
$startY = 0;
if (!imageFill($img, $startX, $startY, $bgColor)) {
throw new Exception('imageFill()失敗');
}
//文字を書く http://jp2.php.net/imageTtfText
$startX = $padSize;
$startY = $boxHeight + $padSize; //左下の座標を指定する
if (!imageTtfText($img, $fontSize, $angle, $startX, $startY, $textColor, $fontPath, $string)) {
throw new Exception('imageChar()失敗');
}
//出力(第2引数にファイルパスを渡すとファイルに保存する)
$type = 'gif';
header('Content-type: image/' . $type);
switch ($type) {
case 'gif': // http://jp2.php.net/imageGif
$result = imageGif($img);
break;
case 'jpeg': // http://jp2.php.net/imageJpeg
$quality = 100; //0~100。大きいほど高品質。デフォルトは75
$result = imageJpeg($img, null, $quality);
break;
case 'png': // http://jp2.php.net/imagePng
$quality = 0; //0~9。小さいほど高品質
$result = imagePng($img, null, $quality);
break;
}
if (!$result) {
throw new Exception('出力失敗');
}
} catch (Exception $e) {
header('Content-type: text/html');
echo $e->getMessage();
}
//後始末 http://jp2.php.net/imageDestroy
if ($img && !imageDestroy($img)) {
throw new Exception('imageDestroy()失敗');
}
$before = array('Google', 'apple', '+11112', 1112, '112', 12, '0', -1);
$array = $before;
sort($array);
foreach ($array as $val) echo $val . ', ';
//sort()の第2引数のデフォルトはSORT_REGULAR
//文字列は大文字優先
//今回のように数値と文字列が混在するとおかしくなる?
// => -1, 0, 112, Google, apple, 12, 1112, +11112,
echo '<hr />';
$array = $before;
sort($array, SORT_NUMERIC);
foreach ($array as $val) echo $val . ', ';
//数値としてソート
//文字列は大文字・小文字を無視したソートで、ゼロの前になるようだ
// => -1, apple, Google, 0, 12, 112, 1112, +11112,
echo '<hr />';
$array = $before;
sort($array, SORT_STRING);
foreach ($array as $val) echo $val . ', ';
//文字列としてソート
//記号、数字、文字列(大文字優先)の順
//数字は数値ではなく文字列としてソートされる
// => +11112, -1, 0, 1112, 112, 12, Google, apple,
echo '<hr />';
$array = $before;
sort($array, SORT_LOCALE_STRING);
foreach ($array as $val) echo $val . ', ';
//localeごとのソート(今回の環境ではSORT_STRINGと同じだった)
// => +11112, -1, 0, 1112, 112, 12, Google, apple,
echo '<hr />';
$array = $before;
natsort($array);
foreach ($array as $val) echo $val . ', ';
//「自然順アルゴリズム」
//人間がやったらまあこうするだろうという感じか
//記号、数値、文字列の順
//数値は文字列ではなく数値としてソートされるのがSORT_STRINGとの違い
// => +11112, -1, 0, 12, 112, 1112, Google, apple,
echo '<hr />';
$array = $before;
natcasesort($array);
foreach ($array as $val) echo $val . ', ';
//「自然順アルゴリズム」、かつ大文字小文字を区別しない
// => +11112, -1, 0, 12, 112, 1112, apple, Google,