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

<channel>
	<title>byCycle.org &#187; Data</title>
	<atom:link href="http://info.bycycle.org/category/data/feed/" rel="self" type="application/rss+xml" />
	<link>http://info.bycycle.org</link>
	<description>Get There by Cycle!</description>
	<lastBuildDate>Fri, 02 Sep 2011 07:28:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Using PostGIS with SQLAlchemy</title>
		<link>http://info.bycycle.org/2007/01/29/using-postgis-with-sqlalchemy/</link>
		<comments>http://info.bycycle.org/2007/01/29/using-postgis-with-sqlalchemy/#comments</comments>
		<pubDate>Tue, 30 Jan 2007 06:35:17 +0000</pubDate>
		<dc:creator>Wyatt</dc:creator>
				<category><![CDATA[Core]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Pylons]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SQLAlchemy]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Trip Planner]]></category>

		<guid isPermaLink="false">http://bycycle.org/2007/01/29/using-postgis-with-sqlalchemy/</guid>
		<description><![CDATA[The development version of the Trip Planner uses a Postgres/PostGIS backend (instead of MySQL) SQLAlchemy as the ORM (instead of raw SQL), and PCL for Python geometry types (instead of our own ugly hacked versions). Question: How do you move &#8230; <a href="http://info.bycycle.org/2007/01/29/using-postgis-with-sqlalchemy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The development version of the Trip Planner uses a Postgres/<a title="PostGIS" href="http://postgis.refractions.net/">PostGIS</a> backend (instead of MySQL) <a title="SQLAlchemy" href="http://www.sqlalchemy.org/">SQLAlchemy</a> as the ORM (instead of raw SQL), and <a title="Python Cartographic Library" href="http://trac.gispython.org/projects/PCL">PCL</a> for Python geometry types (instead of our own ugly hacked versions).</p>
<p>Question: How do you move geometries out of Postgres/PostGIS into PCL types via SQLAlchemy and vice versa?</p>
<p>Answer: Create a custom geometry column type.</p>
<p>Here&#8217;s our SQLAlchemy geometry type definition and subtypes (points, linestrings, and multilinestrings; adding other types should be trivial):</p>
<p><a title="Code: Geometry Types" href="http://project.bycycle.org/browser/Core/trunk/bycycle/core/model/data/sqltypes.py">sqltypes.py </a></p>
<p>Look here for an example of using it:</p>
<p><a title="Code: Example Usage of Geometry Types" href="http://project.bycycle.org/browser/Core/trunk/bycycle/core/model/portlandor/__init__.py">tables.py</a></p>
<p>The type is pretty simple. The only tricky part was figuring out how the database stores the geometry. It&#8217;s in ASCII hex, so we use binascii.a2b_hex to get a binary representation and feed that to the PCL fromWKB factory. In the other direction we use binascii.b2a_hex on the WKB representation of the PCL geometry.</p>
<p><em>[8/7/09: Updated links to source code. Note: latest version uses Shapely, not PCL.]</em></p>
]]></content:encoded>
			<wfw:commentRss>http://info.bycycle.org/2007/01/29/using-postgis-with-sqlalchemy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Test Driven Development, PostgreSQL, SQLAlchemy</title>
		<link>http://info.bycycle.org/2006/09/13/test-driven-development-postgresql-sqlalchemy/</link>
		<comments>http://info.bycycle.org/2006/09/13/test-driven-development-postgresql-sqlalchemy/#comments</comments>
		<pubDate>Thu, 14 Sep 2006 04:35:51 +0000</pubDate>
		<dc:creator>Wyatt</dc:creator>
				<category><![CDATA[Core]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SQLAlchemy]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://bycycle.org/blog/2006/09/13/test-driven-development-postgresql-sqlalchemy/</guid>
		<description><![CDATA[I just tried out some o&#8217; that new-fangle &#8220;Test Driven Development&#8221; (TDD) I&#8217;ve been hearing about. Yeah, it&#8217;s good stuff. At the moment, I&#8217;m in the process of migrating GIS data from MySQL to PostgreSQL so we can take advantage &#8230; <a href="http://info.bycycle.org/2006/09/13/test-driven-development-postgresql-sqlalchemy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just tried out some o&#8217; that new-fangle &#8220;Test Driven Development&#8221; (TDD) I&#8217;ve been hearing about. Yeah, it&#8217;s good stuff.</p>
<p>At the moment, I&#8217;m in the process of migrating GIS data from MySQL to PostgreSQL so we can take advantage of the PostGIS spatial extensions. I&#8217;ve also been making a bunch of related changes (AKA refactoring) in the &#8220;model&#8221;, separating things that never belonged together, and so forth.</p>
<p>I started out by rewriting the MySQL data import script. [Note: basically, the script pulls data out of a flat ESRI shapefile and normalizes it.] This wasn&#8217;t a complete, from-scratch rewrite&#8211;a lot of stuff I just copied over and tweaked a little bit. The biggest changes here were due to using SQLAlchemy instead of typing out SQL queries. I&#8217;ll just note that SQLAlchemy is &#8220;da bomb&#8221; and makes many things easier (once you get the hang of it).</p>
<p>That part was pretty straightforward, and low-level&#8211;I didn&#8217;t get into the ORM aspects of SQLAlchemy at all.</p>
<p>The next step was to modify the routine that creates adjacency matrices for routing. In the end, this was straightforward too. I ended up reusing some stuff from the new import script, which was cool. I refactored a lot during this process, adding some new modules and classes.</p>
<p>[Here's where we get to the TDD aspect.]</p>
<p>So, I was sitting there <em>(here</em> really) thinking, &#8220;Hmmm&#8230; what now?&#8221; I drew some diagrams with the new classes and associations&#8230;. OK, that&#8217;s fun&#8230;. &#8220;Wait, I know. Run the unit tests!&#8221; Doy!</p>
<p>I started with the address normalization service, since the other services both depend on it. The test suite for this service isn&#8217;t as  comprehensive as it probably should be (there are 19 tests),  but it proved to very useful for shaking out a bunch of bugs in all that refactoring. The tests also helped keep me <em>focused</em>, and that aspect might be more important than the bug-squashing aspect (maybe).</p>
<p>Today, address normalization. Tomorrow, geocoding.</p>
]]></content:encoded>
			<wfw:commentRss>http://info.bycycle.org/2006/09/13/test-driven-development-postgresql-sqlalchemy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Portland Data Update</title>
		<link>http://info.bycycle.org/2006/08/30/portland-data-update/</link>
		<comments>http://info.bycycle.org/2006/08/30/portland-data-update/#comments</comments>
		<pubDate>Thu, 31 Aug 2006 04:52:37 +0000</pubDate>
		<dc:creator>Wyatt</dc:creator>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[Meta]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Trip Planner]]></category>

		<guid isPermaLink="false">http://bycycle.org/blog/2006/08/30/portland-data-update/</guid>
		<description><![CDATA[A couple days ago we updated the Portland region data. This was like a bug-fix release for software&#8211;no major changes were made, but a lot of little things here and there were improved and/or fixed. Related to this (but still &#8230; <a href="http://info.bycycle.org/2006/08/30/portland-data-update/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A couple days ago we updated the Portland region data. This was like a bug-fix release for software&#8211;no major changes were made, but a lot of little things here and there were improved and/or fixed.</p>
<p>Related to this (but still quite separate), we improved (hopefully!) the way routes are found. In particular, we made big changes for when the safer option is selected.</p>
<p>Please let us know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://info.bycycle.org/2006/08/30/portland-data-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

