<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>davblog: webdev and stuff</title>
	
	<link>http://www.d-mueller.de/blog</link>
	<description>jeden Tag ein bisschen besser</description>
	<lastBuildDate>Mon, 31 Oct 2011 22:35:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/davblog-webdevandstuff" /><feedburner:info uri="davblog-webdevandstuff" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>PHP WTF #7</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/F1wU_LxO8kQ/</link>
		<comments>http://www.d-mueller.de/blog/php-wtf-7/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 22:35:37 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[PHP-WTF]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=623</guid>
		<description><![CDATA[Direkt entliehen von hier und ein schönes Beispiel für PHPs Handling mit Unicode-Zeichen: 12345&#60;meta charset=&#34;utf8&#34;&#62; &#60;?php $a = 'äa'; echo &#34;with space: &#34; . $a&#91;0&#93; . &#34; &#34; . $a&#91;1&#93; . &#34;&#60;br /&#62;&#34;; &#160;//� � echo &#34;without space: &#34; . &#8230; <a href="http://www.d-mueller.de/blog/php-wtf-7/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Direkt entliehen von <a href="http://www.codenaschereien.de/php/php-string-klasse/">hier</a> und ein schönes Beispiel für PHPs Handling mit Unicode-Zeichen:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;meta charset=&quot;utf8&quot;&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'äa'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;with space: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//� �</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;without space: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ä</span></div></td></tr></tbody></table></div>
<p>bzw. analog dazu:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;meta charset=&quot;utf8&quot;&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'äa'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;substr 0,1: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//�</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;substr 0,2: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ä</span></div></td></tr></tbody></table></div>
<p>Klar: Das <i>ä</i> belegt 2 Byte:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'äa'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;strlen: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//3</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;mb_strlen: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mb_strlen"><span style="color: #990000;">mb_strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//2</span></div></td></tr></tbody></table></div>
<p>Schon besser:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;meta charset=&quot;utf8&quot;&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'äa'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;mb_substr 0,1: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mb_substr"><span style="color: #990000;">mb_substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ä</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;mb_substr 0,2: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mb_substr"><span style="color: #990000;">mb_substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//äa</span></div></td></tr></tbody></table></div>
<p>Mir war das zwar im Prinzip schon alles klar, durch so ein Beispiel wird aber nochmal deutlich, dass man die nicht-mb_* &#8211; Funktionen partout meiden sollte.<strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/php-wtf-1/" rel="bookmark" title="20. November 2010">PHP WTF #1</a></li>
<li><a href="http://www.d-mueller.de/blog/sichere-passworter/" rel="bookmark" title="21. Oktober 2010">Sichere Passwörter</a></li>
<li><a href="http://www.d-mueller.de/blog/utf-8-fur-php-programmierer-und-webanwendungen/" rel="bookmark" title="1. Juli 2009">UTF-8 für PHP-Programmierer und Webanwendungen</a></li>
<li><a href="http://www.d-mueller.de/blog/mysql-views/" rel="bookmark" title="20. November 2010">MySQL Views</a></li>
<li><a href="http://www.d-mueller.de/blog/php-wtf-5/" rel="bookmark" title="23. Februar 2011">PHP WTF #5</a></li>
</ul>
<p><!-- Similar Posts took 11.991 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/F1wU_LxO8kQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/php-wtf-7/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/php-wtf-7/</feedburner:origLink></item>
		<item>
		<title>Best-of-the-Web 10</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/tbvH3dMbiZY/</link>
		<comments>http://www.d-mueller.de/blog/best-of-the-web-10/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 09:18:32 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Best of the Web]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=622</guid>
		<description><![CDATA[Neue Linkwelle! PHP most watched repositories &#8211; Die auf Github meistbeobachteten PHP Repos. PHP in the Dark: Input/Output &#8211; Eingabe / Ausgabe über die Konsole verarbeiten. Parameterverarbeitung etc. AbsoluteChaos.php &#8211; Quellcode bei Github, angelehnt an den Netflix Chaos Monkey Google &#8230; <a href="http://www.d-mueller.de/blog/best-of-the-web-10/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Neue Linkwelle!</p>
<ul>
<li><a href="https://github.com/languages/PHP/most_watched">PHP most watched repositories</a> &#8211; Die auf Github meistbeobachteten PHP Repos.</li>
<li><a href="http://www.amazium.com/blog/php-in-the-dark-input-output">PHP in the Dark: Input/Output</a> &#8211; Eingabe / Ausgabe über die Konsole verarbeiten. Parameterverarbeitung etc.</li>
<li><a href="https://github.com/haavardeide/ChaosMonkey/blob/master/ChaosMonkey/Chaos/AbsoluteChaos.php">AbsoluteChaos.php</a> &#8211; Quellcode bei Github, angelehnt an den <a href="http://www.codinghorror.com/blog/2011/04/working-with-the-chaos-monkey.html">Netflix Chaos Monkey</a></li>
<li><a href="http://www.datenschutzbeauftragter-info.de/fachbeitraege/google-analytics-datenschutzkonform-einsetzen/">Google Analytics datenschutzkonform einsetzen</a> &#8211; Netter Step-by-Step Guide, wie man mit Analytics garantiert auf der sicheren Seite ist.</li>
<li><a href="http://hyperpolyglot.org/">Programming Languages Reference Sheets</a> &#8211; Tolle Gegenüberstellung der meistverwendeten Sprachkonstrukte in zich Sprachen.</li>
<li><a href="https://apigee.com">Apigee API Console: explore, test and debug APIs</a> &#8211; Mit APIs leicht rumprobieren. Foursquare, Facebook, Twitter, LinkedIn &#8230; werden angeboten.</li>
<li><a href="http://demo.phpids.org/">Demo des PHPIDS</a> &#8211; Hat mir Spaß gemacht, damit rumzuspielen.</li>
</ul>
<p><strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/javascript-arrays-kopieren/" rel="bookmark" title="13. März 2011">Javascript: Arrays kopieren</a></li>
<li><a href="http://www.d-mueller.de/blog/zip-archive-entpacken-mit-javascript/" rel="bookmark" title="23. Februar 2011">Zip-Archive entpacken mit Javascript</a></li>
<li><a href="http://www.d-mueller.de/blog/datenbank-klasse-auf-pdo-basierend/" rel="bookmark" title="20. November 2010">Datenbank-Klasse (auf PDO basierend)</a></li>
<li><a href="http://www.d-mueller.de/blog/codevisualisierung-mit-pfff-php-frontend-for-fun/" rel="bookmark" title="24. November 2010">Codevisualisierung mit pfff: PHP Frontend For Fun</a></li>
<li><a href="http://www.d-mueller.de/blog/best-of-the-web-1/" rel="bookmark" title="31. Oktober 2010">Best-of-the-Web 1</a></li>
</ul>
<p><!-- Similar Posts took 12.309 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/tbvH3dMbiZY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/best-of-the-web-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/best-of-the-web-10/</feedburner:origLink></item>
		<item>
		<title>Umkreissuche: Lat/Long und der Radius</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/Q5bNqb9gh1U/</link>
		<comments>http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 17:11:58 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=617</guid>
		<description><![CDATA[Aufgabenstellung: Ich weiß, wo ich mich befinde (Lat / Long, ist ja aus den Smartphones easy herauszubekommen) und habe einen Radius in km, in dem ich POI&#8217;s mit der Open Streemap API suchen möchte. Problem: Die OSM API bietet keine &#8230; <a href="http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
<b>Aufgabenstellung:</b> Ich weiß, wo ich mich befinde (<a href="http://en.wikipedia.org/wiki/Geographic_coordinate_system">Lat / Long</a>, ist ja aus den Smartphones easy herauszubekommen) und habe einen Radius in km, in dem ich <a href="http://www.d-mueller.de/blog/open-streetmap-api-tutorial-umkreissuche/">POI&#8217;s mit der Open Streemap API</a> suchen möchte.
</p>
<p>
<b>Problem:</b> Die OSM API bietet keine (mir bekannte) Möglichkeit, um meinen aktuellen Standort herum eine Radius-Suche in km auszuführen, sondern hätte gern eine Bounding Box angegeben, die die Ecken der Box als Geo-Koordinaten angibt &#8211; siehe hier:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://www.overpass-api.de/api/xapi?node[bbox=8.62,49.85,8.68,49.89][amenity=fast_food|pub][@meta]</div></td></tr></tbody></table></div>
<p>Dabei spezifiziert der Parameter <i>bbox</i> die Lat/Long-Koordinaten in der Reihenfolge <i>links, oben, rechts, unten</i>.</p>
<p>Dazu erstmal zum Verständnis:</p>
<ul>
<li>Der <a href="http://de.wikipedia.org/wiki/Breitengrad">Breitengrad</a> (Latitude) gibt die Nord-Südachse an, &#8220;50&#8243; ist nördlicher als &#8220;49&#8243;</li>
<li>Der <a href="http://de.wikipedia.org/wiki/Geographische_L%C3%A4nge">Längengrad</a> (Longitude) gibt die Ost-Westachse an, &#8220;5&#8243; ist westlicher als &#8220;6&#8243;</li>
</ul>
<h2>Berechnung</h2>
<p>Nun haben wir also den eigenen Standort, wissen über Lat/Long Bescheid und wollen die Eckpunkte für die oben angesprochene Bounding Box errechnen. <a href="http://www.movable-type.co.uk/scripts/latlong-db.html">Aufbauend auf diesem Artikel</a> habe ich folgende PHP-Funktion gebaut:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$lat</span> <span style="color: #339933;">=</span> <span style="color:#800080;">49.869059</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$lon</span> <span style="color: #339933;">=</span> <span style="color:#800080;">8.645318</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$radius</span> <span style="color: #339933;">=</span> <span style="color:#800080;">1.5</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* lat (breitengrad = nord -&gt; sued): 50 ist noerdlicher als 49<br />
&nbsp;* lon (längengrad = west -&gt; ost): 5 ist westlicher als 6 &nbsp;<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> getBoundingBox<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lon</span><span style="color: #339933;">,</span> <span style="color: #000088;">$radius</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$earth_radius</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6371</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$maxLat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lat</span> <span style="color: #339933;">+</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$minLat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lat</span> <span style="color: #339933;">-</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$maxLon</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lon</span> <span style="color: #339933;">+</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #339933;">/</span><a href="http://www.php.net/cos"><span style="color: #990000;">cos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/deg2rad"><span style="color: #990000;">deg2rad</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$minLon</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lon</span> <span style="color: #339933;">-</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #339933;">/</span><a href="http://www.php.net/cos"><span style="color: #990000;">cos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/deg2rad"><span style="color: #990000;">deg2rad</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><br />
&nbsp; &nbsp; <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;center&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$lat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$lon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;nw&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;ne&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sw&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;se&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLon</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$coords</span> <span style="color: #339933;">=</span> getBoundingBox<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lon</span><span style="color: #339933;">,</span> <span style="color: #000088;">$radius</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$coords</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">/*<br />
<br />
Array<br />
(<br />
&nbsp; &nbsp; [center] =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lat] =&gt; 49.869059<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lon] =&gt; 8.645318<br />
&nbsp; &nbsp; &nbsp; &nbsp; )<br />
<br />
&nbsp; &nbsp; [nw] =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lat] =&gt; 49.882548824089<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lon] =&gt; 8.6243885076019<br />
&nbsp; &nbsp; &nbsp; &nbsp; )<br />
<br />
&nbsp; &nbsp; [ne] =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lat] =&gt; 49.882548824089<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lon] =&gt; 8.6662474923981<br />
&nbsp; &nbsp; &nbsp; &nbsp; )<br />
<br />
&nbsp; &nbsp; [sw] =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lat] =&gt; 49.855569175911<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lon] =&gt; 8.6243885076019<br />
&nbsp; &nbsp; &nbsp; &nbsp; )<br />
<br />
&nbsp; &nbsp; [se] =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lat] =&gt; 49.855569175911<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [lon] =&gt; 8.6662474923981<br />
&nbsp; &nbsp; &nbsp; &nbsp; )<br />
<br />
)<br />
*/</span></div></td></tr></tbody></table></div>
<p>Somit haben wir schonmal die Eckpunkte für den Radius 1,5km um unseren Mittelpunkt ausgerechnet. </p>
<h2>Darstellen der Eckpunkte auf einer Google Map</h2>
<p>Zur Verifikation der errechneten Eckpunkte muss Quick&#038;Dirty eine googlemap herhalten (<a href="http://code.google.com/apis/maps/documentation/javascript/examples/marker-simple.html">inspiriert von hier</a>).</p>
<div class="codecolorer-container html4strict dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">link</span></a> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://code.google.com/apis/maps/documentation/javascript/examples/default.css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://maps.googleapis.com/maps/api/js?sensor=false&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
&nbsp; &nbsp; function init() <br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; var markers = [];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;?php</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; foreach <span style="color: #66cc66;">&#40;</span>$coords as $desc <span style="color: #66cc66;">=</span>&gt;</span> $latlong)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; ?&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; markers.push({<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'lat' : <span style="color: #009900;">&lt;?php echo $latlong<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'lat'</span><span style="color: #66cc66;">&#93;</span>; ?&gt;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'lon' : <span style="color: #009900;">&lt;?php echo $latlong<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'lon'</span><span style="color: #66cc66;">&#93;</span>; ?&gt;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'desc' : &quot;<span style="color: #009900;">&lt;?php echo $desc; ?&gt;</span>&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;?php</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; ?&gt;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; var map = new google.maps.Map(document.getElementById(&quot;map_canvas&quot;), {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zoom: 11,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; center: new google.maps.LatLng(<span style="color: #009900;">&lt;?php echo $coords<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'center'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'lat'</span><span style="color: #66cc66;">&#93;</span> . <span style="color: #ff0000;">&quot;,&quot;</span> . $coords<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'center'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'lon'</span><span style="color: #66cc66;">&#93;</span>; ?&gt;</span>),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mapTypeId: google.maps.MapTypeId.ROADMAP<br />
&nbsp; &nbsp; &nbsp; &nbsp; });<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0; i <span style="color: #009900;">&lt; markers.length; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new google.maps.Marker<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position: new google.maps.LatLng<span style="color: #66cc66;">&#40;</span>markers<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.lat, markers<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.lon<span style="color: #66cc66;">&#41;</span>, </span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map: map,</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span>: markers<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.desc</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; </span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></span><br />
<span style="color: #009900;"> &nbsp;</span><br />
<span style="color: #009900;"> &nbsp;window.<span style="color: #000066;">onload</span> <span style="color: #66cc66;">=</span> init;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map_canvas&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<div id="attachment_618" class="wp-caption alignnone" style="width: 614px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/10/radius.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/10/radius.png" alt="radius" title="radius" width="604" height="586" class="size-full wp-image-618" /></a><p class="wp-caption-text">radius</p></div>
<p>Sieht doch gut aus. Somit haben wir unsere Bounding Box Koordinaten auch visuell dargestellt und können die OSM API damit füttern.</p>
<p>Und hier nochmal der komplette Code:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$lat</span> <span style="color: #339933;">=</span> <span style="color:#800080;">49.869059</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$lon</span> <span style="color: #339933;">=</span> <span style="color:#800080;">8.645318</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$radius</span> <span style="color: #339933;">=</span> <span style="color:#800080;">1.5</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* lat (breitengrad = nord -&gt; sued): 50 ist noerdlicher als 49<br />
&nbsp;* lon (längengrad = west -&gt; ost): 5 ist westlicher als 6 &nbsp;<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> getBoundingBox<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lon</span><span style="color: #339933;">,</span> <span style="color: #000088;">$radius</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$earth_radius</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6371</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$maxLat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lat</span> <span style="color: #339933;">+</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$minLat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lat</span> <span style="color: #339933;">-</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$maxLon</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lon</span> <span style="color: #339933;">+</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #339933;">/</span><a href="http://www.php.net/cos"><span style="color: #990000;">cos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/deg2rad"><span style="color: #990000;">deg2rad</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$minLon</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lon</span> <span style="color: #339933;">-</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">/</span><span style="color: #000088;">$earth_radius</span><span style="color: #339933;">/</span><a href="http://www.php.net/cos"><span style="color: #990000;">cos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/deg2rad"><span style="color: #990000;">deg2rad</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><br />
&nbsp; &nbsp; <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;center&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$lat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$lon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;nw&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;ne&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sw&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;se&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$minLat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lon&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$maxLon</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$coords</span> <span style="color: #339933;">=</span> getBoundingBox<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lon</span><span style="color: #339933;">,</span> <span style="color: #000088;">$radius</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.google.com/apis/maps/documentation/javascript/examples/default.css&quot; /&gt;<br />
&lt;script src=&quot;http://maps.googleapis.com/maps/api/js?sensor=false&quot;&gt;&lt;/script&gt;<br />
&lt;script&gt;<br />
&nbsp; &nbsp; function init() <br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; var markers = [];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$coords</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$desc</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$latlong</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; markers.push({<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'lat' : <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$latlong</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lat'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'lon' : <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$latlong</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lon'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'desc' : &quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$desc</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; var map = new google.maps.Map(document.getElementById(&quot;map_canvas&quot;), {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zoom: 11,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; center: new google.maps.LatLng(<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$coords</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'center'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lat'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$coords</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'center'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lon'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mapTypeId: google.maps.MapTypeId.ROADMAP<br />
&nbsp; &nbsp; &nbsp; &nbsp; });<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0; i &lt; markers.length; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new google.maps.Marker({<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position: new google.maps.LatLng(markers[i].lat, markers[i].lon), <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map: map,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title: markers[i].desc<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; <br />
&nbsp; window.onload = init;<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&nbsp; &nbsp; &lt;div id=&quot;map_canvas&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div></td></tr></tbody></table></div>
</p>
<p><strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/javascript-error-handling/" rel="bookmark" title="21. Oktober 2010">Javascript Error-Handling</a></li>
<li><a href="http://www.d-mueller.de/blog/javascript-selbstausfuehrende-anonyme-funktionen/" rel="bookmark" title="19. Februar 2011">Javascript: selbstausführende, anonyme Funktionen</a></li>
<li><a href="http://www.d-mueller.de/blog/reflection-teil-3-reflectionparameter/" rel="bookmark" title="21. November 2010">Reflection – Teil 3: ReflectionParameter</a></li>
<li><a href="http://www.d-mueller.de/blog/aenderungen-einer-form-ueberwachen/" rel="bookmark" title="20. Februar 2011">Änderungen einer Form überwachen</a></li>
<li><a href="http://www.d-mueller.de/blog/usort/" rel="bookmark" title="22. November 2010">usort</a></li>
</ul>
<p><!-- Similar Posts took 14.914 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/Q5bNqb9gh1U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/</feedburner:origLink></item>
		<item>
		<title>Open Streetmap API Tutorial: Umkreissuche</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/zoaOodytwPM/</link>
		<comments>http://www.d-mueller.de/blog/open-streetmap-api-tutorial-umkreissuche/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 16:51:17 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=616</guid>
		<description><![CDATA[Für ein Hochschulprojekt (&#8220;Ortsbezogene Freizeitgestaltung&#8221;) gilt es, die Open Streetmap API zum finden von POI&#8217;s in der Umgebung zu verwenden. In Darmstadt ist auf der OSM fast jede Parkbank kategorisiert. Also frisch ans Werk! API Overflow! &#8211; Kurzvorstellung der einzelnen &#8230; <a href="http://www.d-mueller.de/blog/open-streetmap-api-tutorial-umkreissuche/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Für ein Hochschulprojekt (&#8220;Ortsbezogene Freizeitgestaltung&#8221;) gilt es, die Open Streetmap API zum finden von POI&#8217;s in der Umgebung zu verwenden. In Darmstadt ist auf der OSM <a href="http://www.openstreetmap.org/?minlon=8.64117740631&#038;minlat=49.8627722168&#038;maxlon=8.66117835999&#038;maxlat=49.8827760315">fast jede Parkbank</a> kategorisiert. Also frisch ans Werk!</p>
<h2>API Overflow! &#8211; Kurzvorstellung der einzelnen APIs</h2>
<ul>
<li>Die <a href="http://wiki.openstreetmap.org/wiki/API_v0.6">eigentliche OSM-Api (aktuell: v0.6)</a> fokussiert sich eher auf das Erstellen, Bearbeiten und Auslesen von speziellen Punkten. Weniger hilfreich für den Zweck der Umkreissuche.</li>
<li>Die <a href="http://wiki.openstreetmap.org/wiki/Overpass_API">Overpass (X)API</a> macht uns schon glücklicher. Per REST geben wir den Typ der zu suchenden Punkte in einem einzugrenzenden Bereich an. Beispiele folgen.</li>
<li>Die <a href="http://wiki.openstreetmap.org/wiki/Nominatim">Nominatim API</a> ist am simpelsten zu verwenden: Einfach als Query-Parameter &#8220;Pub, Darmstadt&#8221; angehangen und los gehts. Auch dazu gleich mehr.</li>
</ul>
<h2>Die Noninatim API</h2>
<p>Alle Cafes in Darmstadt gesucht?</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://nominatim.openstreetmap.org/search?q=cafe+darmstadt&amp;format=xml&amp;polygon=0&amp;addressdetails=1</div></td></tr></tbody></table></div>
<div class="codecolorer-container xml dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;searchresults</span> <span style="color: #000066;">timestamp</span>=<span style="color: #ff0000;">&quot;Mon, 17 Oct 11 12:20:28 -0400&quot;</span> <span style="color: #000066;">attribution</span>=<span style="color: #ff0000;">&quot;Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.&quot;</span> <span style="color: #000066;">querystring</span>=<span style="color: #ff0000;">&quot;cafe darmstadt&quot;</span> <span style="color: #000066;">polygon</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">exclude_place_ids</span>=<span style="color: #ff0000;">&quot;6854404,1531978,7020825,8296635,12289661,4985586,7174479,5407915,4156862,1062456&quot;</span> <span style="color: #000066;">more_url</span>=<span style="color: #ff0000;">&quot;http://open.mapquestapi.com/nominatim/v1/search?format=xml&amp;exclude_place_ids=6854404,1531978,7020825,8296635,12289661,4985586,7174479,5407915,4156862,1062456&amp;accept-language=de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4&amp;addressdetails=1&amp;q=cafe+darmstadt&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;place</span> <span style="color: #000066;">place_id</span>=<span style="color: #ff0000;">&quot;6854404&quot;</span> <span style="color: #000066;">osm_type</span>=<span style="color: #ff0000;">&quot;node&quot;</span> <span style="color: #000066;">osm_id</span>=<span style="color: #ff0000;">&quot;634426402&quot;</span> <span style="color: #000066;">place_rank</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #000066;">boundingbox</span>=<span style="color: #ff0000;">&quot;50.0020887756,50.0220925903,8.57511543274,8.59511638641&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;50.0120924&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.5851157&quot;</span> <span style="color: #000066;">display_name</span>=<span style="color: #ff0000;">&quot;cafe, Aschaffenburger Straße, Walldorf, Mörfelden-Walldorf, Groß-Gerau, Regierungsbezirk Darmstadt, Hessen, 64546, Bundesrepublik Deutschland (Landmasse)&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cafe&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;http://open.mapquestapi.com/nominatim/v1/images/mapicons/food_cafe.p.20.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cafe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cafe<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cafe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Aschaffenburger Straße<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Walldorf<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Mörfelden-Walldorf<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Groß-Gerau<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Regierungsbezirk Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hessen<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>64546<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Bundesrepublik Deutschland (Landmasse)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>de<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/place<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;place</span> <span style="color: #000066;">place_id</span>=<span style="color: #ff0000;">&quot;1531978&quot;</span> <span style="color: #000066;">osm_type</span>=<span style="color: #ff0000;">&quot;node&quot;</span> <span style="color: #000066;">osm_id</span>=<span style="color: #ff0000;">&quot;307367574&quot;</span> <span style="color: #000066;">place_rank</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #000066;">boundingbox</span>=<span style="color: #ff0000;">&quot;49.8644659424,49.8844697571,8.65217708588,8.67217803955&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8744697&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.6621778&quot;</span> <span style="color: #000066;">display_name</span>=<span style="color: #ff0000;">&quot;Pueblo, 5-7, Erbacher Straße, Mathildenhöhe, Darmstadt, Darmstadt, Stadt, Regierungsbezirk Darmstadt, Hessen, 64283, Bundesrepublik Deutschland (Landmasse)&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;pub&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;http://open.mapquestapi.com/nominatim/v1/images/mapicons/food_pub.p.20.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pub<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Pueblo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pub<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;house_number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>5-7<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/house_number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Erbacher Straße<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Mathildenhöhe<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Darmstadt, Stadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Regierungsbezirk Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hessen<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;postcode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>64283<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/postcode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>64287<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Bundesrepublik Deutschland (Landmasse)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>de<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/place<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; ...<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/searchresults<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Auf der <a href="http://wiki.openstreetmap.org/wiki/Nominatim">Wiki-Seite zu Nominatim</a> finden sich alle Parameter.</p>
<p><b>Noch ein Beispiel:</b> Wir suchen alle Cafes und Pubs <a href="http://de.wikipedia.org/wiki/Geographische_Breite">im Bereich</a> 8.62 , 49.85 , 8.68 , 49.89 (Parameter <i>viewbox</i> =  left,top,right,bottom)</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://nominatim.openstreetmap.org/search?viewbox=8.62,49.85,8.68,49.89&amp;bounded=1&amp;format=xml&amp;polygon=0&amp;addressdetails=1&amp;q=[cafe][,pub]</div></td></tr></tbody></table></div>
<div class="codecolorer-container xml dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;searchresults</span> <span style="color: #000066;">timestamp</span>=<span style="color: #ff0000;">&quot;Mon, 17 Oct 11 12:28:03 -0400&quot;</span> <span style="color: #000066;">attribution</span>=<span style="color: #ff0000;">&quot;Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.&quot;</span> <span style="color: #000066;">querystring</span>=<span style="color: #ff0000;">&quot; [,pub]&quot;</span> <span style="color: #000066;">polygon</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">exclude_place_ids</span>=<span style="color: #ff0000;">&quot;8064325,1531978,1542766,7020825,1562941,5484206,8296635,3710437,4985586,1545901&quot;</span> <span style="color: #000066;">more_url</span>=<span style="color: #ff0000;">&quot;http://open.mapquestapi.com/nominatim/v1/search?format=xml&amp;exclude_place_ids=8064325,1531978,1542766,7020825,1562941,5484206,8296635,3710437,4985586,1545901&amp;accept-language=de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4&amp;addressdetails=1&amp;viewbox=8.62%2C49.85%2C8.68%2C49.89&amp;q=+%5B%2Cpub%5D&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;place</span> <span style="color: #000066;">place_id</span>=<span style="color: #ff0000;">&quot;8064325&quot;</span> <span style="color: #000066;">osm_type</span>=<span style="color: #ff0000;">&quot;node&quot;</span> <span style="color: #000066;">osm_id</span>=<span style="color: #ff0000;">&quot;769080882&quot;</span> <span style="color: #000066;">place_rank</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #000066;">boundingbox</span>=<span style="color: #ff0000;">&quot;49.8722135925,49.8922174072,8.64747070313,8.6674716568&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8822173&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.6574715&quot;</span> <span style="color: #000066;">display_name</span>=<span style="color: #ff0000;">&quot;Weinstube Osttangente, Arheilger Straße, Martinsviertel-West, Darmstadt, Stadt, Regierungsbezirk Darmstadt, Hessen, 64289, Bundesrepublik Deutschland (Landmasse)&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;pub&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;http://open.mapquestapi.com/nominatim/v1/images/mapicons/food_pub.p.20.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pub<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Weinstube Osttangente<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pub<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Arheilger Straße<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Martinsviertel-West<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;place<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Martinsviertel-West<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/place<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Darmstadt, Stadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Regierungsbezirk Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hessen<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>64289<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Bundesrepublik Deutschland (Landmasse)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>de<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/place<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;place</span> <span style="color: #000066;">place_id</span>=<span style="color: #ff0000;">&quot;1542766&quot;</span> <span style="color: #000066;">osm_type</span>=<span style="color: #ff0000;">&quot;node&quot;</span> <span style="color: #000066;">osm_id</span>=<span style="color: #ff0000;">&quot;310264485&quot;</span> <span style="color: #000066;">place_rank</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #000066;">boundingbox</span>=<span style="color: #ff0000;">&quot;49.864874115,49.8848779297,8.64108585358,8.66108680725&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8748742&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.6510865&quot;</span> <span style="color: #000066;">display_name</span>=<span style="color: #ff0000;">&quot;Cafe Espenschied, Mathildenplatz, Stadtzentrum, Darmstadt, Darmstadt, Stadt, Regierungsbezirk Darmstadt, Hessen, 64283, Bundesrepublik Deutschland (Landmasse)&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cafe&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;http://open.mapquestapi.com/nominatim/v1/images/mapicons/food_cafe.p.20.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cafe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cafe Espenschied<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cafe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Mathildenplatz<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Stadtzentrum<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Darmstadt, Stadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Regierungsbezirk Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hessen<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>64283<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Bundesrepublik Deutschland (Landmasse)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>de<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/place<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; ...<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/searchresults<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Diese Anfrage hat den Vorteil, dass wir nicht den Ortsnamen kennen müssen, sondern einfach die Koordinaten reinstecken können.</p>
<p>Ähnlich zur <a href="http://www.d-mueller.de/blog/yahoo-placefinder-api-tutorial/">hier vorgestellten Yahoo Placefinder API</a> lassen sich mit Nominatim auch noch Geo-Lookups betreiben:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://nominatim.openstreetmap.org/reverse?format=xml&amp;lat=49.869074&amp;lon=8.645331&amp;zoom=18&amp;addressdetails=1</div></td></tr></tbody></table></div>
<div class="codecolorer-container xml dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reversegeocode</span> <span style="color: #000066;">timestamp</span>=<span style="color: #ff0000;">&quot;Mon, 17 Oct 11 12:32:36 -0400&quot;</span> <span style="color: #000066;">attribution</span>=<span style="color: #ff0000;">&quot;Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.&quot;</span> <span style="color: #000066;">querystring</span>=<span style="color: #ff0000;">&quot;format=xml&amp;lat=49.869074&amp;lon=8.645331&amp;zoom=18&amp;addressdetails=1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;result</span> <span style="color: #000066;">place_id</span>=<span style="color: #ff0000;">&quot;53116836&quot;</span> <span style="color: #000066;">osm_type</span>=<span style="color: #ff0000;">&quot;way&quot;</span> <span style="color: #000066;">osm_id</span>=<span style="color: #ff0000;">&quot;54818914&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8689123945855&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.64516022575963&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; Studentenwohnheim Neckarstraße, Elisabethenstraße, Rheintor/Grafenstraße, Darmstadt, Darmstadt, Stadt, Regierungsbezirk Darmstadt, Hessen, 64283, Bundesrepublik Deutschland (Landmasse)<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/result<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;addressparts<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;building<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Studentenwohnheim Neckarstraße<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/building<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Elisabethenstraße<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/road<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Rheintor/Grafenstraße<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/suburb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/city<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Darmstadt, Stadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/county<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Regierungsbezirk Darmstadt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state_district<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hessen<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>64283<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/boundary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Bundesrepublik Deutschland (Landmasse)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>de<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/country_code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/addressparts<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reversegeocode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
</p>
<h2>Overpass (X)API</h2>
<p>Noch etwas feingranular können wir unsere Anfrage mit der <a href="http://wiki.openstreetmap.org/wiki/Overpass_API#XAPI_Compability_Layer">Overpass (X)API</a> gestalten, die ebenfalls per REST zu befeuern ist (siehe ergänzend auch die Doku <a href="http://wiki.openstreetmap.org/wiki/XAPI">zur XAPI</a>).</p>
<p>Wir wollen alle Pubs und Fast-Food-Lokale in der Box 8.62 , 49.85 , 8.68 , 49.89 haben? Kein Problem!</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://www.overpass-api.de/api/xapi?node[bbox=8.62,49.85,8.68,49.89][amenity=fast_food|pub][@meta]</div></td></tr></tbody></table></div>
<div class="codecolorer-container xml dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;osm</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.6&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;Overpass API&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;note<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>The data included in this document is from www.openstreetmap.org. It has there been collected by a large group of contributors. For individual attribution of each item please refer to http://www.openstreetmap.org/api/0.6/[node|way|relation]/#id/history <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/note<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">osm_base</span>=<span style="color: #ff0000;">&quot;2011-10-17T16\:36\:02Z&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;24924135&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8800621&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.6453454&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;11&quot;</span> <span style="color: #000066;">timestamp</span>=<span style="color: #ff0000;">&quot;2011-06-13T19:02:36Z&quot;</span> <span style="color: #000066;">changeset</span>=<span style="color: #ff0000;">&quot;8424331&quot;</span> <span style="color: #000066;">uid</span>=<span style="color: #ff0000;">&quot;290680&quot;</span> <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;wheelmap_visitor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:city&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Darmstadt&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:housenumber&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;41&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:postcode&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;64293&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:street&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Kahlertstraße&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;pub&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Kneipe 41&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;note&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;DaLUG Meeting (4st Friday of month 19:30)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;smoking&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;http://www.kneipe41.de/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;wheelchair&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;limited&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/node<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;203582455&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8716253&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.6393520&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">timestamp</span>=<span style="color: #ff0000;">&quot;2011-06-13T19:04:38Z&quot;</span> <span style="color: #000066;">changeset</span>=<span style="color: #ff0000;">&quot;8424331&quot;</span> <span style="color: #000066;">uid</span>=<span style="color: #ff0000;">&quot;290680&quot;</span> <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;wheelmap_visitor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:city&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Darmstadt&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:country&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;DE&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:housenumber&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;69&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:postcode&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;64295&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:street&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Rheinstraße&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;fast_food&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;cuisine&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;burger&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;McDonald's&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;http://www.mcdonalds.com/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;wheelchair&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/node<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; ...<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/osm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>
Dabei gibt es offensichtlich noch sehr informative Nebenangaben über die Rollstuhltauglichkeit und allerlei anderer Sachen. Für eine vollständige Angabe aller suchbaren Einrichtungen (&#8220;Amenity&#8221;) sei <a href="http://wiki.openstreetmap.org/wiki/Key:amenity">hierauf</a> verwiesen: Vom <a href="http://wiki.openstreetmap.org/wiki/Tag:amenity%3Dcinema">Kino</a> über den <a href="http://wiki.openstreetmap.org/wiki/Tag:amenity%3Dwaste_basket">Mülleimer</a> gibts alles, was das Herz begehrt. Auch auf die <a href="http://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases/DE">Spezialphrasen</a> sei noch verwiesen.
</p>
<h2>Die native API</h2>
<p>Da wir keine Plätze anlegen möchten, sondern nur Daten von OSM beziehen wollen, bietet die native OSM API nur ein nützliches Feature für uns: <a href="http://wiki.openstreetmap.org/wiki/API_v0.6#Multi_fetch:_GET_.2Fapi.2F0.6.2F.5Bnodes.7Cways.7Crelations.5D">Die Location-Suche nach ID</a>. Wenn wir also zu einer oder mehreren Platz-IDs (wie sie bspw. von der Overpass API bzw. Nominatim in der Antwort geliefert werden) nähere Informationen erhalten möchten, kann folgende Query hilfreich sein:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://api.openstreetmap.org/api/0.6/nodes?nodes=307367745,24924135</div></td></tr></tbody></table></div>
<div class="codecolorer-container xml dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;osm</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.6&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;OpenStreetMap server&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;24924135&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8800621&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.6453454&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;11&quot;</span> <span style="color: #000066;">changeset</span>=<span style="color: #ff0000;">&quot;8424331&quot;</span> <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;wheelmap_visitor&quot;</span> <span style="color: #000066;">uid</span>=<span style="color: #ff0000;">&quot;290680&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">timestamp</span>=<span style="color: #ff0000;">&quot;2011-06-13T19:02:36Z&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Kneipe 41&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;wheelchair&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;limited&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:postcode&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;64293&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:housenumber&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;41&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:city&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Darmstadt&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;smoking&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:street&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Kahlertstraße&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;pub&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;http://www.kneipe41.de/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;note&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;DaLUG Meeting (4st Friday of month 19:30)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/node<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;307367745&quot;</span> <span style="color: #000066;">lat</span>=<span style="color: #ff0000;">&quot;49.8702344&quot;</span> <span style="color: #000066;">lon</span>=<span style="color: #ff0000;">&quot;8.6507902&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;7&quot;</span> <span style="color: #000066;">changeset</span>=<span style="color: #ff0000;">&quot;6121669&quot;</span> <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;wheelmap_visitor&quot;</span> <span style="color: #000066;">uid</span>=<span style="color: #ff0000;">&quot;290680&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">timestamp</span>=<span style="color: #ff0000;">&quot;2010-10-21T07:33:35Z&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Subway&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;wheelchair&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:postcode&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;64283&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:housenumber&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;21&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:city&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Darmstadt&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:street&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;Elisabethenstraße&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;amenity&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;fast_food&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;addr:country&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;DE&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;http://www.subway.com/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">k</span>=<span style="color: #ff0000;">&quot;cuisine&quot;</span> <span style="color: #000066;">v</span>=<span style="color: #ff0000;">&quot;sandwich&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/node<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/osm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<h2>Das war&#8217;s vorerst</h2>
<p>Wenn ich im Verlaufe des Projekts noch bahnbrechende, neue Erkenntnisse über die OSM API erlangen sollte, gibt es einen Follow-Up Post. So far.</p>
<p><b>Update:</b> Artikel zur Transformierung von Längenangaben in Geo-Koordinaten ist fertig &#8211; <a href="http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/">Umkreissuche: Lat/Long und der Radius</a>.</p>
<p><strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/yahoo-placefinder-api-tutorial/" rel="bookmark" title="23. November 2010">Yahoo Placefinder-API Tutorial</a></li>
<li><a href="http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/" rel="bookmark" title="17. Oktober 2011">Umkreissuche: Lat/Long und der Radius</a></li>
<li><a href="http://www.d-mueller.de/blog/facebook-api-tutorial/" rel="bookmark" title="30. November 2010">Facebook API &#8211; Tutorial</a></li>
<li><a href="http://www.d-mueller.de/blog/best-of-the-web-2/" rel="bookmark" title="8. Dezember 2010">Best-of-the-Web 2</a></li>
<li><a href="http://www.d-mueller.de/blog/best-of-the-web-8/" rel="bookmark" title="2. April 2011">Best-of-the-Web 8</a></li>
</ul>
<p><!-- Similar Posts took 18.425 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/zoaOodytwPM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/open-streetmap-api-tutorial-umkreissuche/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/open-streetmap-api-tutorial-umkreissuche/</feedburner:origLink></item>
		<item>
		<title>Javascript String Replace ohne Regex</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/J905nHEPt1U/</link>
		<comments>http://www.d-mueller.de/blog/javascript-string-replace-ohne-regex/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 16:07:04 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Quicktips]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=615</guid>
		<description><![CDATA[Wer eine einfache Variante zum String Replacement benötigt, kann entweder den Regex-Weg gehen (siehe Nachbildung der PHP-Funktion str_replace), oder einen schnuckeligen Trick anwenden: 1alert&#40;&#34;Finde mich&#34;.split&#40;&#34;Finde&#34;&#41;.join&#40;&#34;Replace&#34;&#41;&#41;; Den String zum Array am Suchwort zerlegen und dann mit dem Ersatz das Array wieder &#8230; <a href="http://www.d-mueller.de/blog/javascript-string-replace-ohne-regex/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wer eine einfache Variante zum String Replacement benötigt, kann entweder den <a href="http://de.selfhtml.org/javascript/objekte/string.htm#replace">Regex-Weg</a> gehen (siehe <a href="http://phpjs.org/functions/str_replace">Nachbildung der PHP-Funktion str_replace</a>), oder einen schnuckeligen Trick anwenden:</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Finde mich&quot;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Finde&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Replace&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Den String zum Array am Suchwort zerlegen und dann mit dem Ersatz das Array wieder zusammenfügen. Brauchte letztens eine Quick&#038;Dirty-Lösung, um Zahlen des Formats</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">600.000,54</div></td></tr></tbody></table></div>
<p>in das Javascript geläufige Zahlenformat</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">600000.54</div></td></tr></tbody></table></div>
<p>zu überführen, also Dezimalpunkte raus und Komma durch Punkt ersetzen. Gemacht habe ich es so:</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> num <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;600.000,54&quot;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Gewinnt sicher keinen Schönheitspreis, die innovative Verwendung von join und split gefielen mir dann aber doch zu gut ;).<strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/needle-haystack-uebersicht/" rel="bookmark" title="19. Januar 2011">Needle/Haystack Übersicht</a></li>
<li><a href="http://www.d-mueller.de/blog/rechenungenauigkeit-mit-javascript-warum/" rel="bookmark" title="14. Januar 2011">Rechenungenauigkeit mit Javascript &#8211; Warum?</a></li>
<li><a href="http://www.d-mueller.de/blog/yahoo-placefinder-api-tutorial/" rel="bookmark" title="23. November 2010">Yahoo Placefinder-API Tutorial</a></li>
<li><a href="http://www.d-mueller.de/blog/mysql-views/" rel="bookmark" title="20. November 2010">MySQL Views</a></li>
<li><a href="http://www.d-mueller.de/blog/systemaufrufe-linux-windows-ruckgabewerte-und-der-errorstream/" rel="bookmark" title="21. Februar 2011">Systemaufrufe, Linux, Windows, Rückgabewerte und der Errorstream</a></li>
</ul>
<p><!-- Similar Posts took 12.292 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/J905nHEPt1U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/javascript-string-replace-ohne-regex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/javascript-string-replace-ohne-regex/</feedburner:origLink></item>
		<item>
		<title>Appentwicklung mit Webtechniken – Appcelerator Titanium</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/HPNxHE_G60A/</link>
		<comments>http://www.d-mueller.de/blog/appentwicklung-webtechniken-mit-appcelerator-titanium/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 20:18:34 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=593</guid>
		<description><![CDATA[Apps sind zur Zeit in aller Munde. Bekanntlich gibt es mit Android und iOS mal mindestens 2 ernst zu nehmende Plattformen, auf denen man in der Regel vertreten sein möchte. Heißt: Zwei mal dasselbe programmieren, einmal in Java und einmal &#8230; <a href="http://www.d-mueller.de/blog/appentwicklung-webtechniken-mit-appcelerator-titanium/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Apps sind zur Zeit in aller Munde. Bekanntlich gibt es mit Android und iOS mal mindestens 2 ernst zu nehmende Plattformen, auf denen man in der Regel vertreten sein möchte. Heißt: Zwei mal dasselbe programmieren, einmal in Java und einmal in Objective C. Das muss nicht sein. Mit dem Cross Platform Framework <a href="http://www.appcelerator.com/">Appcelerator Titanium</a> wird die Entwicklung in Javascript vorgenommen &#8211; nebst Zugriff auf die Gerät-APIs wie Kamera, Beschleunigungsmesser, GPS und allem Klimbim. Nur am Rande: Titanium ist <b>k</b>ein kleines Nebenprojekt eines gelangweilten Studenten. Ein paar Millionen Apps sind damit schon erstellt worden, u.a. auch das fies gehypte Wunderlist.</p>
<p>Das, was am Ende dabei rauskommt ist eine vollwertige, native App welche selbst in Apples App-Store Bestand hat. Soweit, wie ich das verstanden haben, wird der von euch geschriebene Javascript-Code im Beispielfalle Android von Titanium in natives Java verwandelt. Ergebnis ist eine verhältnismäßig performante App, gegen die ein <a href="http://www.phonegap.com/">Browser ohne UI</a> wie beispielsweise Phonegap abstinkt.</p>
<p>Da die Installation von Titanium allerdings recht komplex ist und man viel falsch machen kann, möchte ich das hier mal Step-by-Step durchziehen. Nicht zuletzt, um es für mich in Stein zu meißeln.</p>
<h2>Schritt 1: Java deinstallieren</h2>
<p>Titanium ist pingelig. Nach <a href="http://wiki.appcelerator.org/display/guides/Titanium+Compatibility+Matrix">Kompatibilitäts-Matrix</a> muss sich das JDK 1.6 auf dem Rechner befinden. Das Java Runtime Environment (JRE), was die meisten durch Netbeans / Eclipse sowieso schon auf der Kiste haben werden, reicht nicht. Auch neuere Versionen als 1.6 verschmäht Titanium. Wenn ihr nun nicht grade das JDK 1.6 inklusive JRE auf dem Rechner haben solltet: Runter damit.</p>
<div id="attachment_594" class="wp-caption alignnone" style="width: 513px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/1-jre-uninstall.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/1-jre-uninstall.png" alt="Java weghauen" title="Java weghauen" width="503" height="388" class="size-full wp-image-594" /></a><p class="wp-caption-text">Java weghauen</p></div>
<h2>Schritt 2: JDK 1.6 installieren</h2>
<p><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Downloadlink zum JDK bei Oracle</a>. Die Java DB könnt ihr euch schenken, der Rest muss drauf. Verzeichnis ist dabei egal.</p>
<div id="attachment_595" class="wp-caption alignnone" style="width: 519px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/2-jdk+jre-install.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/2-jdk+jre-install.png" alt="JDK installieren" title="JDK installieren" width="509" height="392" class="size-full wp-image-595" /></a><p class="wp-caption-text">JDK installieren</p></div>
<p>Direkt danach wird das JRE noch draufgemacht.</p>
<div id="attachment_596" class="wp-caption alignnone" style="width: 516px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/2-jre-install.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/2-jre-install.png" alt="JRE draufmachen" title="JRE draufmachen" width="506" height="388" class="size-full wp-image-596" /></a><p class="wp-caption-text">JRE draufmachen</p></div>
<h2>Schritt 3: Java zum PATH hinzufügen</h2>
<p><a href="http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx">So gehts</a>. Pfad zu eurem <i>\bin</i> &#8211; Folder des JDK mit ; an den PATH anfügen.</p>
<div id="attachment_597" class="wp-caption alignnone" style="width: 414px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/4-jdk-javac-path.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/4-jdk-javac-path.png" alt="Java PATH" title="Java PATH" width="404" height="491" class="size-full wp-image-597" /></a><p class="wp-caption-text">Java PATH</p></div>
<h2>Schritt 4: Java prüfen</h2>
<p>Konsole aufmachen.</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">java -version &amp;&amp; javac -version</div></td></tr></tbody></table></div>
<div id="attachment_598" class="wp-caption alignnone" style="width: 557px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/5-java-version-check.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/5-java-version-check.png" alt="Java Version Check" title="Java Version Check" width="547" height="158" class="size-full wp-image-598" /></a><p class="wp-caption-text">Java Version Check</p></div>
<p>Sowohl java, wie auch javac (Java Compiler) müssen in der gleichen Version 1.6X vorliegen.</p>
<h2>Schritt 5: Android SDK installieren</h2>
<p><a href="http://developer.android.com/sdk/index.html">Download hier</a>. Es könnte nun passieren, dass euch das Android SDK beim installieren trotz korrekt eingerichtetem Java folgendes erzählen möchte:</p>
<div id="attachment_599" class="wp-caption alignnone" style="width: 520px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/6-jdk-not-found.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/6-jdk-not-found.png" alt="Android SDK: Java not found" title="Android SDK: Java not found" width="510" height="393" class="size-full wp-image-599" /></a><p class="wp-caption-text">Android SDK: Java not found</p></div>
<p>Ich hab verdutzt 3mal Java neu draufgemacht, eh mich <a href="http://stackoverflow.com/questions/4382178/android-sdk-installation-doesnt-find-jdk">stackoverflow erleuchtete</a>: </p>
<blockquote><p>
Press Back when you get the notification and then Next. This time it will find the JDK.</p>
<p>(I don&#8217;t know why, but it works on Windows 7 x64.)
</p></blockquote>
<p>Also zurück, wieder vor und siehe da:</p>
<div id="attachment_600" class="wp-caption alignnone" style="width: 524px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/7-jdk-found.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/7-jdk-found.png" alt="Android SDK: Also doch..." title="Android SDK: Also doch..." width="514" height="396" class="size-full wp-image-600" /></a><p class="wp-caption-text">Android SDK: Also doch...</p></div>
<p><b>Wichtig:</b> Das Android SDK unbedingt an einen Ort installieren, der keine Leerzeichen im Pfad hat. Am Besten C:\Android. Das Titanium Manual sagt dazu:</p>
<blockquote><p>
Be aware that there is a bug in Revision 12 of the Android SDK Tools package for Windows that prevents applications from being launched if spaces exist in the filesystem path to the Android SDK (ie C:\Program Files (x86)\Android
</p></blockquote>
<p>Allerdings scheint sich das Problem nach meinen Erkenntnissen nicht nur auf die API Version 12 zu beziehen, sondern Titanium generell so sehr zu verwirren, dass das Android SDK nicht mehr gefunden werden kann. Also einfach auf <i>C:\</i> gekloppt. Wenn ihrs doch schon wo anders hin installiert habt, kann mans auch einfach umkopieren. Scheint portabel zu sein.</p>
<h2>Schritt 6: Die richtige API Auswahl</h2>
<p>Nun werdet ihr mit allen API-Versionen konfrontiert, die es so im Android Ökosystem gibt. Sieh hierzu: <a href="http://www.golem.de/1109/86225.html">Verbreitung der Android Versionen (Stand: 5.9.2011)</a>. Hier lieber zu viel als zu wenig auswählen. Ich habe mich für folgende Konfiguration entschieden:</p>
<div id="attachment_601" class="wp-caption alignnone" style="width: 245px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/8-android-sdk-install.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/8-android-sdk-install-235x300.png" alt="API Auswahl" title="API Auswahl" width="235" height="300" class="size-medium wp-image-601" /></a><p class="wp-caption-text">API Auswahl</p></div>
<p><b>Wichtig:</b> Unbedingt die API Version 7 (Android 2.1) auswählen, sonst mag Titanium das SDK später nicht finden. Die Samples können getrost ignoriert werden, wir wollen ja nicht mit Java sondern mit Titanium entwickeln. Ob ihr Android 3.X mit dabei haben wollt (aktuell noch kaum verbreitet, eher für Tablets geschaffen) bleibt euch überlassen. Nachinstallieren ist übrigens jederzeit möglich.</p>
<p>Die Google API-Versionen scheinen die normalen API&#8217;s mit ein paar Erweiterungen für die Google Dienste &#8211; aka maps und Konsorten &#8211; zu sein. Kann also nicht schaden, die auch noch mit zu installieren.</p>
<p>Der Spaß kann jetzt eine ganze Weile dauern.<br />
<div id="attachment_602" class="wp-caption alignnone" style="width: 581px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/10-android-sdk-installed.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/10-android-sdk-installed.png" alt="Geschafft!" title="Geschafft!" width="571" height="574" class="size-full wp-image-602" /></a><p class="wp-caption-text">Geschafft!</p></div>
</p>
<h2>Schritt 7: Umgebungsvariablen fürs Android SDK</h2>
<p>Zum Path hinzuzufügen:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Android\android-sdk\platform-tools;C:\Android\android-sdk\tools</div></td></tr></tbody></table></div>
<p>Sowie unter der neu zu erstellenden Variablen <b>ANDROID_SDK</b>:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Android\android-sdk\</div></td></tr></tbody></table></div>
<div id="attachment_603" class="wp-caption alignnone" style="width: 370px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/15-PATH-android-sdk.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/15-PATH-android-sdk.png" alt="Android SDK Umgebungsvariable" title="Android SDK Umgebungsvariable" width="360" height="154" class="size-full wp-image-603" /></a><p class="wp-caption-text">Android SDK Umgebungsvariable</p></div>
<h2>Schritt 8: Ausprobieren</h2>
<p>Jetzt testen wir, ob adb (android debug bridge) das Handy findet. Dazu muss euer Android Handy erstmal entsprechend konfiguriert werden. Dazu klaue ich frei <a href="http://developer.android.com/guide/developing/device.html">von hier</a>:</p>
<blockquote>
<ol>
<li>Set up your device to allow installation of non-Market applications. On the device, go to Settings > Applications and enable Unknown sources.</li>
<li>Turn on &#8220;USB Debugging&#8221; on your device. On the device, go to Settings > Applications > Development and enable USB debugging.</li>
</blockquote>
<p>Nun testen wir das. Konsole auf, und <i>adb devices</i> eingeben. ADB wird von Titanium genutzt und sollte direkt gefunden werden, da es sich unter <i>C:\Android\android-sdk\platform-tools</i> und damit ja im PATH befindet.</p>
<p><b>Ohne angeschlossenes Handy:</b></p>
<div id="attachment_604" class="wp-caption alignnone" style="width: 315px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/11-adb-devices.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/11-adb-devices.png" alt="ADB Devides ohne Handy" title="ADB Devides ohne Handy" width="305" height="114" class="size-full wp-image-604" /></a><p class="wp-caption-text">ADB Devices ohne Handy</p></div>
<p><b>Mit angeschlossenem Handy:</b></p>
<div id="attachment_605" class="wp-caption alignnone" style="width: 310px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/11.5-adb-devices.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/11.5-adb-devices-300x64.png" alt="ADB Devices mit Handy" title="ADB Devices mit Handy" width="300" height="64" class="size-medium wp-image-605" /></a><p class="wp-caption-text">ADB Devices mit Handy</p></div>
<p>Sollte ADB euer Gerät nicht fressen wollen, liegt es an Treiberproblemen. Wenn Windows euer Handy als Massenspeichergerät erkennt und mit seinen Default-Treibern zu Werke geht, findet ADB das Gerät nicht mehr. In diesem Fall: Alles aus dem Gerätemanager kicken, was nach Handy aussieht und dann mit <a href="http://developer.android.com/sdk/oem-usb.html">eurem Hersteller USB-Treiber</a> neu versuchen. <a href="http://www.google.de/search?aq=0&#038;oq=adb+dev&#038;sourceid=chrome&#038;ie=UTF-8&#038;q=adb+device+not+found">Ihr seid nicht allein</a>.</p>
<p>Übrigens: Der im Android SDK auswählbare USB Treiber wird euch nicht helfen, er ist nur für die Google Nexus Geräte.</p>
<h2>Schritt 9: Titanium selbst installieren</h2>
<p>Vorarbeit geschafft! <a href="https://my.appcelerator.com/auth/signup/offer/community">Titanium Account erstellen (kostenlos, wie das Programm selbst)</a> und dann Titanium herunterladen. Aktuell (18.9.2011) ist die Version 1.72. Das Titanium Studio basiert übrigens auf Aptana und damit auf Eclipse.</p>
<div id="attachment_606" class="wp-caption alignnone" style="width: 310px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/12.5-titanium-install.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/12.5-titanium-install-300x232.png" alt="Titanium Installation" title="Titanium Installation" width="300" height="232" class="size-medium wp-image-606" /></a><p class="wp-caption-text">Titanium Installation</p></div>
<p>Auch hier solltet ihr ein Verzeichnis wählen, welches bestenfalls keine Leerzeichen im Pfad hat. Dies gilt auch für den Workspace:</p>
<div id="attachment_607" class="wp-caption alignnone" style="width: 310px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/13-titanium-workspace.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/13-titanium-workspace-300x137.png" alt="Titanium Workspace" title="Titanium Workspace" width="300" height="137" class="size-medium wp-image-607" /></a><p class="wp-caption-text">Titanium Workspace</p></div>
<p>Jetzt verlangt Titanium noch GIT, bietet euch aber &#8211; sofern es nicht installiert und von Titanium gefunden wurde &#8211; die Option, Portable Git zu installieren und verwenden.</p>
<div id="attachment_608" class="wp-caption alignnone" style="width: 541px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/14-portable-git.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/14-portable-git.png" alt="Portable Git" title="Portable Git" width="531" height="352" class="size-full wp-image-608" /></a><p class="wp-caption-text">Portable Git</p></div>
<p>Schlussendlich muss noch das Android SDK in Titanium verlinkt werden. Dazu unter <i>Window -> Preferences</i> den Pfad zum SDK auswählen und eure gewünschte API Version als Default setzen:</p>
<div id="attachment_609" class="wp-caption alignnone" style="width: 310px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/16-sdk-in-titanium-verlinken.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/16-sdk-in-titanium-verlinken-300x205.png" alt="SDK in Titanium" title="SDK in Titanium" width="300" height="205" class="size-medium wp-image-609" /></a><p class="wp-caption-text">SDK in Titanium</p></div>
<h2>Schritt 10: Ready to go.</h2>
<p>Nun ist alles eingerichtet. Wir klicken beschwingt auf &#8220;create project&#8221;:</p>
<div id="attachment_610" class="wp-caption alignnone" style="width: 413px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/17-create-project.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/17-create-project.png" alt="Neues Projekt" title="Neues Projekt" width="403" height="275" class="size-full wp-image-610" /></a><p class="wp-caption-text">Neues Projekt</p></div>
<p>Den &#8220;new project wizard&#8221; stellen wir so zufrieden:</p>
<div id="attachment_611" class="wp-caption alignnone" style="width: 525px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/18-new-project.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/18-new-project.png" alt="Projekt-Wizard" title="Projekt-Wizard" width="515" height="514" class="size-full wp-image-611" /></a><p class="wp-caption-text">Projekt-Wizard</p></div>
<p>Und ab dafür. Auf den grünen Startpfeil geklickt und dann erstmal nen Kaffee machen. Android läuft nämlich in einem Emulator, der beim ersten Kaltstart gern mal 3 Minuten braucht. </p>
<div id="attachment_612" class="wp-caption alignnone" style="width: 310px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/19-starting.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/19-starting-300x235.png" alt="Emulator startet" title="Emulator startet" width="300" height="235" class="size-medium wp-image-612" /></a><p class="wp-caption-text">Emulator startet</p></div>
<p>Nach dem vollständigen Start und dem Entriegeln des Emulators sollte eure <i>Hello World</i> &#8211; App automatisch starten. </p>
<p>Links oben im Screenshot markiert ist der Start-Button für den Emulator. Alternativ kann auch der gewohnte, grüne Pfeil oben genommen werden. Rechts unten ist der Button zum Umschalten zur anderen Konsole markiert. Fehler beim Build gibt Titanium in Rot aus, in der Regel wird man aber nach kurzer google Suche schnell fündig &#8211; es gibt noch einige Kinderkrankheiten.</p>
<div id="attachment_614" class="wp-caption alignnone" style="width: 310px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/HelloWorld.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/HelloWorld-300x211.png" alt="Hello, World" title="Hello, World" width="300" height="211" class="size-medium wp-image-614" /></a><p class="wp-caption-text">Hello, World</p></div>
<p>Eventuell kommt beim Start des Emulators eine Dosbox hoch, in der &#8220;Error loading Preferences&#8221; steht. Das soll euch aber keine Gedanken bereiten, scheint beim Android Emulator zum guten Ton zu gehören.</p>
<h2>Schritt 11: Fastdev!</h2>
<p>Einmal gestartet, den Emulator bloß nicht wieder schließen! Titanium Studio verfügt standardmäßig über die Eigenschaft <a href="http://developer.appcelerator.com/blog/2011/05/titanium-mobile-intro-series-fastdev-for-android.html">fastdev</a>, welche es euch ermöglicht, ohne erneuten Emulatorstart Änderungen an der App vorzunehmen. Dazu einfach im Codefenster die <i>app.js</i> manipulieren (Tabtitel umbenennen bspw.) und erneut bei laufendem Emulator auf den Startknopf drücken. Sollte nun viel flotter gehen. Alternativ kann die App auch manuell geschlossen werden (nur die App, nicht den Emulator). Beim Neustart der App sind eure Änderungen dann auch bereits berücksichtigt.</p>
<h2>Schritt 12: Einstieg in die Entwicklung</h2>
<p>Titanium bietet das wunderbare Spielplatzprojekt <i>Kitchen Sink</i> an, in dem so gut wie alle Features von Titanium mal vorgestellt werden. Durch einfaches Copy und Paste kommt man so recht schnell zu brauchbaren Ergebnissen. Kitchensink findet sich als Musterprojekt <a href="https://github.com/appcelerator/KitchenSink">bei Github</a>. Ich muss dazusagen, dass Kitchen Sink ein Spielplatz ist und nicht immer funktionieren muss. Da scheint so ziemlich jeder dran herumbasteln zu dürfen, weswegen nicht unbedingt garantiert ist, dass die App immer funktioniert. Bei mir kam bspw. gern der Fehler <i>Could not find shared library</i>. Achja, Kitchen Sink sollte mit den Google API&#8217;s ausprobiert werden, da u.a. von google maps Gebrauch gemacht wird.</p>
<h2>Schritt 13: Deployen aufs Gerät</h2>
<p>Das oben erwähnte USB-Debugging auf dem Handy anschalten und auch &#8220;nicht vertrauenswürdigen Quellen&#8221; vertrauen, Handy anstöpseln und mit <i>adb devices</i> bestätigen lassen, dass das Handy gefunden wurde. Dann nur noch in Titanium auf &#8220;Android Device&#8221; &#8211; der Rest geht wie von Geisterhand.</p>
<div id="attachment_613" class="wp-caption alignnone" style="width: 247px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/Unbenannt.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/Unbenannt.png" alt="Run on Device" title="Run on Device" width="237" height="389" class="size-full wp-image-613" /></a><p class="wp-caption-text">Run on Device</p></div>
<h2>Und was ist mit iOS?</h2>
<p>Wie uns die <a href="http://wiki.appcelerator.org/display/guides/Titanium+Compatibility+Matrix">Kompatibilitätsmatrix</a> verrät, wird für die App-Entwicklung unter iOS zwingend ein Mac benötigt, deswegen kann ich dazu aktuell noch nichts sagen.</p>
<h2>Weitere Ressourcen</h2>
<ul>
<li><a href="http://wiki.appcelerator.org/display/guides/Home">Alle Guides direkt bei Titanium</a></li>
<li><a href="http://wiki.appcelerator.org/display/guides/Installing+on+Windows+7">Überdetaillierter, allerdings veralteter, Installationsguide für Windows 7</a></li>
<li><a href="http://developer.appcelerator.com/apidoc/mobile/">Titanium API Dokumentation für die Gerätfunktionen</a></li>
<li><a href="http://mobile.tutsplus.com/tutorials/appcelerator/titanium-mobile-build-a-pizza-ordering-app/">Nettes Tutorial zur App-Entwicklung mit Titanium</a></li>
</ul>
<p><strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/java-und-sqlite/" rel="bookmark" title="1. November 2010">Java und SQLite</a></li>
<li><a href="http://www.d-mueller.de/blog/eine-ode-an-das-qualitaetsbewusstsein/" rel="bookmark" title="14. September 2011">Eine Ode an das Qualitätsbewusstsein!</a></li>
<li><a href="http://www.d-mueller.de/blog/java-hibernate-tutorial/" rel="bookmark" title="3. November 2010">Java Hibernate Tutorial</a></li>
<li><a href="http://www.d-mueller.de/blog/windows-vs-linux-aus-developer-perspektive/" rel="bookmark" title="13. Oktober 2010">Windows vs Linux aus Developer-Perspektive</a></li>
<li><a href="http://www.d-mueller.de/blog/java-applet-tutorial/" rel="bookmark" title="21. Februar 2011">Java Applet Tutorial: Applet erstellen, einbinden und mit Javascript ansprechen</a></li>
</ul>
<p><!-- Similar Posts took 14.493 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/HPNxHE_G60A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/appentwicklung-webtechniken-mit-appcelerator-titanium/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/appentwicklung-webtechniken-mit-appcelerator-titanium/</feedburner:origLink></item>
		<item>
		<title>Eine Ode an das Qualitätsbewusstsein!</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/5zvH6t7O1wU/</link>
		<comments>http://www.d-mueller.de/blog/eine-ode-an-das-qualitaetsbewusstsein/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 21:34:47 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Persönlich]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=590</guid>
		<description><![CDATA[Disclaimer: Hier wird Dampf abgelassen. Tiefgründige Ergüsse sind nicht zu erwarten. Vorgeschichte In der letzten Zeit häuft sichs: Dreiste Fehler in ausgewachsener Software. Vielleicht hatte ich auch viel Pech bei der Auswahl, tut aber nichts zur Sache. In der offiziellen &#8230; <a href="http://www.d-mueller.de/blog/eine-ode-an-das-qualitaetsbewusstsein/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><b>Disclaimer:</b> Hier wird Dampf abgelassen. Tiefgründige Ergüsse sind nicht zu erwarten.</p>
<h3>Vorgeschichte</h3>
<p>In der letzten Zeit häuft sichs: Dreiste Fehler in ausgewachsener Software. Vielleicht hatte ich auch viel Pech bei der Auswahl, tut aber nichts zur Sache. In der offiziellen Version 1.7.2. des millionenfach verwendeten Cross-Platform-Mobile-Application-Frameworks &#8482; <a href="http://www.appcelerator.com/">Appcelerator Titanium</a> ist auf einmal die Build-Funktion für Apps so hart kaputt, dass man ohne manuellen Eingriff in das Build-Script nichts mehr in den App-Store / Android Market bekommen wird.</p>
<p>Evaluation anständiger UI-Frameworks, um auf Smartphones simple Apps mit Webtechniken zu schreiben: Ein Graus. Beim stark gefeierten <a href="http://www.sencha.com/products/touch/">Sencha Touch</a> werden wilde Javascript-Abtenteuer abgezogen, um eine simple Liste durchzuscrollen. Resultat: 1,2 GHz Dual Core auf dem Smartphone reichen nur noch für Zeitlupenruckelscrollen. Gern stürzt z.B. bei <a href="http://dojotoolkit.org/features/mobile">Dojo Mobile</a> nach dem Laden von megabyteweise Javascript auch das Handy einfach mal unvermittelt ab. Ganz zu schweigen von <a href="http://jqtouch.com/">jqTouch</a>, was mit fiesen Darstellungsfehlern aufwartet.</p>
<p>Des Jammerns genug &#8211; man kriegt fast das Gefühl, die Leute machen das um einen zu ärgern. <b>Mein eigentlicher Punkt:</b> Wie schafft es solche Software in den Release? Die wollen doch Geld damit verdienen oder sich zumindest nicht bis aufs Blut blamieren. Kann ich denn mit total zerstörtem, halbfertigen Mist beim Kunde antanzen und auch noch Props dafür kriegen? Anscheinend muss mans nur dreist genug betreiben, dann stört sich auch keiner mehr dran.</p>
<p><strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/1062-duplicate-entry-2147483647-for-key-primary/" rel="bookmark" title="9. Januar 2011">#1062 &#8211; Duplicate entry &#8217;2147483647&#8242; for key &#8216;PRIMARY&#8217;</a></li>
<li><a href="http://www.d-mueller.de/blog/windows-vs-linux-aus-developer-perspektive/" rel="bookmark" title="13. Oktober 2010">Windows vs Linux aus Developer-Perspektive</a></li>
<li><a href="http://www.d-mueller.de/blog/niemand-soll-wissen-dass-die-webseite-mit-php-laeuft/" rel="bookmark" title="30. Dezember 2010">Niemand soll wissen, dass die Webseite mit PHP läuft!</a></li>
<li><a href="http://www.d-mueller.de/blog/web-performance-best-practices/" rel="bookmark" title="21. Oktober 2010">Web-Performance: Best Practices</a></li>
<li><a href="http://www.d-mueller.de/blog/best-of-the-web-4/" rel="bookmark" title="3. Januar 2011">Best-of-the-Web 4</a></li>
</ul>
<p><!-- Similar Posts took 12.494 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/5zvH6t7O1wU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/eine-ode-an-das-qualitaetsbewusstsein/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/eine-ode-an-das-qualitaetsbewusstsein/</feedburner:origLink></item>
		<item>
		<title>Erwartete Exceptions richtig testen</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/7UX_NJnXLf4/</link>
		<comments>http://www.d-mueller.de/blog/erwartete-exceptions-richtig-testen/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 21:14:15 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=589</guid>
		<description><![CDATA[Der klassische Ablauf beim Testen von Code, der eine Exception werfen soll, ist der Folgende (PHPUnit): 1234567/** &#160;* @expectedException InvalidArgumentException &#160;*/ public function testException&#40;&#41; &#123; &#160; &#160;throw new InvalidArgumentException&#40;&#41;; &#125; Problem dabei: Wir haben nicht spezifiziert, an welcher Stelle die &#8230; <a href="http://www.d-mueller.de/blog/erwartete-exceptions-richtig-testen/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Der klassische Ablauf beim Testen von Code, der eine Exception werfen <b>soll</b>, ist <a href="http://www.phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.expectedException">der Folgende</a> (PHPUnit):</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @expectedException InvalidArgumentException<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testException<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> InvalidArgumentException<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Problem dabei: Wir haben nicht spezifiziert, an welcher Stelle die Exception geworfen werden soll. Außerdem können wir nicht prüfen, ob die geworfene Exception <b>genau</b> die erwartete oder nur igendeine war.</p>
<p>Jetzt lässt sich das noch aufbohren:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @expectedException &nbsp; &nbsp; &nbsp; &nbsp;InvalidArgumentException<br />
&nbsp;* @expectedExceptionMessage Right Message<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testExceptionHasRightMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> InvalidArgumentException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Right Message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><p>Auch damit werde ich nicht glücklich. Wenn ich jetzt z.B. mehrere Exceptions in einem Test prüfen möchte (guter Stil hin oder her) stößt man an die Grenzen diesen Ansatzes. </p>
<p>Etwas feingranularer ist das Handling mit der nachfolgend vorstellten Methode <i>setExpectedException</i>.</p>
<h3>Alternative Methode</h3>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testExceptionHasRightMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setExpectedException</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'InvalidArgumentException'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Right Message'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> InvalidArgumentException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Right Message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Macht letztlich einen entscheidenden Unterschied verglichen mit der Variante per Annotation: Ich kann den Zeitpunkt selbst bestimmen, ab dem ich eine Exception erwarte. Die Annotation greift direkt ab der ersten Zeile der Methode, in der ich vielleicht noch garkeine Exception haben möchte.</p>
<p>Weils so schön simpel ist: Das macht <i>setExpectedException</i> under the hood:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setExpectedException<span style="color: #009900;">&#40;</span><span style="color: #000088;">$exceptionName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exceptionMessage</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exceptionCode</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$exceptionName</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Exception'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> InvalidArgumentException<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'You must not expect the generic exception class.'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedException</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$exceptionName</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedExceptionMessage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$exceptionMessage</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedExceptionCode</span> &nbsp; &nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$exceptionCode</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedExceptionTrace</span> &nbsp; <span style="color: #339933;">=</span> <a href="http://www.php.net/debug_backtrace"><span style="color: #990000;">debug_backtrace</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>&#8230; und wenn dann eine Exception fliegt, prüft das PHP Unit folgendermaßen ab:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">try <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$testResult</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$method</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">invokeArgs</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array_merge"><span style="color: #990000;">array_merge</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dependencyInput</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$e</span> instanceof PHPUnit_Framework_IncompleteTest <span style="color: #339933;">&amp;&amp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">!</span><span style="color: #000088;">$e</span> instanceof PHPUnit_Framework_SkippedTest <span style="color: #339933;">&amp;&amp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/is_string"><span style="color: #990000;">is_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedException</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$e</span> instanceof <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedException</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_string"><span style="color: #990000;">is_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedExceptionMessage</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedExceptionMessage</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assertContains</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expectedExceptionMessage</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// ...</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<h3>Volle Kontrolle!</h3>
<p>Auch wenn das Testen mehrerer Exceptions in einer Methode durchaus umstritten ist, gibt es nun noch ein weiteres, gern genutztes Pattern, das eben dies ermöglicht:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">try<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; code<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No Exception was thrown&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
catch <span style="color: #009900;">&#40;</span>InvalidArgumentException <span style="color: #000088;">$ex</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ex</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Expected Exception-Text&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Wrong exceptiontext...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$ex</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wrong Exception was thrown&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Muss natürlich für maximalen Komfort noch ausgebaut werden, ihr versteht worauf ich hinauswill.</p>
<p>Um das etwas komfortabler und wiederholungsfreier zu gestalten, hat <a href="http://lars-tesmer.com/blog/2011/08/29/phpunit-better-syntax-for-expecting-exceptions/">dieser Herr</a> eine <a href="https://github.com/kiltec/phpunit/commit/dd5c7bd71d6eb8d4b58ce79b5ae069fbb0734354">Erweiterung</a> zu PHPUnit geschrieben, womit uns seine Methode <i>assertThrowsException</i> die Arbeit abnimmt und den zu testenden Code in einer anonymen Funktion kapselt. Fühlt sich für mich am sympathischsten an.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testSomeImportantMethod<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$someClass</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SomeClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assertThrowsException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'InvalidArgumentException'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">use</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$someClass</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$someClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">someMethod</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><b>Update:</b> Danke an Thomas für eine Richtigstellung, habe den Artikel entsprechend angepasst.<strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/dealing-with-trusted-timestamps-in-php-rfc-3161/" rel="bookmark" title="2. März 2011">Dealing with Trusted Timestamps in PHP (RFC 3161)</a></li>
<li><a href="http://www.d-mueller.de/blog/aufteilen-von-funktionen-doppelte-validierung/" rel="bookmark" title="6. April 2011">Aufteilen von Funktionen = doppelte Validierung</a></li>
<li><a href="http://www.d-mueller.de/blog/php-errors-zu-exceptions-konvertieren/" rel="bookmark" title="25. November 2010">PHP-Errors zu Exceptions konvertieren</a></li>
<li><a href="http://www.d-mueller.de/blog/javascript-error-handling/" rel="bookmark" title="21. Oktober 2010">Javascript Error-Handling</a></li>
<li><a href="http://www.d-mueller.de/blog/5-php-patterns-im-schnelldurchlauf-factory-iterator-observer-singleton-strategy/" rel="bookmark" title="1. Dezember 2010">5 PHP Patterns im Schnelldurchlauf: Factory, Iterator, Observer, Singleton, Strategy</a></li>
</ul>
<p><!-- Similar Posts took 12.802 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/7UX_NJnXLf4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/erwartete-exceptions-richtig-testen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/erwartete-exceptions-richtig-testen/</feedburner:origLink></item>
		<item>
		<title>MySQL “SHOW PROFILE”</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/QREVcbC2FaA/</link>
		<comments>http://www.d-mueller.de/blog/mysql-show-profile/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 20:02:02 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Datenbanken]]></category>
		<category><![CDATA[Quicktips]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=587</guid>
		<description><![CDATA[Hab heute in meiner favorisierten Datenbank-GUI HeidiSQL den Query Profiler entdeckt, hinter dem sich bei genauer Recherche das MySQL-Kommando SHOW PROFILE verbirgt &#8211; nur grafisch aufgehübscht. Eine sinnvolle Ergänzung zu EXPLAIN &#8211; grade die temporären Tabellen oder unerwartet auffällige Sortierungen &#8230; <a href="http://www.d-mueller.de/blog/mysql-show-profile/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hab heute in meiner favorisierten Datenbank-GUI <a href="http://www.heidisql.com/">HeidiSQL</a> den Query Profiler entdeckt, hinter dem sich bei genauer Recherche das MySQL-Kommando <a href="http://dev.mysql.com/doc/refman/5.0/en/show-profiles.html">SHOW PROFILE</a> verbirgt &#8211; nur grafisch aufgehübscht.</p>
<div id="attachment_588" class="wp-caption alignnone" style="width: 529px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/query-profiling.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/09/query-profiling.png" alt="query-profiling" title="query-profiling" width="519" height="551" class="size-full wp-image-588" /></a><p class="wp-caption-text">query-profiling</p></div>
<p>Eine sinnvolle Ergänzung zu <a href="http://dev.mysql.com/doc/refman/5.0/en/explain.html">EXPLAIN</a> &#8211; grade die temporären Tabellen oder unerwartet auffällige Sortierungen fallen hier schnell auf.<br />
<strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/java-hibernate-tutorial/" rel="bookmark" title="3. November 2010">Java Hibernate Tutorial</a></li>
<li><a href="http://www.d-mueller.de/blog/angriffe-auf-webanwendungen-teil-1-xss-beispielangriff/" rel="bookmark" title="28. November 2010">Angriffe auf Webanwendungen &#8211; Teil 1: XSS (+Beispielangriff)</a></li>
<li><a href="http://www.d-mueller.de/blog/utf-8-fur-php-programmierer-und-webanwendungen/" rel="bookmark" title="1. Juli 2009">UTF-8 für PHP-Programmierer und Webanwendungen</a></li>
<li><a href="http://www.d-mueller.de/blog/lasst-die-datenbank-ihren-job-machen/" rel="bookmark" title="27. Dezember 2010">Lasst die Datenbank ihren Job machen!</a></li>
<li><a href="http://www.d-mueller.de/blog/datenbank-klasse-auf-pdo-basierend/" rel="bookmark" title="20. November 2010">Datenbank-Klasse (auf PDO basierend)</a></li>
</ul>
<p><!-- Similar Posts took 12.660 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/QREVcbC2FaA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/mysql-show-profile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/mysql-show-profile/</feedburner:origLink></item>
		<item>
		<title>Schriftartempfehlung: Consolas</title>
		<link>http://feedproxy.google.com/~r/davblog-webdevandstuff/~3/gOXxtK1yoCY/</link>
		<comments>http://www.d-mueller.de/blog/schriftartempfehlung-consolas/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 09:04:37 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[misc IT]]></category>
		<category><![CDATA[Quicktips]]></category>

		<guid isPermaLink="false">http://www.d-mueller.de/blog/?p=584</guid>
		<description><![CDATA[Ein geschätzter Arbeitskollege gab mir neulich den Tipp, es mal mit der von Microsoft speziell für Programmierung entwickelten Schrift Consolas zu versuchen. Ich hab einen Schriftwechsel erst als unnötig abgestempelt, war dann aber doch froh, es getan zu haben. Meine &#8230; <a href="http://www.d-mueller.de/blog/schriftartempfehlung-consolas/">Weiterlesen <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ein geschätzter Arbeitskollege gab mir neulich den Tipp, es mal mit der von Microsoft speziell für <a href="http://de.wikipedia.org/wiki/Consolas">Programmierung entwickelten Schrift Consolas</a> zu versuchen. Ich hab einen Schriftwechsel erst als unnötig abgestempelt, war dann aber doch froh, es getan zu haben.</p>
<p>Meine favorisierte IDE Netbeans kommt standardmäßig mit der Schriftart <i>Monospaced</i> daher. Sieht so aus:</p>
<div id="attachment_585" class="wp-caption alignnone" style="width: 547px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/08/monospaced.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/08/monospaced.png" alt="monospaced" title="monospaced" width="537" height="427" class="size-full wp-image-585" /></a><p class="wp-caption-text">monospaced</p></div>
<h2>Enter Consolas</h2>
<p><a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&#038;id=17879">Heruntergeladen</a> und in Netbeans als Standardfont in Größe 14 eingestellt (12 finde ich zu klein). Resultat:</p>
<div id="attachment_586" class="wp-caption alignnone" style="width: 545px"><a href="http://www.d-mueller.de/blog/wp-content/uploads/2011/08/consolas.png"><img src="http://www.d-mueller.de/blog/wp-content/uploads/2011/08/consolas.png" alt="consolas" title="consolas" width="535" height="458" class="size-full wp-image-586" /></a><p class="wp-caption-text">consolas</p></div>
<p>Finde ich dann doch deutlich angenehmer. <strong>Weitere Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.d-mueller.de/blog/java-und-sqlite/" rel="bookmark" title="1. November 2010">Java und SQLite</a></li>
<li><a href="http://www.d-mueller.de/blog/yahoo-placefinder-api-tutorial/" rel="bookmark" title="23. November 2010">Yahoo Placefinder-API Tutorial</a></li>
<li><a href="http://www.d-mueller.de/blog/webtesting-mit-simpletest-selenium-light/" rel="bookmark" title="14. März 2011">Webtesting mit SimpleTest &#8211; Selenium light</a></li>
<li><a href="http://www.d-mueller.de/blog/datenbank-klasse-auf-pdo-basierend/" rel="bookmark" title="20. November 2010">Datenbank-Klasse (auf PDO basierend)</a></li>
<li><a href="http://www.d-mueller.de/blog/per-php-cli-die-eigene-ip-herausfinden/" rel="bookmark" title="21. Mai 2011">Per PHP-CLI die eigene IP herausfinden</a></li>
</ul>
<p><!-- Similar Posts took 19.193 ms --></p>
<img src="http://feeds.feedburner.com/~r/davblog-webdevandstuff/~4/gOXxtK1yoCY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.d-mueller.de/blog/schriftartempfehlung-consolas/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.d-mueller.de/blog/schriftartempfehlung-consolas/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: www.d-mueller.de @ 2012-03-23 04:02:18 -->

