-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you open older .BAG files? #90
Comments
Hi @heathhenley thanks for posting this. This looks like a bug. I'll have a look over the next few working days and get back to you. |
@heathhenley I finally had a chance to look at this, sorry for the delay. Can you tell me what version of Python you are using? When I open |
Thanks for looking into this! I'm still not convinced that I didn't just miss something, I don't usually use conda so I'm winging it there. I know at least in experience, windows is always weird with open source gis tools (gdal etc) too. I must have torched my set up from last time, so I set up to try it again today on windows 11, here's what I did:
I can run the tests, but I get 4 fails and an error, I haven't dug into them at all: ================================================================= short test summary info =================================================================
FAILED python/test_compat_gdal.py::TestCompatGDAL::test_gdal_create_simple - SystemError: _PyErr_SetObject: exception <class 'bagPy.MetadataNotFound'> is not a BaseException subclass
FAILED python/test_dataset.py::TestDataset::testGetLayerTypes - bagPy.ErrorLoadingMetadata
FAILED python/test_interleavedlegacylayer.py::TestInterleavedLegacyLayer::testGetLayerAndRead - bagPy.ErrorLoadingMetadata
FAILED python/test_simplelayer.py::TestSimpleLayer::testRead - bagPy.ErrorLoadingMetadata
ERROR python/test_compat_gdal.py::TestCompatGDAL::test_gdal_create_simple - PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\heath\\AppData\\Local\\Temp\...
=================================================== 4 failed, 91 passed, 20 warnings, 1 error in 1.54s ==================================================== But three of them maybe related to the original problem I had. There was a problem in the geodjango /gdal tests on windows related to files not being allowed to be opened more than once on windows (without being closed), mac/linux doesn't care, maybe that's what's going on with the permission error, I didn't dig in. To actually answer your question I'm using 3.12.2: (base) c:\dev\BAG>python
Python 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:42:31) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bagPy
>>> dataset = bagPy.Dataset.openDataset(r"C:\dev\BAG\examples\sample-data\sample-2.0.1.bag", bagPy.BAG_OPEN_READ_WRITE)
>>> dataset = bagPy.Dataset.openDataset(r"C:\dev\BAG\examples\sample-data\sample-1.5.0.bag", bagPy.BAG_OPEN_READ_WRITE)
Entity: line 17: parser error : Extra content at the end of the document
erNote></gmd:MD_SecurityConstraints></gmd:metadataConstraints></gmi:MI_Metadata>
^
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\heath\miniconda3\Lib\site-packages\bagPy\__init__.py", line 9401, in openDataset
return _bagPy.Dataset_openDataset(fileName, openMode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bagPy.ErrorLoadingMetadata |
Greetings, Here is the code I was running: I tried it with Python versions 3.8, 3.9, and 3.12. Seeing the same error with all of those conda environments. |
I was able to open a 2022 BAG file, but nothing older than that as far as I know. |
@selimnairb, I had a similar issue in Python using lxml to parse the xml in the BAG files. |
@giumas @stephen-patterson-noaa Can you confirm whether you are seeing this error with any of the sample BAGs in examples/sample-data? |
I tried to open each of the sample BAG files in examples/sample-data and view their layers.
|
@selimnairb, this minimal script replicates the issue without using BagPy:
If I run it using old versions of libxml, it works as is (
However, the same script fails when executed in a more recent version of libxml:
However, if you switch the flag (
So my suggestion is to always |
Thank you @giumas for the helpful test case. @stephen-patterson-noaa @heathhenley we're working on a bug-fix release and will address this issue. This will likely happen as part of this PR. We hope to have this ready in the next few of weeks. Thanks for your interest and contributions! |
@heathhenley @giumas @stephen-patterson-noaa I merged #104, which fixes the Python wheel testing on Windows and adds a test case for opening a BAG 1.5 file. Can you give the latest code in master a try and reconfirm the problems you were seeing before? You can now relatively easily build BAG C++ and Python libraries without using Conda on Windows using the scripts documented here. Let me know if you run into any problems. Thanks! |
@selimnairb I reviewed the changes a couple different ways. The "test_compat_bag15.py" passes when run inside the docker container. I also tried to update/reinstall the bagPy library v2.0.3(build py312h4cf4972_1) through conda and it is still showing me the same error message below about extra content when using Python 3.12.2 on Windows: Entity: line 17: parser error : Extra content at the end of the document self = <test_compat_bag15.TestCompatBAG15 testMethod=test_open_read_write>
|
Thanks @stephen-patterson-noaa. I'll test using conda. It may be related to the version(s) of libxml2 that conda includes... |
…ersion of libxml2 before pushing fix
@stephen-patterson-noaa @giumas I have a PR that fixes the libxml2 issue you were running into. Once this is merged and a new release is made, this will make its way into the conda packages. In the mean time, I wanted you to be aware of the fix in case you needed to deploy from GitHub. |
@heathhenley @stephen-patterson-noaa @giumas BAG [release-2.0.4[(https://github.com/OpenNavigationSurface/BAG/releases/tag/release-2.0.4) was released yesterday, which should fix the libxml2 incompatibility. It is available for install via conda-forge. When you have a chance, please re-run the tests you were running above to verify that things are now working as expected. |
I'm looking to read in some surveys and I'm exploring using the your python bindings here to do it. I came across this xml parse error (
Extra content at the end of the document
) trying to read .BAGs from H12025 and W00426.I'm assuming there's some error with my set up or understanding of how to use it, as I see the same behavior with the
sample-1.5.0.bag
in the repo's examples:If anyone can help me understand what I've missed I would appreciate it.
I'm seeing the same error with the real data, but not failing on the same xml tag, for example:
I am able to parse and manipulate both of those BAGs with the tools in https://github.com/hydroffice/hyo2_bag - so that's an option too, but this package just seemed to be more actively maintained and documented.
The text was updated successfully, but these errors were encountered: