simonw / shapefile-to-sqlite

Load shapefiles into a SQLite (optionally SpatiaLite) database
Apache License 2.0
28 stars 4 forks source link

--spatial-index option #8

Closed simonw closed 4 years ago

simonw commented 4 years ago

I'm not convinced this works. I tried it on macOS and got this:

Traceback (most recent call last):
  File "/Users/simon/.local/share/virtualenvs/shapefile-to-sqlite-momIhBan/bin/sqlite-utils", line 8, in <module>
    sys.exit(cli())
  File "/Users/simon/.local/share/virtualenvs/shapefile-to-sqlite-momIhBan/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/simon/.local/share/virtualenvs/shapefile-to-sqlite-momIhBan/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/simon/.local/share/virtualenvs/shapefile-to-sqlite-momIhBan/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/simon/.local/share/virtualenvs/shapefile-to-sqlite-momIhBan/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/simon/.local/share/virtualenvs/shapefile-to-sqlite-momIhBan/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/simon/.local/share/virtualenvs/shapefile-to-sqlite-momIhBan/lib/python3.8/site-packages/sqlite_utils/cli.py", line 744, in query
    db.conn.load_extension(ext)
sqlite3.OperationalError: dlopen(SPATIALITE.dylib, 10): image not found
simonw commented 4 years ago

But the new test did pass in Circle CI:

tests/test_shapefile_to_sqlite.py::test_missing PASSED                   [ 16%]
tests/test_shapefile_to_sqlite.py::test_import_features[None] PASSED     [ 33%]
tests/test_shapefile_to_sqlite.py::test_import_features[customtable] PASSED [ 50%]
tests/test_shapefile_to_sqlite.py::test_import_features_spatialite PASSED [ 66%]
tests/test_shapefile_to_sqlite.py::test_import_features_spatialite_with_custom_crs PASSED [ 83%]
tests/test_shapefile_to_sqlite.py::test_import_features_spatial_index PASSED [100%]

============================== 6 passed in 0.75s ===============================

Maybe my Python / SpatiaLite environment on my Mac is messed up somehow?

simonw commented 4 years ago

The tests pass on my Mac too.

simonw commented 4 years ago

Managed to successfully test this on Mac:

shapefile-to-sqlite with_index.db shape/scc_trails.shp --spatial-index