Skip to content

Commit

Permalink
adjust travis builds, add osx build
Browse files Browse the repository at this point in the history
add cli.bounds test

tracking down these GDAL_DATA files
  • Loading branch information
fitnr committed Dec 3, 2017
1 parent 7241620 commit 16a84a9
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 35 deletions.
80 changes: 56 additions & 24 deletions .travis.yml
Expand Up @@ -3,59 +3,91 @@

# Licensed under the GNU General Public License v3 (GPLv3) license:
# http://opensource.org/licenses/GPL-3.0
# Copyright (c) 2016, Neil Freeman <contact@fakeisthenewreal.org>
# Copyright (c) 2016-7, Neil Freeman <contact@fakeisthenewreal.org>

language: python

python:
- 2.7
- 3.4
- 3.5
- 3.6
- 2.7
- 3.4
- 3.5
- 3.6

os:
- linux
- linux

git:
depth: 3

sudo: true

env:
- SIMPLIFY=yes
- CLIP=yes
- SIMPLIFY= CLIP=
- GDAL=gdal
- GDAL=gdal1
- GDAL=gdal EXTRAS=yes
- GDAL=gdal1 EXTRAS=yes

matrix:
exclude:
- python: 3.3
env: SIMPLIFY=yes
- python: 3.3
env: CLIP=yes
- python: 3.4
env: SIMPLIFY=yes
- python: 3.4
env: CLIP=yes
- env: GDAL=gdal EXTRAS=yes
python: 3.4

- env: GDAL=gdal1 EXTRAS=yes
python: 3.4

- env: GDAL=gdal EXTRAS=yes
python: 3.5

- env: GDAL=gdal1 EXTRAS=yes
python: 3.5

allow_failures:
- os: osx

include:
- language: generic
os: osx
env: PYTHON3
before_install:
- brew --version
- brew install python gdal
- virtualenv env -p python
- source env/bin/activate

- language: generic
os: osx
env: PYTHON
before_install:
- brew --version
- brew install python3 gdal
- virtualenv env -p python3
- source env/bin/activate

cache:
directories:
- $HOME/.cache/pip

before_install:
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get -qq update; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get -qq install -y libgdal1-dev gdal-bin; fi
- pip install docutils coverage python-coveralls
- if [[ $SIMPLIFY != "yes" ]]; then pip uninstall -y numpy visvalingamwyatt || :; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get -q update; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get -q install -y lib${GDAL}-dev ; fi
- if [[ $TRAVIS_PYTHON_VERSION != 3.6 ]]; then export GDAL_DATA=/usr/share/gdal/1.10 PROJ_LIB=/usr/share/proj ; fi
- if [[ -z "$EXTRAS" ]]; then pip uninstall -y numpy visvalingamwyatt || :; fi

install:
- make
- python setup.py install
- if [[ $CLIP == "yes" ]]; then pip install .[clip]; fi
- if [[ $SIMPLIFY == "yes" ]]; then pip install .[simplify]; fi
- if [[ $EXTRAS == "yes" ]]; then pip install .[clip,simplify]; fi

before_script:
- gdalinfo --version
- pip list
- fio --version
- fio --gdal-version
- fio info tests/test_data/cb_2014_us_nation_20m.json

after_failure:
- echo $GDAL_DATA $PROJ_LIB
- fio info --indent 2 tests/test_data/cb_2014_us_nation_20m.json
- fio info --indent 2 tests/test_data/tl_2015_11_place.json

script:
- make test QUIET=
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -36,9 +36,8 @@ test: $(TIGERS) tests/test_data/test.svg tests/test_data/zip.svg
svgis project -m local -- $(wordlist 1,2,$(coords))
svgis graticule -s 1 -- $(coords) | wc -l
svgis bounds $<
-svgis bounds - < $<
-svgis draw -f 1000 -j utm $< | wc -l
svgis bounds - < $< | \
svgis bounds $< | \
xargs -n4 svgis draw -f 1000 -j '$(PROJECTION)' $< -b | \
svgis style -c 'polygon{fill:green}' | \
svgis scale -f 10 - | wc
Expand All @@ -47,6 +46,8 @@ test: $(TIGERS) tests/test_data/test.svg tests/test_data/zip.svg
coverage report
coverage html

-svgis bounds - < $<

tests/test_data/zip.svg: tests/test_data/test.zip $(TIGERS)
svgis draw $(addprefix zip://$</,$(filter %.json,$^)) | \
svgis style -c 'polygon{fill:green}' | \
Expand Down
2 changes: 0 additions & 2 deletions svgis/cli.py
Expand Up @@ -121,8 +121,6 @@ def scale(layer, output, **kwargs):
def bounds(layer, crs, latlon=False):
'''
Return the bounds for a given layer, optionally projected.
Use - for stdin.
'''
meta = meta_complete(layer)

Expand Down
2 changes: 1 addition & 1 deletion svgis/style.py
Expand Up @@ -75,7 +75,7 @@ def pick(style):
with open(style) as f:
return f.read()

except AttributeError:
except (AttributeError, TypeError):
# Probably style is None.
return None

Expand Down
9 changes: 7 additions & 2 deletions tests/test_cli.py
Expand Up @@ -36,8 +36,8 @@ def setUp(self):
self.assertTrue(os.path.exists(self.fixture))
self.assertTrue(os.path.exists(self.shp))

def invoke(self, argument):
return self.runner.invoke(svgis.cli.main, argument, catch_exceptions=False)
def invoke(self, argument, **kwargs):
return self.runner.invoke(svgis.cli.main, argument, catch_exceptions=False, **kwargs)

def testSvgStyle(self):
sys.stdout = io.StringIO()
Expand All @@ -57,6 +57,11 @@ def testSvgScale(self):
finally:
os.remove('tmp.svg')

def testBounds(self):
result = self.invoke(['bounds', self.shp])
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output.strip(), '-179.174265 17.913769 179.773922 71.352561')

def testSvgProjectUtm(self):
p = self.invoke(['project', '--method', 'utm', '--', '-110.277906', '35.450777', '-110.000477', '35.649030'])
expected = set('+proj=utm +zone=12 +datum=WGS84 +units=m +no_defs'.split(' '))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_data/tl_2015_11_place.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_style.py
Expand Up @@ -113,7 +113,7 @@ def testPickStyle(self):
result = style.pick(self.css)
self.assertEqual(self.css, result)

assert style.pick(None) is None
self.assertIsNone(style.pick(None))

def testAddCli(self):
result = style.add_style(self.file, self.css)
Expand Down

0 comments on commit 16a84a9

Please sign in to comment.