I believe the answer to this question has now changed. As of MySQL 5.6, there is now a fully-featured OpenGIS geospatial feature set in MySQL (it's not even an extension; it's built in). Thus, from a purely theoretical standpoint, there's no reason you can't import the OSM data into MySQL using the standard, supported database schema that you'd use for PostgreSQL (with syntax changed as necessary, of course). In fact, this presentation (which still refers to an older, incomplete version of MySQL's OpenGIS support) suggests that, with proper indexing, some MySQL geospatial actions may actually perform better than PostgreSQL PostGIS, though I'm sure that's up for debate. So the remaining problem is import tooling...
Currently, there's no official osm2mysql
equivalent to osm2pgsql
. There are a couple of projects out there named osm2mysql
, but I've seen people have only moderate—if any—success using those projects. However, GDAL's open source ogr2ogr
appears to be a very viable solution.
I downloaded, compiled, and installed ogr2ogr
and was able to import a shapefile into a geospatial schema in MySQL, and successfully (and apparently accurately) query against the data using things like ST_Contains(...)
. I have not yet tried OSM (that's my next step), but ogr2ogr
claims to have full support for OSM (XML and binary), so given my success with shapefiles, I imagine I'll have similar success with OSM.
I did have some initial problems, one of which was likely related to my not using make clean
between configure
attempts, and the others which were related to the large queries involved (some inserts > 1MB) and some MySQL settings that needed adjusting to compensate. You can view the details of my solutions in this mailing list thread.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…