[Imports] Rewritten ogr2osm
Josh Doe
josh at joshdoe.com
Thu Feb 16 17:44:27 UTC 2012
On Thu, Feb 16, 2012 at 12:22 PM, Andrew Guertin <andrew.guertin at uvm.edu> wrote:
> Hi,
>
> For some files I was working with, I was struggling with some bugs and
> limitations in ogr2osm. And since I wasn't smart enough to fix the
> problems, I just got rid of them by rewriting.
>
>
> The three major changes I've made with the rewrite are:
>
> 1) Changed the internal representation of objects.
>
> In OGR, features are the important objects, and geometries only exist as
> parts of features. In OSM, geometries are the important objects, and
> features are just tags on top of geometries.
>
> In the current ogr2osm, the OGR feature is maintained in the data until
> output. In the rewritten version, the OSM model is more quickly bought
> in to, and features are maintained as simply lists of tags with a
> pointer to a geometry they should be placed on.
>
> 2) Changed the data structures used to represent the objects
>
> Instead of using a bunch of arrays with matching indexes, I've made
> classes for the various geometries and the features, and each feature or
> geometry is an object.
>
> 3) Added in more object and tag filtering options
>
> I needed to filter out some things from my input that were irrelevant,
> and to do some more complex things like setting one object's tags based
> on the information from the closest object of a different type.
>
>
> I've tried to keep the interface as similar to the old version as
> possible. Most of the options parsing code, in fact, has been copied
> with only minimal rearrangement. The attribute translation will, of
> course, be different, but uses the same mechanism.
>
> A few things the old version had I haven't (yet?) implemented. In
> particular, the code that looks for shared way segments isn't there yet.
> It should be easy enough to implement, but I didn't need it for my data
> and didn't want to keep the code hidden. I also did not reimplement the
> tag statistics.
>
> I've published on github at https://github.com/andrewguertin/ogr2osm .
>
> I'm open to any comments, positive or negative, so let me know what you
> think.
I just took a quick look at it, and it seems like a very nice
improvement to me, especially the cleaner (and more Pythonic) code and
the versatile filtering. If we can reimplement the shared-way to
multipolygon conversion, I'd say this should be merged with the "main"
ogr2osm. It would help to check for existence of the old
translateAttributes to be backwards compatible. I'll try and test it
this weekend.
-Josh
More information about the Imports
mailing list