<?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>mobile and gis dev notes &#187; GIS</title>
	<atom:link href="http:///wordpress/category/gis-general/feed/" rel="self" type="application/rss+xml" />
	<link>/wordpress</link>
	<description>by rupert</description>
	<lastBuildDate>Sun, 22 Jan 2012 04:34:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Nominatim + homebrew on OSX + OSM data + PHP = open sourced reverse geocoder</title>
		<link>/wordpress/2011/11/nominatim-on-osx/</link>
		<comments>/wordpress/2011/11/nominatim-on-osx/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 05:45:20 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">/wordpress/?p=1098</guid>
		<description><![CDATA[This installation guide (at the time of writing) was tested on SVN trunk of OSM2PGSQL and running on latest/stable Postgres/Postgis versions on OSX via homebrew. 1. Summary OSX Snow Leopard &#160; OSM2PGSQL: Head http://svn.openstreetmap.org/applications/utils/export/osm2pgsql Revision: 27034 Last Changed Author: frederik Last Changed Rev: 27030 Last Changed Date: 2011-11-09 10:57:49 +1100 (Wed, 09 Nov 2011) &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This installation guide (at the time of writing) was tested on SVN trunk of OSM2PGSQL and running on latest/stable Postgres/Postgis versions on OSX via homebrew.</p>
<p><strong>1. Summary</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">OSX Snow Leopard
&nbsp;
OSM2PGSQL: 
Head http://svn.openstreetmap.org/applications/utils/export/osm2pgsql Revision: 27034
Last Changed Author: frederik
Last Changed Rev: 27030
Last Changed Date: 2011-11-09 10:57:49 +1100 (Wed, 09 Nov 2011)
&nbsp;
POSTGRES: 9.0.4
&nbsp;
POSTGIS: &quot;POSTGIS=&quot;1.5.3&quot; GEOS=&quot;3.3.1-CAPI-1.7.1&quot; PROJ=&quot;Rel. 4.7.1, 23 September 2009&quot; LIBXML=&quot;2.7.3&quot; USE_STATS&quot; # SELECT POSTGIS_FULL_VERSION();
&nbsp;
PHP: 5.3.8 (cli) (built: Nov 14 2011 14:41:52) #php -v</pre></div></div>

<p><strong>2. Installation</strong><br />
Most of the software is installed via <a href="https://github.com/mxcl/homebrew">homebrew.</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Install homebrew</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(curl -fsSL https://raw.github.com/gist/323731)</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Install postgresql</span>
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql
<span style="color: #000000; font-weight: bold;">%</span> initdb <span style="color: #660033;">-E</span> utf8 <span style="color: #660033;">-D</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>postgres
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>9.0.4<span style="color: #000000; font-weight: bold;">/</span>org.postgresql.postgres.plist ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">%</span> launchctl load <span style="color: #660033;">-w</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>org.postgresql.postgres.plist
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> postgres <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>9.0.4<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>adminpack.sql
&nbsp;
<span style="color: #666666; font-style: italic;"># Install postgis</span>
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> proj
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> geos
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> postgis
&nbsp;
<span style="color: #666666; font-style: italic;"># Create template_postgis_osm</span>
<span style="color: #000000; font-weight: bold;">%</span> createdb <span style="color: #660033;">-E</span> utf8 template_postgis_osm
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> template_postgis_osm <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;/usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/pg_trgm.sql&quot;</span>
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> template_postgis_osm <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>1.5.3<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>postgis.sql
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> template_postgis_osm <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>1.5.3<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql
&nbsp;
<span style="color: #666666; font-style: italic;"># Install osm2pgsql. Can skip this.</span>
<span style="color: #666666; font-style: italic;"># % brew install osm2pgsql</span></pre></div></div>

<p>For detail instructions on installing Postgres/Postgis via Homebrew, read this <a href="/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/">homebrew + postgresql9.0.4 + postgis.1.5.3 + proj4 + geos3.3.1 + osm2pgsql</a>.  If you are having problems installing GEOS, then read that link as it shows you how to upgrade GEOS to 3.3.1.</p>
<p>OSM2PGSQL needs GEOS as well. Note that brew only install the osm2pgsql binary. Don&#8217;t worry, we will compile this via source later. </p>
<p><strong>3. More Installation.</strong></p>
<p>We need to get PHP installed to run gazetteer <a href="http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/">http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Install PHP</span>
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> php <span style="color: #660033;">--with-mysql</span> <span style="color: #660033;">--with-pgsql</span> <span style="color: #660033;">--with-apache</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Hookup with Apache</span>
<span style="color: #666666; font-style: italic;"># Edit httpd.conf to LoadModule</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Install PEAR DB</span>
<span style="color: #000000; font-weight: bold;">%</span> pear <span style="color: #c20cb9; font-weight: bold;">install</span> db</pre></div></div>

<p><strong>4. OSM2PGSQL</strong><br />
Read this wiki: <a href="http://wiki.openstreetmap.org/wiki/Osm2pgsql">http://wiki.openstreetmap.org/wiki/Osm2pgsql</a>. Well, we eventually need the whole OSM2PGSQL source as it contains the website (gazetteer).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.openstreetmap.org<span style="color: #000000; font-weight: bold;">/</span>applications<span style="color: #000000; font-weight: bold;">/</span>utils<span style="color: #000000; font-weight: bold;">/</span>export<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql osm2pgsql
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> osm2pgsql
<span style="color: #000000; font-weight: bold;">%</span> .<span style="color: #000000; font-weight: bold;">/</span>autogen.sh
<span style="color: #000000; font-weight: bold;">%</span> .<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># At this point there should be an osm2pgsql binary.</span></pre></div></div>

<p><em>We need to compile gazetteer for gazetteer.so which is used by gazetteer-functions.sql</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> clean
gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> 
gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;/usr/local/lib/osm2pgsql&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> ..<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">/</span>install-sh <span style="color: #660033;">-c</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;/usr/local/lib/osm2pgsql&quot;</span>
 <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> ..<span style="color: #000000; font-weight: bold;">/</span>libtool <span style="color: #660033;">--mode</span>=<span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span>  <span style="color: #ff0000;">'gazetteer.la'</span> <span style="color: #ff0000;">'/usr/local/lib/osm2pgsql/gazetteer.la'</span>
libtool: <span style="color: #c20cb9; font-weight: bold;">install</span>: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> .libs<span style="color: #000000; font-weight: bold;">/</span>gazetteer.so <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer.so
libtool: <span style="color: #c20cb9; font-weight: bold;">install</span>: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> .libs<span style="color: #000000; font-weight: bold;">/</span>gazetteer.lai <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer.la
<span style="color: #660033;">----------------------------------------------------------------------</span>
Libraries have been installed <span style="color: #000000; font-weight: bold;">in</span>:
   <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql
&nbsp;
If you ever happen to want to <span style="color: #c20cb9; font-weight: bold;">link</span> against installed libraries
<span style="color: #000000; font-weight: bold;">in</span> a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the <span style="color: #000000; font-weight: bold;">`</span>-LLIBDIR<span style="color: #ff0000;">'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH'</span> environment variable
     during execution
&nbsp;
See any operating system documentation about shared libraries <span style="color: #000000; font-weight: bold;">for</span>
<span style="color: #c20cb9; font-weight: bold;">more</span> information, such <span style="color: #c20cb9; font-weight: bold;">as</span> the <span style="color: #c20cb9; font-weight: bold;">ld</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> and ld.so<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> manual pages.
<span style="color: #660033;">----------------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;/usr/local/share/gazetteer&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> ..<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">/</span>install-sh <span style="color: #660033;">-c</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;/usr/local/share/gazetteer&quot;</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'extract_countrynames.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/extract_countrynames.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-index.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-index.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-loaddata.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-loaddata.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-tables.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-tables.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_country_name.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_country_name.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_country_osm_grid.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_country_osm_grid.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_gb_postcodearea.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_gb_postcodearea.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_gb_postcode.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_gb_postcode.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_specialwords.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_specialwords.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_us_statecounty.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_us_statecounty.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_us_state.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_us_state.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_worldboundaries.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_worldboundaries.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-functions.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-functions.sql'</span></pre></div></div>

<p><strong>5. Download Data</strong><br />
You can get some regional OSM data from cloudmade. <a href="http://downloads.cloudmade.com/oceania/australia_and_new_zealand/australia/victoria">http://downloads.cloudmade.com/oceania/australia_and_new_zealand/australia/victoria</a> </p>
<p>I suggest you download a regional extract prior to downloading/testing with the whole planet-osm. If you don&#8217;t believe me that it will take long, you can read <a href="http://wiki.openstreetmap.org/wiki/Nominatim/Installation">http://wiki.openstreetmap.org/wiki/Nominatim/Installation</a></p>
<p><strong>6. Load and Index Data</strong><br />
Basically, this is the summary of commands taken from <a href="http://wiki.openstreetmap.org/wiki/Nominatim/Installation">http://wiki.openstreetmap.org/wiki/Nominatim/Installation</a> At the time of writing this, I had issues such as &#8220;planet_osm_ways&#8221; (and several tables) does not exist. So I did a pg_dump and restored the tables afterwards. Be very careful with using the script below, you can comment the indexing part just to speed up on loading and see if you have errors, etc.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">DATABASE_NAME</span>=gazetteer_vic
<span style="color: #007800;">OSM2PGSQL_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql
<span style="color: #007800;">SOURCE_DATA</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>australia<span style="color: #000000; font-weight: bold;">/</span>victoria.osm
<span style="color: #007800;">DUMP_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>pg_dumps<span style="color: #000000; font-weight: bold;">/</span>streetlookup
&nbsp;
dropdb <span style="color: #007800;">$DATABASE_NAME</span> 
<span style="color: #666666; font-style: italic;">#dropuser www-data</span>
&nbsp;
createdb <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-E</span> UTF8 <span style="color: #660033;">-T</span> template_postgis_osm
createuser <span style="color: #660033;">-SDR</span> www-data
&nbsp;
<span style="color: #666666; font-style: italic;"># This will create the planet_osm_ways, etc</span>
<span style="color: #007800;">$OSM2PGSQL_HOME</span><span style="color: #000000; font-weight: bold;">/</span>osm2pgsql <span style="color: #660033;">--create</span> <span style="color: #660033;">--latlong</span> <span style="color: #660033;">--database</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--slim</span> <span style="color: #660033;">--prefix</span> planet_osm <span style="color: #660033;">--cache</span> <span style="color: #000000;">2048</span> <span style="color: #007800;">$SOURCE_DATA</span>
&nbsp;
pg_dump <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--format</span> custom <span style="color: #660033;">--file</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_ways.backup&quot;</span> <span style="color: #660033;">--table</span> public.planet_osm_ways <span style="color: #007800;">$DATABASE_NAME</span>
pg_dump <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--format</span> custom <span style="color: #660033;">--file</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_nodes.backup&quot;</span> <span style="color: #660033;">--table</span> public.planet_osm_nodes <span style="color: #007800;">$DATABASE_NAME</span>
pg_dump <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--format</span> custom <span style="color: #660033;">--file</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_rels.backup&quot;</span> <span style="color: #660033;">--table</span> public.planet_osm_rels <span style="color: #007800;">$DATABASE_NAME</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This will create the place table</span>
<span style="color: #007800;">$OSM2PGSQL_HOME</span><span style="color: #000000; font-weight: bold;">/</span>osm2pgsql <span style="color: #660033;">--latlong</span> <span style="color: #660033;">-O</span> gazetteer <span style="color: #660033;">--database</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--slim</span> <span style="color: #660033;">--prefix</span> planet_osm <span style="color: #660033;">--cache</span> <span style="color: #000000;">2048</span> <span style="color: #007800;">$SOURCE_DATA</span>
&nbsp;
pg_restore <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--dbname</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_ways.backup&quot;</span>
pg_restore <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--dbname</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_nodes.backup&quot;</span>
pg_restore <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--dbname</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_rels.backup&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-Rf</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #000000; font-weight: bold;">/*</span>.backup
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_country_osm_grid.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_worldboundaries.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_country_name.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_gb_postcode.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_gb_postcodearea.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_us_state.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_us_statecounty.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-functions.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-tables.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-functions.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-loaddata.sql
&nbsp;
<span style="color: #666666; font-style: italic;">#Indexing</span>
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-index.sql</pre></div></div>

<p>Save this as run.sh in <code>/Users/rupert/projects/gis/osm2pgsql/gazetteer</code></p>
<p>Where do you run this?</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> run.sh</pre></div></div>

<p><strong>6. Test</strong><br />
If you are successful, <strong>you should have a &#8220;placex&#8221; table.</strong> Now that we have a postgis database running, you can now run spatial statements thru pgadmin. See the guts of <a href="http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/reverse.php">reverse.php</a></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> 
<span style="color: #993333; font-weight: bold;">FROM</span> placex
<span style="color: #993333; font-weight: bold;">WHERE</span> ST_DWithin<span style="color: #66cc66;">&#40;</span> ST_SetSRID<span style="color: #66cc66;">&#40;</span>ST_Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">145.234377</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">37.856320</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">4326</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> geometry<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0.0001</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">AND</span> ST_GeometryType<span style="color: #66cc66;">&#40;</span>geometry<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'ST_Polygon'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'ST_MultiPolygon'</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This one took only 21 ms.</p>
<p><strong>7. Website</strong></p>
<p>Make sure <code>www-data</code> have permissions to the tables. Rememeber to replace gazetteer_vic with your DATABASE_NAME.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> tbl <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>psql <span style="color: #660033;">-qAt</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;select tablename from pg_tables where schemaname = 'public';&quot;</span> gazetteer_vic<span style="color: #000000; font-weight: bold;">`</span> ; <span style="color: #000000; font-weight: bold;">do</span> psql <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;alter table <span style="color: #007800;">$tbl</span> owner to <span style="color: #000099; font-weight: bold;">\&quot;</span>www-data<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> gazetteer_vic; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Assuming you have PHP and PEAR DB installed. Then update the data connection settings found in <a href="http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/.htlib/settings.php">http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/.htlib/settings.php</a></p>
<p>Run the same query but using reverse.php.</p>
<p><a href="http://127.0.0.1/nominatim/reverse.php?format=xml&#038;lat=-37.856320&#038;lon=145.234377&#038;zoom=18&#038;addressdetails=1">http://127.0.0.1/nominatim/reverse.php?format=xml&#038;lat=-37.856320&#038;lon=145.234377&#038;zoom=18&#038;addressdetails=1</a></p>
<p><img src="/wordpress/wp-content/uploads/2011/11/reverse.png" alt="reverse.png" border="0" width="920" height="343" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/nominatim-on-osx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>osx + homebrew + postgresql9.0.4 + postgis.1.5.3 + proj4 + geos3.3.1 + osm2pgsql</title>
		<link>/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/</link>
		<comments>/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 02:02:21 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[homebrew]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=1088</guid>
		<description><![CDATA[For the impatient % /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.github.com/gist/323731)&#34; % brew install postgresql % initdb -E utf8 -D /usr/local/var/postgres % cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/ % launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist % psql -d postgres -f /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql % brew install proj % brew install geos %you should really read below before running this % brew install postgis % [...]]]></description>
			<content:encoded><![CDATA[<p><strong>For the impatient</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% /usr/bin/ruby -e &quot;$(curl -fsSL https://raw.github.com/gist/323731)&quot;
% brew install postgresql
% initdb -E utf8 -D /usr/local/var/postgres
% cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
% launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
% psql -d postgres -f /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql
% brew install proj
% brew install geos %you should really read below before running this
% brew install postgis
% createdb -E utf8 template_postgis
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/postgis.sql
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/spatial_ref_sys.sql</pre></div></div>

<p><strong>1. Install homebrew</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">%open https://github.com/mxcl/homebrew
%open https://github.com/mxcl/homebrew/wiki/Installation
%/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.github.com/gist/323731)&quot;</pre></div></div>

<p>Install python first if you need PL/Python in postgres. The &#8211;framework option tells Homebrew to compile a Framework-style Python build, rather than a UNIX-style build. Read this <a href="/wordpress/2011/12/homebrew-python/">INSTALLATION GUIDE.</a></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">%brew install python --framework</pre></div></div>

<p><strong>2. Install Postgres</strong><br />
Note that postgres installation will pick up the latest Python Configuration, <strong>so it is important to ensure that we want the specific PYTHON interpreter to compile with our postgresql installation</strong>. You can turn the flag <em>-v</em> to enable verbose installation.  Watch for the configuration log output for PYTHON to check if it loads the PYTHON environment that we expect</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">%PYTHON=/usr/local//bin/python brew install postgresql -v
....
checking for python... /usr/local/bin/python
checking for Python distutils module... yes
checking Python configuration directory... /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
...
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/mxcl/homebrew/issues/issue/2510
&nbsp;
To build plpython against a specific Python, set PYTHON prior to brewing:
  PYTHON=/usr/local/bin/python  brew install postgresql
See:
  http://www.postgresql.org/docs/9.0/static/install-procedure.html
&nbsp;
&nbsp;
If this is your first install, create a database with:
  initdb /usr/local/var/postgres
&nbsp;
If this is your first install, automatically load on login with:
  mkdir -p ~/Library/LaunchAgents
  cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
&nbsp;
If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
  launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
  cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
&nbsp;
Or start manually with:
  pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
&nbsp;
And stop with:
  pg_ctl -D /usr/local/var/postgres stop -s -m fast
&nbsp;
&nbsp;
Some machines may require provisioning of shared memory:
  http://www.postgresql.org/docs/current/static/kernel-resources.html%SYSVIPC
&nbsp;
If you want to install the postgres gem, including ARCHFLAGS is recommended:
    env ARCHFLAGS=&quot;-arch x86_64&quot; gem install pg
&nbsp;
To install gems without sudo, see the Homebrew wiki.
==&gt; Summary
/usr/local/Cellar/postgresql/9.0.4: 2577 files, 35M, built in 3.1 minutes
brew install postgresql  188.73s user 62.38s system 106% cpu 3:55.06 total</pre></div></div>

<p><strong>3. Postgres Post Installation. Initialize DB.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% initdb -E utf8 -D /usr/local/var/postgres
The files belonging to this database system will be owned by user &quot;rupert&quot;.
This user must also own the server process.
&nbsp;
The database cluster will be initialized with locale en_AU.UTF-8.
The default text search configuration will be set to &quot;english&quot;.
&nbsp;
creating directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 2400kB
creating configuration files ... ok
creating template1 database in /usr/local/var/postgres/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
&nbsp;
WARNING: enabling &quot;trust&quot; authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
&nbsp;
Success. You can now start the database server using:
&nbsp;
    postgres -D /usr/local/var/postgres
or
    pg_ctl -D /usr/local/var/postgres -l logfile start</pre></div></div>

<p><strong>4. Postgres Startup</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
% launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
%telnet 127.0.0.1 5432
Trying 127.0.0.1...
Connected to rupert-mbp.
Escape character is '^]'.
% psql -d postgres -f /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql</pre></div></div>

<p>UPDATE:<br />
I have now disabled the automatic startup of Postgres as it provides me more control especially during development. Extract <a href="/wordpress/wp-content/uploads/2011/12/Postgres9.1.2.tar.gz" title="Postgres9.1.2.tar.gz">Postgres9.1.2.tar.gz</a> to /Library/StartupItems.</p>
<p>To start/stop</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">/Library/StartupItems/Postgres9.1.2/Postgres9.1.2 start</pre></div></div>

<p><strong>5. Postgis</strong><br />
Note this will install dependencies, PROJ4 and GEOS. At the time of writing this, we have a problem with GEOS. Need to update GEOS formula to 3.3.1. For more info read:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% open https://github.com/mxcl/homebrew/issues/8151
% open https://gist.github.com/1306088
% brew edit geos</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% brew install proj
% brew install geos
% brew install postgis
% createdb -E utf8 template_postgis
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/postgis.sql
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/spatial_ref_sys.sql</pre></div></div>

<p><strong>6. osm2pgsql</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% brew install osm2pgsql
==&gt; Checking out http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/
==&gt; ./autogen.sh
==&gt; ./configure
==&gt; make
/usr/local/Cellar/osm2pgsql/HEAD: 6 files, 328K, built in 70 seconds</pre></div></div>

<p><strong>7. Check for loaded/configured PLPYTHON environment for POSTGRES</strong><br />
If you get import module errors, you should check your PYTHON version and if the module is loaded in your python&#8217;s site-packages.  The function below will provide which version of PYTHON is compiled with your POSTGRESQL.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURAL</span> <span style="color: #993333; font-weight: bold;">LANGUAGE</span>
<span style="color: #ff0000;">'plpythonu'</span> HANDLER plpython_call_handler;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pyver<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> returns text <span style="color: #993333; font-weight: bold;">AS</span>
$$
import sys
<span style="color: #993333; font-weight: bold;">RETURN</span> sys<span style="color: #66cc66;">.</span>version
$$ <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #ff0000;">'plpythonu'</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> pyver<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #ff0000;">&quot;2.7.2 (default, Dec 30 2011, 09:25:27) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)]&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Postgres8.3,8.4,9.0, Postgis1.3.3,1.4.1,2.0, pgRouting on OSX  (updated)</title>
		<link>/wordpress/2011/02/installing-postgres83-postgis133-pgrouting-on-macosx-leopard-2/</link>
		<comments>/wordpress/2011/02/installing-postgres83-postgis133-pgrouting-on-macosx-leopard-2/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 03:31:08 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pgRouting]]></category>

		<guid isPermaLink="false">/wordpress/?p=843</guid>
		<description><![CDATA[(Updated):Postgres9.0.3 Postgis2.0svn Before you go any further. Dump data before migrating and installing. Warning: Most of the packages listed below is installed by source. 1. Download the current postgres source. http://www.postgresql.org/ftp/source/ 8.3: $./configure --with-prefix=/usr/local/pgsql --with-python &#160; 8.4: $./configure --prefix=/usr/local/pgsql --with-python &#160; $make $sudo make install 2. Don&#8217;t delete the postgres folder. You might need this [...]]]></description>
			<content:encoded><![CDATA[<p><strong>(Updated):Postgres9.0.3 Postgis2.0svn</strong></p>
<p>Before you go any further. <a href="/wordpress/2011/02/migrating-data-from-postgres82-to-postgres83-3/">Dump data before migrating and installing.</a>  <i>Warning: Most of the packages listed below is installed by source.</i></p>
<p>1. Download the current postgres source. <a href="http://www.postgresql.org/ftp/source/">http://www.postgresql.org/ftp/source/</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">8.3</span>:
$.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql <span style="color: #660033;">--with-python</span>
&nbsp;
<span style="color: #000000;">8.4</span>:
$.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql <span style="color: #660033;">--with-python</span>
&nbsp;
<span style="color: #007800;">$make</span>
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>2. Don&#8217;t delete the postgres folder. You might need this later on for future compilations. See pgadmin3 admin pack below.</p>
<p>3. Add a postgres user from <strong>System Preferences &gt; Accounts</strong></p>
<p>4. Initialize the data directory</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data
<span style="color: #007800;">$chown</span> postgres <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #007800;">$su</span> - postgres
$<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>initdb <span style="color: #660033;">-E</span> utf8 <span style="color: #660033;">-D</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data</pre></div></div>

<blockquote>
<pre>
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale C.
The default text search configuration will be set to "english".

fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers/max_fsm_pages ... 2400kB/20000
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
or
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
</pre>
</blockquote>
<p>4. Install Geos , PROJ4, and Postgis</p>
<p><b>GEOS:</b><br/><br />
- install geos with the Kyngchaos installer</p>
<p>- installing by source</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> checkout http:<span style="color: #000000; font-weight: bold;">//</span>svn.osgeo.org<span style="color: #000000; font-weight: bold;">/</span>geos<span style="color: #000000; font-weight: bold;">/</span>trunk trunk
<span style="color: #7a0874; font-weight: bold;">cd</span> trunk<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">sh</span> autogen.sh
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>geos <span style="color: #660033;">--enable-python</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>PROJ4:</b><br/></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.osgeo.org<span style="color: #000000; font-weight: bold;">/</span>metacrs<span style="color: #000000; font-weight: bold;">/</span>proj<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>proj<span style="color: #000000; font-weight: bold;">/</span> proj
<span style="color: #7a0874; font-weight: bold;">cd</span> proj
<span style="color: #c20cb9; font-weight: bold;">sh</span> autogen.sh
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>proj4
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>POSTGIS:</b><br/></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">8.3</span>:
$.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-pgsql</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pg_config <span style="color: #660033;">--with-geos</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>geos-config
&nbsp;
<span style="color: #000000;">8.4</span> using Kyngchaos GEOS Framework:
$.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-pgsql</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pg_config <span style="color: #660033;">--with-geosconfig</span>=<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Frameworks<span style="color: #000000; font-weight: bold;">/</span>GEOS.framework<span style="color: #000000; font-weight: bold;">/</span>unix<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>geos-config
&nbsp;
<span style="color: #000000;">9.0</span>:using Kyngchaos GEOS + PROJ framework:<span style="color: #7a0874; font-weight: bold;">&#40;</span>Update Feb <span style="color: #000000;">15</span>, <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-pgsql</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pg_config <span style="color: #660033;">--with-geosconfig</span>=<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Frameworks<span style="color: #000000; font-weight: bold;">/</span>GEOS.framework<span style="color: #000000; font-weight: bold;">/</span>unix<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>geos-config <span style="color: #660033;">--with-projdir</span>=<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Frameworks<span style="color: #000000; font-weight: bold;">/</span>PROJ.framework<span style="color: #000000; font-weight: bold;">/</span>unix<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--with-gettext</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gettext<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
Note: libintl.h error. You need <span style="color: #c20cb9; font-weight: bold;">gettext</span>
<span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-g</span> <span style="color: #660033;">-O2</span>  <span style="color: #660033;">-fno-common</span> <span style="color: #660033;">-DPIC</span>  <span style="color: #660033;">-Wall</span> <span style="color: #660033;">-Wmissing-prototypes</span>  -DUSE_NLS <span style="color: #660033;">-DLOCALEDIR</span>=<span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>locale<span style="color: #000000; font-weight: bold;">\&quot;</span> -Iyes<span style="color: #000000; font-weight: bold;">/</span>include  <span style="color: #660033;">-c</span> shp2pgsql-core.c
In <span style="color: #c20cb9; font-weight: bold;">file</span> included from shp2pgsql-core.c:<span style="color: #000000;">15</span>:
shp2pgsql-core.h:<span style="color: #000000;">17</span>:<span style="color: #000000;">21</span>: error: libintl.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or di
&nbsp;
9.0.4: using src from GEOS + PROJ
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-pgconfig</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pg_config <span style="color: #660033;">--with-geosconfig</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>geos<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>geos-config <span style="color: #660033;">--with-projdir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>proj4
&nbsp;
<span style="color: #007800;">$make</span>
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>If everthing is successful, you should see files in /usr/local/pgsql/share/contrib/.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>postgis-<span style="color: #000000;">2.0</span>
- legacy.sql
- postgis.sql
- postgis_upgrade_20_minor.sql
- spatial_ref_sys.sql
- uninstall_legacy.sql
- uninstall_postgis.sql</pre></div></div>

<p>5. Starting postgres on boot. Download <a href='/wordpress/wp-content/uploads/2008/05/postgresstartup.tar.gz'>postgresstartup.tar.gz</a> then extract to your /Library/StartupItems</p>
<p>6. Creating the database</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createdb <span style="color: #660033;">-E</span> utf8 template_postgis
createlang plpgsql template_postgis
&nbsp;
<span style="color: #000000;">8.3</span>:
psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>lwpostgis.sql
psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql
&nbsp;
<span style="color: #000000;">8.4</span>:
psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>postgis.sql 
psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql
&nbsp;
<span style="color: #000000;">9.0</span> + postgis2.0:
psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>postgis-<span style="color: #000000;">2.0</span><span style="color: #000000; font-weight: bold;">/</span>postgis.sql 
psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>postgis-<span style="color: #000000;">2.0</span><span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql</pre></div></div>

<p>7. Install and download pgAdmin3 for MacOS X </p>
<p><a href="http://www.postgresql.org/ftp/pgadmin3/release/">http://www.postgresql.org/ftp/pgadmin3/release/</a></p>
<p>Update Feb 15, 2011: Use pgadmin1.12 to connect with postgres9. <a href="http://postgresql.1045698.n5.nabble.com/BUG-5668-initdb-failed-to-create-postgres-database-td2847489.html<br />
">Other versions (1.8.4, 1.6.3 don&#8217;t work)</a></p>
<p>8. Startup pgadmin3. You will notice there is a window stating&#8230;</p>
<blockquote><p>Server instrumentation<br />
The server lacks instrumentation functions.<br />
pgAdmin III uses some support functions that are not available by default in all PostgreSQL versions. These enable some tasks that make life easier when dealing with log files and configuration files. </p></blockquote>
<p>9. Compile the adminpack. Go to $postgresql_install_directory/contrib/adminpack</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-no-cpp-precomp</span> <span style="color: #660033;">-O2</span> <span style="color: #660033;">-Wall</span> <span style="color: #660033;">-Wmissing-prototypes</span> <span style="color: #660033;">-Wpointer-arith</span> <span style="color: #660033;">-Winline</span> <span style="color: #660033;">-Wdeclaration-after-statement</span> <span style="color: #660033;">-Wendif-labels</span> <span style="color: #660033;">-fno-strict-aliasing</span> <span style="color: #660033;">-fwrapv</span>  <span style="color: #660033;">-bundle</span> -multiply_defined suppress  adminpack.o  -L..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>port -bundle_loader ..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>backend<span style="color: #000000; font-weight: bold;">/</span>postgres  <span style="color: #660033;">-o</span> libadminpack.0.0.so
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> libadminpack.0.so
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> libadminpack.0.0.so libadminpack.0.so
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> libadminpack.so
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> libadminpack.0.0.so libadminpack.so
&nbsp;
rupert:adminpack rupert$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
Password:
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> ..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>config<span style="color: #000000; font-weight: bold;">/</span>install-sh <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> .<span style="color: #000000; font-weight: bold;">/</span>uninstall_adminpack.sql <span style="color: #ff0000;">'/usr/local/pgsql/share/contrib'</span>
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> ..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>config<span style="color: #000000; font-weight: bold;">/</span>install-sh <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> adminpack.sql <span style="color: #ff0000;">'/usr/local/pgsql/share/contrib'</span>
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> ..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>config<span style="color: #000000; font-weight: bold;">/</span>install-sh <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">755</span>  libadminpack.0.0.so <span style="color: #ff0000;">'/usr/local/pgsql/lib/adminpack.so'</span></pre></div></div>

<p>10. Load the adminpack.sql into your maintenance and template database</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> postgres <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>adminpack.sql 
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
...</pre></div></div>

<p>11. Disconnect and Reconnect from pgAdmin3. You shouldn&#8217;t see the window again.</p>
<p>Continue only if you want pgRouting</p>
<p>12. Essentially we would need <a href="http://www.boost.org/">Boost Graph Library (BGL)</a> a.k.a boost, <a href="http://gaul.sourceforge.net/">Genetic Algorithm Utility Library</a> (or, GAUL for short), and GEOS (which we installed earlier when we installed postgis).</p>
<p>13. The easiest way to install boost is using MacPorts.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> boost-jam
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Fetching boost-jam
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Attempting to fetch boost-jam-3.1.16.tgz from http:<span style="color: #000000; font-weight: bold;">//</span>downloads.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>boost
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Verifying checksum<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">for</span> boost-jam
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Extracting boost-jam
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Configuring boost-jam
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Building boost-jam
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Staging boost-jam into destroot
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Installing boost-jam 3.1.16_0
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Activating boost-jam 3.1.16_0
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Cleaning boost-jam
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Fetching <span style="color: #c20cb9; font-weight: bold;">gmake</span>
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Attempting to fetch make-3.81.tar.bz2 from http:<span style="color: #000000; font-weight: bold;">//</span>ftp.gnu.org<span style="color: #000000; font-weight: bold;">/</span>gnu<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">make</span>
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Verifying checksum<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">gmake</span>
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Extracting <span style="color: #c20cb9; font-weight: bold;">gmake</span>
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Configuring <span style="color: #c20cb9; font-weight: bold;">gmake</span>
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Building <span style="color: #c20cb9; font-weight: bold;">gmake</span> with target all
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Staging <span style="color: #c20cb9; font-weight: bold;">gmake</span> into destroot
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Installing <span style="color: #c20cb9; font-weight: bold;">gmake</span> <span style="color: #000000;">3.81</span>_0
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Activating <span style="color: #c20cb9; font-weight: bold;">gmake</span> <span style="color: #000000;">3.81</span>_0
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Cleaning <span style="color: #c20cb9; font-weight: bold;">gmake</span>
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Fetching boost
---<span style="color: #000000; font-weight: bold;">&gt;</span>  Attempting to fetch boost_1_34_1.tar.bz2 from http:<span style="color: #000000; font-weight: bold;">//</span>downloads.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>boost
...
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> boost</pre></div></div>

<p>Note: I encountered an error when I directly installed &#8220;sudo port install boost&#8221; on my first run. A quick workaround is to install boost-jam, then install boost afterwards. For more details:</p>
<ul>
<li><a href="http://trac.macosforge.org/projects/macports/ticket/13714">http://trac.macosforge.org/projects/macports/ticket/13714</a></li>
<li><a href="http://trac.macosforge.org/projects/macports/ticket/14043">http://trac.macosforge.org/projects/macports/ticket/14043</a></li>
</ul>
<blockquote><p>Error: Target org.macports.build returned: shell command &#8221; cd &#8220;/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_boost/work/boost_1_34_1&#8243; &#038;&#038; gmake all &#8221; returned error 2 Command output: Makefile:2: *** missing separator.  Stop.</p></blockquote>
<p>14. You can check if boost was successfully installed by&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #660033;">-v</span> installed boost boost-jam
The following ports are currently installed:
  boost <span style="color: #000000; font-weight: bold;">@</span>1.34.1_3+darwin_9 <span style="color: #7a0874; font-weight: bold;">&#40;</span>active<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  boost-jam <span style="color: #000000; font-weight: bold;">@</span>3.1.16_0 <span style="color: #7a0874; font-weight: bold;">&#40;</span>active<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>15. For GAUL, we don&#8217;t need slang base on <a href="http://pgrouting.postlbs.org/wiki/1.x/InstallationManual">http://pgrouting.postlbs.org/wiki/1.x/InstallationManual</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--enable-slang</span>=no
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>16. Ok, so this is the heartbreaker. I was able to get pass cmake on pgRouting on version 1.02 however, I received &#8220;undefined symbols&#8221; when linking the librouting.dylib</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Linking CXX shared library ../../lib/librouting.dylib
Undefined symbols:
  &quot;_errcode&quot;, referenced from:
      _shortest_path in dijkstra.o
      _shortest_path_astar in astar.o
      _shortest_path_shooting_star in shooting_star.o</pre></div></div>

<p>For the complete error details, see <a href='/wordpress/wp-content/uploads/2008/05/pgrouting_problem.txt'>pgrouting_problem.txt</a></p>
<p>17. Thanks to www.kyngchaos.com, we can install <a href="http://www.kyngchaos.com/files/software/unixport/pgRouting-1.0.1-4.dmg">http://www.kyngchaos.com/files/software/unixport/pgRouting-1.0.1-4.dmg</a> binary from http://www.kyngchaos.com/wiki/software:postgres</p>
<p>18. Now we can load the pgRouting functions to our template database</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_core.sql 
psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_core_wrappers.sql 
psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_dd.sql
psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_dd_wrappers.sql 
psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_dd_tsp.sql
psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_tsp.sql
psql <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_tsp_wrappers.sql</pre></div></div>

<p>References:</p>
<p>http://developer.apple.com/internet/opensource/postgres.html</p>
<p>http://www2.russbrooks.com:8080/2007/11/4/install-postgresql-on-mac-os-x-10-5-leopard</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/02/installing-postgres83-postgis133-pgrouting-on-macosx-leopard-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating postgres/postgis data (updated)</title>
		<link>/wordpress/2011/02/migrating-data-from-postgres82-to-postgres83-3/</link>
		<comments>/wordpress/2011/02/migrating-data-from-postgres82-to-postgres83-3/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 00:51:56 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=827</guid>
		<description><![CDATA[One of my hurdles recently is migrating data from my Debian Lenny Desktop Box (Postgres8.2.7/Postgis1.3.1) to my new MacBookPro Leopard(Postgres8.3.1/Postgis1.3.3). I found it out the hard way by inspecting the dump files manually. 1. pg_dump is your friend. pg_dump --help 2. I strongly suggest if you have a big dump file (mine is 500MB) to [...]]]></description>
			<content:encoded><![CDATA[<p>One of my hurdles recently is migrating data from my Debian Lenny Desktop Box (Postgres8.2.7/Postgis1.3.1) to my new MacBookPro Leopard(Postgres8.3.1/Postgis1.3.3). I found it out the hard way by inspecting the dump files manually.</p>
<p>1. pg_dump is your friend.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pg_dump <span style="color: #660033;">--help</span></pre></div></div>

<p>2. I strongly suggest if you have a big dump file (mine is 500MB) to split the schema from the data. </p>
<p>Add &#8220;-s&#8221; to create the schema:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pg_dump <span style="color: #660033;">-C</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> lbs <span style="color: #660033;">-W</span> beijing <span style="color: #000000; font-weight: bold;">&gt;</span> beijing_20080507_schema.sql</pre></div></div>

<p>Add &#8220;-a&#8221; to dump the data only:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pg_dump <span style="color: #660033;">-a</span> <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> lbs <span style="color: #660033;">-W</span> beijing <span style="color: #000000; font-weight: bold;">&gt;</span> beijing_20080507_schema.sql</pre></div></div>

<p>3. pg_dump from an 8.2 would have statically linked liblwgeom to /usr/lib/postgresql/8.2/liblwgeom. You should change that to whereever your liblwgeom resides, mine is on /usr/local/pgsql/lib/liblwgeom. Just do a simple search and replace using vim on your file_schema.sql</p>
<p>4. After editing the schema, we can now restore the structure of the database. Check for errors and manually update the schema if needs be.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> beijing_4326 <span style="color: #000000; font-weight: bold;">&lt;</span> beijing_20080507_schema.sql</pre></div></div>

<p>5. Ok, so now we have the structure ready, we can also check this from pgAdmin3. Have a good look on the functions and table structures if they are fully restored. </p>
<p>6. Let&#8217;s load the data.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> beijing_4326 <span style="color: #000000; font-weight: bold;">&lt;</span> beijing_20080507_data.sql</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/02/migrating-data-from-postgres82-to-postgres83-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgres PostGIS CheatSheet v2</title>
		<link>/wordpress/2010/11/postgres-postgis-cheatsheet-v2-2/</link>
		<comments>/wordpress/2010/11/postgres-postgis-cheatsheet-v2-2/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 02:29:12 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=798</guid>
		<description><![CDATA[This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual. How do I know the version of Postgis? SELECT POSTGIS_FULL_VERSION&#40;&#41;; How do I Show all databases? 1. Using &#8220;psql -l&#8221; 2. Using postgres=# \l List of databases Name &#124; Owner &#124; Encoding ------------------+----------+---------- postgis &#124; postgres &#124; UTF8 [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual.</p>
<p><strong>How do I know the version of Postgis? </strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> POSTGIS_FULL_VERSION<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><strong>How do I Show all databases? </strong><br />
1. Using &#8220;psql -l&#8221;</p>
<p>2. Using</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">postgres</span>=<span style="color: #666666; font-style: italic;"># \l</span>
List of databases
Name       <span style="color: #000000; font-weight: bold;">|</span>  Owner   <span style="color: #000000; font-weight: bold;">|</span> Encoding
------------------+----------+----------
postgis          <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
postgres         <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template0        <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template1        <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template_postgis <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5</span> rows<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Note: Do not drop template databases if not necessary.</p>
<p><strong>How do I run a script from the prompt?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-d</span> cybersoftbj <span style="color: #660033;">-u</span> user <span style="color: #660033;">-f</span> myfile.sql</pre></div></div>

<p>Its very useful in reloading user-defined functions.</p>
<p><strong>How do I create a user/role?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> ROLE lbs <span style="color: #993333; font-weight: bold;">WITH</span> LOGIN PASSWORD <span style="color: #ff0000;">'mypassword'</span> SUPERUSER INHERIT CREATEDB CREATEROLE;</pre></div></div>

<p><strong>How do I change the password for a user/role?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> ROLE lbs PASSWORD <span style="color: #ff0000;">'mynewpassword'</span>;</pre></div></div>

<p><strong>How to provide/restrict access privileges to tables?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">TO</span> user;
<span style="color: #993333; font-weight: bold;">REVOKE</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">FROM</span> user;</pre></div></div>

<p><strong>How to dump database in a text file?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pg_dump <span style="color: #660033;">-U</span> lbs <span style="color: #660033;">-d</span> cybersoftbjv1 <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-W</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; cybersoftbjv1.sql</pre></div></div>

<p><strong>How to dump database cleanly?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> pg_dump <span style="color: #660033;">-c</span>  <span style="color: #660033;">-d</span> <span style="color: #660033;">-E</span> UTF8 <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> lbs <span style="color: #660033;">-W</span> platform_v1 <span style="color: #000000; font-weight: bold;">&amp;</span>gt; platform_v1.sql</pre></div></div>

<p><strong>How to rename a database?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> beijing_app <span style="color: #993333; font-weight: bold;">RENAME</span> <span style="color: #993333; font-weight: bold;">TO</span> beijing_app_20080801;</pre></div></div>

<p><strong>How to update using two tables?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> road_for_update u
<span style="color: #993333; font-weight: bold;">SET</span> the_geom <span style="color: #66cc66;">=</span> r<span style="color: #66cc66;">.</span>the_geom
<span style="color: #993333; font-weight: bold;">FROM</span> roads r
<span style="color: #993333; font-weight: bold;">WHERE</span> r<span style="color: #66cc66;">.</span>rd_id <span style="color: #66cc66;">=</span> u<span style="color: #66cc66;">.</span>rd_id;</pre></div></div>

<p><strong>DROP TABLE</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #ff0000;">&quot;my_table&quot;</span>;</pre></div></div>

<p><strong>How to change a column type with Cast?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> roads <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">COLUMN</span> class_new TYPE integer <span style="color: #993333; font-weight: bold;">USING</span> class_new::integer;</pre></div></div>

<p><strong>How to add a geometry column to a table?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> AddGeometryColumn<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'public'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'poi'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'the_geom'</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">4326</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'POINT'</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p><strong>Changing column names with spaces?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ALTER TABLE class_aroundme RENAME <span style="color: #ff0000;">&quot;level 1&quot;</span> TO level_1;</pre></div></div>

<p><strong>Setting kernel shmmax for postgres</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> sysctl <span style="color: #660033;">-w</span> kernel.shmmax=<span style="color: #000000;">134217728</span></pre></div></div>

<p>Note: For permanent changes see /etc/sysctl.cfg</p>
<p><strong>11. How to backup table(s) from pg_dump?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> pg_dump poi_beijing <span style="color: #660033;">-t</span> class <span style="color: #660033;">-t</span> poi_class <span style="color: #660033;">-f</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>test_<span style="color: #007800;">$MYDATE</span>.sql</pre></div></div>

<p><strong>Change integer primary key to serial</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> SEQUENCE seq_job_id INCREMENT <span style="color: #cc66cc;">1</span> MINVALUE <span style="color: #cc66cc;">1000</span> MAXVALUE <span style="color: #cc66cc;">2147483648</span> START <span style="color: #cc66cc;">1000</span> CACHE <span style="color: #cc66cc;">1</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> job <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">COLUMN</span> job_id <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NEXTVAL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'seq_job_id'</span>::regclass<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> job
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">NEXTVAL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'seq_job_id'</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p><strong>Date and Time Function Helper: date_add</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> date_add<span style="color: #66cc66;">&#40;</span>diffType Character Varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> incrementValue bigint<span style="color: #66cc66;">,</span> inputDateTime timestamp without time zone<span style="color: #66cc66;">&#41;</span> RETURNS timestamp <span style="color: #993333; font-weight: bold;">AS</span> $$
DECLARE
   YEAR_CONST Char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'year'</span>;
   MONTH_CONST Char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'month'</span>;
   DAY_CONST Char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'day'</span>;
   HOUR_CONST Char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'hour'</span>;
   MIN_CONST Char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'minute'</span>;
   SEC_CONST Char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'second'</span>;
&nbsp;
   dateTemp timestamp without time zone;
   intervals interval;
BEGIN
   <span style="color: #993333; font-weight: bold;">IF</span> lower<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> lower<span style="color: #66cc66;">&#40;</span>YEAR_CONST<span style="color: #66cc66;">&#41;</span> THEN
       <span style="color: #993333; font-weight: bold;">SELECT</span> cast<span style="color: #66cc66;">&#40;</span>cast<span style="color: #66cc66;">&#40;</span>incrementvalue <span style="color: #993333; font-weight: bold;">AS</span> character varying<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">' year'</span> <span style="color: #993333; font-weight: bold;">AS</span> interval<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">INTO</span> intervals;
   ELSEIF lower<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> lower<span style="color: #66cc66;">&#40;</span>MONTH_CONST<span style="color: #66cc66;">&#41;</span> THEN
       <span style="color: #993333; font-weight: bold;">SELECT</span> cast<span style="color: #66cc66;">&#40;</span>cast<span style="color: #66cc66;">&#40;</span>incrementvalue <span style="color: #993333; font-weight: bold;">AS</span> character varying<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">' months'</span> <span style="color: #993333; font-weight: bold;">AS</span> interval<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">INTO</span> intervals;
   ELSEIF lower<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> lower<span style="color: #66cc66;">&#40;</span>DAY_CONST<span style="color: #66cc66;">&#41;</span> THEN
       <span style="color: #993333; font-weight: bold;">SELECT</span> cast<span style="color: #66cc66;">&#40;</span>cast<span style="color: #66cc66;">&#40;</span>incrementvalue <span style="color: #993333; font-weight: bold;">AS</span> character varying<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">' day'</span> <span style="color: #993333; font-weight: bold;">AS</span> interval<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">INTO</span> intervals;
   ELSEIF lower<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> lower<span style="color: #66cc66;">&#40;</span>HOUR_CONST<span style="color: #66cc66;">&#41;</span> THEN
       <span style="color: #993333; font-weight: bold;">SELECT</span> cast<span style="color: #66cc66;">&#40;</span>cast<span style="color: #66cc66;">&#40;</span>incrementvalue <span style="color: #993333; font-weight: bold;">AS</span> character varying<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">' hours'</span> <span style="color: #993333; font-weight: bold;">AS</span> interval<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">INTO</span> intervals;
   ELSEIF lower<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> lower<span style="color: #66cc66;">&#40;</span>MIN_CONST<span style="color: #66cc66;">&#41;</span> THEN
       <span style="color: #993333; font-weight: bold;">SELECT</span> cast<span style="color: #66cc66;">&#40;</span>cast<span style="color: #66cc66;">&#40;</span>incrementvalue <span style="color: #993333; font-weight: bold;">AS</span> character varying<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">' minutes'</span> <span style="color: #993333; font-weight: bold;">AS</span> interval<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">INTO</span> intervals;
   ELSEIF lower<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> lower<span style="color: #66cc66;">&#40;</span>SEC_CONST<span style="color: #66cc66;">&#41;</span> THEN
       <span style="color: #993333; font-weight: bold;">SELECT</span> cast<span style="color: #66cc66;">&#40;</span>cast<span style="color: #66cc66;">&#40;</span>incrementvalue <span style="color: #993333; font-weight: bold;">AS</span> character varying<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">' seconds'</span> <span style="color: #993333; font-weight: bold;">AS</span> interval<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">INTO</span> intervals;            
   END <span style="color: #993333; font-weight: bold;">IF</span>;
&nbsp;
   dateTemp:<span style="color: #66cc66;">=</span> inputDateTime <span style="color: #66cc66;">+</span> intervals;
&nbsp;
   <span style="color: #993333; font-weight: bold;">RETURN</span> dateTemp;
END;
$$ <span style="color: #993333; font-weight: bold;">LANGUAGE</span> plpgsql;</pre></div></div>

<p><strong>How to set the current timezone in postgres?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># Session based only</span>
<span style="color: #993333; font-weight: bold;">SET</span> time zone <span style="color: #ff0000;">'utc'</span>;
<span style="color: #993333; font-weight: bold;">SELECT</span>  current_setting<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'TIMEZONE'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Permanent</span>
<span style="color: #808080; font-style: italic;"># Edit /usr/local/var/postgres/postgresql.conf (#postgres installed via homebrew)</span>
timezone <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'UTC'</span></pre></div></div>

<p><strong>Date/Time Functions</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> current_setting<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'TIMEZONE'</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #808080; font-style: italic;">--&quot;Australia/Victoria&quot;</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> Now<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> 
timezone<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'UTC'</span><span style="color: #66cc66;">,</span> now<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> 
EXTRACT<span style="color: #66cc66;">&#40;</span>EPOCH <span style="color: #993333; font-weight: bold;">FROM</span> CURRENT_TIMESTAMP<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
to_timestamp<span style="color: #66cc66;">&#40;</span>EXTRACT<span style="color: #66cc66;">&#40;</span>EPOCH <span style="color: #993333; font-weight: bold;">FROM</span> CURRENT_TIMESTAMP<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
to_timestamp<span style="color: #66cc66;">&#40;</span>EXTRACT<span style="color: #66cc66;">&#40;</span>EPOCH <span style="color: #993333; font-weight: bold;">FROM</span> CURRENT_TIMESTAMP<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>::TIMESTAMP
&nbsp;
<span style="color: #808080; font-style: italic;">--&quot;2011-11-14 09:29:14.249427+11&quot; </span>
<span style="color: #808080; font-style: italic;">--&quot;2011-11-13 22:29:14.249427&quot;</span>
<span style="color: #808080; font-style: italic;">--1321223354</span>
<span style="color: #808080; font-style: italic;">--&quot;2011-11-14 09:29:14+11&quot;</span>
<span style="color: #808080; font-style: italic;">--&quot;2011-11-14 09:29:14&quot;</span></pre></div></div>

<p><strong>How to specify the id of a sequence to prevent SQL Error: PGRES_FATAL_ERROR:ERROR:  duplicate key value violates unique constraint &#8220;gps_histories_pkey&#8221;?</strong><br />
This happens when the maximum number of records in gps_histories is not in sync with the sequence id.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">SETVAL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'dfms_4000.gps_histories_id_seq'</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> MAX<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span> dfms_4000<span style="color: #66cc66;">.</span>gps_histories<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2010/11/postgres-postgis-cheatsheet-v2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Note #20:Integrating Mapserver/TileCache to RouteMe</title>
		<link>/wordpress/2010/01/iphone-note-20integrating-mapservertilecache-to-routeme/</link>
		<comments>/wordpress/2010/01/iphone-note-20integrating-mapservertilecache-to-routeme/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 01:37:57 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[tilecache]]></category>
		<category><![CDATA[route-me]]></category>

		<guid isPermaLink="false">/wordpress/?p=700</guid>
		<description><![CDATA[Below is a summary of how I was able to implement Mapserver, TileCache and Route-Me iPhone Mapping Framework. 1. Assuming you have a working Mapserver/TileCache setup. Take note of the ff parameters: resolution and bbox. Below is my tilecache.cfg: 61 [mapserver_australia_3857] 62 type=MapServerLayer 63 mapfile=/Users/rupert/projects/pelicancorp/DMOB/trunk/map/australia_3857.map 64 layers=all 65 extension=jpg 66 bbox=-20037508.34, -20037508.34, 20037508.34, 20037508.34 68 [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a summary of how I was able to implement Mapserver, TileCache and Route-Me iPhone Mapping Framework. </p>
<p>1.  Assuming you have a <strong>working</strong> Mapserver/TileCache setup. Take note of the ff parameters: resolution and bbox. Below is my tilecache.cfg:</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;"> 61 [mapserver_australia_3857]
 62 type=MapServerLayer
 63 mapfile=/Users/rupert/projects/pelicancorp/DMOB/trunk/map/australia_3857.map
 64 layers=all
 65 extension=jpg
 66 bbox=-20037508.34, -20037508.34, 20037508.34, 20037508.34
 68 maxResolution=156543.033928041
 70 levels=20
 71 srs=EPSG:3857
 72 tms_type=google
 73 extent_type=loose
 74 spherical_mercator=true</pre></div></div>

<p>2. Grab the RMGenericMercatorWMSSource from <a href="http://groups.google.com/group/route-me-map/browse_thread/thread/b58fa1d20cf15823/e30c42d9c90a8170?lnk=gst&#038;q=Generic#e30c42d9c90a8170">http://groups.google.com/group/route-me-map/browse_thread/thread/b58fa1d20cf15823/e30c42d9c90a8170?lnk=gst&#038;q=Generic#e30c42d9c90a8170</a></p>
<p>3. By default without any changes, the RMGenericMercatorWMSSource could display Mapserver WMS Tiles. This is possible by passing an NSDictionary *parameters, which contains arrayValues and arrayKeys for creating an http 256&#215;256 image request to the http://127.0.0.1/cgi-bin/mapserv binary.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//This would request to http://127.0.0.1/cgi-bin/mapserv</span>
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>arrayValues <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;/path-to/australia_3857.map&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;all&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;png&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;EPSG:3857&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>arrayKeys <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;MAP&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;LAYERS&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;FORMAT&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SRS&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>wmsParameters <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span> arrayValues forKeys<span style="color: #002200;">:</span>arrayKeys <span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Resulting http requests to the mapserv binary:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">http://192.168.1.193:81/tilecache/tilecache.py?LAYERS=australia_3857&amp;SRS=EPSG:3857&amp;REQUEST=GetMap&amp;SERVICE=WMS&amp;STYLES=&amp;EXCEPTIONS=application%2Fvnd.ogc.se_inimage&amp;FORMAT=png&amp;VERSION=1.1.1&amp;WIDTH=256&amp;HEIGHT=256&amp;BBOX=16828376.000000,-4006523.000000,16833268.000000,-4001631.000000</pre></div></div>

<p>Note that the bbox values does not contain decimal places. Nevertheless, it still works on Mapserver.</p>
<p>4. Now, assuming we have a valid tilecache running. And it is tested from browser, i.e http://127.0.0.1/map/tilecache_3857.html, open up firebug to see the requests. Below is a sample&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">http://192.168.1.193:81/tilecache/tilecache.py?LAYERS=australia_3857&amp;FORMAT=jpg&amp;SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;STYLES=&amp;EXCEPTIONS=application%2Fvnd.ogc.se_inimage&amp;SRS=EPSG%3A3857&amp;BBOX=16123932.497377,-4539747.9811239,16143500.376618,-4520180.1018829&amp;WIDTH=256&amp;HEIGHT=256</pre></div></div>

<p>But it seems, route-me is not supplying the bbox values accurately, as the decimal values is truncated (BBOX=16828376.000000,-4006523.000000,16833268.000000,-4001631.000000) from our previous request(3). </p>
<p>After changing the wmsParameter values to create a tilecache request, I noticed that route-me is not displaying the tiles correctly.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//Testing for Windows:TileCache - ?</span>
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>arrayValues <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;australia_3857&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;png&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;EPSG:3857&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>; <span style="color: #11740a; font-style: italic;">//for WIndows</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">//TileCache URL Parameters:</span>
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>arrayKeys <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;LAYERS&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;FORMAT&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SRS&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>5. The workaround is to use &#8220;double&#8221; instead of &#8220;floats&#8221; in the RMGenericMercatorWMSSource. You can download the zip from <a href="/wordpress/wp-content/uploads/2010/01/RMGenericMercatorWMSSource.zip" title="RMGenericMercatorWMSSource.zip">RMGenericMercatorWMSSource.zip</a>. I have modified &#8220;initialResolution&#8221; and &#8220;originShift&#8221; to both use <em>&#8220;double&#8221;</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">typedef</span> <span style="color: #a61390;">struct</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">double</span> x;
	<span style="color: #a61390;">double</span> y;
<span style="color: #002200;">&#125;</span> CGDoublePoint;
&nbsp;
<span style="color: #a61390;">typedef</span> <span style="color: #a61390;">struct</span> <span style="color: #002200;">&#123;</span> 
	CGDoublePoint ul; 
	CGDoublePoint lr; 
<span style="color: #002200;">&#125;</span> CGXYRect;</pre></div></div>

<p>Afterwards, I copied the maxResolution and bbox (tilecache) and specified it for the initialResoultion and originShift respectively.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;RMGenericMercatorWMSSource.h&quot;</span>
&nbsp;
CGFloat DegreesToRadians<span style="color: #002200;">&#40;</span>CGFloat degrees<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><span style="color: #a61390;">return</span> degrees <span style="color: #002200;">*</span> M_PI <span style="color: #002200;">/</span> <span style="color: #2400d9;">180</span>;<span style="color: #002200;">&#125;</span>; 
CGFloat RadiansToDegrees<span style="color: #002200;">&#40;</span>CGFloat radians<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><span style="color: #a61390;">return</span> radians <span style="color: #002200;">*</span> <span style="color: #2400d9;">180</span><span style="color: #002200;">/</span> M_PI;<span style="color: #002200;">&#125;</span>; 
&nbsp;
<span style="color: #a61390;">@implementation</span> RMGenericMercatorWMSSource
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> initWithBaseUrl<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>baseUrl parameters<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>params
<span style="color: #002200;">&#123;</span> 
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span>super init<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> 
		<span style="color: #a61390;">return</span> <span style="color: #a61390;">nil</span>; 
&nbsp;
	<span style="color: #11740a; font-style: italic;">// 156543.03392804062 for sideLength 256 pixels </span>
	<span style="color: #11740a; font-style: italic;">// initialResolution = 2 * M_PI * 6378137 / [self tileSideLength];</span>
	<span style="color: #11740a; font-style: italic;">// specify here whatever the resolution is from tilecache.</span>
	initialResolution <span style="color: #002200;">=</span> <span style="color: #2400d9;">156543.033928041</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// 20037508.342789244 </span>
	<span style="color: #11740a; font-style: italic;">//originShift = 2 * M_PI * 6378137 / 2;</span>
	<span style="color: #11740a; font-style: italic;">//originShift = 20037508.342789244f;</span>
	<span style="color: #11740a; font-style: italic;">// specify here whatever the bbox is from tilecache.</span>
	originShift <span style="color: #002200;">=</span> <span style="color: #2400d9;">20037508.32</span>;
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;test initialResolution:%f originShift:%f&quot;</span>, initialResolution, originShift<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// setup default parameters</span>
	<span style="color: #11740a; font-style: italic;">// use official EPSG:3857 by default, user can override to 900913 if needed.</span>
	wmsParameters <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableDictionary</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;EPSG:3857&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;image/png&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;GetMap&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;1.1.1&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;WMS&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span> 
											  forKeys<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SRS&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;FORMAT&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;REQUEST&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;VERSION&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SERVICE&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>wmsParameters addEntriesFromDictionary<span style="color: #002200;">:</span>params<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// build WMS request URL template</span>
	urlTemplate <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithString<span style="color: #002200;">:</span>baseUrl<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSEnumerator</span> <span style="color: #002200;">*</span>e <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>wmsParameters keyEnumerator<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>key;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>delimiter <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span>;
	<span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span>key <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>e nextObject<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		urlTemplate <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>urlTemplate stringByAppendingFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@%@=%@&quot;</span>,
					   delimiter,
					   <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>key uppercaseString<span style="color: #002200;">&#93;</span> stringByAddingPercentEscapesUsingEncoding<span style="color: #002200;">:</span>NSASCIIStringEncoding<span style="color: #002200;">&#93;</span>, 
					   <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>wmsParameters objectForKey<span style="color: #002200;">:</span>key<span style="color: #002200;">&#93;</span> stringByAddingPercentEscapesUsingEncoding<span style="color: #002200;">:</span>NSASCIIStringEncoding<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		delimiter <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&amp;&quot;</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">int</span> sideLength <span style="color: #002200;">=</span>  <span style="color: #002200;">&#91;</span>self tileSideLength<span style="color: #002200;">&#93;</span>;
	urlTemplate <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>urlTemplate stringByAppendingFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&amp;WIDTH=%d&amp;HEIGHT=%d&quot;</span>,sideLength,sideLength<span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// implement in subclass?</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> uniqueTilecacheKey
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;AbstractMercatorWMSSource&quot;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>shortName
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Generic WMS Source&quot;</span>;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>longDescription
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Generic WMS Source&quot;</span>;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>shortAttribution
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Generic WMS Source&quot;</span>;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>longAttribution
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Generic WMS Source&quot;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span> minZoom
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> 1.0f;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span> maxZoom
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> 19.0f;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:3857 </span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span> LatLonToMeters<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>CLLocationCoordinate2D<span style="color: #002200;">&#41;</span> latlon 
<span style="color: #002200;">&#123;</span> 
	CGPoint meters; 
	meters.x <span style="color: #002200;">=</span> latlon.longitude <span style="color: #002200;">*</span> originShift <span style="color: #002200;">/</span> <span style="color: #2400d9;">180</span>; 
	meters.y <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">log</span><span style="color: #002200;">&#40;</span> <span style="color: #a61390;">tan</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">90.0</span> <span style="color: #002200;">+</span> latlon.latitude<span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> M_PI <span style="color: #002200;">/</span> <span style="color: #2400d9;">360.0</span> <span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">/</span> <span style="color: #002200;">&#40;</span>M_PI <span style="color: #002200;">/</span> <span style="color: #2400d9;">180.0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> originShift <span style="color: #002200;">/</span> <span style="color: #2400d9;">180</span>; 
	<span style="color: #a61390;">return</span> meters; 
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">//Converts XY point from Spherical Mercator EPSG:3857 to lat/lon in WGS84 Datum </span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>CLLocationCoordinate2D<span style="color: #002200;">&#41;</span> MetersToLatLon<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span> meters 
<span style="color: #002200;">&#123;</span> 
	CLLocationCoordinate2D latlon; 
	latlon.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>meters.x <span style="color: #002200;">/</span> originShift<span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> <span style="color: #2400d9;">180.0</span>; 
	latlon.latitude <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>meters.y <span style="color: #002200;">/</span> originShift<span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> <span style="color: #2400d9;">180.0</span>; 
	<span style="color: #11740a; font-style: italic;">//latlon.latitude = - 180 / M_PI * (2 * atan( exp( latlon.latitude * M_PI / 180.0)) - M_PI / 2.0); </span>
	latlon.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">180</span> <span style="color: #002200;">/</span> M_PI <span style="color: #002200;">*</span> <span style="color: #002200;">&#40;</span><span style="color: #2400d9;">2</span> <span style="color: #002200;">*</span> <span style="color: #a61390;">atan</span><span style="color: #002200;">&#40;</span> <span style="color: #a61390;">exp</span><span style="color: #002200;">&#40;</span> latlon.latitude <span style="color: #002200;">*</span> M_PI <span style="color: #002200;">/</span> <span style="color: #2400d9;">180.0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">-</span> M_PI <span style="color: #002200;">/</span> <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>; 
	<span style="color: #a61390;">return</span> latlon; 
<span style="color: #002200;">&#125;</span> 
&nbsp;
<span style="color: #11740a; font-style: italic;">// Converts pixel coordinates in given zoom level of pyramid to EPSG:3857 </span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>CGDoublePoint<span style="color: #002200;">&#41;</span> PixelsToMeters<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span> px PixelY<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>py atZoom<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>zoom 
<span style="color: #002200;">&#123;</span> 
	<span style="color: #a61390;">double</span> resolution <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self ResolutionAtZoom<span style="color: #002200;">:</span> zoom<span style="color: #002200;">&#93;</span>; 
	CGDoublePoint meters; 
	<span style="color: #a61390;">double</span> x <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>px <span style="color: #002200;">*</span> resolution <span style="color: #002200;">-</span> originShift<span style="color: #002200;">&#41;</span>; 
	<span style="color: #a61390;">double</span> y <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>py <span style="color: #002200;">*</span> resolution <span style="color: #002200;">-</span> originShift<span style="color: #002200;">&#41;</span>; 
&nbsp;
	meters.x <span style="color: #002200;">=</span> x;
	meters.y <span style="color: #002200;">=</span> y;
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;px: %d py: %d resolution: %f originShift: %f x: %f y: %f&quot;</span>, px, py, resolution, originShift, x, y<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #a61390;">return</span> meters; 
<span style="color: #002200;">&#125;</span> 
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> tileURL<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>RMTile<span style="color: #002200;">&#41;</span> tile 
<span style="color: #002200;">&#123;</span> 
	<span style="color: #11740a; font-style: italic;">//RMLatLongBounds tileBounds = [self TileLatLonBounds:tile];</span>
	<span style="color: #11740a; font-style: italic;">// Get BBOX coordinates in meters</span>
	CGXYRect tileBounds <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self TileBounds<span style="color: #002200;">:</span>tile<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>urlTemplate stringByAppendingFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&amp;BBOX=%f,%f,%f,%f&quot;</span>,
					 tileBounds.ul.x,
					 tileBounds.lr.y,
					 tileBounds.lr.x,
					 tileBounds.ul.y<span style="color: #002200;">&#93;</span>;
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Tile %d,%d,%d yields %@&quot;</span>,tile.zoom, tile.x, tile.y, url<span style="color: #002200;">&#41;</span>; 
&nbsp;
	<span style="color: #a61390;">return</span> url; 
<span style="color: #002200;">&#125;</span> 
&nbsp;
&nbsp;
<span style="color: #11740a; font-style: italic;">//Returns bounds of the given tile in EPSG:3857 coordinates </span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>CGXYRect<span style="color: #002200;">&#41;</span>  TileBounds<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>RMTile<span style="color: #002200;">&#41;</span> tile 
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">int</span> sideLength <span style="color: #002200;">=</span>  <span style="color: #002200;">&#91;</span>self tileSideLength<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">int</span> zoom <span style="color: #002200;">=</span> tile.zoom;
	<span style="color: #a61390;">long</span> twoToZoom <span style="color: #002200;">=</span> <span style="color: #a61390;">pow</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">2</span>,zoom<span style="color: #002200;">&#41;</span>;
	CGXYRect tileBounds; 
	tileBounds.ul <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self PixelsToMeters<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>tile.x <span style="color: #002200;">*</span> sideLength<span style="color: #002200;">&#41;</span> 
								  PixelY<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>twoToZoom<span style="color: #002200;">-</span>tile.y<span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> sideLength<span style="color: #002200;">&#41;</span> 
								  atZoom<span style="color: #002200;">:</span> zoom <span style="color: #002200;">&#93;</span>; 
	tileBounds.lr <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self PixelsToMeters<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>tile.x<span style="color: #002200;">+</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> sideLength<span style="color: #002200;">&#41;</span> 
								  PixelY<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>twoToZoom<span style="color: #002200;">-</span>tile.y<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> sideLength<span style="color: #002200;">&#41;</span> 
								  atZoom<span style="color: #002200;">:</span> zoom<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">return</span> tileBounds; 
<span style="color: #002200;">&#125;</span> 
&nbsp;
<span style="color: #11740a; font-style: italic;">//Resolution (meters/pixel) for given zoom level (measured at Equator) </span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">double</span><span style="color: #002200;">&#41;</span> ResolutionAtZoom <span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span> zoom 
<span style="color: #002200;">&#123;</span> 
	<span style="color: #a61390;">return</span> initialResolution <span style="color: #002200;">/</span> <span style="color: #a61390;">pow</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">2</span>,zoom<span style="color: #002200;">&#41;</span>; 
<span style="color: #002200;">&#125;</span> 
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>6. Download <a href="/wordpress/wp-content/uploads/2010/01/TileCache_RouteMe.zip" title="TileCache_RouteMe.zip">TileCache_RouteMe.zip</a> Note: You need a valid mapserver and tilecache running.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2010/01/iphone-note-20integrating-mapservertilecache-to-routeme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TileCache: Getting Cutoff on the edges</title>
		<link>/wordpress/2008/10/tilecache-getting-cutoff-on-the-edges/</link>
		<comments>/wordpress/2008/10/tilecache-getting-cutoff-on-the-edges/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 03:37:43 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[tilecache]]></category>

		<guid isPermaLink="false">/wordpress/?p=275</guid>
		<description><![CDATA[In Tilecache, metaTiling creates larger tiles and chops them up. Note the difference between using metatile=yes and metatile=no. Figure 1: metatile=no Figure 2: metatile=yes]]></description>
			<content:encoded><![CDATA[<p>In Tilecache, metaTiling creates larger tiles and chops them up.<br />
Note the difference between using metatile=yes and metatile=no.</p>
<p><img src="/wordpress/wp-content/uploads/2008/10/metatile-no.png" alt="metatile_no.png" border="0" width="323" height="332" /></p>
<p>Figure 1: metatile=no</p>
<p><img src="/wordpress/wp-content/uploads/2008/10/metatile-yes.png" alt="metatile_yes.png" border="0" width="325" height="338" /></p>
<p>Figure 2: metatile=yes</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/10/tilecache-getting-cutoff-on-the-edges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recaching single tiles in Tilecache</title>
		<link>/wordpress/2008/09/recaching-single-tiles-in-tilecache/</link>
		<comments>/wordpress/2008/09/recaching-single-tiles-in-tilecache/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 04:16:12 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[tilecache]]></category>

		<guid isPermaLink="false">/wordpress/?p=265</guid>
		<description><![CDATA[Got this one from IRC this morning.. In order to recache single tiles in TC, as long as it is not metatile (metatile=false), then we can simply append &#8220;FORCE=1&#8243; in the URL.. http://192.168.2.14/tilecache/tilecache.py?FORCE=1&#038;LAYERS=beijing_900913_wide_en&#038;MAP=%2Fmyhome%2Fmap%2Fbeijing%2Fnew%2Fbeijing_900913_wide_en%2Fbeijing.map&#038;FORMAT=jpg&#038;TRANSPARENT=true&#038;SERVICE=WMS&#038;VERSION=1.1.1&#038;REQUEST=GetMap&#038;STYLES=&#038;EXCEPTIONS=application%2Fvnd.ogc.se_inimage&#038;SRS=EPSG%3A900913&#038;BBOX=12951949.03168994,4852222.893873828,12952101.905746482,4852375.767930372&#038;WIDTH=256&#038;HEIGHT=256 Well for completeness, I gave my ofcmate a DELETE tool which wipes out everything in the /tilecache/map_dir directory..]]></description>
			<content:encoded><![CDATA[<p>Got this one from IRC this morning.. In order to recache single tiles in TC, as long as it is not metatile (metatile=false), then we can simply append &#8220;FORCE=1&#8243; in the URL..</p>
<p>http://192.168.2.14/tilecache/tilecache.py?<strong>FORCE=1</strong>&#038;LAYERS=beijing_900913_wide_en&#038;MAP=%2Fmyhome%2Fmap%2Fbeijing%2Fnew%2Fbeijing_900913_wide_en%2Fbeijing.map&#038;FORMAT=jpg&#038;TRANSPARENT=true&#038;SERVICE=WMS&#038;VERSION=1.1.1&#038;REQUEST=GetMap&#038;STYLES=&#038;EXCEPTIONS=application%2Fvnd.ogc.se_inimage&#038;SRS=EPSG%3A900913&#038;BBOX=12951949.03168994,4852222.893873828,12952101.905746482,4852375.767930372&#038;WIDTH=256&#038;HEIGHT=256</p>
<p><img src="/wordpress/wp-content/uploads/2008/09/picture-22.png" alt="Picture 2.png" border="0" width="531" height="275"/></p>
<p>Well for completeness, I gave my ofcmate a DELETE tool which wipes out everything in the /tilecache/map_dir directory.. </p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/09/recaching-single-tiles-in-tilecache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transform 900913 to 4326</title>
		<link>/wordpress/2008/09/transform-900913-to-4326/</link>
		<comments>/wordpress/2008/09/transform-900913-to-4326/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 14:37:18 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>

		<guid isPermaLink="false">/wordpress/?p=261</guid>
		<description><![CDATA[Stumbled upon an error in reprojecting data from 900913 (Google Speherical Mercator) to 4326 (WGS84). I&#8217;m recalling this from my head now, the error was something related to &#8220;NAD sth&#8221;. Workaround was to convert it as follows: 1. 900913 2. 32650 (UTM for your area) 3. 4326 I&#8217;ll get the SQL from my ofcmate and [...]]]></description>
			<content:encoded><![CDATA[<p>Stumbled upon an error in reprojecting data from 900913 (Google Speherical Mercator) to 4326 (WGS84). I&#8217;m recalling this from my head now, the error was something related to &#8220;NAD sth&#8221;. Workaround was to convert it as follows:</p>
<p>1. 900913<br />
2. 32650 (UTM for your area)<br />
3. 4326</p>
<p>I&#8217;ll get the SQL from my ofcmate and paste it here&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/09/transform-900913-to-4326/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Postgres PostGIS CheatSheet v2</title>
		<link>/wordpress/2008/08/postgres-postgis-cheatsheet-v2/</link>
		<comments>/wordpress/2008/08/postgres-postgis-cheatsheet-v2/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 05:10:32 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=229</guid>
		<description><![CDATA[This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual. How do I Show all databases? 1. Using &#8220;psql -l&#8221; 2. Using postgres=# \l List of databases Name &#124; Owner &#124; Encoding ------------------+----------+---------- postgis &#124; postgres &#124; UTF8 postgres &#124; postgres &#124; UTF8 template0 &#124; postgres &#124; UTF8 [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual.</p>
<p><strong>How do I Show all databases? </strong><br />
1. Using &#8220;psql -l&#8221;</p>
<p>2. Using</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">postgres</span>=<span style="color: #666666; font-style: italic;"># \l</span>
List of databases
Name       <span style="color: #000000; font-weight: bold;">|</span>  Owner   <span style="color: #000000; font-weight: bold;">|</span> Encoding
------------------+----------+----------
postgis          <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
postgres         <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template0        <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template1        <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template_postgis <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5</span> rows<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Note: Do not drop template databases if not necessary.</p>
<p><strong>How do I run a script from the prompt?</strong><br />
<code>psql -d cybersoftbj -u user -f myfile.sql</code></p>
<p>Its very useful in reloading user-defined functions.</p>
<p><strong>How do I create a user/role?</strong><br />
<code><br />
CREATE ROLE lbs WITH LOGIN PASSWORD 'mypassword' SUPERUSER INHERIT CREATEDB CREATEROLE;<br />
</code></p>
<p><strong>How do I change the password for a user/role?</strong><br />
<code><br />
ALTER ROLE lbs PASSWORD 'mynewpassword';<br />
</code></p>
<p><strong>How to provide/restrict access privileges to tables?</strong><br />
<code><br />
GRANT SELECT ON TABLE table TO user;<br />
REVOKE SELECT ON TABLE table FROM user;<br />
</code></p>
<p><strong>How to dump database in a text file?</strong><br />
<code><br />
pg_dump -U lbs -d cybersoftbjv1 -h 127.0.0.1 -W &gt; cybersoftbjv1.sql<br />
</code></p>
<p><strong>How to dump database cleanly?</strong><br />
<code><br />
pg_dump -c  -d -E UTF8 -h 127.0.0.1 -U lbs -W platform_v1 &gt; platform_v1.sql<br />
</code></p>
<p><strong>How to rename a database?</strong><br />
<code><br />
ALTER DATABASE beijing_app RENAME TO beijing_app_20080801;<br />
</code></p>
<p><strong>How to update using two tables?</strong><br />
<code><br />
UPDATE road_for_update u<br />
SET the_geom = r.the_geom<br />
FROM roads r<br />
WHERE r.rd_id = u.rd_id;<br />
</code></p>
<p><strong>How to change a column type with Cast?</strong><br />
<code><br />
ALTER TABLE roads ALTER COLUMN class_new TYPE integer USING class_new::integer;<br />
</code></p>
<p><strong>How to add a geometry column to a table?</strong><br />
EXAMPLE: SELECT AddGeometryColumn(&#8216;public&#8217;, &#8216;poi&#8217;, &#8216;the_geom&#8217;, 4326, &#8216;POINT&#8217;, 2)</p>
<p><strong>Changing column names with spaces?</strong><br />
<code>ALTER TABLE class_aroundme RENAME "level 1" TO level_1;</code> </p>
<p><strong>Setting kernel shmmax for postgres</strong><br />
<code>sysctl -w kernel.shmmax=134217728</code><br />
Note: For permanent changes see /etc/sysctl.cfg<strong>11. How to backup table(s) from pg_dump?</strong><br />
pg_dump poi_beijing -t class -t poi_class -f $BACKUPDIR/test_$MYDATE.sql</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/08/postgres-postgis-cheatsheet-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using GDALWARP to reproject raster that will fit with Google Satellite</title>
		<link>/wordpress/2008/07/using-gdalwarp-to-reproject-raster-that-will-fit-with-google-satellite/</link>
		<comments>/wordpress/2008/07/using-gdalwarp-to-reproject-raster-that-will-fit-with-google-satellite/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 12:48:21 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[GDAL/OGR]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[maserver]]></category>
		<category><![CDATA[openlayers]]></category>
		<category><![CDATA[tilecache]]></category>

		<guid isPermaLink="false">/wordpress/?p=208</guid>
		<description><![CDATA[Just a couple of notes to onself using gdal: Use gdalwarp to reproject your GeoTIFF files! I wanted to use my own satellite images acquired from GeoEye, however, on some areas I wanted to use google sat images as well since I don&#8217;t have the coverage. In order to do so, I need to reproject [...]]]></description>
			<content:encoded><![CDATA[<p>Just a couple of notes to onself using gdal: Use <em>gdalwarp</em> to reproject your GeoTIFF files! I wanted to use my own satellite images acquired from GeoEye, however, on some areas I wanted to use google sat images as well since I don&#8217;t have the coverage. In order to do so, I need to reproject the sat images to 900913. Note you need to specify this in your epsg file in my previous post.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rupert:beijing_900913_satellite rupert$ gdalinfo Mosaic_RGB.tif
Driver: GTiff<span style="color: #000000; font-weight: bold;">/</span>GeoTIFF
Files: Mosaic_RGB.tif
Size is <span style="color: #000000;">4248</span>, <span style="color: #000000;">4553</span>
Coordinate System is:
GEOGCS<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;WGS 84&quot;</span>,
    DATUM<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;WGS_1984&quot;</span>,
        SPHEROID<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;WGS 84&quot;</span>,<span style="color: #000000;">6378137</span>,<span style="color: #000000;">298.2572235630016</span>,
            AUTHORITY<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;EPSG&quot;</span>,<span style="color: #ff0000;">&quot;7030&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
        AUTHORITY<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;EPSG&quot;</span>,<span style="color: #ff0000;">&quot;6326&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    PRIMEM<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;Greenwich&quot;</span>,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    UNIT<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;degree&quot;</span>,<span style="color: #000000;">0.0174532925199433</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    AUTHORITY<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;EPSG&quot;</span>,<span style="color: #ff0000;">&quot;4326&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
Origin = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">116.291476140000000</span>,<span style="color: #000000;">40.025198500000002</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Pixel Size = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.000046860000000</span>,-<span style="color: #000000;">0.000035970000000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Metadata:
  <span style="color: #007800;">AREA_OR_POINT</span>=Area
  <span style="color: #007800;">TIFFTAG_XRESOLUTION</span>=<span style="color: #000000;">100</span>
  <span style="color: #007800;">TIFFTAG_YRESOLUTION</span>=<span style="color: #000000;">100</span>
Image Structure Metadata:
  <span style="color: #007800;">INTERLEAVE</span>=BAND
Corner Coordinates:
Upper Left  <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #000000;">116.2914761</span>,  <span style="color: #000000;">40.0251985</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>116d17<span style="color: #ff0000;">'29.31&quot;E, 40d 1'</span><span style="color: #000000;">30.71</span><span style="color: #ff0000;">&quot;N)
Lower Left  ( 116.2914761,  39.8614271) (116d17'29.31&quot;</span>E, 39d51<span style="color: #ff0000;">'41.14&quot;N)
Upper Right ( 116.4905374,  40.0251985) (116d29'</span><span style="color: #000000;">25.93</span><span style="color: #ff0000;">&quot;E, 40d 1'30.71&quot;</span>N<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Lower Right <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #000000;">116.4905374</span>,  <span style="color: #000000;">39.8614271</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>116d29<span style="color: #ff0000;">'25.93&quot;E, 39d51'</span><span style="color: #000000;">41.14</span><span style="color: #ff0000;">&quot;N)
Center      ( 116.3910068,  39.9433128) (116d23'27.62&quot;</span>E, 39d56<span style="color: #ff0000;">'35.93&quot;N)
Band 1 Block=4248x1 Type=Byte, ColorInterp=Red
Band 2 Block=4248x1 Type=Byte, ColorInterp=Green
Band 3 Block=4248x1 Type=Byte, ColorInterp=Blue</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rupert:beijing_900913_satellite rupert$ gdalwarp -s_srs epsg:<span style="color: #000000;">4326</span> -t_srs epsg:<span style="color: #000000;">900913</span> Mosaic_RGB.tif sat_4m_rgb.tif
Creating output <span style="color: #c20cb9; font-weight: bold;">file</span> that is 4245P x 4556L.
Processing input <span style="color: #c20cb9; font-weight: bold;">file</span> Mosaic_RGB.tif.
0...10...20...30...40...50...60...70...80...90...100 - done.</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rupert:beijing_900913_satellite rupert$ gdalinfo sat_4m_rgb.tif
Driver: GTiff<span style="color: #000000; font-weight: bold;">/</span>GeoTIFF
Files: sat_4m_rgb.tif
Size is <span style="color: #000000;">4245</span>, <span style="color: #000000;">4556</span>
Coordinate System is:
PROJCS<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;Google Maps Global Mercator&quot;</span>,
    GEOGCS<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;WGS 84&quot;</span>,
        DATUM<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;WGS_1984&quot;</span>,
            SPHEROID<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;WGS 84&quot;</span>,<span style="color: #000000;">6378137</span>,<span style="color: #000000;">298.2572235630016</span>,
                AUTHORITY<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;EPSG&quot;</span>,<span style="color: #ff0000;">&quot;7030&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
            AUTHORITY<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;EPSG&quot;</span>,<span style="color: #ff0000;">&quot;6326&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
        PRIMEM<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;Greenwich&quot;</span>,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
        UNIT<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;degree&quot;</span>,<span style="color: #000000;">0.0174532925199433</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
        AUTHORITY<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;EPSG&quot;</span>,<span style="color: #ff0000;">&quot;4326&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    PROJECTION<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;Mercator_1SP&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    PARAMETER<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;central_meridian&quot;</span>,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    PARAMETER<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;scale_factor&quot;</span>,<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    PARAMETER<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;false_easting&quot;</span>,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    PARAMETER<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;false_northing&quot;</span>,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,
    UNIT<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;metre&quot;</span>,<span style="color: #000000;">1</span>,
        AUTHORITY<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;EPSG&quot;</span>,<span style="color: #ff0000;">&quot;9001&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
Origin = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">12945507.907502911984921</span>,<span style="color: #000000;">4869604.732793668285012</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Pixel Size = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5.219801430503303</span>,-<span style="color: #000000;">5.219801430503303</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Metadata:
  <span style="color: #007800;">AREA_OR_POINT</span>=Area
Image Structure Metadata:
  <span style="color: #007800;">INTERLEAVE</span>=PIXEL
Corner Coordinates:
Upper Left  <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">12945507.908</span>, <span style="color: #000000;">4869604.733</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>116d17<span style="color: #ff0000;">'29.31&quot;E, 40d12'</span><span style="color: #000000;">53.10</span><span style="color: #ff0000;">&quot;N)
Lower Left  (12945507.908, 4845823.317) (116d17'29.31&quot;</span>E, 40d <span style="color: #000000;">3</span><span style="color: #ff0000;">'2.78&quot;N)
Upper Right (12967665.965, 4869604.733) (116d29'</span><span style="color: #000000;">25.89</span><span style="color: #ff0000;">&quot;E, 40d12'53.10&quot;</span>N<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Lower Right <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">12967665.965</span>, <span style="color: #000000;">4845823.317</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>116d29<span style="color: #ff0000;">'25.89&quot;E, 40d 3'</span><span style="color: #000000;">2.78</span><span style="color: #ff0000;">&quot;N)
Center      (12956586.936, 4857714.025) (116d23'27.60&quot;</span>E, 40d <span style="color: #000000;">7</span><span style="color: #ff0000;">'58.12&quot;N)
Band 1 Block=4245x1 Type=Byte, ColorInterp=Red
Band 2 Block=4245x1 Type=Byte, ColorInterp=Green
Band 3 Block=4245x1 Type=Byte, ColorInterp=Blue</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/07/using-gdalwarp-to-reproject-raster-that-will-fit-with-google-satellite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Mapserver on MacOSX (by source)</title>
		<link>/wordpress/2008/07/installing-mapserver-on-macosx-by-source/</link>
		<comments>/wordpress/2008/07/installing-mapserver-on-macosx-by-source/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 02:03:16 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[leopard]]></category>

		<guid isPermaLink="false">/wordpress/?p=195</guid>
		<description><![CDATA[Just noticed that William of kyngchaos has updated the mapserver binary for MacOSX. But right now, I need to tile these images bought from GeoEye, so I need TIFF support. Below is a summary of getting Mapserver installed by source. Note that I have the necessary GEOS, GDAL from kyngchaos as well from this ealier [...]]]></description>
			<content:encoded><![CDATA[<p>Just noticed that <a href="http://www.kyngchaos.com/wiki/software:mapserver">William of kyngchaos has updated the mapserver binary</a> for MacOSX.</p>
<p>But right now, I need to tile these images bought from GeoEye, so I need TIFF support. Below is a summary of getting Mapserver installed by source. Note that I have the necessary GEOS, GDAL from kyngchaos as well from this ealier post.</p>
<p>1. Download the ff files:<br />
<code>-rw-r--r--@ 1 rupert  admin   564313 Jul 26 10:32 agg-2.5.tar.gz<br />
-rw-r--r--@ 1 rupert  admin  1345700 Jul 26 10:22 gd-2.0.35.tar.gz<br />
-rw-r--r--@ 1 rupert  admin   613261 Jul 26 10:22 jpegsrc.v6b.tar.gz<br />
-rw-r--r--@ 1 rupert  admin   796551 Jul 26 10:22 libpng-1.2.29.tar.gz<br />
-rw-r--r--@ 1 rupert  admin  1948751 Jul 26 09:55 mapserver-5.2.0.tar.gz<br />
-rw-r--r--@ 1 rupert  admin  1336295 Jul 26 11:11 tiff-3.8.2.tar.gz</code></p>
<p>2. Install in the ff order:</p>
<p>- <a href="http://www.sfr-fresh.com/unix/misc/jpegsrc.v6b.tar.gz">jpegsrc</a><br />
- <a href="http://libpng.sourceforge.net/">libpng</a><br />
- <a href="http://www.libgd.org/Downloads">gd</a> (if you have trouble installing gd, then follow this pdf:<a href='/wordpress/wp-content/uploads/2008/07/installing_gd2_on_os_x_server.pdf'>installing_gd2_on_os_x_server</a>)<br />
- <a href="http://www.antigrain.com/agg-2.5.tar.gz">agg</a> (<em>make</em> only)<br />
- <a href="http://www.libtiff.org/">tiff</a><br />
- mapserver</p>
<p>3. For mapserver, please install using the ff configure switches:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure \
<span style="color: #660033;">--with-agg</span>=<span style="color: #000000; font-weight: bold;">/</span>myhome<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>mapserver<span style="color: #000000; font-weight: bold;">/</span>agg-<span style="color: #000000;">2.5</span> \
<span style="color: #660033;">--with-jpeg</span> \
<span style="color: #660033;">--with-gd</span> \
<span style="color: #660033;">--with-freetype</span> \
<span style="color: #660033;">--with-png</span> \
<span style="color: #660033;">--with-ogr</span> \
<span style="color: #660033;">--with-proj</span> \
<span style="color: #660033;">--with-gd</span> \
<span style="color: #660033;">--with-httpd</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>httpd \
<span style="color: #660033;">--with-tiff</span> \
<span style="color: #660033;">--with-wfs</span> \
<span style="color: #660033;">--with-wcs</span> \
<span style="color: #660033;">--with-sos</span> \
<span style="color: #660033;">--with-wmsclient</span> \
<span style="color: #660033;">--with-wfsclient</span> \
<span style="color: #660033;">--with-tiff</span> \
<span style="color: #660033;">--with-gdal</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gdal<span style="color: #000000; font-weight: bold;">/</span>gdal-config \
<span style="color: #660033;">--with-geos</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>geos-config \
<span style="color: #660033;">--with-postgis</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pg_config</pre></div></div>

<p>4. Mapserver output</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rupert:mapserver-5.2.0 rupert$ .<span style="color: #000000; font-weight: bold;">/</span>mapserv <span style="color: #660033;">-v</span>
MapServer version 5.2.0 <span style="color: #007800;">OUTPUT</span>=GIF <span style="color: #007800;">OUTPUT</span>=PNG <span style="color: #007800;">OUTPUT</span>=JPEG <span style="color: #007800;">OUTPUT</span>=WBMP <span style="color: #007800;">OUTPUT</span>=SVG <span style="color: #007800;">SUPPORTS</span>=PROJ <span style="color: #007800;">SUPPORTS</span>=AGG <span style="color: #007800;">SUPPORTS</span>=FREETYPE <span style="color: #007800;">SUPPORTS</span>=ICONV <span style="color: #007800;">SUPPORTS</span>=WMS_SERVER <span style="color: #007800;">SUPPORTS</span>=WMS_CLIENT <span style="color: #007800;">SUPPORTS</span>=WFS_SERVER <span style="color: #007800;">SUPPORTS</span>=WFS_CLIENT <span style="color: #007800;">SUPPORTS</span>=WCS_SERVER <span style="color: #007800;">SUPPORTS</span>=SOS_SERVER <span style="color: #007800;">SUPPORTS</span>=GEOS <span style="color: #007800;">INPUT</span>=TIFF <span style="color: #007800;">INPUT</span>=EPPL7 <span style="color: #007800;">INPUT</span>=POSTGIS <span style="color: #007800;">INPUT</span>=OGR <span style="color: #007800;">INPUT</span>=GDAL <span style="color: #007800;">INPUT</span>=SHAPEFILE</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/07/installing-mapserver-on-macosx-by-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgres PostGis PostInstall</title>
		<link>/wordpress/2008/06/postgres-postgis-postinstall/</link>
		<comments>/wordpress/2008/06/postgres-postgis-postinstall/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 23:34:36 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/index.php/2008/06/07/postgres-postgis-postinstall/</guid>
		<description><![CDATA[1. Edit pg_hba.conf # &#34;local&#34; is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 192.168.1.0 255.255.255.0 md5 # IPv6 local connections: #host all all ::1/128 trust 2. Edit postgres.conf 55 56 listen_addresses = '*' # what IP address(es) to listen on; [...]]]></description>
			<content:encoded><![CDATA[<p>1. Edit pg_hba.conf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># &quot;local&quot; is for Unix domain socket connections only</span>
<span style="color: #7a0874; font-weight: bold;">local</span>   all         all                               trust
<span style="color: #666666; font-style: italic;"># IPv4 local connections:</span>
host    all         all         127.0.0.1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span>          md5
host    all         all         192.168.1.0 255.255.255.0       md5
<span style="color: #666666; font-style: italic;"># IPv6 local connections:</span>
<span style="color: #666666; font-style: italic;">#host    all         all         ::1/128               trust</span></pre></div></div>

<p>2. Edit postgres.conf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">55</span>
<span style="color: #000000;">56</span> listen_addresses = <span style="color: #ff0000;">'*'</span> <span style="color: #666666; font-style: italic;"># what IP address(es) to listen on;</span>
<span style="color: #000000;">57</span> <span style="color: #666666; font-style: italic;"># comma-separated list of addresses;</span>
<span style="color: #000000;">58</span> <span style="color: #666666; font-style: italic;"># defaults to 'localhost', '*' = all</span>
<span style="color: #000000;">59</span> <span style="color: #666666; font-style: italic;"># (change requires restart)</span></pre></div></div>

<p>4. For CentOS5.1, create symbolic links:<br />
  ln -s /usr/local/lib/libproj.so.0 /usr/lib/libproj.so.0<br />
  ln -s /usr/local/lib/libgeos_c.so.1 /usr/lib/libgeos_c.so.1<br />
  ldconfig<br />
  /etc/init.d/postgresql stop<br />
  /etc/init.d/postgresql start</p>
<p>3. Postgis Post Install</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createdb <span style="color: #660033;">-E</span> utf8 template_routing
createlang plpgsql template_routing
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.3</span>-postgis<span style="color: #000000; font-weight: bold;">/</span>lwpostgis.sql 
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.3</span>-postgis<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql 
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postlbs<span style="color: #000000; font-weight: bold;">/</span>routing_core.sql 
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postlbs<span style="color: #000000; font-weight: bold;">/</span>routing_core_wrappers.sql</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/06/postgres-postgis-postinstall/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Postgresql, Postgis, pgRouting on Debian</title>
		<link>/wordpress/2008/05/installing-postgresql-postgis-pgrouting-on-debian/</link>
		<comments>/wordpress/2008/05/installing-postgresql-postgis-pgrouting-on-debian/#comments</comments>
		<pubDate>Sun, 25 May 2008 03:55:57 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[pgRouting]]></category>

		<guid isPermaLink="false">/wordpress/index.php/2008/05/25/installing-postgresql-postgis-pgrouting-on-debian/</guid>
		<description><![CDATA[Operating System: Debian sid Versions: postgres 8.3.1 postgis 1.3.3 pgRouting1.02 1. Install base system and ssh #vi /etc/apt/sources.list to include deb http://debian.cn99.com/debian etch main deb-src http://debian.cn99.com/debian etch main #apt-get update #apt-get upgrade libc6 2. Install the required packages for postgres8.3 and postgis1.3.3 #apt-get install sudo nmap telnet #apt-get install python2.5 python2.5-dev python-setuptools #apt-get install g++ [...]]]></description>
			<content:encoded><![CDATA[<p>Operating System: Debian sid</p>
<p>Versions:</p>
<ul>
<li>postgres 8.3.1</li>
<li>postgis 1.3.3</li>
<li>pgRouting1.02</li>
</ul>
<p>1. Install base system and ssh</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#vi /etc/apt/sources.list to include</span>
deb http:<span style="color: #000000; font-weight: bold;">//</span>debian.cn99.com<span style="color: #000000; font-weight: bold;">/</span>debian etch main
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>debian.cn99.com<span style="color: #000000; font-weight: bold;">/</span>debian etch main
<span style="color: #666666; font-style: italic;">#apt-get update</span>
<span style="color: #666666; font-style: italic;">#apt-get upgrade libc6</span></pre></div></div>

<p>2. Install the required packages for postgres8.3 and postgis1.3.3</p>
<pre lang="bash" xml:lang="bash">
#apt-get install sudo nmap telnet
#apt-get install python2.5 python2.5-dev python-setuptools
#apt-get install g++
#apt-get install build-essential cmake ibboost-graph-dev
#apt-get install libreadline5 libreadline5-dev
#apt-get install zlib-bin zlib1g-dev
#apt-get install libkrb5-dev
#apt-get install libcurl3
#apt-get install libssl-dev
#apt-get install postgresql-8.3
#apt-get install postgresql-8.3-postgis
#apt-get install postgresql-server-dev-8.3
</pre>
<p>3. Installing pgRouting</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># tar -zxvf pgRouting-1.02.tgz</span>
<span style="color: #666666; font-style: italic;"># cmake .</span>
<span style="color: #666666; font-style: italic;"># make </span>
<span style="color: #666666; font-style: italic;"># make install</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/05/installing-postgresql-postgis-pgrouting-on-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jpeg decoder problem on TileCache on MacOSX Leopard</title>
		<link>/wordpress/2008/05/jpeg-decoder-problem-on-tilecache-on-macosx-leopard/</link>
		<comments>/wordpress/2008/05/jpeg-decoder-problem-on-tilecache-on-macosx-leopard/#comments</comments>
		<pubDate>Mon, 12 May 2008 07:26:07 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[tilecache]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">/wordpress/?p=184</guid>
		<description><![CDATA[There is a problem with a &#8220;jpeg decoder&#8221; because Python Imaging Library (PIL) cannot find the jpeg libraries. Remember that we installed kyngchaos UnixIO libraries, therefore the PIL setup.py script should point to use those libraries. Actually, I even installed the jpegsrc manually. I believe there is no need to do this, since UnixIO Image [...]]]></description>
			<content:encoded><![CDATA[<p>There is a problem with a <em>&#8220;jpeg decoder&#8221;</em> because <a href="http://www.pythonware.com/products/pil/">Python Imaging Library (PIL)</a> cannot find the jpeg libraries. Remember that we installed <a href="http://www.kyngchaos.com/wiki/software:frameworks">kyngchaos UnixIO libraries</a>, therefore the PIL setup.py script should point to use those libraries. </p>
<p>Actually, I even installed the jpegsrc manually. I believe there is no need to do this, since UnixIO Image libraries is sufficient enough for PIL to install. What is important is to ensure that python tests succeeded. Once you get passed that, then installing PIL should work.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">1. Extract Imaging-1.1.6.tar.gz
2. Edit setup.py to reflect:
<span style="color: #007800;">JPEG_ROOT</span>=<span style="color: #ff0000;">&quot;/Library/Frameworks/UnixImageIO.framework/unix&quot;</span>
3. python setup.py build_ext <span style="color: #660033;">-i</span>
4. If no <span style="color: #7a0874; font-weight: bold;">test</span> fails, <span style="color: #000000; font-weight: bold;">then</span> go ahead and <span style="color: #c20cb9; font-weight: bold;">install</span>
5. python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/05/jpeg-decoder-problem-on-tilecache-on-macosx-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Mapserver on MacOSX Leopard (the easy way)</title>
		<link>/wordpress/2008/05/installing-mapserver-on-macosx-leopard-the-easy-way/</link>
		<comments>/wordpress/2008/05/installing-mapserver-on-macosx-leopard-the-easy-way/#comments</comments>
		<pubDate>Tue, 06 May 2008 13:01:09 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[leopard]]></category>

		<guid isPermaLink="false">/wordpress/?p=178</guid>
		<description><![CDATA[The easiest way to install mapserver on your Leopard is by downloading and installing dmg files from www.kyngchaos.com (courtesy of William Kyngesburye). These binaries were also noted from Mapserver&#8217;s Download Page. 1. Download the ff binaries in order (please note the version numbers at the time of writing): 1. UnixImageIO_Framework-1.0.22a.dmg 2. FreeType_Framework-2.3.5-3.dmg 3. GEOS_Framework-3.0.0-2.dmg 4. [...]]]></description>
			<content:encoded><![CDATA[<p>The easiest way to install mapserver on your Leopard is by downloading and installing dmg files from <a href="http://http://www.kyngchaos.com/wiki/software:mapserver">www.kyngchaos.com (courtesy of William Kyngesburye)</a>. These binaries were also noted from <a href="http://mapserver.gis.umn.edu/download/current">Mapserver&#8217;s Download Page.</a></p>
<p>1. Download the ff binaries in order (please note the version numbers at the time of writing):</p>
<p>1. <a href="http://www.kyngchaos.com/files/software/unixport/UnixImageIO_Framework-1.0.22a.dmg">UnixImageIO_Framework-1.0.22a.dmg</a><br />
2. <a href="http://www.kyngchaos.com/files/software/unixport/FreeType_Framework-2.3.5-3.dmg">FreeType_Framework-2.3.5-3.dmg</a><br />
3. <a href="http://www.kyngchaos.com/files/software/unixport/GEOS_Framework-3.0.0-2.dmg">GEOS_Framework-3.0.0-2.dmg</a><br />
4. <a href="http://www.kyngchaos.com/files/software/unixport/PROJ_Framework-4.6.0-1.dmg">PROJ_Framework-4.6.0-1.dmg</a><br />
5. <a href="http://www.kyngchaos.com/files/software/unixport/SQLite3_Framework-3.5.7-1.dmg">SQLite3_Framework-3.5.7-1.dmg</a><br />
6. <a href="http://www.kyngchaos.com/files/software/unixport/MapServer-5.0.2-2.dmg">MapServer-5.0.2-2.dmg</a></p>
<p>2. Once installed, you can copy the mapserv binaries to your apache cgi-bin</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>WebServer<span style="color: #000000; font-weight: bold;">/</span>CGI-Executables<span style="color: #000000; font-weight: bold;">/</span>mapserv <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>3. Check the mapserv output</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rupert:~ rupert$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span>mapserv <span style="color: #660033;">-v</span>
MapServer version 5.0.2 <span style="color: #007800;">OUTPUT</span>=GIF <span style="color: #007800;">OUTPUT</span>=PNG <span style="color: #007800;">OUTPUT</span>=JPEG <span style="color: #007800;">OUTPUT</span>=WBMP <span style="color: #007800;">OUTPUT</span>=SWF <span style="color: #007800;">OUTPUT</span>=SVG <span style="color: #007800;">SUPPORTS</span>=PROJ <span style="color: #007800;">SUPPORTS</span>=AGG <span style="color: #007800;">SUPPORTS</span>=FREETYPE <span style="color: #007800;">SUPPORTS</span>=WMS_SERVER <span style="color: #007800;">SUPPORTS</span>=WMS_CLIENT <span style="color: #007800;">SUPPORTS</span>=WFS_SERVER <span style="color: #007800;">SUPPORTS</span>=WFS_CLIENT <span style="color: #007800;">SUPPORTS</span>=WCS_SERVER <span style="color: #007800;">SUPPORTS</span>=SOS_SERVER <span style="color: #007800;">SUPPORTS</span>=FASTCGI <span style="color: #007800;">SUPPORTS</span>=GEOS <span style="color: #007800;">INPUT</span>=EPPL7 <span style="color: #007800;">INPUT</span>=POSTGIS <span style="color: #007800;">INPUT</span>=OGR <span style="color: #007800;">INPUT</span>=GDAL <span style="color: #007800;">INPUT</span>=SHAPEFILE</pre></div></div>

<p>This is actually the first time I was able to install mapserver NOT BY SOURCE and still achieve the same binaries that I wanted (with AGG support). Full credit should be given to William.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/05/installing-mapserver-on-macosx-leopard-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interesting Location Technologies</title>
		<link>/wordpress/2008/04/interesting-location-technologies/</link>
		<comments>/wordpress/2008/04/interesting-location-technologies/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 02:32:46 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[routing]]></category>
		<category><![CDATA[lbs]]></category>

		<guid isPermaLink="false">/wordpress/?p=170</guid>
		<description><![CDATA[Been very busy for the past few days/weeks in the office. Just read this one from Google Reader, Nokia develops navigating system based on image recognition, landmarks. In summary, base from Nokia&#8217;s Palo Alto Research center, providing direction guiding varies from gender and culture. However, providing examples such as &#8220;Turn Right after the next gas [...]]]></description>
			<content:encoded><![CDATA[<p>Been very busy for the past few days/weeks in the office. Just read this one from Google Reader, <a href="http://www.thestandard.com/news/2008/04/11/nokia-develops-navigating-system-based-image-recognition-landmarks">Nokia develops navigating system based on image recognition, landmarks</a>. In summary, base from <a href="http://research.nokia.com/locations/palo-alto/">Nokia&#8217;s Palo Alto Research center</a>, providing direction guiding varies from gender and culture. However, providing examples such as &#8220;<em>Turn Right after the next gas station</em>&#8221; seems to be a universal and a normal behavior of providing directions, the person can relate more to the advice than providing line routes above synthetic maps.</p>
<p><img class="alignleft size-medium wp-image-171" title="nokiascreen7-300x206" src="http://www.gisnotes.com/wordpress/wp-content/uploads/2008/04/nokiascreen7-300x206.jpg" alt="" width="300" height="206" /></p>
<p>This is interesting facts as it supports our theory in Call Center Directed Guiding. Although, a <a href="www.mapjack.com">360 or panoramic view</a> of any point along the line would be ideal, an easier and more realistic approach for the time being would be to include <strong>important landmark</strong> snapshots along the route.  However, I believe our organisation&#8217;s project is one step ahead since we have a warm body who already gave a summary of the route during the conversation. This means the caller have an idea of the route complexity beforehand.  Then, we could also send this landmark images to the subscriber&#8217;s mobile as his future reference (which means additional VAS).</p>
<p>Another interesting location technology, fruitful for direction guiding, would be <a href="http://www.i-spatialtech.com/iPointer.htm">iPointer</a>. I believe, base on the coordinates and orientation, the server could algorithmically predict which POI you are looking at or infront of. They mentioned they have a thin client on the mobile device, so I guess the S60 client tries to get the orientation base on the <strong>bearing</strong>. Also check this one out, <a href="http://www.geovector.com/press/mls.html">&#8220;users can now walk down the street anywhere in Japan and point at over 700,000 objects such as buildings, shops, restaurants, banks, historical sites and instantly retrieve information on what they are looking at or find what they are looking for just by pointing their phone.&#8221;</a>. Niche eh? Just compells me more to start up our mobile pursuit&#8230;</p>
<p>But what rocked me the most was <a href="http://geothought.blogspot.com/2008/04/ubisense-location-tracking-to-be.html">indoor tracking by Ubisense</a> using ultrawideband technology which is close to a foot?!?. This I have to see, as it opens new business cases for direction guiding indoors such as big malls, etc. Imagine mapjack views inside malls with Ubisense technology. Sweet. </p>
<p>Other References:<br />
<a href="http://www.openlandmark.com/">http://www.openlandmark.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/04/interesting-location-technologies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using TileCache, OpenLayers, Mapserver for Projection 900913</title>
		<link>/wordpress/2008/04/using-tilecache-openlayers-mapserver-for-projection-900913/</link>
		<comments>/wordpress/2008/04/using-tilecache-openlayers-mapserver-for-projection-900913/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 01:50:12 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[openlayers]]></category>
		<category><![CDATA[tilecache]]></category>

		<guid isPermaLink="false">http://www.gisnotes.com/wordpress/?p=166</guid>
		<description><![CDATA[I had a few problems with TileCache the other week which I am eager to blog about, since I knew for sure that later on, I might encounter the same. I don&#8217;t have the exact errors with me right now, so I&#8217;m jotting this down from my head&#8230; Classic Resolutions problem. Use extent_type=loose Can not [...]]]></description>
			<content:encoded><![CDATA[<p>I had a few problems with <a href="www.tilecache.org">TileCache</a> the other week which I am eager to blog about, since I knew for sure that later on, I might encounter the same. I don&#8217;t have the exact errors with me right now, so I&#8217;m jotting this down from my head&#8230;</p>
<ol>
<li>Classic Resolutions problem. Use extent_type=loose</li>
<li>Can not set image type</li>
</ol>
<p>UPDATED (JAN 11, 2010): Classic Resolutions problem:</p>
<p>How are resolutions calculated? Assuming we have:</p>
<p>Original:<br />
	Lower Left (LL) or minx, miny: 12453557, -5434940<br />
	Upper Right (UR) or max, maxy: 16980842, -1180729</p>
<p>maxResolution = (max &#8211; minx)/tilesize = (16980842 &#8211; 12453557)/512 = 8842.353<br />
	where tilesize = 512.</p>
<p>Therefore, we can set/guess for max so that we have maxResolution as a whole number.</p>
<p>Adjusted:<br />
	minx, miny: 12453557, -5434940<br />
	maxx, maxy: 16980661, -1180729</p>
<p>gives a maxResolution (whole number) of 8842.</p>
<p>Now, you can use 8842 in both the TileCache.cfg and OpenLayers Javascript.<span id="more-166"></span><br />
<strong>A. Google BaseLayer + Road WMS Overlay = Validation approach before we proceed to TC.</strong></p>
<p>1. OpenLayers (OL) Code: <a href="http://www.gisnotes.com/platform/docs/examples/GoogleWMSRoads.cfm">http://www.gisnotes.com/platform/docs/examples/GoogleWMSRoads.cfm</a></p>
<p>2. Map File Configuration: <code>/home/map/beijing/new/beijing_google_roads</code></p>
<p>Well the above files are not exactly for TC, but it is a good demonstration that we could overlay our custom layers (WMS) on top of Google as the base layer. For a more detailed explanation regarding Google + OL, please read my previous <a href="/wordpress/index.php/2007/12/22/openlayers-google-spherical-mercator-example/">gisnote</a>. Also, this is a good test to see if our <a href="">Mapserver <em>mapfile</em> configuration</a> is correct. I do suggest not to proceed with OL + TC not unless you have validated the mapfile through OL (Google + WMS).</p>
<p><strong>B. Google900913 Tilecache as baselayer</strong></p>
<p>Ok.. so here it is..</p>
<p>1. OpenLayers Code: <a href="http://www.gisnotes.com/platform/docs/examples/TilecacheGoogle900913Base.cfm">http://www.gisnotes.com/platform/docs/examples/TilecacheGoogle900913Base.cfm</a></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">        window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                        projection<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Projection</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;EPSG:900913&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                        units<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;m&quot;</span><span style="color: #339933;">,</span>
&nbsp;
                        <span style="color: #006600; font-style: italic;">//maxResolution: 156543.0339,</span>
                        resolutions <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">156543.03390000001</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">78271.516950000005</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">39135.758475000002</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">19567.879237500001</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9783.9396187500006</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4891.9698093750003</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2445.9849046875001</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1222.9924523437501</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">611.49622617187504</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">305.74811308593752</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">152.87405654296876</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">76.43702827148438</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">38.21851413574219</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">19.109257067871095</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9.5546285339355475</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4.7773142669677737</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2.3886571334838869</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1.1943285667419434</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0.59716428337097172</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0.29858214168548586</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                        <span style="color: #006600; font-style: italic;">//zoom: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] @ numZoomLevels: 20</span>
                        numZoomLevels<span style="color: #339933;">:</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span>
                        <span style="color: #006600; font-style: italic;">//maxExtent: new OpenLayers.Bounds(12823075.86334, 4800551.12375, 13101918.14248, 5021301.26141)</span>
                        <span style="color: #006600; font-style: italic;">//maxExtent: new OpenLayers.Bounds(12823075, 4800551, 13101918, 5021301)</span>
                        <span style="color: #006600; font-style: italic;">//maxExtent: new OpenLayers.Bounds(12848138, 4785083, 13080212, 5021118.5)</span>
                        maxExtent<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Bounds</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #CC0000;">20037508</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">20037508</span><span style="color: #339933;">,</span><span style="color: #CC0000;">20037508</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20037508.34</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
            OpenLayers.<span style="color: #660066;">IMAGE_RELOAD_ATTEMPTS</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
            OpenLayers.<span style="color: #660066;">Util</span>.<span style="color: #660066;">onImageLoadErrorColor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;transparent&quot;</span><span style="color: #339933;">;</span>
&nbsp;
            map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Map</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mapdiv'</span><span style="color: #339933;">,</span>options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">var</span> serverURL <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;/tilecache/tilecache.py&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #006600; font-style: italic;">// start custom layer here</span>
            <span style="color: #003366; font-weight: bold;">var</span> layer_obj <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Layer</span>.<span style="color: #660066;">WMS</span><span style="color: #009900;">&#40;</span>
                <span style="color: #3366CC;">&quot;Beijing&quot;</span><span style="color: #339933;">,</span>
                serverURL<span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span>
                    layers<span style="color: #339933;">:</span> <span style="color: #3366CC;">'beijing_900913'</span><span style="color: #339933;">,</span>
                    map<span style="color: #339933;">:</span> <span style="color: #3366CC;">'/home/map/beijing/new/beijing_900913/beijing.map'</span><span style="color: #339933;">,</span>
                    format<span style="color: #339933;">:</span> <span style="color: #3366CC;">'image/jpg'</span><span style="color: #339933;">,</span>
                    <span style="color: #3366CC;">'transparent'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'off'</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            layer_obj.<span style="color: #660066;">setIsBaseLayer</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            layer_obj.<span style="color: #660066;">setVisibility</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>layer_obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>2. TileCache Configuration: /wwwroot/tilecache/tilecache.cfg</p>

<div class="wp_syntax"><div class="code"><pre class="cnf" style="font-family:monospace;">[beijing_900913]
type=WMSLayer
url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/beijing_900913/beijing.map
layers=beijing_900913
metatile=true
extension=jpg
levels=20
resolutions=156543.03390000001, 78271.516950000005, 39135.758475000002, 19567.879237500001, 9783.9396187500006, 4891.9698093750003, 2445.9849046875001, 1222.9924523437501, 611.49622617187504, 305.74811308593752, 152.87405654296876, 76.43702827148438, 38.21851413574219, 19.109257067871095, 9.5546285339355475, 4.7773142669677737, 2.3886571334838869, 1.1943285667419434, 0.59716428337097172, 0.29858214168548586
srs=EPSG:900913
bbox=-20037508, -20037508, 20037508, 20037508.34
#maxResolution=156543.0339
extent_type=loose
debug=on</pre></div></div>

<p>You can either set resolutions or maxResolutions. I always wanted to be explicit, so setting the <strong>resolutions</strong> is my preference.</p>
<p>3. MapFile Configuration: <code>/home/map/beijing/new/beijing_900913/beijing.map</code><br />
I have a long mapfile, and using <a href="http://mapserver.gis.umn.edu/docs/reference/mapfile/Include">includes</a> helped a lot, see my previous <a href="/wordpress/index.php/2007/08/19/103/">gisnote</a>.  For debugging your mapfile, read this <a href="/wordpress/index.php/2007/08/24/mapserver-debug-output/">post.</a></p>
<p><strong>Always Remember&#8230;I believe when they made TC, I presume they always tested on WGS84(lonlat), this means if you don&#8217;t set anything explicit, it would <em>implicitly</em> set settings in WGS84(lon/lat)&#8230;</strong></p>
<ul>
<li>Ensure that you have the vector data in the necessary projection, in my case it&#8217;s 900913.</li>
<p><br/> </p>
<li>Ensure that the <em>resolutions</em> from OL (B.1) is reflected in TC configuration (B.2).</li>
<p><br/></p>
<li>Ensure that the <em>maxextents</em> from OL (B.1) is reflected in TC configuration (B.2) as <em>bbox</em>.</li>
<p><br/>
</ul>
<p><strong>C. Still can&#8217;t get it running?</strong></p>
<p>1. Narrow down the error.</p>
<p>2. <strong>tail -f /var/log/apache2/error.log</strong> and <strong>access.log</strong> is your bestfriend. It&#8217;s a good starting point to trace down what went wrong.  If you can&#8217;t see it from Apache&#8217;s error.log then ensure that <a href="/wordpress/index.php/2007/07/25/installing-tilecache/">python debugging is turned on.</a></p>
<p>3. Sometimes TC <strong>[a]</strong> gives you an obvious error or <strong>[b]</strong> its just a link to the mapserv request. </p>
<p>Examples of <strong>[a]</strong>:</p>
<ul>
<li><em>Classic Resolution problem stated above. </em>- If you followed my final notes above, then this should not happen. If you&#8217;ve set up things correctly but it&#8217;s still broken and you want to pull your hair out, then do a clean test stated below in D.</li>
<li><em>Cannot set image type</em> &#8211; Check the extensions from the mapfile and TC config. Are they both in jpg&#8217;s?</li>
</ul>
<p>The latter <strong>[b]</strong> is harder to debug. Most likely its a mapserver mapfile mishap and the easiest way to hunt this down is only thru your error.log (note: you need mapserver to have a debug=true when you compiled it, that&#8217;s another story.)</p>
<p><strong>D. Doing a clean test as always</strong><br />
1. Always disable any caching when testing. Disable cache from your browser, for FF I use the webdeveloper toolbar. It&#8217;s as easy as Disable -> Disable Cache.</p>
<p>2. Stop/Start Apache. Hoping Python get&#8217;s a clean start as well. If you found any pyc (python compiled) under TC source directory&#8230; then stop Apache; remove the pycs; start Apache.</p>
<p>3. Seeing the same images? Always remove the image caches! rm -Rf /data/tilecache/beijing_900913</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/04/using-tilecache-openlayers-mapserver-for-projection-900913/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Mapserver on Debian (reprise)</title>
		<link>/wordpress/2008/03/installing-mapserver-on-debian-reprise/</link>
		<comments>/wordpress/2008/03/installing-mapserver-on-debian-reprise/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 11:31:43 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mapserver]]></category>

		<guid isPermaLink="false">http://www.gisnotes.com/wordpress/index.php/2008/03/28/installing-mapserver-on-debian-reprise/</guid>
		<description><![CDATA[As noted from my previous blog post regarding Mapserver on Debian, you don&#8217;t get AGG with Mapserver when installing directly from Debian packages. Thus, it would be better to install Mapserver by source. However, debian still helps because it would install all the necessary libraries needed for compiling mapserver. ./configure \ --with-agg \ --with-jpeg \ [...]]]></description>
			<content:encoded><![CDATA[<p>As noted from my <a href="/wordpress/index.php/2007/08/01/debian-howto-installing-mapserver/">previous blog post regarding Mapserver on Debian</a>, you don&#8217;t get AGG with Mapserver when installing directly from Debian packages. Thus, it would be better to <a href="http://mapserver.gis.umn.edu/download/current">install Mapserver by source.</a> However, debian still helps because it would install all the necessary libraries needed for compiling mapserver.<span id="more-165"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure \
<span style="color: #660033;">--with-agg</span> \
<span style="color: #660033;">--with-jpeg</span> \
<span style="color: #660033;">--with-gd</span> \
<span style="color: #660033;">--with-freetype</span> \
<span style="color: #660033;">--with-png</span> \
<span style="color: #660033;">--with-ogr</span> \
<span style="color: #660033;">--with-proj</span> \
<span style="color: #660033;">--with-gdal</span> \
<span style="color: #660033;">--with-httpd</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 \
<span style="color: #660033;">--with-tiff</span> \
<span style="color: #660033;">--with-wfs</span> \
<span style="color: #660033;">--with-wcs</span> \
<span style="color: #660033;">--with-threads</span> \
<span style="color: #660033;">--with-wmsclient</span> \
<span style="color: #660033;">--with-wfsclient</span> \
<span style="color: #660033;">--with-geos</span> \
<span style="color: #660033;">--with-postgis</span> \
<span style="color: #660033;">--enable-debug</span></pre></div></div>

<p>When I started installing yesterday, I did not know which packages/libraries are installed in my box. I dove off immediately by running my configure.sh above and received an error: <font color="red"><code>Could not find gd.h or libgd.a/libgd.so in /usr/local..</code></font></p>
<p>The best way to figure out if you&#8217;re ready is reading thru the <em>configure</em> output.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">checking <span style="color: #000000; font-weight: bold;">for</span> gcc... <span style="color: #c20cb9; font-weight: bold;">gcc</span>
checking <span style="color: #000000; font-weight: bold;">for</span> C compiler default output <span style="color: #c20cb9; font-weight: bold;">file</span> name... a.out
checking whether the C compiler works... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking whether we are cross compiling... no
checking <span style="color: #000000; font-weight: bold;">for</span> suffix of executables...
checking <span style="color: #000000; font-weight: bold;">for</span> suffix of object files... o
checking whether we are using the GNU C compiler... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking whether <span style="color: #c20cb9; font-weight: bold;">gcc</span> accepts -g... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> option to accept ANSI C... none needed
checking <span style="color: #000000; font-weight: bold;">for</span> g++... <span style="color: #c20cb9; font-weight: bold;">g++</span>
checking whether we are using the GNU C++ compiler... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking whether <span style="color: #c20cb9; font-weight: bold;">g++</span> accepts -g... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> ranlib... ranlib
checking <span style="color: #000000; font-weight: bold;">for</span> flex... no
checking <span style="color: #000000; font-weight: bold;">for</span> lex... no
checking <span style="color: #000000; font-weight: bold;">for</span> yywrap <span style="color: #000000; font-weight: bold;">in</span> -lfl... no
checking <span style="color: #000000; font-weight: bold;">for</span> yywrap <span style="color: #000000; font-weight: bold;">in</span> -ll... no
checking <span style="color: #000000; font-weight: bold;">for</span> bison... no
checking <span style="color: #000000; font-weight: bold;">for</span> byacc... no
checking <span style="color: #000000; font-weight: bold;">if</span> compiler supports -R... no
checking <span style="color: #000000; font-weight: bold;">if</span> compiler supports -Wl,-rpath,... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> exp <span style="color: #000000; font-weight: bold;">in</span> -lm... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> __gxx_personality_v0 <span style="color: #000000; font-weight: bold;">in</span> -lstdc++... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking how to run the C preprocessor... <span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-E</span>
checking <span style="color: #000000; font-weight: bold;">for</span> egrep... <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-E</span>
checking <span style="color: #000000; font-weight: bold;">for</span> ANSI C header files... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> strcasecmp... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> strncasecmp... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> strdup... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> strlcat... no
checking <span style="color: #000000; font-weight: bold;">for</span> vsnprintf... <span style="color: #c20cb9; font-weight: bold;">yes</span>
MapServer Version from mapserver.h: <span style="color: #ff0000;">'5.0.2'</span>
configure: checking where FreeType 2.x is installed...
checking <span style="color: #000000; font-weight: bold;">for</span> freetype-config... <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>freetype-config
        using libfreetype from <span style="color: #660033;">-lfreetype</span> <span style="color: #660033;">-lz</span>
checking <span style="color: #000000; font-weight: bold;">for</span> FT_Init_FreeType <span style="color: #000000; font-weight: bold;">in</span> -lfreetype... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using libfreetype <span style="color: #660033;">-lfreetype</span> from system libs.
configure: checking where Zlib is installed...
checking <span style="color: #000000; font-weight: bold;">for</span> zlibVersion <span style="color: #000000; font-weight: bold;">in</span> -lz... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using libz from system libs <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_ZLIB<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
configure: checking where PNG is installed...
checking <span style="color: #000000; font-weight: bold;">for</span> png_init_io <span style="color: #000000; font-weight: bold;">in</span> -lpng... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using libpng from system libs.
configure: checking whether we should include JPEG support...
checking <span style="color: #000000; font-weight: bold;">for</span> jpeg_read_header <span style="color: #000000; font-weight: bold;">in</span> -ljpeg... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using libjpeg from system libs.
configure: checking where libXpm is installed...
checking <span style="color: #000000; font-weight: bold;">for</span> XpmFreeXpmImage <span style="color: #000000; font-weight: bold;">in</span> -lXpm... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using libXpm from system libs.
configure: checking where libiconv is installed...
checking <span style="color: #000000; font-weight: bold;">for</span> iconv_open <span style="color: #000000; font-weight: bold;">in</span> -lc... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> libiconv_open <span style="color: #000000; font-weight: bold;">in</span> -liconv... no
        using libiconv from system libs.
        libiconv found. Enabling internationalization <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_ICONV<span style="color: #7a0874; font-weight: bold;">&#41;</span>
configure: checking <span style="color: #000000; font-weight: bold;">for</span> GD 2.0.16 or higher...
checking <span style="color: #000000; font-weight: bold;">for</span> gdFontCacheSetup <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using libgd 2.0.16 <span style="color: #7a0874; font-weight: bold;">&#40;</span>or higher<span style="color: #7a0874; font-weight: bold;">&#41;</span> from system libs <span style="color: #7a0874; font-weight: bold;">&#40;</span>-L<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib <span style="color: #660033;">-lgd</span> <span style="color: #660033;">-ljpeg</span> <span style="color: #660033;">-lfreetype</span> <span style="color: #660033;">-lpng</span> <span style="color: #660033;">-lz</span> <span style="color: #660033;">-lXpm</span> <span style="color: #660033;">-lX11</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>.
checking <span style="color: #000000; font-weight: bold;">for</span> gdImageCreate <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdImageGif <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdImagePng <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdImageJpeg <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdImageWBMP <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdImageStringFT <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdImageOpenPolygon <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdImageGifPtr <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> gdFontGetTiny <span style="color: #000000; font-weight: bold;">in</span> -lgd... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using GD <span style="color: #7a0874; font-weight: bold;">&#40;</span> -DUSE_GD_GIF -DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DGD_HAS_FTEX_XSHOW -DGD_HAS_GDIMAGEGIFPTR -DGD_HAS_GETBITMAPFONTS<span style="color: #7a0874; font-weight: bold;">&#41;</span> from system libs.
configure: checking whether we should include PDF support...
checking <span style="color: #000000; font-weight: bold;">for</span> PDF_setlinewidth <span style="color: #000000; font-weight: bold;">in</span> -lpdf... no
checking <span style="color: #000000; font-weight: bold;">for</span> PDF_setrgbcolor <span style="color: #000000; font-weight: bold;">in</span> -lpdf... no
checking <span style="color: #000000; font-weight: bold;">for</span> PDF_moveto <span style="color: #000000; font-weight: bold;">in</span> -lpdf... no
checking <span style="color: #000000; font-weight: bold;">for</span> PDF_curveto <span style="color: #000000; font-weight: bold;">in</span> -lpdf... no
checking <span style="color: #000000; font-weight: bold;">for</span> PDF_show_xy <span style="color: #000000; font-weight: bold;">in</span> -lpdf... no
checking <span style="color: #000000; font-weight: bold;">for</span> PDF_load_font <span style="color: #000000; font-weight: bold;">in</span> -lpdf... no
        libpdf not found or too old... PDF support not included.
checking <span style="color: #000000; font-weight: bold;">if</span> AGG support requested... looking <span style="color: #000000; font-weight: bold;">for</span> agg libs <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr
using libagg from <span style="color: #000000; font-weight: bold;">/</span>usr
using libaggfontfreetype from <span style="color: #000000; font-weight: bold;">/</span>usr
configure: checking whether we should include EPPL7 support...
        including EPPL7 support.
configure: checking whether we should include PROJ.4 support...
checking <span style="color: #000000; font-weight: bold;">for</span> pj_init <span style="color: #000000; font-weight: bold;">in</span> -lproj... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> pj_transform <span style="color: #000000; font-weight: bold;">in</span> -lproj... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using PROJ.4 from system libs.
configure: checking whether we should include thread safe support...
checking <span style="color: #000000; font-weight: bold;">for</span> pthread_create <span style="color: #000000; font-weight: bold;">in</span> -lpthread... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using <span style="color: #660033;">-lpthread</span> from system libs.
configure: checking whether we should include ESRI SDE support...
        ESRI SDE support not requested.
checking <span style="color: #000000; font-weight: bold;">if</span> GEOS support requested... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> geos-config... <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>geos-config
checking <span style="color: #000000; font-weight: bold;">for</span> GEOS version <span style="color: #000000; font-weight: bold;">&amp;</span>gt;= 2.2.2... yes. Found version 2.2.3
configure: checking whether we should include OGR support...
checking <span style="color: #000000; font-weight: bold;">for</span> gdal-config... <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gdal-config
        OGR enabled <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_OGR<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
checking <span style="color: #000000; font-weight: bold;">if</span> GDAL support requested... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking checking ms JPEG output... no we, have GDAL available.
configure: checking whether we should include TIFF support...
checking <span style="color: #000000; font-weight: bold;">for</span> TIFFOpen <span style="color: #000000; font-weight: bold;">in</span> -ltiff... <span style="color: #c20cb9; font-weight: bold;">yes</span>
        using libtiff from system libs.
checking <span style="color: #000000; font-weight: bold;">if</span> PostGIS support requested... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> pg_config... <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pg_config
<span style="color: #c20cb9; font-weight: bold;">yes</span>, user supplied pg_config
checking <span style="color: #000000; font-weight: bold;">if</span> MyGIS support requested... no
checking <span style="color: #000000; font-weight: bold;">if</span> OracleSpatial support requested... no
checking <span style="color: #000000; font-weight: bold;">if</span> MING<span style="color: #000000; font-weight: bold;">/</span>Flash support requested... no
configure: checking whether we should include WMS Server support...
        OGC WMS compatibility enabled <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_WMS_SVR<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
configure: checking whether we should include WFS Server support...
        OGC WFS Server support enabled <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_WFS_SVR<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
configure: checking whether we should include WCS Server support...
        OGC WCS Server support enabled <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_WCS_SVR<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
configure: checking whether we should include WMS Client Connections support...
configure: checking whether we should include WFS Client Connections support...
configure: checking whether we should include OGC SOS Server support...
configure: checking <span style="color: #000000; font-weight: bold;">for</span> curl-config...
checking <span style="color: #000000; font-weight: bold;">for</span> curl-config... <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>curl-config
        found libcurl version 7.18.0
        OGC WMS Client Connections enabled <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_WMS_LYR<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
        OGC WFS Client Connections enabled <span style="color: #7a0874; font-weight: bold;">&#40;</span>-DUSE_WFS_LYR<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
configure: checking <span style="color: #000000; font-weight: bold;">for</span> xml2-config...
configure: checking whether FastCGI support should be enabled...
        FastCGI support not enabled.
configure: checking HTTPD server <span style="color: #7a0874; font-weight: bold;">&#40;</span>Apache<span style="color: #7a0874; font-weight: bold;">&#41;</span> version...
        using user-supplied httpd <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 version is Apache<span style="color: #000000; font-weight: bold;">/</span>2.2.8 <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2002008</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.
        Your system is apparently running Apache<span style="color: #000000; font-weight: bold;">/</span>2.2.8.  Setting stderr to non-blocking <span style="color: #000000; font-weight: bold;">for</span> msDebug<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> due to Apache 2.x bug <span style="color: #7a0874; font-weight: bold;">&#40;</span>see MapServer bug <span style="color: #000000;">458</span> or Apache bug <span style="color: #000000;">22030</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.
Compiling with fast MS_NINT
checking compiler warnings... basic
configure: checking whether we should <span style="color: #7a0874; font-weight: bold;">enable</span> debug features...
        Enabling debug features: <span style="color: #660033;">-g</span> <span style="color: #000000; font-weight: bold;">in</span> CFLAGS.
configure: checking <span style="color: #000000; font-weight: bold;">for</span> PHP<span style="color: #000000; font-weight: bold;">/</span>MapScript module options...
        PHP<span style="color: #000000; font-weight: bold;">/</span>MapScript module not configured.
checking <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">g++</span> <span style="color: #660033;">-shared</span> ... <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #660033;">--enable-runpath</span> requested... no
checking <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #660033;">--with-java-include-os-name</span> specified... no, autodetected linux
configure: creating .<span style="color: #000000; font-weight: bold;">/</span>config.status
config.status: creating Makefile
config.status: creating mapscript<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>Makefile
config.status: creating mapscript<span style="color: #000000; font-weight: bold;">/</span>csharp<span style="color: #000000; font-weight: bold;">/</span>Makefile
&nbsp;
MapServer is now configured <span style="color: #000000; font-weight: bold;">for</span>
&nbsp;
 <span style="color: #660033;">--------------</span> Compiler Info <span style="color: #660033;">-------------</span>
  C compiler:                <span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-g</span> <span style="color: #660033;">-O2</span> <span style="color: #660033;">-fPIC</span> <span style="color: #660033;">-Wall</span>
  C++ compiler:              <span style="color: #c20cb9; font-weight: bold;">g++</span> <span style="color: #660033;">-g</span> <span style="color: #660033;">-O2</span> <span style="color: #660033;">-fPIC</span> <span style="color: #660033;">-Wall</span>
  Debug:                     <span style="color: #660033;">-g</span>  -DNEED_NONBLOCKING_STDERR
  Generic NINT:
  Threading support:         -DUSE_THREAD
&nbsp;
 <span style="color: #660033;">--------------</span> Renderer Settings <span style="color: #660033;">---------</span>
  zlib support:              -DUSE_ZLIB
  png support:
  jpeg support:
  iconv support:             -DUSE_ICONV
  AGG support:               -DUSE_AGG
  AGG Freetype support:      <span style="color: #660033;">-laggfontfreetype</span>
  Ming<span style="color: #7a0874; font-weight: bold;">&#40;</span>flash<span style="color: #7a0874; font-weight: bold;">&#41;</span> support:
  PDFLib support:
&nbsp;
 <span style="color: #660033;">--------------</span> Data Format Drivers <span style="color: #660033;">-------</span>
  native tiff support:       -DUSE_TIFF
  PostGIS support:           -DUSE_POSTGIS
  Proj.4 support:            -DUSE_PROJ
  EPPL7 support:             -DUSE_EPPL
  ArcSDE support:
  OGR support:               -DUSE_OGR
  GDAL support:              -DUSE_GDAL
  GEOS support:              -DUSE_GEOS
  Oracle Spatial support:
  FastCGI support:
&nbsp;
 <span style="color: #660033;">--------------</span> OGC Services <span style="color: #660033;">--------------</span>
  WMS Server:                -DUSE_WMS_SVR
  WMS Client:                -DUSE_WMS_LYR
  WFS Server:                -DUSE_WFS_SVR
  WFS Client:                -DUSE_WMS_LYR
  WCS Server:                -DUSE_WCS_SVR
  SOS Server:
&nbsp;
 <span style="color: #660033;">--------------</span> MapScript <span style="color: #660033;">-----------------</span>
  PHP MapScript:             no</pre></div></div>

<p>I was able to weed out the problem above by checking on the libraries noted with &#8220;yes&#8221; above if they are installed or not. To overcome this, I needed to install the ff debian packages on &#8216;lenny(testing)&#8217;:</p>
<p><code>libagg-dev libgd2-xpm libgd2-xpm-dev libtiff4 libtiff4-dev libpng libpng-dev libxpm4 libxpm4-dev libfreetype6-dev libapache2-mod-python python-imaging </code></p>
<p>Results:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">debsexy:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #666666; font-style: italic;"># ./mapserv -v</span>
MapServer version 5.0.2 <span style="color: #007800;">OUTPUT</span>=GIF <span style="color: #007800;">OUTPUT</span>=PNG <span style="color: #007800;">OUTPUT</span>=JPEG <span style="color: #007800;">OUTPUT</span>=WBMP <span style="color: #007800;">OUTPUT</span>=SVG <span style="color: #007800;">SUPPORTS</span>=PROJ <span style="color: #007800;">SUPPORTS</span>=AGG <span style="color: #007800;">SUPPORTS</span>=FREETYPE <span style="color: #007800;">SUPPORTS</span>=WMS_SERVER <span style="color: #007800;">SUPPORTS</span>=WMS_CLIENT <span style="color: #007800;">SUPPORTS</span>=WFS_SERVER <span style="color: #007800;">SUPPORTS</span>=WFS_CLIENT <span style="color: #007800;">SUPPORTS</span>=WCS_SERVER <span style="color: #007800;">SUPPORTS</span>=THREADS <span style="color: #007800;">SUPPORTS</span>=GEOS <span style="color: #007800;">INPUT</span>=TIFF <span style="color: #007800;">INPUT</span>=EPPL7 <span style="color: #007800;">INPUT</span>=POSTGIS <span style="color: #007800;">INPUT</span>=OGR <span style="color: #007800;">INPUT</span>=GDAL <span style="color: #007800;">INPUT</span>=SHAPEFILE</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/03/installing-mapserver-on-debian-reprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PostGres8.3 and Postgis1.3.2 on Windows</title>
		<link>/wordpress/2008/03/installing-postgres83-and-postgis-on-windows/</link>
		<comments>/wordpress/2008/03/installing-postgres83-and-postgis-on-windows/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 00:15:05 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/index.php/2008/03/04/installing-postgres83-and-postgis-on-windows/</guid>
		<description><![CDATA[It seems very nice for the new PostGres8.3 installer to bundle up third party libraries installation with the new admin pack feature. Using this feature, you can install PostGis, nPgsql, etc. The installation was painless and smooth this time. I have to backup all my data though using pg_dump. To lessen the learning curve on [...]]]></description>
			<content:encoded><![CDATA[<p>It seems very nice for the new PostGres8.3 installer to bundle up third party libraries installation with the new <em>admin pack</em> feature. Using this feature, you can install PostGis, nPgsql, etc. The installation was painless and smooth this time. I have to backup all my data though using pg_dump.</p>
<p>To lessen the learning curve on installing PostGres + PostGis together, I made a <a href="http://www.gisnotes.com/wordpress/training/postgres-tut1.html" title="postgres-tut1.html">short flash movie</a> here.  There is no audio in the tutorial. The idea was to introduce PostGres to my Chinese staff.  I have to remove PostGreSQL 8.2 first before installing 8.3.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/03/installing-postgres83-and-postgis-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

