Skip to content

Commit

Permalink
#33 Add test case for filter_layer translations returning None
Browse files Browse the repository at this point in the history
  • Loading branch information
roelderickx committed Sep 10, 2023
1 parent 8a282f8 commit a70e3c4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/basic_geometries_filterlayer.pbf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="osmconvert 0.8.10">
</osm>
3 changes: 3 additions & 0 deletions test/basic_geometries_filterlayer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="ogr2osm 1.1.2" upload="false">
</osm>
12 changes: 12 additions & 0 deletions test/osm_output.t
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,15 @@ shiftjis:
Writing file footer
$ xmllint --format shift-jis.osm | diff -uNr - $TESTDIR/shift-jis.xml

basicgeometriesfilterlayer:
$ ogr2osm -t $TESTDIR/translations/filterlayer-translation.py -f $TESTDIR/shapefiles/basic_geometries.kml
Found valid translation class FilterLayerTranslation
Preparing to convert .* (re)
Splitting long ways
Writing file header
Writing nodes
Writing ways
Writing relations
Writing file footer
$ xmllint --format basic_geometries.osm | diff -uNr - $TESTDIR/basic_geometries_filterlayer.xml

12 changes: 12 additions & 0 deletions test/pbf_output.t
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,15 @@ shiftjis:
\[.[0-9]\] (re)
$ xmllint --format shift-jis.osm | diff -uNr - $TESTDIR/shift-jis.pbf.xml

basicgeometriesfilterlayer:
$ ogr2osm --pbf -t $TESTDIR/translations/filterlayer-translation.py -f $TESTDIR/shapefiles/basic_geometries.kml
Found valid translation class FilterLayerTranslation
Preparing to convert .* (re)
Splitting long ways
Writing file header
Writing nodes
Writing ways
Writing relations
$ osmconvert --drop-author basic_geometries.osm.pbf > basic_geometries.osm 2> /dev/null
$ xmllint --format basic_geometries.osm | diff -uNr - $TESTDIR/basic_geometries_filterlayer.pbf.xml

21 changes: 21 additions & 0 deletions test/translations/filterlayer-translation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-

'''
Copyright (c) 2012-2021 Roel Derickx, Paul Norman <penorman@mac.com>,
Sebastiaan Couwenberg <sebastic@xs4all.nl>, The University of Vermont
<andrew.guertin@uvm.edu>, github contributors
Released under the MIT license, as given in the file LICENSE, which must
accompany any distribution of this code.
'''

import ogr2osm, logging

class FilterLayerTranslation(ogr2osm.TranslationBase):
def __init__(self):
self.logger = logging.getLogger('ogr2osm')


def filter_layer(self, layer):
# suppress all layers
return None

0 comments on commit a70e3c4

Please sign in to comment.