Closed caver456 closed 1 month ago
updated line number in the code = 2026 (in 'crop') = the last line of the snippet below, 'for r in result[1:]:'
elif isinstance(result,MultiLineString):
rids.append(self.editFeature(id=targetShape['id'],geometry={'coordinates':list(result[0].coords)}))
if rids==[]:
logging.error('crop: target shape not found; operation aborted.')
return False
suffix=0
for r in result[1:]:
It is time... now on Shapely 2.0.2 and the geometry operations seem to be failing. Discovered by Steve during testing of the signed GET issue.
Not sure what the Feb 25 2022 comment refers to...
With Shapely 2.0.2, this is the error in question:
20:42:58 [sartopo_python:2489:CRITICAL] Uncaught exception:
Traceback (most recent call last):
File "C:\Users\caver\Documents\GitHub\sartopo_python\sartopo_python\test.py", line 54, in <module>
sts.cut('AB','zz') # cut area assignment using line
^^^^^^^^^^^^^^^^^^
File "C:\Users\caver\Documents\GitHub\sartopo_python\sartopo_python\sartopo_python.py", line 1838, in cut
rids.append(self.editFeature(id=targetShape['id'],geometry={'coordinates':[list(result[0].exterior.coords)]}))
~~~~~~^^^
TypeError: 'MultiPolygon' object is not subscriptable
Getting .geoms like so
elif isinstance(result,MultiPolygon):
##### EDIT FEATURE is used to update the original feature information (geometry)
resultGeoms=result.geoms
returns a sequence of polygons; trying to slice it like so
for r in resultGeoms[1:]:
returns this error:
21:16:58 [sartopo_python:2494:CRITICAL] Uncaught exception:
Traceback (most recent call last):
File "C:\Users\caver\Documents\GitHub\sartopo_python\sartopo_python\test.py", line 54, in <module>
sts.cut('AB','zz') # cut area assignment using line
^^^^^^^^^^^^^^^^^^
File "C:\Users\caver\Documents\GitHub\sartopo_python\sartopo_python\sartopo_python.py", line 1844, in cut
for r in resultGeoms[1:]:
TypeError: 'MultiPolygon' object is not iterable
Need to turn it into a list first:
for r in list(resultGeoms)[1:]:
which iterates as expected.
elif isinstance(result,MultiPolygon):
##### EDIT FEATURE is used to update the original feature information (geometry)
resultGeoms=result.geoms
rids.append(self.editFeature(id=targetShape['id'],geometry={'coordinates':[list(resultGeoms[0].exterior.coords)]}))
if rids==[]:
logging.warning('cut: target shape not found; operation aborted.')
return False
for r in list(resultGeoms)[1:]:
Sending to Steve for testing, but, I also need to make sure the tests exercise all places in the code that this could happen. Found at least four spots searching for 'if.*Multi'
After first commit: testing a simple crop:
15:29:41 [sartopo_python:2250:INFO] crop: target=z boundary=AA
15:29:41 [sartopo_python:2496:CRITICAL] Uncaught exception:
Traceback (most recent call last):
File "C:\Users\caver\Documents\GitHub\sartopo_python\sartopo_python\test.py", line 55, in <module>
sts.crop('z','AA')
File "C:\Users\caver\Documents\GitHub\sartopo_python\sartopo_python\sartopo_python.py", line 2282, in crop
result=self.intersection2(targetGeom,boundaryGeom)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\caver\Documents\GitHub\sartopo_python\sartopo_python\sartopo_python.py", line 2085, in intersection2
mpcoords=[(p.x,p.y) for p in mp]
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'MultiPoint' object is not iterable
15:29:41 [sartopo_python:684:INFO] SartopoSession instance deleted for map PVTGT.
all complex cut operations are working as expected
During crop: