Translation failing 'filter_layer()'
Bandit253 opened this issue · 2 comments
Bandit253 commented
When I try my translation file I get
TypeError: TranslationBase.filter_layer() missing 1 required positional argument: 'layer'
but it works without error when I use the base class, I have tried to copy the base class def of filter_layer to mine and still fails.
from DTP_OSM import InitialMatch
infile = r'match_result.shp'
outfile = r'match_result.osm.pbf'
translation_object = InitialMatch
# translation_object = ogr2osm.TranslationBase()
datasource = ogr2osm.OgrDatasource(translation_object)
datasource.open_datasource(infile)
osmdata = ogr2osm.OsmData(translation_object)
osmdata.process(datasource) # <<<--- Error here
datawriter = ogr2osm.OsmDataWriter(outfile)
osmdata.output(datawriter)
the above code is pretty much exactly the example.
This is my Translation file
import ogr2osm
class InitialMatch(ogr2osm.TranslationBase):
def filter_tags(self, attrs):
if not attrs:
return
tags = {}
if 'EZI_ROAD_NAME_LABLE' in attrs:
tags['name'] = attrs['EZI_ROAD_NAME_LABLE'].title()
if 'road_class' in attrs:
tags['highway'] = attrs['road_class']
return tags
roelderickx commented
Hi,
I think the error message is a bit misleading. The problem is that there is no instance of your translation class, as such translation_object
is a class in stead of an object.
Try changing translation_object = InitialMatch
into translation_object = InitialMatch()
.
Bandit253 commented
Thanks so much, such a noob mistake.