[Git][debian-gis-team/glymur][master] 4 commits: New upstream version 0.11.3

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Wed Aug 17 18:03:44 BST 2022



Antonio Valentino pushed to branch master at Debian GIS Project / glymur


Commits:
6136ba06 by Antonio Valentino at 2022-08-17T16:56:21+00:00
New upstream version 0.11.3
- - - - -
918288f4 by Antonio Valentino at 2022-08-17T16:56:25+00:00
Update upstream source from tag 'upstream/0.11.3'

Update to upstream version '0.11.3'
with Debian dir c8eeb0647c1869cd927ff846dbb44a861d8c8bf3
- - - - -
19f4eaf4 by Antonio Valentino at 2022-08-17T16:57:04+00:00
New upstream release

- - - - -
b9830622 by Antonio Valentino at 2022-08-17T16:57:51+00:00
Set distribution to unstable

- - - - -


11 changed files:

- CHANGES.txt
- debian/changelog
- docs/source/conf.py
- docs/source/whatsnew/0.11.rst
- glymur/jp2k.py
- glymur/version.py
- setup.cfg
- tests/test_jp2box_uuid.py
- tests/test_jp2k.py
- tests/test_tiff2jp2.py
- tests/test_writing_tiles.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,3 +1,6 @@
+August 16, 2022 - v0.11.3
+    Fix placement of Resolutionbox
+
 August 9, 2022 - v0.11.2
     Relax ResolutionBox requirement on child boxes.
 


=====================================
debian/changelog
=====================================
@@ -1,8 +1,9 @@
-glymur (0.11.2-2) UNRELEASED; urgency=medium
+glymur (0.11.3-1) unstable; urgency=medium
 
+  * New upstream release.
   * Use a more generic glob pattern in d/not-installed.
 
- -- Antonio Valentino <antonio.valentino at tiscali.it>  Sat, 13 Aug 2022 15:32:34 +0000
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Wed, 17 Aug 2022 16:57:25 +0000
 
 glymur (0.11.2-1) unstable; urgency=medium
 


=====================================
docs/source/conf.py
=====================================
@@ -78,7 +78,7 @@ copyright = '2013-2022, John Evans'
 # The short X.Y version.
 version = '0.11'
 # The full version, including alpha/beta/rc tags.
-release = '0.11.2'
+release = '0.11.3'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


=====================================
docs/source/whatsnew/0.11.rst
=====================================
@@ -2,6 +2,11 @@
 Changes in glymur 0.11
 ######################
 
+*****************
+Changes in 0.11.3
+*****************
+    * Fix placement of ResolutionBox
+
 *****************
 Changes in 0.11.2
 *****************


=====================================
glymur/jp2k.py
=====================================
@@ -13,6 +13,7 @@ from itertools import filterfalse
 import ctypes
 import pathlib
 import re
+import shutil
 import struct
 from uuid import UUID
 import warnings
@@ -285,34 +286,37 @@ class Jp2k(Jp2kBox):
             return
 
         # So we DO have extra boxes.  Handle them, and THEN parse.
-        self._append_resolution_superbox()
         self.parse()
+        self._insert_resolution_superbox()
 
-    def _append_resolution_superbox(self):
+    def _insert_resolution_superbox(self):
         """
-        As a close-out task, append a resolution superbox to the end of the
-        file if we were so instructed.
+        As a close-out task, insert a resolution superbox into the jp2
+        header box if we were so instructed.  This requires a wrapping
+        operation.
         """
-        with open(self.filename, mode='ab') as f:
-
-            extra_boxes = []
+        jp2h = [box for box in self.box if box.box_id == 'jp2h'][0]
 
-            if self._capture_resolution is not None:
-                resc = glymur.jp2box.CaptureResolutionBox(
-                    self._capture_resolution[0], self._capture_resolution[1],
-                )
-                extra_boxes.append(resc)
+        extra_boxes = []
+        if self._capture_resolution is not None:
+            resc = glymur.jp2box.CaptureResolutionBox(
+                self._capture_resolution[0], self._capture_resolution[1],
+            )
+            extra_boxes.append(resc)
 
-            if self._display_resolution is not None:
-                resd = glymur.jp2box.DisplayResolutionBox(
-                    self._display_resolution[0], self._display_resolution[1],
-                )
-                extra_boxes.append(resd)
+        if self._display_resolution is not None:
+            resd = glymur.jp2box.DisplayResolutionBox(
+                self._display_resolution[0], self._display_resolution[1],
+            )
+            extra_boxes.append(resd)
 
-            rbox = glymur.jp2box.ResolutionBox(extra_boxes)
-            rbox.write(f)
+        rbox = glymur.jp2box.ResolutionBox(extra_boxes)
+        jp2h.box.append(rbox)
 
