<?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/"
	xmlns:georss="http://www.georss.org/georss">

<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>Life ramblings</description>
	<lastBuildDate>Thu, 02 Sep 2010 12:29:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<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[OSM]]></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>
	<georss:point>31.203057 121.6174866</georss:point>	</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; &#160; &#160;* create some predefined sites &#160; &#160; &#160;* @return &#160; &#160; &#160;*/ &#160; &#160; [...]]]></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 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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 default" 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 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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>
	<georss:point>31.203057 121.6174866</georss:point>	</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 geolocation information. The API we use will return a GML document like &#60;?xml version=&#34;1.0&#34; encoding=&#34;ISO-8859-1&#34; [...]]]></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 default" 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 default" style="border:1px solid #9F9F9F;width:435px;height:300px;"><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>
	<georss:point>32.032377 118.793506</georss:point>	</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[OSM]]></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>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>Adding Ubuntu-GIS repository</title>
		<link>http://sunng.info/blog/2009/11/adding-ubuntu-gis-repository/</link>
		<comments>http://sunng.info/blog/2009/11/adding-ubuntu-gis-repository/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 08:13:27 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[把戏]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=349</guid>
		<description><![CDATA[在Ubuntu上安装GIS软件，可以添加这个PPA源： deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu karmic main 导入GPG KEY gpg &#8211;keyserver subkeys.pgp.net &#8211;recv 089EBE08314DF160 gpg &#8211;export &#8211;armor 089EBE08314DF160 &#124; sudo apt-key add - 这个源中目前包含了最新版本的GIS软件： gdal 1.6 grass qgis]]></description>
			<content:encoded><![CDATA[<p>在Ubuntu上安装GIS软件，可以添加这个PPA源：<em><br />
deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu karmic main</em></p>
<p>导入GPG KEY<br />
<em>gpg &#8211;keyserver subkeys.pgp.net &#8211;recv 089EBE08314DF160<br />
gpg &#8211;export &#8211;armor 089EBE08314DF160 | sudo apt-key add -</em></p>
<p>这个源中目前包含了最新版本的GIS软件：</p>
<ul>
<li>gdal 1.6</li>
<li>grass</li>
<li>qgis</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/11/adding-ubuntu-gis-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>Mapping Geometry in Grails and MySQL</title>
		<link>http://sunng.info/blog/2009/10/mapping-geometry-in-grails-and-mysql/</link>
		<comments>http://sunng.info/blog/2009/10/mapping-geometry-in-grails-and-mysql/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 11:14:36 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[手艺]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[jts]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=238</guid>
		<description><![CDATA[针对地理数据的ORM，有一个Hibernate的扩展HibernateSpatial项目可以将JTS对象映射到MySQL/PostGIS/Oracle中。这个扩展同样可以用在Grails里，这里有一篇简单的介绍，关于在Grails和MySQL中管理地理数据： http://www.grails.org/MySQL+GIS-Geometry+with+Grails 不过按照这个文章里介绍的方法用，很可能会遭遇这样的报错： org.hibernate.MappingException: No Dialect mapping for JDBC type: 2003 这个问题最终在这里得到了解答： http://n2.nabble.com/No-Dialect-mapping-for-JDBC-type-2003-td1141106.html 按照邮件列表里的反映，上面的配置在Postgis里是可以work的，但是如果用Mysql还需要指定JPA的columnDefinition，对应的Hibernate属性是sql-type。虽然作者承诺会在今后的版本里修改这个问题，不过眼下的M2版本还没有修正这个问题。为此，Grails的用户特地提出在Grails中加入sql-type的支持： http://jira.codehaus.org/browse/GRAILS-3201 现在按照下面文档的说明，可以在mapping里指定sqlType了： http://grails.org/doc/latest/ref/Database%20Mapping/column.html 实例代码里的domain定义应该改成： import com.vividsolutions.jts.geom.Polygon import org.hibernatespatial.GeometryUserType public class MyPoly { String name Polygon poly static mapping = { poly type: GeometryUserType， sqlType:"GEOMETRY" } } 于是，再也没有莫名其妙的No Dialect报错了。]]></description>
			<content:encoded><![CDATA[<p>针对地理数据的ORM，有一个Hibernate的扩展<a href="http://www.hibernatespatial.org/" target="_blank">HibernateSpatial</a>项目可以将JTS对象映射到MySQL/PostGIS/Oracle中。这个扩展同样可以用在Grails里，这里有一篇简单的介绍，关于在Grails和MySQL中管理地理数据：<br />
<a href="http://www.grails.org/MySQL+GIS-Geometry+with+Grails" target="_blank">http://www.grails.org/MySQL+GIS-Geometry+with+Grails</a></p>
<p>不过按照这个文章里介绍的方法用，很可能会遭遇这样的报错：</p>
<blockquote><p>org.hibernate.MappingException: No Dialect mapping for JDBC type: 2003</p></blockquote>
<p>这个问题最终在这里得到了解答：<br />
<a href="http://n2.nabble.com/No-Dialect-mapping-for-JDBC-type-2003-td1141106.html" target="_blank">http://n2.nabble.com/No-Dialect-mapping-for-JDBC-type-2003-td1141106.html</a><br />
按照邮件列表里的反映，上面的配置在Postgis里是可以work的，但是如果用Mysql还需要指定JPA的columnDefinition，对应的Hibernate属性是sql-type。虽然作者承诺会在今后的版本里修改这个问题，不过眼下的M2版本还没有修正这个问题。为此，Grails的用户特地提出在Grails中加入sql-type的支持：<br />
<a href="http://jira.codehaus.org/browse/GRAILS-3201" target="_blank">http://jira.codehaus.org/browse/GRAILS-3201</a><br />
现在按照下面文档的说明，可以在mapping里指定sqlType了：<br />
<a href="http://grails.org/doc/latest/ref/Database%20Mapping/column.html" target="_blank">http://grails.org/doc/latest/ref/Database%20Mapping/column.html</a></p>
<p>实例代码里的domain定义应该改成：</p>
<pre class="brush:groovy">
import com.vividsolutions.jts.geom.Polygon
import org.hibernatespatial.GeometryUserType

public class MyPoly {
    String name
    Polygon poly

    static mapping = {
        poly type: GeometryUserType， sqlType:"GEOMETRY"
    }

}
</pre>
<p>于是，再也没有莫名其妙的No Dialect报错了。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/10/mapping-geometry-in-grails-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading GPS Data From EXIF Using Groovy</title>
		<link>http://sunng.info/blog/2009/10/reading-gps-data-from-exif-using-groovy/</link>
		<comments>http://sunng.info/blog/2009/10/reading-gps-data-from-exif-using-groovy/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 15:29:10 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[手艺]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=232</guid>
		<description><![CDATA[废话不说了，直接上code吧： import com.drew.imaging.jpeg.*; import com.drew.metadata.*; import com.drew.metadata.exif.*; file = new File("sample.jpg"); meta = JpegMetadataReader.readMetadata(file); gpsdir = meta.getDirectory(GpsDirectory.class); lat = gpsdir.getRationalArray(GpsDirectory.TAG_GPS_LATITUDE); lon = gpsdir.getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE); lats = lat[0].doubleValue() + lat[1].doubleValue()/60 + lat[2].doubleValue()/3600; lons = lon[0].doubleValue() + lon[1].doubleValue()/60 + lon[2].doubleValue()/3600; println(lats); println(lons); metadata-extractor似乎是现在惟一的读取exif信息的java库。在ivy中可以添加这样一个依赖： &#60;dependency org=&#34;com.drewnoakes&#34; name=&#34;metadata-extractor&#34; rev=&#34;2.4.0-beta-1&#34; conf=&#34;runtime&#34;/&#62;]]></description>
			<content:encoded><![CDATA[<p>废话不说了，直接上code吧：</p>
<pre class="brush:groovy">
import com.drew.imaging.jpeg.*;
import com.drew.metadata.*;
import com.drew.metadata.exif.*;

file = new File("sample.jpg");
meta = JpegMetadataReader.readMetadata(file);

gpsdir = meta.getDirectory(GpsDirectory.class);
lat = gpsdir.getRationalArray(GpsDirectory.TAG_GPS_LATITUDE);
lon = gpsdir.getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE);
lats = lat[0].doubleValue() + lat[1].doubleValue()/60 + lat[2].doubleValue()/3600;
lons = lon[0].doubleValue() + lon[1].doubleValue()/60 + lon[2].doubleValue()/3600;
println(lats);
println(lons);
</pre>
<p>metadata-extractor似乎是现在惟一的读取exif信息的java库。在ivy中可以添加这样一个依赖：</p>
<pre class="brush:xml">
&lt;dependency org=&quot;com.drewnoakes&quot; name=&quot;metadata-extractor&quot; rev=&quot;2.4.0-beta-1&quot; conf=&quot;runtime&quot;/&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/10/reading-gps-data-from-exif-using-groovy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>libchamplain: Map Widget of Gnome Desktop</title>
		<link>http://sunng.info/blog/2009/10/libchamplain-map-widget-of-gnome-desktop/</link>
		<comments>http://sunng.info/blog/2009/10/libchamplain-map-widget-of-gnome-desktop/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 06:58:29 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=224</guid>
		<description><![CDATA[续昨，虽然昨天升级到了gnome2.28，也安装了libchamplain，但是却没有发现这个库应用。Ubuntu上的Empathy似乎是没有把location support编译进去。看不到效果怎么办，好在libchamplain的作者还提供了另一个应用。这是一个eog的插件，用于读取照片的exif信息中的gps latitude和longitude，进而将他显示在libchamplain的地图里。 安装这个插件可以follow官方网站上的做法，当然开发包、头文件之类的东西要齐备。 libchamplain使用了clutter，在载入地图的时候还有fadein的效果。clutter是将要应用在下一代桌面gnome shell中的图形特效库。 插件是用C写的，可以看成是libchamplain的一个例子，作者说已经有了其他语言的binding，如此未来在gnome桌面上开发tile地图程序会变得简单。]]></description>
			<content:encoded><![CDATA[<p>续昨，虽然昨天升级到了gnome2.28，也安装了libchamplain，但是却没有发现这个库应用。Ubuntu上的Empathy似乎是没有把location support编译进去。看不到效果怎么办，好在<a href="http://www.pierlux.com/" target="_blank">libchamplain的作者</a>还提供了另一个应用。这是一个eog的插件，用于读取照片的exif信息中的gps latitude和longitude，进而将他显示在libchamplain的地图里。</p>
<p><img class="alignnone" src="http://pic.yupoo.com/classicning/2698882a6ac0/medium.jpg" alt="" width="500" height="343" /></p>
<p>安装这个插件可以follow<a href="http://live.gnome.org/EyeOfGnome/Plugins" target="_blank">官方网站上的做法</a>，当然开发包、头文件之类的东西要齐备。</p>
<p>libchamplain使用了<a href="http://www.clutter-project.org/" target="_blank">clutter</a>，在载入地图的时候还有fadein的效果。clutter是将要应用在下一代桌面gnome shell中的图形特效库。</p>
<p>插件是用C写的，可以看成是libchamplain的一个例子，作者说已经有了其他语言的binding，如此未来在gnome桌面上开发tile地图程序会变得简单。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/10/libchamplain-map-widget-of-gnome-desktop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GeoHash</title>
		<link>http://sunng.info/blog/2009/09/geohash/</link>
		<comments>http://sunng.info/blog/2009/09/geohash/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 13:05:59 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[手艺]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=180</guid>
		<description><![CDATA[今天偶然看到一个Ruby的GeoHash库，功能非常简单，就是将经纬度坐标哈希成字符串，并且，利用这个字符串可以粗略地比较两点的距离。这个库的代码host在GitHub上，要安装，需要将github加入gem： sudo gem sources -a http://gems.github.com sudo gem install davotroy-geohash 用法，irb： irb(main):001:0&#62; require &#8216;rubygems&#8217; =&#62; true irb(main):002:0&#62; require &#8216;geohash&#8217; =&#62; true irb(main):003:0&#62; GeoHash.encode(32.168, 118.54) =&#62; &#8220;wtsr12n0nj&#8221; irb(main):004:0&#62; GeoHash.decode(&#8216;wtsr12n0nj&#8217;) =&#62; [32.168, 118.54] 代码可以从github上获得 git clone git://github.com/davetroy/geohash.git GeoHash的核心部分用C实现，仔细看一下可以发现是一个四叉树的结构： [codesyntax lang="c"] #define BASE32 "0123456789bcdefghjkmnpqrstuvwxyz" static void encode_geohash(double latitude, double longitude, int precision, char *geohash) { int is_even=1, i=0; [...]]]></description>
			<content:encoded><![CDATA[<p>今天偶然看到一个Ruby的GeoHash库，功能非常简单，就是将经纬度坐标哈希成字符串，并且，利用这个字符串可以粗略地比较两点的距离。这个库的代码host在GitHub上，要安装，需要将github加入gem：<br />
<em>sudo gem sources -a http://gems.github.com<br />
sudo gem install davotroy-geohash</em></p>
<p>用法，irb：<br />
<em>irb(main):001:0&gt; require &#8216;rubygems&#8217;<br />
=&gt; true<br />
irb(main):002:0&gt; require &#8216;geohash&#8217;<br />
=&gt; true<br />
irb(main):003:0&gt; GeoHash.encode(32.168, 118.54)<br />
=&gt; &#8220;wtsr12n0nj&#8221;<br />
irb(main):004:0&gt; GeoHash.decode(&#8216;wtsr12n0nj&#8217;)<br />
=&gt; [32.168, 118.54]</em></p>
<p>代码可以从github上获得<br />
<em>git clone git://github.com/davetroy/geohash.git</em></p>
<p>GeoHash的核心部分用C实现，仔细看一下可以发现是一个四叉树的结构：</p>
<pre>[codesyntax lang="c"]
#define BASE32	"0123456789bcdefghjkmnpqrstuvwxyz"
static void encode_geohash(double latitude, double longitude, int precision, char *geohash) {
	int is_even=1, i=0;
	double lat[2], lon[2], mid;
	char bits[] = {16,8,4,2,1};
	int bit=0, ch=0;

	lat[0] = -90.0;  lat[1] = 90.0;
	lon[0] = -180.0; lon[1] = 180.0;

	while (i &lt; precision) {
		if (is_even) {
 			mid = (lon[0] + lon[1]) / 2;
 			if (longitude &gt; mid) {
				ch |= bits[bit];
				lon[0] = mid;
			} else
				lon[1] = mid;
		} else {
			mid = (lat[0] + lat[1]) / 2;
			if (latitude &gt; mid) {
				ch |= bits[bit];
				lat[0] = mid;
			} else
				lat[1] = mid;
		}

		is_even = !is_even;
		if (bit &lt; 4)
			bit++;
		else {
			geohash[i++] = BASE32[ch];
			bit = 0;
			ch = 0;
		}
	}
	geohash[i] = 0;
}

[/codesyntax]
</pre>
<p>可惜在学校的时候没有看到这么精致的代码。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/09/geohash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
