<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Here comes the Sun &#187; GIS</title>
	<atom:link href="http://sunng.info/blog/tag/gis/feed/" rel="self" type="application/rss+xml" />
	<link>http://sunng.info/blog</link>
	<description>47% users on this site use *nix</description>
	<lastBuildDate>Sat, 04 Feb 2012 13:08:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>GPS数据采集与OpenStreetMap编辑</title>
		<link>http://sunng.info/blog/2011/10/gps%e6%95%b0%e6%8d%ae%e9%87%87%e9%9b%86%e4%b8%8eopenstreetmap%e7%bc%96%e8%be%91/</link>
		<comments>http://sunng.info/blog/2011/10/gps%e6%95%b0%e6%8d%ae%e9%87%87%e9%9b%86%e4%b8%8eopenstreetmap%e7%bc%96%e8%be%91/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 03:17:48 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[手艺]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[OpenStreetMap]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=1018</guid>
		<description><![CDATA[简单介绍一下通过GPS采集道路数据并上传到OpenStreetMap的流程。 采集 首先你需要一个GPS数据记录器，或者叫做GPS Logger。这类产品在淘宝上可以找到很多，台湾的长天(HOLUX)是相对价廉物美的品牌。我的设备是HOLUX m1000c，下文以此为例。 m1000c的使用非常简单。开机之后，指示GPS的黄灯点亮，设备开始搜索GPS卫星。根据你所出的位置、遮挡情况以及天气情况，搜星的时间略有不同。当GPS黄灯开始闪烁时Logger即开始记录数据，默认情况下m1000c每隔5秒记录一次数据。每次重启后，Logger都会新开一条记录。 导入 对Windows用户，将Logger通过USB线与电脑连接后，可以利用随机附带的软件将数据导入为GPX格式。对Linux用户，可以利用gpsbabel导入数据： gpsbabel -t -i m241 -f /dev/ttyACM0 -o gpx -F myfile.gpx 其中： -t 表示数据为track类型 -i m241 输入格式为HOLUX m241，m1000c使用的是这种格式 -f /dev/ttyACM0 输入设备是/dev/ttyACM0 -o gpx 输出格式是gpx -F 输出文件myfile.gpx 在一些发行版上，需要root权限访问/dev/ttyACM0，所以不要忘记将输出的文件chown给普通用户。 导入完成后可以利用下面的命令清空Logger gpsbabel -i m241,erase_only=1 -f /dev/ttyACM0 &#8230; <a href="http://sunng.info/blog/2011/10/gps%e6%95%b0%e6%8d%ae%e9%87%87%e9%9b%86%e4%b8%8eopenstreetmap%e7%bc%96%e8%be%91/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>简单介绍一下通过GPS采集道路数据并上传到OpenStreetMap的流程。</p>
<h3>采集</h3>
<p>首先你需要一个GPS数据记录器，或者叫做GPS Logger。这类产品在淘宝上可以找到很多，台湾的长天(HOLUX)是相对价廉物美的品牌。我的设备是HOLUX m1000c，下文以此为例。</p>
<p>m1000c的使用非常简单。开机之后，指示GPS的黄灯点亮，设备开始搜索GPS卫星。根据你所出的位置、遮挡情况以及天气情况，搜星的时间略有不同。当GPS黄灯开始闪烁时Logger即开始记录数据，默认情况下m1000c每隔5秒记录一次数据。每次重启后，Logger都会新开一条记录。</p>
<h3>导入</h3>
<p>对Windows用户，将Logger通过USB线与电脑连接后，可以利用随机附带的软件将数据导入为GPX格式。对Linux用户，可以利用<a href="http://www.gpsbabel.org/" target="_blank">gpsbabel</a>导入数据：<br />
<em>gpsbabel -t -i m241 -f /dev/ttyACM0 -o gpx -F myfile.gpx</em></p>
<p>其中：</p>
<ul>
<li>-t 表示数据为track类型</li>
<li>-i m241 输入格式为HOLUX m241，m1000c使用的是这种格式</li>
<li>-f /dev/ttyACM0 输入设备是/dev/ttyACM0</li>
<li>-o gpx 输出格式是gpx</li>
<li>-F 输出文件myfile.gpx</li>
</ul>
<p>在一些发行版上，需要root权限访问/dev/ttyACM0，所以不要忘记将输出的文件chown给普通用户。</p>
<p>导入完成后可以利用下面的命令清空Logger<br />
<em>gpsbabel -i m241,erase_only=1 -f /dev/ttyACM0</em></p>
<p>在Windows和Linux上都可以使用<a href="http://sourceforge.net/apps/mediawiki/viking/index.php?title=Main_Page" target="_blank">Viking</a>查看导入的数据：</p>
<ul>
<li>启动viking</li>
<li>添加一个OSM地图图层： Layers->New Map Layer</li>
<li>导入GPX数据： File->Append File&#8230;</li>
<li>下载OSM地图，右键点击左侧的Map图层，Download Missing Onscreen Maps</li>
</ul>
<p><a href="http://www.flickr.com/photos/40741608@N08/6213079184/" title="Screenshot at 2011-10-05 09:45:20 by 贝小塔, on Flickr"><img src="http://farm7.static.flickr.com/6103/6213079184_f653ca2ca6.jpg" width="500" height="387" alt="Screenshot at 2011-10-05 09:45:20"></a></p>
<h3>编辑</h3>
<p>Windows和Linux用户都可以通过<a href="http://merkaartor.be/" target="_blank">Merkaartor</a>编辑OSM数据。</p>
<p>启动Merkaartor，导入GPS数据： File->Import。<br />
选择左侧的GPS图层，对需要导入的数据，右键点击Extract Drawing Layer将GPS转换为可编辑数据。<br />
<a href="http://www.flickr.com/photos/40741608@N08/6213247680/" title="Screenshot at 2011-10-05 10:57:17 by 贝小塔, on Flickr"><img src="http://farm7.static.flickr.com/6167/6213247680_046e360c63.jpg" width="500" height="303" alt="Screenshot at 2011-10-05 10:57:17"></a></p>
<p>根据实际情况编辑道路数据的属性。对GPS转换的数据，选择菜单Feature->Force Upload，将其加入dirty set准备上传。点击Upload即可将数据上传到OpenStreetMap。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2011/10/gps%e6%95%b0%e6%8d%ae%e9%87%87%e9%9b%86%e4%b8%8eopenstreetmap%e7%bc%96%e8%be%91/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HeatCanvas support for Leaflet</title>
		<link>http://sunng.info/blog/2011/07/heatcanvas-support-for-leaflet/</link>
		<comments>http://sunng.info/blog/2011/07/heatcanvas-support-for-leaflet/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 12:50:03 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[ANN]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[heatcanvas]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[map]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=916</guid>
		<description><![CDATA[Leaflet is a light weight web mapping library developed by Cloudmade. Leaflet is designed for compatibility with both desktop browser and mobile browser. HeatCanvas-Leaflet extension enables heat map on Leaflet. You can create heat map layer and add it to &#8230; <a href="http://sunng.info/blog/2011/07/heatcanvas-support-for-leaflet/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://leaflet.cloudmade.com/" title="leaflet" target="_blank">Leaflet</a> is a light weight web mapping library developed by <a href="http://cloudmade.com/" title="cloudmade" target="_blank">Cloudmade</a>. Leaflet is designed for compatibility with both desktop browser and mobile browser.</p>
<p>HeatCanvas-Leaflet extension enables heat map on Leaflet. You can create heat map layer and add it to Leatlet map:</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> heatmap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> L.<span style="color: #660066;">TileLayer</span>.<span style="color: #660066;">HeatCanvas</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Heat Canvas&quot;</span><span style="color: #339933;">,</span> map<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'step'</span><span style="color: #339933;">:</span><span style="color: #CC0000;">0.3</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'degree'</span><span style="color: #339933;">:</span>HeatCanvas.<span style="color: #660066;">QUAD</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'opacity'</span><span style="color: #339933;">:</span><span style="color: #CC0000;">0.7</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
heatmap.<span style="color: #660066;">pushData</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">32.1104</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">118.0852</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//push more data ...</span><br />
map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>heatmap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>You can find live demo on:<br />
<a href="http://sunng87.github.com/heatcanvas/leaflet.html" title="heatcanvas demo" target="_blank">http://sunng87.github.com/heatcanvas/leaflet.html</a><br />
Mobile browser is also supported. (Tested on Firefox Android and default Android browser)</p>
<p>Find more about HeatCanvas on <a href="https://github.com/sunng87/heatcanvas">github page</a>.</p>
<p>Leaflet is still buggy for extension. There is a latlng-pixel coordinate conversion <a href="https://github.com/CloudMade/Leaflet/issues/190" target="_blank">issue</a> in low zoom level, affects this demo. Hope it could be fixed soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2011/07/heatcanvas-support-for-leaflet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ngeohash: node module for geohash algorithm</title>
		<link>http://sunng.info/blog/2011/06/ngeohash-node-module-for-geohash-algorithm/</link>
		<comments>http://sunng.info/blog/2011/06/ngeohash-node-module-for-geohash-algorithm/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 12:34:26 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[ANN]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2011/06/ngeohash-node-module-for-geohash-algorithm/</guid>
		<description><![CDATA[ngeohash是一个geohash的javascript实现，之所以叫做ngeohash是因为到了Publish的时候才发现已经有geohash这个module了。这么令人沮丧的事就不多说了。 安装 npm install ngeohash 使用 var geohash = require(&#8216;ngeohash&#8217;); sys.puts(geohash.encode(32.1717, 118.2342)); 详细 访问github的相关页面：https://github.com/sunng87/node-geohash]]></description>
			<content:encoded><![CDATA[<p>ngeohash是一个geohash的javascript实现，之所以叫做ngeohash是因为到了Publish的时候才发现已经有geohash这个module了。这么令人沮丧的事就不多说了。</p>
<p>安装<br />
<font face="monospace">npm install ngeohash<br />
</font></p>
<p>使用<br />
var geohash = require(&#8216;ngeohash&#8217;);<br />
sys.puts(geohash.encode(32.1717, 118.2342));</p>
<p>详细<br />
访问github的相关页面：<a href="https://github.com/sunng87/node-geohash">https://github.com/sunng87/node-geohash<br />
</a></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=62cf2f06-ce63-87a6-a76b-5899455660e7" /></div>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2011/06/ngeohash-node-module-for-geohash-algorithm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPS Track of Train K221: Nanjing to Guangzhou</title>
		<link>http://sunng.info/blog/2011/04/gps-track-of-train-k221-nanjing-to-guangzhou/</link>
		<comments>http://sunng.info/blog/2011/04/gps-track-of-train-k221-nanjing-to-guangzhou/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 13:47:58 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[自话]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[gps]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2011/04/gps-track-of-train-k221-nanjing-to-guangzhou/</guid>
		<description><![CDATA[GPS Logger完成了它有生以来最长的一次旅行，1477分钟，行程1767公里，途径江苏、安徽、江西、湖南、广东，包含了宁芜线、浙赣线、京广线等。有了GPS终端，贴地的旅途就变成一件非常严肃的事情。这周末去西安，这个GPS也是16个小时上铺车程唯一的安慰了。 这个数据分享在OpenStreetMap上，也许你会感兴趣： http://www.openstreetmap.org/user/Sunng/traces/996794]]></description>
			<content:encoded><![CDATA[<p>GPS Logger完成了它有生以来最长的一次旅行，1477分钟，行程1767公里，途径江苏、安徽、江西、湖南、广东，包含了宁芜线、浙赣线、京广线等。有了GPS终端，贴地的旅途就变成一件非常严肃的事情。这周末去西安，这个GPS也是16个小时上铺车程唯一的安慰了。<br />
<a href="http://www.flickr.com/photos/40741608@N08/5657757338/" title="Railway-K221 - Viking by 贝小塔, on Flickr"><img src="http://farm6.static.flickr.com/5305/5657757338_9bbcc6af42.jpg" alt="Railway-K221 - Viking" height="302" width="500" /></a></p>
<p>这个数据分享在OpenStreetMap上，也许你会感兴趣：<br />
<a href="http://www.openstreetmap.org/user/Sunng/traces/996794">http://www.openstreetmap.org/user/Sunng/traces/996794</a></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=e4cdedff-8fec-852d-876b-830e16846036" /></div>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2011/04/gps-track-of-train-k221-nanjing-to-guangzhou/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I am Location Aware</title>
		<link>http://sunng.info/blog/2010/12/i-am-location-aware/</link>
		<comments>http://sunng.info/blog/2010/12/i-am-location-aware/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 14:11:54 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[自话]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[OpenStreetMap]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2010/12/i-am-location-aware/</guid>
		<description><![CDATA[身为一个跟GIS沾过边的人，我直到今年才真正知道我在哪。尽管有了带GPS功能的手机，但是为了能离cartographer更进一步，今天我又买了一个专门的GPS Logger设备Holux M1000C。所谓GPS Logger就是以固定时间间隔采集GPS数据并记录的设备，现在国内的绝大多数GPS设备都是以导航为主，少有这样功能简单价格合理的GPS产品。 这类设备，自带的软件当然都是Windows only的，不过在Linux上也不是没有办法。处理GPS数据最著名的工具叫做BT747，支持多种设备、格式，用Java写的，可以通过jnlp启动，quick and dirty一下还是很不错的。不过如果要找一个长相厮守的命令行工具，还是要用gpsbabel。 以USB连接为例，将M1000C通过USB线连接到电脑，开启设备。可以用dmesg命令查看连接的USB设备，找到该设备（我的机器上设备叫做 /dev/ttyACM0）。M1000C使用的是MTK芯片，gpsbabel的命令为： gpsbabel -t -i m241 -f /dev/ttyACM0 -o gpx -F output.gpx 其中： -t 表示track -i 输入格式，可以带参数如 -i m241,erase=1 表示导入并擦除设备上的数据 -f 输入设备 -o 输出格式，导出gpx格式 -F 输出文件 有了GPS设备，现在可以名正言顺地为OpenStreetMap贡献了，今天揣着设备把下班的路记录了一下，而且还专门走了小区后面没有路灯的一条路上采集了一下数据，没有路灯还真有点&#8230; View Larger Map 来吧，加入到OpenStreetMap的贡献者队伍里吧！ The &#8230; <a href="http://sunng.info/blog/2010/12/i-am-location-aware/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>身为一个跟GIS沾过边的人，我直到今年才真正知道我在哪。尽管有了带GPS功能的手机，但是为了能离cartographer更进一步，今天我又买了一个专门的GPS Logger设备Holux M1000C。所谓GPS Logger就是以固定时间间隔采集GPS数据并记录的设备，现在国内的绝大多数GPS设备都是以导航为主，少有这样功能简单价格合理的GPS产品。<br />
<a href="http://www.flickr.com/photos/40741608@N08/5229058140/" title="DSC_0006 by 贝小塔, on Flickr"><img src="http://farm6.static.flickr.com/5249/5229058140_cb0e8e44a2.jpg" width="500" height="335" alt="DSC_0006" /></a></p>
<p>这类设备，自带的软件当然都是Windows only的，不过在Linux上也不是没有办法。处理GPS数据最著名的工具叫做BT747，支持多种设备、格式，用Java写的，可以通过jnlp启动，quick and dirty一下还是很不错的。不过如果要找一个长相厮守的命令行工具，还是要用gpsbabel。</p>
<p>以USB连接为例，将M1000C通过USB线连接到电脑，开启设备。可以用dmesg命令查看连接的USB设备，找到该设备（我的机器上设备叫做 /dev/ttyACM0）。M1000C使用的是MTK芯片，gpsbabel的命令为：<br />
<i>gpsbabel -t -i m241 -f /dev/ttyACM0 -o gpx -F output.gpx</i></p>
<p>其中：</p>
<ul>
<li>-t 表示track</li>
<li>-i 输入格式，可以带参数如 -i m241,erase=1 表示导入并擦除设备上的数据</li>
<li>-f 输入设备</li>
<li>-o 输出格式，导出gpx格式</li>
<li>-F 输出文件</li>
</ul>
<p>有了GPS设备，现在可以名正言顺地为OpenStreetMap贡献了，今天揣着设备把下班的路记录了一下，而且还专门走了小区后面没有路灯的一条路上采集了一下数据，没有路灯还真有点&#8230;<br />
<a href="http://www.flickr.com/photos/40741608@N08/5228648495/" title="merkator by 贝小塔, on Flickr"><img src="http://farm6.static.flickr.com/5043/5228648495_accb4185cc.jpg" width="500" height="313" alt="merkator" /></a></p>
<p><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox=121.62538,31.19607,121.64143,31.20659&amp;layer=mapnik" style="border: 1px solid black"></iframe><br /><small><a href="http://www.openstreetmap.org/?lat=31.20133&amp;lon=121.633405&amp;zoom=15&amp;layers=M">View Larger Map</a></small></p>
<p>来吧，加入到OpenStreetMap的贡献者队伍里吧！</p>
<p>The post is brought to you by <a href="http://fedorahosted.org/lekhonee">lekhonee</a> v0.7</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/12/i-am-location-aware/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Perfomed my first commit to OpenStreetMap.org</title>
		<link>http://sunng.info/blog/2010/06/perfomed-my-first-commit-to-openstreetmap-org/</link>
		<comments>http://sunng.info/blog/2010/06/perfomed-my-first-commit-to-openstreetmap-org/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 04:59:02 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[自话]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[OpenStreetMap]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2010/06/perfomed-my-first-commit-to-openstreetmap-org/</guid>
		<description><![CDATA[每每看到OSM上南京的地图都一阵唏嘘，这么多年了几乎没有任何变化，仅有的一些数据也都是错误百出，身为一个南京人，又是一个GIS专业毕业的，深感压力巨大。 实际上编辑OSM没有大家想象的那么复杂。任何人都可以注册登录网站，用默认的Potlatch工具进行编辑，即使你手上没有数据也可以编辑一些基本的属性，比如把错误的中山路纠正为北京东路。我从MapMyTracks上导出GPX文件上传到OSM，GPS数据会在OSM上被显示出来，根据这些数据稍作加工就是道路信息了。浏览器里的编辑器功能并不强大，KDE桌面的Merkaator的编辑能力要强大得多，可以对道路进行split/join操作，这些操作对之前南京地图上各种错误的数据非常必要。 其实OpenStreetMap可以借助一些背景图进行数字化，但是在国内，目前只有分辨率非常低Yahoo卫星地图可以用。至于Google的卫星地图，由于License的原因，你是不能在编辑自由地图时使用的。 上海的OSM已经非常完善，数据完善的程度、渲染出地图的壮观已经让你难以想象，连去年开通的张江电车已经在地图上标出，还有各个站名。注册后可以发现，仅仅在浦东就有十几位OSM的贡献者。相比之下，南京在这方面一片空白，甚至还没有苏州的地图完善。考虑到南京有这么多学校这么多GIS专业学生，每年做那么多无用的、自以为是的数字化作业，真正有意义的工作却无人问津，并非没有人愿意去做，而恐怕是大部分人对OSM都闻所未闻。 今后每周我回抽出一定的时间来编辑南京的地图，也算是为家乡做一些贡献吧。 The post is brought to you by lekhonee v0.7]]></description>
			<content:encoded><![CDATA[<p>每每看到OSM上<a href="http://osm.org/go/5nFq9bhH-">南京的地图</a>都一阵唏嘘，这么多年了几乎没有任何变化，仅有的一些数据也都是错误百出，身为一个南京人，又是一个GIS专业毕业的，深感压力巨大。</p>
<p>实际上编辑OSM没有大家想象的那么复杂。任何人都可以注册登录网站，用默认的Potlatch工具进行编辑，即使你手上没有数据也可以编辑一些基本的属性，比如把错误的中山路纠正为北京东路。我从MapMyTracks上导出GPX文件上传到OSM，GPS数据会在OSM上被显示出来，根据这些数据稍作加工就是道路信息了。浏览器里的编辑器功能并不强大，KDE桌面的Merkaator的编辑能力要强大得多，可以对道路进行split/join操作，这些操作对之前南京地图上各种错误的数据非常必要。</p>
<p>其实OpenStreetMap可以借助一些背景图进行数字化，但是在国内，目前只有分辨率非常低Yahoo卫星地图可以用。至于Google的卫星地图，<a href="http://wiki.openstreetmap.org/wiki/FAQ#What_images_and_maps_may_I_use_to_make_maps_from.3F">由于License的原因</a>，你是不能在编辑自由地图时使用的。</p>
<p>上海的OSM已经非常完善，数据完善的程度、渲染出地图的壮观已经让你难以想象，连去年开通的张江电车已经在地图上标出，还有各个站名。注册后可以发现，仅仅在浦东就有十几位OSM的贡献者。相比之下，南京在这方面一片空白，甚至还没有苏州的地图完善。考虑到南京有这么多学校这么多GIS专业学生，每年做那么多无用的、自以为是的数字化作业，真正有意义的工作却无人问津，并非没有人愿意去做，而恐怕是大部分人对OSM都闻所未闻。</p>
<p>今后每周我回抽出一定的时间来编辑南京的地图，也算是为家乡做一些贡献吧。</p>
<p>The post is brought to you by <a href="http://fedorahosted.org/lekhonee">lekhonee</a> v0.7</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/06/perfomed-my-first-commit-to-openstreetmap-org/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Firefox addon for wms development</title>
		<link>http://sunng.info/blog/2010/03/firefox-addon-for-wms-development/</link>
		<comments>http://sunng.info/blog/2010/03/firefox-addon-for-wms-development/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 10:55:21 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[wms]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=517</guid>
		<description><![CDATA[今天一个叫做WMS Inspector的Firefox扩展发布了。这个扩展用来查看页面上的WMS请求，还可以生成GetCapabilities的Report。]]></description>
			<content:encoded><![CDATA[<p>今天一个叫做<a href="http://wiki.github.com/amercader/WMS-Inspector/">WMS Inspector</a>的Firefox扩展发布了。这个扩展用来查看页面上的WMS请求，还可以生成GetCapabilities的Report。</p>
<p><a href="http://www.flickr.com/photos/40741608@N08/4427008096/" title="Screenshot by 贝小塔, on Flickr"><img src="http://farm3.static.flickr.com/2678/4427008096_1e27a3caa8.jpg" width="500" height="116" alt="Screenshot" /></a><br />
<a href="http://www.flickr.com/photos/40741608@N08/4427007996/" title="Screenshot-GetCapabilities request by 贝小塔, on Flickr"><img src="http://farm3.static.flickr.com/2715/4427007996_30f5b42791_o.png" width="394" height="314" alt="Screenshot-GetCapabilities request" /></a><br />
<a href="http://www.flickr.com/photos/40741608@N08/4427007932/" title="Screenshot-Capabilities report - WMS Inspector - Mozilla Firefox by 贝小塔, on Flickr"><img src="http://farm3.static.flickr.com/2734/4427007932_8c3260710f.jpg" width="500" height="286" alt="Screenshot-Capabilities report - WMS Inspector - Mozilla Firefox" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/03/firefox-addon-for-wms-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New features in JTS 1.11</title>
		<link>http://sunng.info/blog/2010/03/new-features-in-jts-1-11/</link>
		<comments>http://sunng.info/blog/2010/03/new-features-in-jts-1-11/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 05:16:08 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=505</guid>
		<description><![CDATA[JTS最近发布了1.11版本，新增了： 对Delaunay三角网、Voronoi多边形的支持； 把Geometry对象转换为AWT的Shape对象的功能 对几何对象进行densify的操作（增加结点）； 计算Hausdorff相似度和Area相似度的支持 计算Delaunay三角网和Voronoi多边形： import java.util.ArrayList; import java.util.Collection; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; import com.vividsolutions.jts.triangulate.VoronoiDiagramBuilder; /** &#160;* &#160;* @author Sun Ning/SNDA &#160;* @since 2010-3-3 &#160;*/ public class DelaunayAndVoronoiApp &#123; &#160; &#160; /** &#160; &#8230; <a href="http://sunng.info/blog/2010/03/new-features-in-jts-1-11/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://lin-ear-th-inking.blogspot.com/2010/03/jts-version-111-released.html">JTS最近发布了1.11版本</a>，新增了：</p>
<ul>
<li>对<a href="http://en.wikipedia.org/wiki/Delaunay_triangulation">Delaunay三角网</a>、<a href="http://en.wikipedia.org/wiki/Voronoi">Voronoi多边形</a>的支持；</li>
<li>把Geometry对象转换为AWT的Shape对象的功能</li>
<li>对几何对象进行densify的操作（增加结点）；</li>
<li>计算<a href="http://en.wikipedia.org/wiki/Hausdorff_distance">Hausdorff相似度</a>和Area相似度的支持</li>
</ul>
<p>计算Delaunay三角网和Voronoi多边形：</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collection</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.geom.Coordinate</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.geom.Geometry</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.geom.GeometryCollection</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.geom.GeometryFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.triangulate.VoronoiDiagramBuilder</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp;*<br />
&nbsp;* @author Sun Ning/SNDA<br />
&nbsp;* @since 2010-3-3<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DelaunayAndVoronoiApp <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* create some predefined sites<br />
&nbsp; &nbsp; &nbsp;* @return<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Collection<span style="color: #339933;">&lt;</span>coordinate<span style="color: #339933;">&gt;</span> getPredefinedSites<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">double</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> coords <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">27</span><span style="color: #009900;">&#125;</span>,<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">28</span>, <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#125;</span>,<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">29</span>, <span style="color: #cc66cc;">40</span><span style="color: #009900;">&#125;</span>,<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">32</span>, <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#125;</span>, <span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">26</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ArrayList<span style="color: #339933;">&lt;</span>coordinate<span style="color: #339933;">&gt;</span> coordinates <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>coordinate<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>coords.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>coords.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; coordinates.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Coordinate<span style="color: #009900;">&#40;</span>coords<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, coords<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> coordinates<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @param coords<br />
&nbsp; &nbsp; &nbsp;* @return a geometry collection of triangulations<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Geometry buildDelaunayTriangulation<span style="color: #009900;">&#40;</span>Collection<span style="color: #339933;">&lt;</span>coordinate<span style="color: #339933;">&gt;</span> coords<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DelaunayTriangulationBuilder builder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DelaunayTriangulationBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; builder.<span style="color: #006633;">setSites</span><span style="color: #009900;">&#40;</span>coords<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> builder.<span style="color: #006633;">getTriangles</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GeometryFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @param coords<br />
&nbsp; &nbsp; &nbsp;* @return a collection of polygons<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Geometry buildVoronoiDiagram<span style="color: #009900;">&#40;</span>Collection<span style="color: #339933;">&lt;</span>coordinate<span style="color: #339933;">&gt;</span> coords<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; VoronoiDiagramBuilder builder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> VoronoiDiagramBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; builder.<span style="color: #006633;">setSites</span><span style="color: #009900;">&#40;</span>coords<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> builder.<span style="color: #006633;">getDiagram</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GeometryFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @param args<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Collection<span style="color: #339933;">&lt;</span>coordinate<span style="color: #339933;">&gt;</span> coordinates <span style="color: #339933;">=</span> getPredefinedSites<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Delauny<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GeometryCollection triangulations<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>GeometryCollection<span style="color: #009900;">&#41;</span>buildDelaunayTriangulation<span style="color: #009900;">&#40;</span>coordinates<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> total <span style="color: #339933;">=</span> triangulations.<span style="color: #006633;">getNumGeometries</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Total triangulations: %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, total<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>total<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Geometry g <span style="color: #339933;">=</span> triangulations.<span style="color: #006633;">getGeometryN</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Coordinate<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> coords <span style="color: #339933;">=</span> g.<span style="color: #006633;">getCoordinates</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Triangulation %d: &quot;</span>, i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>Coordinate c <span style="color: #339933;">:</span> coords<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(%.3f, %.3f) &quot;</span>, c.<span style="color: #006633;">x</span>, c.<span style="color: #006633;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Voronoi<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GeometryCollection diagram <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>GeometryCollection<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buildVoronoiDiagram<span style="color: #009900;">&#40;</span>coordinates<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> totalDia <span style="color: #339933;">=</span> diagram.<span style="color: #006633;">getNumGeometries</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>totalDia<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Geometry g <span style="color: #339933;">=</span> diagram.<span style="color: #006633;">getGeometryN</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Coordinate<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> coords <span style="color: #339933;">=</span> g.<span style="color: #006633;">getCoordinates</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Diagram %d: &quot;</span>, i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>Coordinate c <span style="color: #339933;">:</span> coords<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(%.3f, %.3f) &quot;</span>, c.<span style="color: #006633;">x</span>, c.<span style="color: #006633;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></div>
<p>输出：</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Total triangulations: 5<br />
Triangulation 0: (32.000, 90.000) (12.000, 26.000) (28.000, 50.000) (32.000, 90.000)<br />
Triangulation 1: (32.000, 90.000) (28.000, 50.000) (100.000, 27.000) (32.000, 90.000)<br />
Triangulation 2: (100.000, 27.000) (28.000, 50.000) (29.000, 40.000) (100.000, 27.000)<br />
Triangulation 3: (100.000, 27.000) (29.000, 40.000) (12.000, 26.000) (100.000, 27.000)<br />
Triangulation 4: (12.000, 26.000) (29.000, 40.000) (28.000, 50.000) (12.000, 26.000)<br />
Diagram 0: (-76.000, 88.625) (-76.000, 178.000) (176.713, 178.000) (72.699, 65.730) (-38.235, 76.824) (-76.000, 88.625)<br />
Diagram 1: (-76.000, -62.000) (-76.000, 88.625) (-38.235, 76.824) (11.978, 43.348) (56.422, -10.619) (57.006, -62.000) (-76.000, -62.000)<br />
Diagram 2: (11.978, 43.348) (-38.235, 76.824) (72.699, 65.730) (67.316, 48.882) (11.978, 43.348)<br />
Diagram 3: (176.713, 178.000) (188.000, 178.000) (188.000, -62.000) (57.006, -62.000) (56.422, -10.619) (67.316, 48.882) (72.699, 65.730) (176.713, 178.000)<br />
Diagram 4: (11.978, 43.348) (67.316, 48.882) (56.422, -10.619) (11.978, 43.348)</div></div>
<p>将Geometry对象转换成Shape对象，绘制在JPanel上：</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Color</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Dimension</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Graphics</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Graphics2D</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Shape</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collection</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JFrame</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JPanel</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.awt.ShapeWriter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.geom.Coordinate</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.vividsolutions.jts.geom.Geometry</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Random</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp;*<br />
&nbsp;* @author Sun Ning/SNDA<br />
&nbsp;* @since 2010-3-3<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JTS2Awt <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> showUI<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ashape+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Shape</span></a>... <span style="color: #006633;">shape</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajframe+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JFrame</span></a> jframe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajframe+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JFrame</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JTS Geometry to AWT Shape&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajpanel+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JPanel</span></a> jp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajpanel+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JPanel</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> paint<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agraphics+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Graphics</span></a> g<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">paint</span><span style="color: #009900;">&#40;</span>g<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agraphics2d+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Graphics2D</span></a> g2d <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agraphics2d+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Graphics2D</span></a><span style="color: #009900;">&#41;</span>g<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>shape <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ashape+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Shape</span></a> s<span style="color: #339933;">:</span> shape<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g2d.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #006633;">HSBtoRGB</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Arandom+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Random</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">nextFloat</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, 1f, 0.6f<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g2d.<span style="color: #006633;">draw</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jp.<span style="color: #006633;">setPreferredSize</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adimension+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Dimension</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; jframe.<span style="color: #006633;">getContentPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>jp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jframe.<span style="color: #006633;">setDefaultCloseOperation</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajframe+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JFrame</span></a>.<span style="color: #006633;">EXIT_ON_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jframe.<span style="color: #006633;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jframe.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ashape+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Shape</span></a> toShape<span style="color: #009900;">&#40;</span>Geometry geom<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ShapeWriter writer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ShapeWriter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> writer.<span style="color: #006633;">toShape</span><span style="color: #009900;">&#40;</span>geom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Collection<span style="color: #339933;">&lt;</span>coordinate<span style="color: #339933;">&gt;</span> coords <span style="color: #339933;">=</span> DelaunayAndVoronoiApp.<span style="color: #006633;">getPredefinedSites</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Geometry geomT <span style="color: #339933;">=</span> DelaunayAndVoronoiApp.<span style="color: #006633;">buildDelaunayTriangulation</span><span style="color: #009900;">&#40;</span>coords<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Geometry geomD <span style="color: #339933;">=</span> DelaunayAndVoronoiApp.<span style="color: #006633;">buildVoronoiDiagram</span><span style="color: #009900;">&#40;</span>coords<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; showUI<span style="color: #009900;">&#40;</span>toShape<span style="color: #009900;">&#40;</span>geomT<span style="color: #009900;">&#41;</span>, toShape<span style="color: #009900;">&#40;</span>geomD<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></div>
<p><a href="http://www.flickr.com/photos/40741608@N08/4403349474/" title="jts by 贝小塔, on Flickr"><img src="http://farm5.static.flickr.com/4010/4403349474_cc3db44369_o.png" width="158" height="177" alt="jts" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/03/new-features-in-jts-1-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get your conky location aware</title>
		<link>http://sunng.info/blog/2010/02/get-your-conky-location-aware/</link>
		<comments>http://sunng.info/blog/2010/02/get-your-conky-location-aware/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 15:17:26 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[location]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=494</guid>
		<description><![CDATA[Add this in your conkyrc ${exec curl -s &#34;http://api.hostip.info&#34; &#124; xpath -e &#34;//gml:featureMember/Hostip/gml:name/text()&#34; -q} ${exec curl -s &#34;http://api.hostip.info&#34; &#124; xpath -e &#34;//gml:featureMember/Hostip//gml:coordinates/text()&#34; -q} Hostip is well known as a service provider of the geoclue framework. It translates IP address to &#8230; <a href="http://sunng.info/blog/2010/02/get-your-conky-location-aware/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/40741608@N08/4370628754/" title="2010-02-19-225826_188x44_scrot by 贝小塔, on Flickr"><img src="http://farm5.static.flickr.com/4014/4370628754_5a22522b80_o.png" width="188" height="44" alt="2010-02-19-225826_188x44_scrot" /></a></p>
<p>Add this in your conkyrc</p>
<div class="codecolorer-container text twitlight" style="border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">${exec curl -s &quot;http://api.hostip.info&quot; | xpath -e &quot;//gml:featureMember/Hostip/gml:name/text()&quot; -q} ${exec curl -s &quot;http://api.hostip.info&quot; | xpath -e &quot;//gml:featureMember/Hostip//gml:coordinates/text()&quot; -q}</div></div>
<p>Hostip is well known as a service provider of the geoclue framework. It translates IP address to geolocation information. The API we use will return a GML document like</p>
<div class="codecolorer-container xml twitlight" style="border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;ISO-8859-1&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hostipLookupResultSet</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0.1&quot;</span> <span style="color: #000066;">xmlns:gml</span>=<span style="color: #ff0000;">&quot;http://www.opengis.net/gml&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:noNamespaceSchemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.hostip.info/api/hostip-1.0.1.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>This is the Hostip Lookup Service<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>hostip<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:boundedBy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:Null<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>inapplicable<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:Null<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:boundedBy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:featureMember<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hostip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>58.212.88.212<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Nanjing<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;countryName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>CHINA<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/countryName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;countryAbbrev<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>CN<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/countryAbbrev<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">&lt;!-- Co-ordinates are available as lng,lat --&gt;</span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ipLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:pointProperty<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:Point</span> <span style="color: #000066;">srsName</span>=<span style="color: #ff0000;">&quot;http://www.opengis.net/gml/srs/epsg.xml#4326&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gml:coordinates<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>118.883,32.05<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:coordinates<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:Point<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:pointProperty<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ipLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hostip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/gml:featureMember<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hostipLookupResultSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Because it uses ip to lookup your address, you cannot expect higher resolution and precision currently.</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/02/get-your-conky-location-aware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emerillon: map viewer for gnome desktop</title>
		<link>http://sunng.info/blog/2010/01/emerillon-map-viewer-for-gnome-desktop/</link>
		<comments>http://sunng.info/blog/2010/01/emerillon-map-viewer-for-gnome-desktop/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 15:03:47 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[OpenStreetMap]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=435</guid>
		<description><![CDATA[自从libchamplain / geoclue等库发布之后，gnome桌面的地理信息工具和支持发展很迅速：例如之前提到过的eye-of-gnome的地理信息插件，根据EXIF信息在地图上显示。现在gnome桌面上终于有一个专门的地图查看器了，仍然是基于libchamplain，名字叫做emerillon 仍然是使用open street maps，这两年上海的地图发展的非常不错，连最新的二号线东延都已经被标注出来了。相比之下，南京的地图就还是一片空白。 在Ubuntu上安装emerillon，可以从其网站上下载源码编译安装： http://www.novopia.com/emerillon/download.html emerillon的几个主要依赖： libchamplain librest ethos libchamplain在ubuntu 9.10的仓库已经包含 librest也在软件仓库中，不过需要注意的是ubuntu将librest安装在pkg-config里时的名字叫做rest.pc，而emerillon查找的是rest-0.6.pc，所以需要手动建立一个软连接： sudo ln -s /usr/lib/pkgconfig/rest.pc /usr/lib/pkgconfig/rest-0.6.pc ethos是一个Gtk的插件框架，目前还不在软件仓库中，需要从网站下载代码编译： http://git.dronelabs.com/ethos/ ethos网站上提到的PPA源中的版本偏旧，不建议使用。 实际上也可以直接添加emerillon的PPA源： deb http://ppa.launchpad.net/mathieu-tl/emerillon/ubuntu karmic main deb-src http://ppa.launchpad.net/mathieu-tl/emerillon/ubuntu karmic main 另外，也可以通过Ubuntu Tweak安装。 作者Blog： http://blog.pierlux.com/en/]]></description>
			<content:encoded><![CDATA[<p>自从libchamplain / geoclue等库发布之后，gnome桌面的地理信息工具和支持发展很迅速：例如之前提到过的eye-of-gnome的地理信息插件，根据EXIF信息在地图上显示。现在gnome桌面上终于有一个专门的地图查看器了，仍然是基于libchamplain，名字叫做<a href="http://www.novopia.com/emerillon/" target="_blank">emerillon</a></p>
<p><a title="Emerillon Map Viewer by 贝小塔, on Flickr" href="http://www.flickr.com/photos/40741608@N08/4315412541/"><img src="http://farm5.static.flickr.com/4021/4315412541_d34e08d02b.jpg" alt="Emerillon Map Viewer" width="500" height="286" /></a></p>
<p>仍然是使用open street maps，这两年上海的地图发展的非常不错，连最新的二号线东延都已经被标注出来了。相比之下，南京的地图就还是一片空白。</p>
<p>在Ubuntu上安装emerillon，可以从其网站上下载源码编译安装：<br />
<a href="http://www.novopia.com/emerillon/download.html">http://www.novopia.com/emerillon/download.html</a></p>
<p>emerillon的几个主要依赖：</p>
<ul>
<li>libchamplain</li>
<li>librest</li>
<li>ethos</li>
</ul>
<p>libchamplain在ubuntu 9.10的仓库已经包含</p>
<p>librest也在软件仓库中，不过需要注意的是ubuntu将librest安装在pkg-config里时的名字叫做rest.pc，而emerillon查找的是rest-0.6.pc，所以需要手动建立一个软连接：<br />
<em>sudo ln -s /usr/lib/pkgconfig/rest.pc /usr/lib/pkgconfig/rest-0.6.pc</em></p>
<p>ethos是一个Gtk的插件框架，目前还不在软件仓库中，需要从网站下载代码编译：<br />
<a href="http://git.dronelabs.com/ethos/" target="_blank">http://git.dronelabs.com/ethos/</a><br />
ethos网站上提到的PPA源中的版本偏旧，不建议使用。</p>
<p><em>实际上也可以直接添加emerillon的PPA源：<br />
deb http://ppa.launchpad.net/mathieu-tl/emerillon/ubuntu karmic main<br />
deb-src http://ppa.launchpad.net/mathieu-tl/emerillon/ubuntu karmic main</em></p>
<p>另外，也可以通过Ubuntu Tweak安装。</p>
<p>作者Blog：<br />
<a href="http://blog.pierlux.com/en/">http://blog.pierlux.com/en/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/01/emerillon-map-viewer-for-gnome-desktop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