-            # self.box.append(rbox)
+        temp_filename = self.filename + '.tmp'
+        self.wrap(temp_filename, boxes=self.box)
+        shutil.move(temp_filename, self.filename)
+        self.parse()
 
     def _validate_kwargs(self):
         """


=====================================
glymur/version.py
=====================================
@@ -21,7 +21,7 @@ from .lib import tiff
 
 # Do not change the format of this next line!  Doing so risks breaking
 # setup.py
-version = "0.11.2"
+version = "0.11.3"
 
 version_tuple = parse(version).release
 


=====================================
setup.cfg
=====================================
@@ -1,6 +1,6 @@
 [metadata]
 name = Glymur
-version = 0.11.2
+version = 0.11.3
 author = 'John Evans'
 author_email = "John Evans" <john.g.evans.ne at gmail.com>
 license = 'MIT'


=====================================
tests/test_jp2box_uuid.py
=====================================
@@ -248,9 +248,16 @@ class TestSuite(fixtures.TestCommon):
         bf = io.BytesIO(box_data)
         bf.seek(8)
         box = UUIDBox.parse(bf, 0, 703)
-        with self.assertWarns(UserWarning):
+        with warnings.catch_warnings(record=True) as w:
             str(box)
 
+        if fixtures._HAVE_GDAL:
+            self.assertEqual(len(w), 1)
+        else:
+            # If no gdal, there's no warning.  It's just an Exif UUID in
+            # that case.
+            self.assertEqual(len(w), 0)
+
     def test_append_xmp_uuid(self):
         """
         SCENARIO:  Append an XMP UUID box to an existing JP2 file.
@@ -365,7 +372,6 @@ class TestSuite(fixtures.TestCommon):
         EXPECTED RESULT:  No errors.  There is a warning issued when we try
         to print the box.
         """
-        self.maxDiff = None
         with ir.path(data, 'issue398.dat') as path:
             with path.open('rb') as f:
                 f.seek(8)
@@ -373,7 +379,11 @@ class TestSuite(fixtures.TestCommon):
                     box = glymur.jp2box.UUIDBox.parse(f, 0, 380)
                     str(box)
 
-        self.assertEqual(len(w), 1)
+        if fixtures._HAVE_GDAL:
+            self.assertEqual(len(w), 1)
+        else:
+            # No warning issued if GDAL is not present.
+            self.assertEqual(len(w), 0)
 
 
 class TestSuiteHiRISE(fixtures.TestCommon):


=====================================
tests/test_jp2k.py
=====================================
@@ -1140,15 +1140,15 @@ class TestJp2k_write(fixtures.MetadataBase):
             display_resolution=[vresd, hresd],
         )
 
-        self.assertEqual(j.box[-1].box_id, 'res ')
+        self.assertEqual(j.box[2].box[2].box_id, 'res ')
 
-        self.assertEqual(j.box[-1].box[0].box_id, 'resc')
-        self.assertEqual(j.box[-1].box[0].vertical_resolution, vresc)
-        self.assertEqual(j.box[-1].box[0].horizontal_resolution, hresc)
+        self.assertEqual(j.box[2].box[2].box[0].box_id, 'resc')
+        self.assertEqual(j.box[2].box[2].box[0].vertical_resolution, vresc)
+        self.assertEqual(j.box[2].box[2].box[0].horizontal_resolution, hresc)
 
-        self.assertEqual(j.box[-1].box[1].box_id, 'resd')
-        self.assertEqual(j.box[-1].box[1].vertical_resolution, vresd)
-        self.assertEqual(j.box[-1].box[1].horizontal_resolution, hresd)
+        self.assertEqual(j.box[2].box[2].box[1].box_id, 'resd')
+        self.assertEqual(j.box[2].box[2].box[1].vertical_resolution, vresd)
+        self.assertEqual(j.box[2].box[2].box[1].horizontal_resolution, hresd)
 
     def test_capture_resolution_when_j2k_specified(self):
         """
@@ -1200,14 +1200,14 @@ class TestJp2k_write(fixtures.MetadataBase):
             capture_resolution=[vresc, hresc],
         )
 
-        self.assertEqual(j.box[-1].box_id, 'res ')
+        self.assertEqual(j.box[2].box[2].box_id, 'res ')
 
-        self.assertEqual(j.box[-1].box[0].box_id, 'resc')
-        self.assertEqual(j.box[-1].box[0].vertical_resolution, vresc)
-        self.assertEqual(j.box[-1].box[0].horizontal_resolution, hresc)
+        self.assertEqual(j.box[2].box[2].box[0].box_id, 'resc')
+        self.assertEqual(j.box[2].box[2].box[0].vertical_resolution, vresc)
+        self.assertEqual(j.box[2].box[2].box[0].horizontal_resolution, hresc)
 
         # there's just one child box
