<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />前回の投稿では、昼を背景のビットマップで表し、夜を白抜きの輪郭で表す、世界の昼夜マップを作成しました。この例では、IP ロケーションをプロットし、以下のマップの夜の部分に黄色いもやを作成することで、夜のマップに興味深い詳細を追加する方法を示します。
クリックすると大きな画像が表示されます...

IP の場所は、スクリプトが MaxMind からダウンロードしたファイルから取得されます。彼らのデータは非常に優れており、IP アドレスを場所にマッピングできます。ここではそのためには使用しません。彼らの通知は次のとおりです。
This example includes GeoLite data created by MaxMind, available from http://www.maxmind.com.
ファイルはかなり大きいため、この JSL はデータが既に $temp ディレクトリにダウンロードされているかどうかを確認します。TRY ステートメントがテーブルを開くのに失敗した場合 (カンマの前の最初のステートメント)、キャッチの一部試す(カンマ以降のステートメント)新しいコピーをダウンロードして保存します。ダウンロードでは 2 つの open() ステートメントが使用されます。最初のステートメントは zip アーカイブを取得し、2 つ目は zip アーカイブから読み取られた CSV メンバーのテキスト インポートを実行します。テーブル (Lat,Lon 列のみ) を保存する直前に、<
// download the maxmind zip file http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.zip// it isn't required, but provides a beautiful nighttime glow around parts of the world with internet connections.Try( cityloc = Open( "$temp/cityloc.jmp" ); // try to open an existing saved table , // if that fails, open a zip archive from the internet za = Open( "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.zip", "zip" ); zipMemberList = za << dir;// there are two files in the zipped archive, with any luck, this is still the name... // this zip archive member has the Lat,Lon data citylocblob = za << read( zipMemberList[If( // the member name includes a date that changes. this should pick the right member Ends With( zipMemberList[1], "GeoLiteCity-Location.csv" ), 1, Ends With( zipMemberList[2], "GeoLiteCity-Location.csv" ), 2, . // if this happens, perhaps there is an extra file in the zip? )], Format( blob ) ); cityloc = Open( citylocblob, // open understands a blob can hold CSV data columns( // there are only two cols we need Omitted Column( . ), Omitted Column( . ), Omitted Column( . ), Omitted Column( . ), Omitted Column( . ), Column( "latitude", Numeric, "Continuous", Format( "Best", 10 ) ), Column( "longitude", Numeric, "Continuous", Format( "Best", 10 ) ), Omitted Column( . ), Omitted Column( . ) ), Import Settings( // runs fast when it doesn't have to guess End Of Line( CRLF, CR, LF ), End Of Field( Comma, CSV( 1 ) ), Strip Quotes( 1 ), Use Apostrophe as Quotation Mark( 0 ), Scan Whole File( 1 ), Treat empty columns as numeric( 0 ), CompressNumericColumns( 0 ), CompressCharacterColumns( 0 ), CompressAllowListCheck( 0 ), Labels( 1 ), Column Names Start( 2 ), Data Starts( 3 ), Lines To Read( "All" ), Year Rule( "20xx" ) ) ); // add Creative Commons Attribution-ShareAlike 3.0 Unported License text MaxMind wants... cityloc << settablevariable( "MaxMind", "This table includes GeoLite data created by MaxMind, available from http://www.maxmind.com" ); cityloc<);
上部のマップの夜間エリアの境界内に黄白色のエリアを作成する約 300/400 万の場所が取得されます (テーブルが頻繁に更新されるため、取得される行数は異なります)。

スクリプトの次の部分では、次のタイムゾーン関数を使用します。いくつかの投稿が戻ってきました。GMT 時間は、地図の太陽/影を正しい位置に配置するために必要です。今。スクリプトの残りの部分は、前のスクリプト追加のスクリプトが 1 つだけ GraphBox に追加され、追加の位置を描画します (および位置を緯度経度行列に読み込むための小さなスクリプトも含まれます)。
Try( IPdt = cityloc; lat = IPdt:latitude << getasmatrix; lon = IPdt:longitude << getasmatrix;, // data not available? lat = []; lon = [];);g[framebox( 1 )] << addGraphicsScript( 3, // before shape's new position, after the shadow transparency(.2); Marker( Color State( {0.8, 0.8, 0.7} ),lon, lat ););補足: コンピュータの時計が数秒以上ずれている場合、タイム ゾーン関数は整数を返しません。私の自宅のコンピューターは約 4 秒オフで、5 ではなく 4.999 を報告しました (スクリプトのround 関数が小数点以下 3 桁を要求しているため)。このような四捨五入は、数値の使用方法によっては結果に影響を与える可能性があります。
try() は Lat,Lon が行列であることを確認しますが、何か問題が発生した場合は空である可能性があります。グラフィック スクリプトは、緯度と経度のマトリックスからマーカーを作成し、RGB カラーを明るい黄色がかったグラフに設定します。.2 の透明度により、重複ポイントが単一ポイントよりも強く表示されます。黄色により、グラフの昼間の部分のポイントが目立たなくなり、その下のマップ テクスチャの一部が失われます。
今後: Twitter データのキャプチャ:
