2011年11月11日金曜日

webkitNotifications(デスクトップ通知)

地理空間情報は蓄積されたデータがメインだった。WEBで扱うその手の情報は今後だんだんリアルタイム情報へ変化していっている。 その背景にはWeb標準化でリアうタイム情報をより扱いやすくなってきた点が大きい。 例えば、特売情報や車両の動態管理などのデータは情報の鮮度が重要で、更新情報を効果的に表現する手法が必要になってくる。 websocketでデータ更新情報を受けた後、デスクトップ通知は良いUIの一つなので早めに採用していきたい。 今日時点ではChrome限定だけど下のボタンがこんな感じと分かるようにしてみた。

2011年10月22日土曜日

テスト

今日はアメッシュ

2011年8月24日水曜日

maptailを動かしてみる

環境が揃ってきたいので、手始めにmaptailを動かしてみます

$npm install maptail

でインストールは終わりです。

使い方は、access_logのpathとexpressのbindの設定を引数で与えるだけです

apacheのaccresslogをchmodとかchownするのもあれなので、一旦rootでテストしてみます

$sudo su - 
#export PATH=/home/shin/local/node/bin:$PATH
#export  NODE_PATH=/home/shin/local/node:/home/shin/local/node/lib/node_modules
#cd /home/shin/dev/node_modules/maptail/
#node ./maptail.js /var/log/apache2/access.log luckyxrea.bf1.jp 5124


 これで、
http://luckyxrea.bf1.jp:5124/map
にchromeでアクセスすると見たかった画面を見ることができます。


まずは、サンプルが動いたので次にコード検証をしていきます。


26-34行目で、express...って書いてある。何となくこいつがweb frameworkっぽい初期化コードになっている。
// configuration
var app = express.createServer()
app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.logger());
  app.use(express.methodOverride());
  app.use(express.bodyParser());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

viewの定義が気になったので
 #cat views/map.jade

link(rel='stylesheet', href='/css/wargames.css')
script(src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js')
script(src='/js/config.js')
script(src='http://' + wshost + ':' + wsport + '/socket.io/socket.io.js')
script(src='/js/raphael.js')
script(src='/js/map.js')
script(src='/js/client.js')
|
|
| had activity 0.00 sec ago
|
| messages in the last 40min
|
|
|
    |
    となっている。なるほど。
    ふんわりexpressについての意義は分かったので、maptailを掘り下げてみる

     74 // start Server
     75 app.listen(port, host);
    引数のportとhostでbindしている


     77 // socket.io 
     79 var wsserver = http.createServer() 
     80 wsserver.listen(wsport, wshost);
    Websocketのサーバもbindしておくのね
     18   var wsport = process.env.WSPORT || + port + 111
     19   var wshost = process.env.WSHOST || host
     この辺のportも使ってるのか。
    #netstal -l 
    tcp        0      0 localhost:5235          *:*                     LISTEN     
    tcp        0      0 localhost:ipp           *:*                     LISTEN     
    tcp        0      0 localhost:postgresql    *:*                     LISTEN     
    tcp        0      0 localhost:smtp          *:*                     LISTEN     
    tcp        0      0 localhost:5124          *:*                     LISTEN     

    たしかに、port5124と+111の5235が使われていますね
    コードの続きを読むと
     81 var socket = io.listen(wsserver)
     83 socket.on('connection', function(client) {
     84   var id = client.sessionId
     85     , ip = client && client.request && client.request.socket && client.request.socket.remoteAddress || '000'
     86 
     87   connected[id] = client
     88 
     89   world.sendStartupData(client)
     90 
     91   client.on('disconnect', function() {
     92     delete connected[id]
     93   })
     94 })
    なるほど。worldの中身はgeoip判定がメインな感じなので大枠この辺までが重要な感じです。


    2011年8月20日土曜日

    Node Package Manager(npm)のインストール

    前回に続きnpmをインストールします

    shin@debian:~/dev$ curl http://npmjs.org/install.sh | sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3927  100  3927    0     0   4464      0 --:--:-- --:--:-- --:--:--  9350
    fetching: http://registry.npmjs.org/npm/-/npm-1.0.26.tgz
    0.4.11
    1.0.26
    cleanup prefix=/home/shin/local/node

    This script will find and eliminate any shims, symbolic
    links, and other cruft that was installed by npm 0.x.

    Is this OK? enter 'yes' or 'no' 
    yes

    All clean!
    ! [ -d .git ] || git submodule update --init --recursive
    node cli.js rm npm -g -f
    node cli.js cache clean
    node cli.js install -g -f
    /home/shin/local/node/bin/npm -> /home/shin/local/node/lib/node_modules/npm/bin/npm.js
    /home/shin/local/node/bin/npm_g -> /home/shin/local/node/lib/node_modules/npm/bin/npm.js
    /home/shin/local/node/bin/npm-g -> /home/shin/local/node/lib/node_modules/npm/bin/npm.js
    npm@1.0.26 /home/shin/local/node/lib/node_modules/npm 

    いい感じにインストールできました
    早速試してみます

    shin@debian:~/dev$ npm install express
    express@2.4.5 ./node_modules/express 
    ├── mime@1.2.2
    ├── connect@1.6.2
    └── qs@0.3.1

    うまくインストール出来たようです

    node.jsインストール

    もろもろバージョンが上がって来たので、今日はnodeのインストールを再構築してみます。
    v4.11で進めます。

    環境はW5に入れている、debian squeezeです。
    Linux debian 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux
    日本語解説サイトはもはや役に立たないので公式情報を参考に進めていきます
    特にsidしかパッケージがないこともあり自前でbuildする必要があります。/usr以下を汚したくないため$HOME/localにインストール方法なので後で後くされなく消せるのでおすすめな方法です。


    まずは、gitから落としてきます
    shin@debian:~/dev$ git clone --depth 1 git://github.com/joyent/node.git
    Cloning into node...
    remote: Counting objects: 21010, done.
    remote: Compressing objects: 100% (8487/8487), done.
    remote: Total 21010 (delta 16287), reused 16130 (delta 12136)
    Receiving objects: 100% (21010/21010), 32.83 MiB | 263 KiB/s, done.
    Resolving deltas: 100% (16287/16287), done.

    つぎにv4.11 をcheck outします


    shin@debian:~/dev$ cd node/
    shin@debian:~/dev/node$ git checkout v0.4.11
    Note: checking out 'v0.4.11'.

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.

    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:

      git checkout -b new_branch_name

    HEAD is now at a745d19... Bump version to v0.4.11

    $HOME/local/nodeへのインストールを指示しconfigureします。


    shin@debian:~/dev/node$ export JOBS=2
    shin@debian:~/dev/node$ mkdir ~/local
    shin@debian:~/dev/node$ ./configure --prefix=$HOME/local/node
    Checking for program g++ or c++          : /usr/bin/g++ 
    Checking for program cpp                 : /usr/bin/cpp 
    Checking for program ar                  : /usr/bin/ar 
    Checking for program ranlib              : /usr/bin/ranlib 
    Checking for g++                         : ok  
    Checking for program gcc or cc           : /usr/bin/gcc 
    Checking for program ar                  : /usr/bin/ar 
    Checking for program ranlib              : /usr/bin/ranlib 
    Checking for gcc                         : ok  
    Checking for library dl                  : yes 
    Checking for openssl                     : yes 
    Checking for library util                : yes 
    Checking for library rt                  : yes 
    --- libeio ---
    Checking for library pthread             : yes 
    Checking for function pthread_create     : yes 
    Checking for function pthread_atfork     : yes 
    Checking for futimes(2)                  : yes 
    Checking for readahead(2)                : yes 
    Checking for fdatasync(2)                : yes 
    Checking for pread(2) and pwrite(2)      : yes 
    Checking for sendfile(2)                 : yes 
    Checking for sync_file_range(2)          : yes 
    --- libev ---
    Checking for header sys/inotify.h        : yes 
    Checking for function inotify_init       : yes 
    Checking for header sys/epoll.h          : yes 
    Checking for function epoll_ctl          : yes 
    Checking for header port.h               : not found 
    Checking for header poll.h               : yes 
    Checking for function poll               : yes 
    Checking for header ['sys/types.h', 'sys/event.h'] : not found 
    Checking for header sys/queue.h                    : yes 
    Checking for function kqueue                       : not found 
    Checking for header sys/select.h                   : yes 
    Checking for function select                       : yes 
    Checking for header sys/eventfd.h                  : yes 
    Checking for function eventfd                      : yes 
    Checking for SYS_clock_gettime                     : yes 
    Checking for library rt                            : yes 
    Checking for function clock_gettime                : yes 
    Checking for function nanosleep                    : yes 
    Checking for function ceil                         : yes 
    Checking for fdatasync(2) with c++                 : yes 
    'configure' finished successfully (4.283s)

     あとは、まけまけインストール

    shin@debian:~/dev/node$ make
    shin@debian:~/dev/node$ make install

    最後に.profileにPATHを設定します

    shin@debian:~$ echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
    shin@debian:~$ echo 'export NODE_PATH=$HOME/local/node:$HOME/local/node/lib/node_modules' >> ~/.profile
    shin@debian:~$ source ~/.profile

    インストールはこれで終わりです

    2011年4月20日水曜日

    Where2.0 - Realtime Geo

    Realtime geo

    Twitterの紹介。

    初見の人には、初めから紹介されていたのでわかりやすい。
    ジオメディアサミット名古屋でデジガレの方が紹介されていた内容を詳しく説明している感じ。

    GeoRSS,GeoJSON

    Across all Twitter APIs(REST,Search and Streaming)

    REST File I/O
    Search Search
    Streamin GeoHOSE



    GEOHOSE
    TREND API latlng or WOEID

    spatial search
    ->遅い。 だからBBOX検索
    ->BBOXにID付与 GeoHash

    あとは写真参照

    http://www.flickr.com/photos/luckyxrea/sets/72157626533252296/

    2011年2月12日土曜日

    YOLPのLAYERとPluginの違いが不明確

    ヒートマップを実装しようとしたときのメモ(イマイチ使いにくいなと思ったところ)

    KMLでもgeoRSSでもYDFでもいいとしてたくさんのPOIを表示する

    var url="http://1st.geocities.jp/yjmapstaff/yolp/ydf/geoSearch.xml";

    通常のアイコンをのせるにはLayerの追加
    // var layer = new Y.GeoXmlLayer(url); 通常の方法
    var layer = new Y.GeoXmlLayer(url, { heat:true}); //ヒートの指定をしたいができない
    map.addLayer(layer);
    layer.execute();

    ヒートマップは専用プラグインを使わないとダメ。使いにくい。このプラグインは廃止にして標準機能に入れてほしい
    var geoxml = new Y.GeoXmlPlugin(url, { heat:true});
    map.addPlugin(geoxml);
    これで出るにはでるんだが...

    2011年1月6日木曜日

    フリーで使える拠点情報7つ(YOLPデータ)



    インターネットにダウンロード可能なオープンデータはたくさんあるが、ロケーション情報となると途端に少なくなります。
    気軽にロケーション系サイトを立ち上げようとしても、データ形式もバラバラでほとんどの方はその整形に苦労されているのが実情ではないでしょうか?

    OR Mapper的に使えるYDF形式のデータを使って、簡単に地図上へのマッピングも可能な拠点情報データを纏めてみました。

    データ名称APIで利用する際のcid
    全国電話帳データd8a23e9e64a4c817227ab09858bc1330
    一休ホテルデータ72dbf05e5bdf74120d0deb3bb92343cf
    近畿日本ツーリストデータ2ba51df90620ffcf020f3f5f2a687ddb
    全国BOOK OFFデータ3498f6b0ee477d5bee714513fef7c89a
    ラブホテルデータ6ee7f59476555c28ad003417985e04fc
    日本レンタカーデータae8d8d10ea8c3ff00f55896ede3c97d4
    すき屋データ8cfa8ed3d825ba896fa8d7cffd28cd67
    手持ちのデータをアップロード既に持っているデータ利用

    サンプルのソースはあまり使い出がないので、ローカルサーチAPIから情報を引き出して開発します。次回はiPhoneでも動く簡単なサイトを作ります。

    ※ちなみに、サンプルソースをそのまま利用した場合