-        self.assertEqual(len(j.box[-1].box), 1)
+        self.assertEqual(len(j.box[2].box[2].box), 1)
 
     def test_display_resolution_supplied_but_not_capture(self):
         """
@@ -1223,14 +1223,14 @@ class TestJp2k_write(fixtures.MetadataBase):
             display_resolution=[vresd, hresd],
         )
 
-        self.assertEqual(j.box[-1].box_id, 'res ')
+        self.assertEqual(j.box[2].box[2].box_id, 'res ')
 
-        self.assertEqual(j.box[-1].box[0].box_id, 'resd')
-        self.assertEqual(j.box[-1].box[0].vertical_resolution, vresd)
-        self.assertEqual(j.box[-1].box[0].horizontal_resolution, hresd)
+        self.assertEqual(j.box[2].box[2].box[0].box_id, 'resd')
+        self.assertEqual(j.box[2].box[2].box[0].vertical_resolution, vresd)
+        self.assertEqual(j.box[2].box[2].box[0].horizontal_resolution, hresd)
 
         # there's just one child box
-        self.assertEqual(len(j.box[-1].box), 1)
+        self.assertEqual(len(j.box[2].box[2].box), 1)
 
     def test_no_jp2c_box_in_outermost_jp2_list(self):
         """


=====================================
tests/test_tiff2jp2.py
=====================================
@@ -1926,18 +1926,19 @@ class TestSuiteNoScikitImage(fixtures.TestCommon):
 
         j = Jp2k(self.temp_jp2_filename)
 
-        # the resolution superbox is appended after the codestream, but before
-        # the exif uuid
-        self.assertEqual(j.box[-2].box_id, 'res ')
+        # the resolution superbox is appended in the jp2 header box.
+        # the exit uuid comes later
         self.assertEqual(j.box[-1].box_id, 'uuid')
 
-        self.assertEqual(j.box[-2].box[0].box_id, 'resc')
-        self.assertEqual(j.box[-2].box[0].vertical_resolution, vresc)
-        self.assertEqual(j.box[-2].box[0].horizontal_resolution, hresc)
+        self.assertEqual(j.box[2].box[2].box_id, 'res ')
 
-        self.assertEqual(j.box[-2].box[1].box_id, 'resd')
-        self.assertEqual(j.box[-2].box[1].vertical_resolution, vresd)
-        self.assertEqual(j.box[-2].box[1].horizontal_resolution, hresd)
+        self.assertEqual(j.box[2].box[2].box[0].box_id, 'resc')
+        self.assertEqual(j.box[2].box[2].box[0].vertical_resolution, vresc)
+        self.assertEqual(j.box[2].box[2].box[0].horizontal_resolution, hresc)
+
+        self.assertEqual(j.box[2].box[2].box[1].box_id, 'resd')
+        self.assertEqual(j.box[2].box[2].box[1].vertical_resolution, vresd)
+        self.assertEqual(j.box[2].box[2].box[1].horizontal_resolution, hresd)
 
     def test_commandline_tiff2jp2_xmp_uuid(self):
         """


=====================================
tests/test_writing_tiles.py
=====================================
@@ -160,6 +160,36 @@ class TestSuite(fixtures.TestCommon):
         codestream = j.get_codestream()
         self.assertEqual(codestream.segment[2].layers, 3)  # layers = 3
 
+    def test_capture_resolution_and_tiled_writing(self):
+        """
+        SCENARIO:  Use the capture_resolution keyword.
+
+        EXPECTED RESULT:  The resolution superbox, along with a capture
+        box, is inserted into the jp2 header box.
+        """
+        j2k_data = fixtures.skimage.data.astronaut()
+
+        shape = (
+            j2k_data.shape[0] * 2, j2k_data.shape[1] * 2, j2k_data.shape[2]
+        )
+        tilesize = (j2k_data.shape[0], j2k_data.shape[1])
+
+        vresc, hresc = 0.1, 0.2
+
+        j = glymur.Jp2k(
+            self.temp_jp2_filename, shape=shape, tilesize=tilesize,
+            capture_resolution=[vresc, hresc],
+        )
+
+        for tw in j.get_tilewriters():
+            tw[:] = j2k_data
+
+        self.assertEqual(j.box[2].box[2].box_id, 'res ')
+
+        self.assertEqual(j.box[2].box[2].box[0].box_id, 'resc')
+        self.assertEqual(j.box[2].box[2].box[0].vertical_resolution, vresc)
+        self.assertEqual(j.box[2].box[2].box[0].horizontal_resolution, hresc)
+
     def test_plt_for_tiled_writing(self):
         """
         SCENARIO:  Use the plt keyword.



View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/compare/d5cd68bff8335a2c46ef64ef6cc7f374265b00a1...b9830622e8e35ee68230ce3669e55f84c7791c5b

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/compare/d5cd68bff8335a2c46ef64ef6cc7f374265b00a1...b9830622e8e35ee68230ce3669e55f84c7791c5b
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20220817/c881014a/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list