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

<channel>
	<title>Fabian Moser &#187; Arbeit</title>
	<atom:link href="http://fabianmoser.at/kategorie/arbeit/feed/" rel="self" type="application/rss+xml" />
	<link>http://fabianmoser.at</link>
	<description>&#34;as simple as possible, but not simpler&#34;</description>
	<lastBuildDate>Thu, 26 Jan 2012 13:19:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/at/</creativeCommons:license>		<item>
		<title>Umlaute von Zotero nach BibTeX exportieren</title>
		<link>http://fabianmoser.at/blog/2011/09/20/umlaute-von-zotero-in-bibtex-exportieren/</link>
		<comments>http://fabianmoser.at/blog/2011/09/20/umlaute-von-zotero-in-bibtex-exportieren/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 08:41:48 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[BibTeX]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Umlaut]]></category>
		<category><![CDATA[UTF-8]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://fabianmoser.at/?p=1128</guid>
		<description><![CDATA[Mag sein, dass dieser Artikel eine beinahe inexistente (Wissens-) Lücke füllt. Für all jene, denen weder BibTeX noch Zotero etwas sagt, ist er mit Sicherheit nicht lesenswert, aber allein die Möglichkeit, dass ich selbst nochmal auf das geschilderte Problem treffe, &#8230; <a href="http://fabianmoser.at/blog/2011/09/20/umlaute-von-zotero-in-bibtex-exportieren/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Mag sein, dass dieser Artikel eine beinahe inexistente (Wissens-) Lücke füllt. Für all jene, denen weder BibTeX noch Zotero etwas sagt, ist er mit Sicherheit nicht lesenswert, aber allein die Möglichkeit, dass ich selbst nochmal auf das geschilderte Problem treffe, rechtfertigt ihn dennoch.</p>
<p>Das Problem von dem ich spreche ist der Dateiexport von <a href="http://www.zotero.org/" target="_blank">Zotero</a>, einem Programm das ich zur Verwaltung meiner Bibliographie verwende, nach <a href="http://de.wikipedia.org/wiki/BibTeX" target="_blank">BibTeX</a>, dem Dateiformat das ich zur automatischen Erstellung der Referenzen und des Quellenverzeichnisses in meiner Dissertation verwende. Wenn nun im Titel von verwendeten Quellen oder in Namen von deren Autoren deutsche Umlaute oder diakritische Zeichen (wie z.B. französische Akzente) vorkommen, werden diese in der exportierten Datei unverändert wiedergegeben, weil Zotero die ausgegebene Datei per Vorgabe als UTF-8 kodiert. Diese Kodierung wird aber von BibTeX nicht richtig verarbeitet.</p>
<p>Für diese Problem gibt es zwei Lösungswege, wobei ich leider viel Zeit mit dem ersten verloren habe:</p>
<ol>
<li>Man kann versuchen, BibTeX zur richtigen Verarbeitung der UTF-8 Datei zu bringen, bzw. einen dementsprechenden Ersatz für BibTeX einzusetzen. Diesbezüglich gibt es jede Menge Diskussionen im Internet, die die Hoffnung (leider) nicht schnell genug sterben lassen. Der Vollständigkeit halber sei hier beispielhaft auf <a href="http://ctan.org/tex-archive/biblio/bibtex/8-bit" target="_blank"><code>bibtex8</code></a> verwiesen.</li>
<li>Viel einfacher ist es jedoch, Zotero dazu zu bringen, die kritischen Zeichen entsprechend der LaTeX Syntax auszugeben. Das schafft man aber nicht, indem man selbst die Einträge entsprechend ändert, sondern indem man die Dateikodierung für den Export ändert.<br />
<em><br />
Dazu muss man lediglich in den Einstellungen von Zotero in der Kategorie Export ein Häkchen bei &#8220;Option für Zeichenkodierung beim Export anzeigen&#8221; setzen. Beim nächsten BibTeX Export ist dann einfach &#8220;Westlich (ISO-8859-1)&#8221; aus der Liste auszuwählen und schon erstellt Zotero eine problemlos verwendbare BibTeX Datei.</em></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2011/09/20/umlaute-von-zotero-in-bibtex-exportieren/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zurück von der IPAC</title>
		<link>http://fabianmoser.at/blog/2011/09/11/zuruck-von-der-ipac/</link>
		<comments>http://fabianmoser.at/blog/2011/09/11/zuruck-von-der-ipac/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 11:25:16 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>

		<guid isPermaLink="false">http://fabianmoser.at/?p=1122</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="g3client_wrapper"><div class="g3client_singleview"><a href="http://fabianmoser.at/gallery3/var/resizes/fabian/IPAC-2011/IPAC2011_001.jpg?m=1315739945"><img class="colorbox-1122"  src="http://fabianmoser.at/gallery3/var/resizes/fabian/IPAC-2011/IPAC2011_001.jpg?m=1315739945" alt=""></a><p class="g3client_singletitle">IPAC 2011</p></div></div>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2011/09/11/zuruck-von-der-ipac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zurück aus dem Urlaub</title>
		<link>http://fabianmoser.at/blog/2011/07/25/zuruck-aus-dem-urlaub/</link>
		<comments>http://fabianmoser.at/blog/2011/07/25/zuruck-aus-dem-urlaub/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 12:05:56 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>

		<guid isPermaLink="false">http://fabianmoser.at/?p=1102</guid>
		<description><![CDATA[Jetzt (unter anderem) noch ein guter Monat Vorbereitung der IPAC und dann ein paar Tage in San Sebastián.]]></description>
			<content:encoded><![CDATA[<p>Jetzt (unter anderem) noch ein guter Monat Vorbereitung der <a href="http://www.ipac-2011.org/">IPAC</a> und dann ein paar Tage in <a href="http://maps.google.ch/maps?q=san+sebastian">San Sebastián</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2011/07/25/zuruck-aus-dem-urlaub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inkscape Standardvorlage</title>
		<link>http://fabianmoser.at/blog/2010/06/15/inkscape-standardvorlage/</link>
		<comments>http://fabianmoser.at/blog/2010/06/15/inkscape-standardvorlage/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 08:41:45 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[EPS]]></category>
		<category><![CDATA[Grafik]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Inkscape]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Vektorgrafik]]></category>

		<guid isPermaLink="false">http://www.fabianmoser.at/?p=671</guid>
		<description><![CDATA[Gestern war ich wieder einmal in der Situation, dass ich eine per Hand gezeichnete Skizze in einem Dokument verwenden wollte. In solchen Faellen ist Vektorgrafik Software Inkscape für mich die erste Wahl. In Inkscape angefertigte Zeichnungen lassen lassen sich ganz &#8230; <a href="http://fabianmoser.at/blog/2010/06/15/inkscape-standardvorlage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Gestern war ich wieder einmal in der Situation, dass ich eine per Hand gezeichnete Skizze in einem Dokument verwenden wollte. In solchen Faellen ist Vektorgrafik Software <a href="http://www.inkscape.org/">Inkscape</a> für mich die erste Wahl. In Inkscape angefertigte Zeichnungen lassen lassen sich ganz natürlich im EPS Format exportieren, das wiederum erste Wahl für Grafiken in LaTeX Dokumenten ist. Bei Bedarf lassen sich EPS Dateien auch unkompliziert in PDF umwandeln und mit pdfLaTeX verwenden.</p>
<p>Nun muss ich jedes Mal, wenn ich eine neue Zeichnung mit Inkscape beginnen wollte, zuerst eine Reihe von Dokumenteneinstellungen ändern, weil eine A4 Seite im Hochformat und mit Pixel Angaben auf den Linealen nicht das ist, was ich brauche. Stattdessen verwende ich immer A6 im Querformat mit Millimeter Angaben und einem 1mm Gitter. Die Vermutung, dass sich die Standardeinstellungen ändern lassen, bestätigte sich anhand eines <a href="http://wiki.inkscape.org/wiki/index.php/FAQ#Can_I_use_different_settings_for_the_new_documents_created_by_Inkscape.3F">Treffers in den Inkscape FAQ</a>.</p>
<p>Um es kurz zu machen: Man muss ein leeres Dokument nach den eigenen Vorstellungen erstellen und es als</p>
<pre>~/.config/inkscape/templates/default.de.svg</pre>
<p>speichern, wenn man, wie ich, Deutsch als Systemsprache verwendet.</p>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2010/06/15/inkscape-standardvorlage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embed PDFs from Zotero</title>
		<link>http://fabianmoser.at/blog/2010/06/03/embed-pdfs-from-zotero/</link>
		<comments>http://fabianmoser.at/blog/2010/06/03/embed-pdfs-from-zotero/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 08:51:22 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Evince]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://www.fabianmoser.at/?p=648</guid>
		<description><![CDATA[I&#8217;m using Zotero to organise my bibliography. Not only do I store citation information, but I also love the possibility to let it organise the corresponding PDF files. That way I have full-text search and a superb tagging facility for &#8230; <a href="http://fabianmoser.at/blog/2010/06/03/embed-pdfs-from-zotero/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using <a href="http://www.zotero.org/">Zotero</a> to organise my bibliography. Not only do I store citation information, but I also love the possibility to let it organise the corresponding PDF files. That way I have full-text search and a superb tagging facility for almost everything I read and might need to use and cite later. As a Fedora user, I didn&#8217;t have Firefox configured to embed all kind of media into the browser by default. In general I perceive this as an advantage, but in my use-case I have Firefox with Zotero running in full-screen on a separate workspace and want it to manage the screen entirely. And since Evince is the default PDF viewer on Gnome at the moment, I would like it to be embedded into Firefox tabs as I open PDFs from Zotero.</p>
<p>As quick search for the topic brought me to an <a href="http://ubuntuforums.org/showthread.php?t=25685">article in the Ubuntu Forums</a> which solved 90% of the problem. Installing Mozplugger</p>
<pre style="padding-left: 30px;">yum install mozplugger</pre>
<p>and raising the priority of Evince as its PDF handler made most of the PDFs open embedded just as intended. However, Zotero seems to assign an unusual MIME type for the PDFs it stores that is &#8220;application/octetstream&#8221;. Thus to fit my needs, I added that type to the Mozplugger PDF handler</p>
<pre style="padding-left: 30px;">sudo vim /etc/mozpluggerrc</pre>
<p>which now reads as</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">application<span style="color: #000000; font-weight: bold;">/</span>pdf:pdf:PDF <span style="color: #c20cb9; font-weight: bold;">file</span>
application<span style="color: #000000; font-weight: bold;">/</span>x-pdf:pdf:PDF <span style="color: #c20cb9; font-weight: bold;">file</span>
text<span style="color: #000000; font-weight: bold;">/</span>pdf:pdf:PDF <span style="color: #c20cb9; font-weight: bold;">file</span>
text<span style="color: #000000; font-weight: bold;">/</span>x-pdf:pdf:PDF <span style="color: #c20cb9; font-weight: bold;">file</span>
application<span style="color: #000000; font-weight: bold;">/</span>octetstream:pdf:PDF <span style="color: #c20cb9; font-weight: bold;">file</span>
        repeat noisy swallow<span style="color: #7a0874; font-weight: bold;">&#40;</span>evince<span style="color: #7a0874; font-weight: bold;">&#41;</span> fill: evince <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>
<span style="color: #666666; font-style: italic;">#       ACROREAD()</span>
<span style="color: #666666; font-style: italic;">#       repeat noisy swallow(kpdf) fill: kpdf &quot;$file&quot;</span>
<span style="color: #666666; font-style: italic;">#       repeat noisy swallow(Xpdf) fill: xpdf -g +9000+9000 &quot;$file&quot;</span>
<span style="color: #666666; font-style: italic;">#       repeat noisy swallow(okular) fill: okular &quot;$file&quot;</span>
<span style="color: #666666; font-style: italic;">#       GV()</span>
<span style="color: #666666; font-style: italic;">#       repeat noisy fill exits: evince &quot;$file&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2010/06/03/embed-pdfs-from-zotero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zim</title>
		<link>http://fabianmoser.at/blog/2010/05/19/zim/</link>
		<comments>http://fabianmoser.at/blog/2010/05/19/zim/#comments</comments>
		<pubDate>Wed, 19 May 2010 12:43:37 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Bugzilla]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[OneNote]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[Wiki]]></category>
		<category><![CDATA[Zim]]></category>

		<guid isPermaLink="false">http://www.fabianmoser.at/?p=624</guid>
		<description><![CDATA[Jene Linux Anwendung, die OneNote im Funktionsumfang am nächsten kommt ist vermutlich BasKet. Trotzdem schreibe ich diesen Artikel, weil ich für mich Zim als geeignetste Anwendung befunden habe. Zim wird vom Autor als "Desktop Wiki" bezeichnet. Was die Textverarbeitung betrifft, wird damit das meiste bereits erklärt. Wer jemals einen Wiki Artikel geschrieben hat, kennt das Prinzip.

Was Zim für mich aber perfekt macht, denn es ist beileibe nicht das einzige Desktop Wiki, sind drei Plugins, die folgende Funktionen zur grundlegenden Wiki Funktionalität hinzufügen: <a href="http://fabianmoser.at/blog/2010/05/19/zim/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wie eventuell aus dem Countdown zur Veröffentlichung von Fedora 13 im rechten Rand zu schließen war, ist momentan Linux das Desktop und Laptop Betriebssystem meiner Wahl. Ohne weiter ausholen zu wollen, möchte ich nur anmerken, dass diese Wahl nicht aus ideologischen sondern aus technischen Überlegungen resultiert. Die Hardwareanforderungen aktueller Windows Versionen haben sich zu weit von den mir zur Verfügung stehenden Tatsachen entfernt als dass ein vernünftiger Betrieb möglich wäre. Andererseits ist eine Weiterverwendung veralteter Windows Versionen mit zu vielen, nicht zuletzt sicherheitstechnischen, Nachteilen verbunden.</p>
<p>Die eigentliche Herausforderung, wenn man Windows gänzlich den Rücken kehren möchte, besteht kaum mehr in Inkompatibilitäten wie es scheint, sondern vor allem im Bruch mit Gewohntem. Damit meine ich nicht das Betriebssystem, denn damit hat man als Benutzer kaum Kontakt, sondern die Anwendungen. Ich kann mir gut vorstellen, dass in manchen Bereichen für Linux keine adäquaten Entsprechungen für tausende Euro teure kommerzielle Software zu finden ist. Dennoch möchte ein Beispiel für (m)einen Fall bringen, wo eine Anwendung trotz kleinerem Funktionsumfang eine andere ersetzen kann.</p>
<h2>Zim</h2>
<p>Eine meiner Lieblingsanwendungen unter Windows ist OneNote. Als Notiz- und Logbuch hat sich dieses Programm als sehr nützlich erwiesen. Die Hauptvorteile gegenüber einem Papierblock sind für mich die Suchfunktion, der Umgang mit Markierungen (Schlagworten) und nicht zuletzt die Möglichkeit, schnell und einfach Bildschirmausschnitte in den Text einzufügen. Da ich beinahe sämtliche Information über den Bildschirm verarbeite, ist das Speichern von Bildschirmausschnitten das allgemeinste Interface. Als Naturwissenschaftler verwende ich diese Technik sehr oft, um Diagramme, die von einem beliebigen Programm erzeugt wurden, in das elektronische Notizbuch zu &#8220;kleben&#8221;.</p>
<p>Jene Linux Anwendung, die OneNote im Funktionsumfang am nächsten kommt ist vermutlich <a href="http://basket.kde.org/">BasKet</a>. Trotzdem schreibe ich diesen Artikel, weil ich für mich <a href="http://zim-wiki.org/">Zim</a> als geeignetste Anwendung befunden habe. Zim wird vom Autor als &#8220;Desktop Wiki&#8221; bezeichnet. Was die Textverarbeitung betrifft, wird damit das meiste bereits erklärt. Wer jemals einen Wiki Artikel geschrieben hat, kennt das Prinzip.</p>
<p>Was Zim für mich aber perfekt macht, denn es ist beileibe nicht das einzige Desktop Wiki, sind drei Plugins, die folgende Funktionen zur grundlegenden Wiki Funktionalität hinzufügen:</p>
<ul>
<li>Es ist möglich Schnappschüsse vom ganzen Bildschirm, einzelnen Fenstern und frei wählbaren Ausschnitten zu machen.</li>
<li>Es ist möglich, Formeln einzufügen, die man in einem separaten Dialog per LaTeX Syntax formulieren kann.</li>
<li>Eine Versionsverwaltung kann verwendet werden, um Änderungen an den Notizen zu verfolgen.</li>
</ul>
<p>Zur absoluten Perfektion fehlen meiner Meinung nach nur zwei Features:</p>
<ul>
<li>Schlagworte (Tags) &#8211; ein für die Zukunft geplantes Feature</li>
<li>Versionsverwaltung mit Git (statt Bazaar oder Subversion) &#8211; Gewohnheit</li>
</ul>
<h3>Zim in Fedora</h3>
<p>Leider enthält Fedora, selbst in der noch nicht freigegebenen Version 13, nicht die aktuelle Version von Zim. Man findet aber in Bugzilla den <a href="https://bugzilla.redhat.com/show_bug.cgi?id=563844">Bug 563844</a>, der neben einer aufschlussreichen Diskussion auch einen Link auf eine aktuelle SRPM enthält. Wie man daraus eine installierbare RPM baut erfährt man (neben sicherlich unzähligen anderen Stellen) im <a href="https://fedoraproject.org/wiki/How_to_create_an_RPM_package">Fedora Wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2010/05/19/zim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lightning Problem</title>
		<link>http://fabianmoser.at/blog/2010/01/14/lightning-problem/</link>
		<comments>http://fabianmoser.at/blog/2010/01/14/lightning-problem/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 09:49:42 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Kalender]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://fabianmoser.at/?p=522</guid>
		<description><![CDATA[Ich hatte schon seit einiger Zeit ein Problem mit dem Lightning Plugin von Mozilla Thunderbird. Angefangen hat es mit dem Update auf Version 0.9. Jedes Mal wenn ich Thunderbird gestartet habe kam zweimal folgende Fehlermeldung: An error was encountered preparing &#8230; <a href="http://fabianmoser.at/blog/2010/01/14/lightning-problem/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ich hatte schon seit einiger Zeit ein Problem mit dem Lightning Plugin von Mozilla Thunderbird. Angefangen hat es mit dem Update auf Version 0.9. Jedes Mal wenn ich Thunderbird gestartet habe kam zweimal folgende Fehlermeldung:</p>
<blockquote><p>An error was encountered preparing the calendar located at moz-profile-calendar:// for use. It will not be available.</p></blockquote>
<p>Da ich die Funktionalität von Lightning nicht viel verwendet habe, entschied ich mich als schnellste &#8220;Lösung&#8221;, das Plugin zu deinstallieren.</p>
<p>Heute habe ich nach kurzer Recherche eine Lösung für das Problem gefunden. Sie wird im Bugzilla System von Fedora an folgender Stelle erklärt:</p>
<p><a title="RedHat BugZilla" href="https://bugzilla.redhat.com/show_bug.cgi?id=542736#c5">https://bugzilla.redhat.com/show_bug.cgi?id=542736#c5</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2010/01/14/lightning-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rekordverdächtig</title>
		<link>http://fabianmoser.at/blog/2010/01/13/rekordverdaechtig/</link>
		<comments>http://fabianmoser.at/blog/2010/01/13/rekordverdaechtig/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 10:14:31 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Auto]]></category>
		<category><![CDATA[Schnee]]></category>

		<guid isPermaLink="false">http://fabianmoser.at/?p=511</guid>
		<description><![CDATA[Heute Nacht hat es, wie vom Wetterdienst gestern vorhergesagt, erneut geschneit. In Annemasse haben wir also mittlerweile geschätzte 30 cm Schnee vor dem Haus liegen. Für Dory ist das zwar unangenehm, stellt aber kein echtes Problem dar. Leider gilt das &#8230; <a href="http://fabianmoser.at/blog/2010/01/13/rekordverdaechtig/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Heute Nacht hat es, wie vom Wetterdienst gestern vorhergesagt, erneut geschneit. In Annemasse haben wir also mittlerweile geschätzte 30 cm Schnee vor dem Haus liegen. Für Dory ist das zwar unangenehm, stellt aber kein echtes Problem dar. Leider gilt das für den Verkehr nicht. Ich hatte heute von zuhause bis auf den CERN Parkplatz genau 2 Stunden und 21 Minuten Fahrtzeit, was eindeutig ein neuer Rekord ist. Üblicherweise benötige ich für die etwa 35 km (davon 26 km Autobahn) 40-50 Minuten wenn ich zur selben Zeit fahre wie alle anderen. Immerhin gilt es zweimal die Grenze zwischen der Schweiz und Frankreich zu überqueren. Außerhalb der Stoßzeit habe ich die Strecke auch schon in 32 Minuten geschafft.</p>
<p>Gegen Ende war die heutige Fahrt dann schon fast unterhaltsam. In einem der vielen Kreisverkehre hat sich das vor mir fahrende Auto um 180 Grad gedreht und stand mir frontal gegenüber.</p>
<p>Ich hoffe nur, dass der Nachhauseweg etwas weniger Zeit braucht.</p>
<h3>Nachtrag</h3>
<p>Der Rückweg war eine positive Überraschung: Ich habe meine Bestzeit von 32 Minuten wiederholt, da wundersamer Weise zwischen 17:50 und 18:22 Uhr kaum Verkehr war.</p>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2010/01/13/rekordverdaechtig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sicherung eines Netzwerkpfades unter Windows Vista</title>
		<link>http://fabianmoser.at/blog/2009/09/14/sicherung-eines-netzwerkpfades-unter-windows-vista/</link>
		<comments>http://fabianmoser.at/blog/2009/09/14/sicherung-eines-netzwerkpfades-unter-windows-vista/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 08:46:24 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[7-zip]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[DFS]]></category>
		<category><![CDATA[robocopy]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://fabianmoser.at/?p=441</guid>
		<description><![CDATA[Ich weiß, dass es für gewöhnlich umgekehrt ist, aber ich stand vor dem Problem, dass ich auf einer zentral verwalteten Maschine mit einem Benutzerkonto auf einem DFS-Server die dort abgelegten Daten gerne lokal gesichert hätte. Der Grund dafür war in &#8230; <a href="http://fabianmoser.at/blog/2009/09/14/sicherung-eines-netzwerkpfades-unter-windows-vista/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ich weiß, dass es für gewöhnlich umgekehrt ist, aber ich stand vor dem Problem, dass ich auf einer zentral verwalteten Maschine mit einem Benutzerkonto auf einem DFS-Server die dort abgelegten Daten gerne lokal gesichert hätte. Der Grund dafür war in erster Linie mein Misstrauen gegenüber der Verfügbarkeit der Netzwerkverbindung. Ich wollte auch an Tagen, an denen es Netzwerkprobleme gab, mit meinen Daten ungestört weiterarbeiten können (ohne mich auf die Vista-eigenen Offline Mechanismen verlassen zu müssen).</p>
<p>Das <a href="http://www.fabianmoser.at/files/2009/09/backup_dfs.cmd">folgende Skript</a> erfüllt genau diese Aufgabe und ist auch leicht per Taskplaner zu automatisieren. Um es einzusetzen, müssen nur die Einstellungen in Zeile 3 bis 6 angepasst werden und dafür gesorgt sein, dass <a href="http://www.7-zip.org/">7-zip</a> installiert ist.</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;"><span style="color: #33cc33;">@</span><span style="color: #b1b100; font-weight: bold;">echo</span> off
&nbsp;
<span style="color: #b1b100; font-weight: bold;">set</span> source=\\cern.ch\dfs\Users\f\fmoser
<span style="color: #b1b100; font-weight: bold;">set</span> destination=D:\fmoser\Backup
<span style="color: #b1b100; font-weight: bold;">set</span> prefix=fmoser_
<span style="color: #b1b100; font-weight: bold;">set</span> szip=&quot;C:\Program Files <span style="color: #33cc33;">(</span>x86<span style="color: #33cc33;">)</span>\7-Zip\7z.exe&quot;
&nbsp;
<span style="color: #00b100; font-weight: bold;">For</span> /f &quot;tokens=1-3 delims=/ &quot; <span style="color: #33cc33;">%%</span><span style="color: #448888;">a</span> <span style="color: #00b100; font-weight: bold;">in</span> <span style="color: #33cc33;">(</span>'date /t'<span style="color: #33cc33;">)</span> <span style="color: #00b100; font-weight: bold;">do</span> <span style="color: #33cc33;">(</span><span style="color: #b1b100; font-weight: bold;">set</span> mydate=<span style="color: #33cc33;">%%</span><span style="color: #448888;">c</span>-<span style="color: #33cc33;">%%</span><span style="color: #448888;">a</span>-<span style="color: #33cc33;">%%</span><span style="color: #448888;">b</span><span style="color: #33cc33;">)</span>
<span style="color: #00b100; font-weight: bold;">For</span> /f &quot;tokens=1-2 delims=/:&quot; <span style="color: #33cc33;">%%</span><span style="color: #448888;">a</span> <span style="color: #00b100; font-weight: bold;">in</span> <span style="color: #33cc33;">(</span>'time /t'<span style="color: #33cc33;">)</span> <span style="color: #00b100; font-weight: bold;">do</span> <span style="color: #33cc33;">(</span><span style="color: #b1b100; font-weight: bold;">set</span> mytime=<span style="color: #33cc33;">%%</span><span style="color: #448888;">a</span><span style="color: #33cc33;">%%</span><span style="color: #448888;">b</span><span style="color: #33cc33;">)</span>
<span style="color: #b1b100; font-weight: bold;">set</span> backupname=<span style="color: #33cc33;">%</span><span style="color: #448888;">destination</span><span style="color: #33cc33;">%</span>\<span style="color: #33cc33;">%</span><span style="color: #448888;">prefix</span><span style="color: #33cc33;">%%</span><span style="color: #448888;">mydate</span><span style="color: #33cc33;">%</span>_<span style="color: #33cc33;">%</span><span style="color: #448888;">mytime</span><span style="color: #33cc33;">%</span>
<span style="color: #b1b100; font-weight: bold;">mkdir</span> <span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span>
robocopy <span style="color: #33cc33;">%</span><span style="color: #448888;">source</span><span style="color: #33cc33;">%</span> <span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span> /MIR /Z /R:10 /W:30 /<span style="color: #b1b100; font-weight: bold;">COPY</span>:DATSO /XJ /LOG:<span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span>.log /NP
<span style="color: #33cc33;">%</span><span style="color: #448888;">szip</span><span style="color: #33cc33;">%</span> a -t7z -mx9 <span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span>.7z <span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span> <span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span>.log <span style="color: #33cc33;">&amp;&amp;</span> <span style="color: #b1b100; font-weight: bold;">rd</span> /S /Q <span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span> <span style="color: #33cc33;">&amp;&amp;</span> <span style="color: #b1b100; font-weight: bold;">del</span> <span style="color: #33cc33;">%</span><span style="color: #448888;">backupname</span><span style="color: #33cc33;">%</span>.log</pre></div></div>

<p><a href="http://www.fabianmoser.at/uploads/2009/09/backup_dfs.cmd">backup_dfs.cmd</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2009/09/14/sicherung-eines-netzwerkpfades-unter-windows-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find overlapping polygons with Python</title>
		<link>http://fabianmoser.at/blog/2009/04/30/find-overlapping-polygons-with-python/</link>
		<comments>http://fabianmoser.at/blog/2009/04/30/find-overlapping-polygons-with-python/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 09:11:10 +0000</pubDate>
		<dc:creator>Fabian Moser</dc:creator>
				<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Geometry]]></category>
		<category><![CDATA[Pylab]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.fabianmoser.at/?p=293</guid>
		<description><![CDATA[Yesterday I was confronted with a seemingly simple problem: how can one find out if the rectangles or, more general, polygons on a surface are overlapping or not? Surprisingly, because they have an amazing collection of tools, the matplotlib library &#8230; <a href="http://fabianmoser.at/blog/2009/04/30/find-overlapping-polygons-with-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was confronted with a seemingly simple problem: how can one find out if the rectangles or, more general, polygons on a surface are overlapping or not? Surprisingly, because they have an amazing collection of tools, the <a href="http://matplotlib.sourceforge.net/">matplotlib</a> library used in this context to actually draw the rectangles, doesn&#8217;t seem to have this kind of functionality. Of course there are loads of examples on the web for 2D collision detection, but I couldn&#8217;t find one written in Python. But nevertheless, I found <a href="http://www.cs.wustl.edu/~pless/546/lectures/lecture21.pdf">lecture notes</a> on <a href="http://www.cs.wustl.edu/~pless/">Robert Pless&#8217;s website</a>, which taught me the quadrant method to check if one point lies inside a polygon. Then it is only a small step to find if polygons are intersecting.</p>
<p>After writing a Python module providing the functionality, it naturally turned out to be rather slow on big numbers of polygons to be checked. So I continued to write a function which checks which polygons in a given set are overlapping or touching. To use the resources on my machine efficiently, I made two versions of this later function: one for conservative, serial processing and a second which uses <a href="http://www.parallelpython.com/">Parallel Python</a> to distribute the workload among the CPUs found in the system.</p>
<p>If someone else needs this kind of functionaltiy as well or simply is interested in how I did it, here is the interesting part. The whole file with unit tests and documentation can be downloaded as well: <a href="http://www.fabianmoser.at/files/2009/04/polygons_overlapping.py">polygons_overlapping.py</a></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> pylab
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> PolygonsTouching<span style="color: black;">&#40;</span> <span style="color: #008000;">Exception</span> <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; This exception is triggered when two polygons touch at one point.
&nbsp;
    This is for internal use only and will be caught before returning.
&nbsp;
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span> <span style="color: #008000;">self</span>, x=<span style="color: #ff4500;">0</span>, y=<span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">x</span>, <span style="color: #008000;">self</span>.<span style="color: black;">y</span> = x, y
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__str__</span><span style="color: black;">&#40;</span> <span style="color: #008000;">self</span> <span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'The tested polygons at least touch each other at (%f,%f)'</span>\
               <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span> <span style="color: #008000;">self</span>.<span style="color: black;">x</span>, <span style="color: #008000;">self</span>.<span style="color: black;">y</span> <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> shift<span style="color: black;">&#40;</span> <span style="color: #008000;">self</span>, dx, dy <span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">x</span> += dx
        <span style="color: #008000;">self</span>.<span style="color: black;">y</span> += dy
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> pair_overlapping<span style="color: black;">&#40;</span> polygon1, polygon2, digits = <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; Find out if polygons are overlapping or touching.
&nbsp;
    The function makes use of the quadrant method to find out if a point is
    inside a given polygon.
&nbsp;
    polygon1, polygon2 -- Two arrays of [x,y] pairs where the last and the
        first pair is the same, because the polygon has to be closed.
    digits -- The number of digits relevant for the decision between
        separate and touching or touching and overlapping
&nbsp;
    Returns 0 if the given polygons are neither overlapping nor touching,
    returns 1 if they are not overlapping, but touching and
    returns 2 if they are overlapping
&nbsp;
    &quot;&quot;&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> calc_walk_summand<span style="color: black;">&#40;</span> r1, r2, digits = <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot; Calculates the summand along one edge depending on axis crossings.
&nbsp;
        Follows the edge between two points and checks if one or both axes are
        being crossed. If They are crossed in clockwise sense, it returns +1
        otherwise -1. Going through the origin raises the PolygonsTouching
        exception.
&nbsp;
        Returns one of -2, -1, 0, +1, +2 or raises PolygonsTouching
&nbsp;
        &quot;&quot;&quot;</span>
        x, y = <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1</span> <span style="color: #808080; font-style: italic;"># indices for better readability</span>
        summand = <span style="color: #ff4500;">0</span> <span style="color: #808080; font-style: italic;"># the return value</span>
        tx, ty = <span style="color: #008000;">None</span>, <span style="color: #008000;">None</span> <span style="color: #808080; font-style: italic;"># on division by zero, set parameters to None</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> r1<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= r2<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span>:
            ty = r1<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> / <span style="color: black;">&#40;</span> r1<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> - r2<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># where it crosses the y axis</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> r1<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= r2<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span>:
            tx = r1<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> / <span style="color: black;">&#40;</span> r1<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> - r2<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># where it crosses the x axis</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> tx == <span style="color: #008000;">None</span>: tx = ty
        <span style="color: #ff7700;font-weight:bold;">if</span> ty == <span style="color: #008000;">None</span>: ty = tx
        rsign = pylab.<span style="color: black;">sign</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> digits <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span>:
            rsign = <span style="color: #ff7700;font-weight:bold;">lambda</span> x: pylab.<span style="color: black;">sign</span><span style="color: black;">&#40;</span> <span style="color: #008000;">round</span><span style="color: black;">&#40;</span> x, digits <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
        sign_x = rsign<span style="color: black;">&#40;</span> r1<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> + tx <span style="color: #66cc66;">*</span> <span style="color: black;">&#40;</span> r2<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> - r1<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
        sign_y = rsign<span style="color: black;">&#40;</span> r1<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> + ty <span style="color: #66cc66;">*</span> <span style="color: black;">&#40;</span> r2<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> - r1<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span> tx <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: black;">&#40;</span> tx <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">1</span> <span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span> sign_x == <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: black;">&#40;</span> sign_y == <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">raise</span> PolygonsTouching<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            summand += sign_x <span style="color: #66cc66;">*</span> pylab.<span style="color: black;">sign</span><span style="color: black;">&#40;</span> r2<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> - r1<span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span> ty <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: black;">&#40;</span> ty <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">1</span> <span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span> sign_x == <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: black;">&#40;</span> sign_y == <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">raise</span> PolygonsTouching<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            summand += sign_y <span style="color: #66cc66;">*</span> pylab.<span style="color: black;">sign</span><span style="color: black;">&#40;</span> r1<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> - r2<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> summand
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> current_and_next<span style="color: black;">&#40;</span> iterable <span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot; Returns an iterator for each element and its following element.
&nbsp;
        &quot;&quot;&quot;</span>
        iterator = <span style="color: #008000;">iter</span><span style="color: black;">&#40;</span> iterable <span style="color: black;">&#41;</span>
        item = iterator.<span style="color: black;">next</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> next <span style="color: #ff7700;font-weight:bold;">in</span> iterator:
            <span style="color: #ff7700;font-weight:bold;">yield</span> <span style="color: black;">&#40;</span> item, next <span style="color: black;">&#41;</span>
            item = next
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> point_in_polygon<span style="color: black;">&#40;</span> xy, xyarray, digits = <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot; Checks if a point lies inside a polygon using the quadrant method.
&nbsp;
        This moves the given point to the origin and shifts the polygon
        accordingly. Then for each edge of the polygon, calc_walk_summand is
        called. If the sum of all returned values from these calls is +4 or -4,
        the point lies indeed inside the polygon. Otherwise, if a
        PolygonsTouching exception has been caught, the point lies on ond of
        the edges of the polygon.
&nbsp;
        Returns the number of nodes of the polygon, if the point lies inside,
        otherwise 1 if the point lies on the polygon and if not, 0.
&nbsp;
        &quot;&quot;&quot;</span>
        moved = xyarray - xy <span style="color: #808080; font-style: italic;"># move currently checked point to the origin (0,0)</span>
        touching = <span style="color: #008000;">False</span> <span style="color: #808080; font-style: italic;"># this is used only if no overlap is found</span>
        walk_sum = <span style="color: #ff4500;">0</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> cnxy <span style="color: #ff7700;font-weight:bold;">in</span> current_and_next<span style="color: black;">&#40;</span> moved <span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">try</span>:
                walk_sum += calc_walk_summand<span style="color: black;">&#40;</span> cnxy<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, cnxy<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, digits <span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">except</span> PolygonsTouching, <span style="color: black;">&#40;</span>e<span style="color: black;">&#41;</span>:
                e.<span style="color: black;">shift</span><span style="color: black;">&#40;</span> <span style="color: #66cc66;">*</span>xy <span style="color: black;">&#41;</span>
                touching = <span style="color: #008000;">True</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span> <span style="color: #008000;">abs</span><span style="color: black;">&#40;</span> walk_sum <span style="color: black;">&#41;</span> == <span style="color: #ff4500;">4</span> <span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span> xyarray <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">elif</span> touching:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> polygons_overlapping<span style="color: black;">&#40;</span> p1, p2, digits = <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot; Checks if one of the nodes of p1 lies inside p2.
&nbsp;
        This repeatedly calls point_in_polygon for each point of polygon p1
        and immediately returns if it is the case, because then the polygons
        are obviously overlapping.
&nbsp;
        Returns 2 for overlapping polygons, 1 for touching polygons and 0
        otherwise.
&nbsp;
        &quot;&quot;&quot;</span>
        degree_of_contact = <span style="color: #ff4500;">0</span>
        xyarrays = <span style="color: black;">&#91;</span> p1, p2 <span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> xy <span style="color: #ff7700;font-weight:bold;">in</span> xyarrays<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>:
            degree_of_contact += point_in_polygon<span style="color: black;">&#40;</span> xy, xyarrays<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, digits <span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> degree_of_contact <span style="color: #66cc66;">&gt;</span>= <span style="color: #008000;">len</span><span style="color: black;">&#40;</span> xyarrays<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">2</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> degree_of_contact <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
    way1 = polygons_overlapping<span style="color: black;">&#40;</span> polygon1, polygon2, digits <span style="color: black;">&#41;</span>
    way2 = <span style="color: #ff4500;">0</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> way1 <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">2</span>: <span style="color: #808080; font-style: italic;"># Only if the polygons are not already found to be overlapping</span>
        way2 = polygons_overlapping<span style="color: black;">&#40;</span> polygon2, polygon1, digits <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">max</span><span style="color: black;">&#40;</span> way1, way2 <span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> collection_overlapping_serial<span style="color: black;">&#40;</span> polygons, digits = <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; Similar to the collection_overlapping function, but forces serial
    processing.
&nbsp;
    &quot;&quot;&quot;</span>
    result = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    pickle_polygons = <span style="color: black;">&#91;</span>p.<span style="color: black;">get_xy</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> polygons<span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span> polygons <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span> i+<span style="color: #ff4500;">1</span>, <span style="color: #008000;">len</span><span style="color: black;">&#40;</span> polygons <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>:
            result.<span style="color: black;">append</span><span style="color: black;">&#40;</span> <span style="color: black;">&#40;</span> i, j, \
                pair_overlapping<span style="color: black;">&#40;</span> pickle_polygons<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span>, pickle_polygons<span style="color: black;">&#91;</span>j<span style="color: black;">&#93;</span>, \
                                  digits <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> result
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> __cop_bigger_job<span style="color: black;">&#40;</span> polygons, index, digits = <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; This is a helper to efficiently distribute workload among processors.
&nbsp;
    &quot;&quot;&quot;</span>
    result = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span> index + <span style="color: #ff4500;">1</span>, <span style="color: #008000;">len</span><span style="color: black;">&#40;</span> polygons <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>:
        result.<span style="color: black;">append</span><span style="color: black;">&#40;</span> <span style="color: black;">&#40;</span> index, j, \
            pair_overlapping<span style="color: black;">&#40;</span> polygons<span style="color: black;">&#91;</span>index<span style="color: black;">&#93;</span>, polygons<span style="color: black;">&#91;</span>j<span style="color: black;">&#93;</span>, digits <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> result
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> collection_overlapping_parallel<span style="color: black;">&#40;</span> polygons, digits = <span style="color: #008000;">None</span>, \
        ncpus = <span style="color: #483d8b;">'autodetect'</span> <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; Like collection_overlapping, but forces parallel processing.
&nbsp;
    This function crashes if Parallel Python is not found on the system.
&nbsp;
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">import</span> pp
    ppservers = <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    job_server = pp.<span style="color: black;">Server</span><span style="color: black;">&#40;</span> ncpus, ppservers=ppservers <span style="color: black;">&#41;</span>
    pickle_polygons = <span style="color: black;">&#91;</span>p.<span style="color: black;">get_xy</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> polygons<span style="color: black;">&#93;</span>
    jobs = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span> polygons <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>:
        job = job_server.<span style="color: black;">submit</span><span style="color: black;">&#40;</span> __cop_bigger_job, \
                                 <span style="color: black;">&#40;</span> pickle_polygons, i, digits, <span style="color: black;">&#41;</span>, \
                                 <span style="color: black;">&#40;</span> pair_overlapping, PolygonsTouching, <span style="color: black;">&#41;</span>, \
                                 <span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;pylab&quot;</span>, <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
        jobs.<span style="color: black;">append</span><span style="color: black;">&#40;</span> job <span style="color: black;">&#41;</span>
    result = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> job <span style="color: #ff7700;font-weight:bold;">in</span> jobs:
        result += job<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;">#job_server.print_stats()</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> result
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> collection_overlapping<span style="color: black;">&#40;</span> polygons, digits = <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; Look for pair-wise overlaps in a given list of polygons.
&nbsp;
    The function makes use of the quadrant method to find out if a point is
    inside a given polygon. It invokes the pair_overlapping function for each
    combination and produces and array of index pairs of these combinations
    together with the overlap number of that pair. The overlap number is 0 for
    no overlap, 1 for touching and 2 for overlapping polygons.
&nbsp;
    This function automatically selects between a serial and a parallel
    implementation of the search depending on whether Parallel Python is
    installed and can be imported or not.
&nbsp;
    polygons -- A list of arrays of [x,y] pairs where the last and the first
        pair of each array in the list is the same, because the polygons have
        to be closed.
    digits -- The number of digits relevant for the decision between
        separate and touching or touching and overlapping polygons.
&nbsp;
    Returns a list of 3-tuples
&nbsp;
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        <span style="color: #ff7700;font-weight:bold;">import</span> pp <span style="color: #808080; font-style: italic;"># try if parallel python is installed</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">ImportError</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> collection_overlapping_serial<span style="color: black;">&#40;</span> polygons, digits <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> collection_overlapping_parallel<span style="color: black;">&#40;</span> polygons, digits <span style="color: black;">&#41;</span></pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>http://fabianmoser.at/blog/2009/04/30/find-overlapping-polygons-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

