Closed caver456 closed 1 year ago
The obvious easy failsafe option is: don't try to keep the 3rd or 4th elements of each vertex; just return the two-element-vertex feature. We should explore options for keeping the 4-element lists before giving up:
1) do all the shapely operations on the 2-element vertices, then try to match them back up again afterwards 2) overload a bunch of shapely guts to deal with 4-element vertices - probably ugly!
Either way, getting a 2-element list from a either-2-or-4-element list is easy:
>>> a=[[1,2,3,4],[2,3,4,5],[3,4,5,6]]
>>> b=[x[0:2] for x in a]
>>> b
[[1, 2], [2, 3], [3, 4]]
>>> [x[0:2] for x in b]
[[1, 2], [2, 3], [3, 4]]
and, searching is easy - just a question of how slow it is:
>>> [x for x in a if x[0:2]==[1,2]]
[[1, 2, 3, 4]]
>>> [x for x in a if x[0:2]==[1,3]]
[]
During testing on CTD 4231, crop of apptrack just returns 200 with no json. This doesn't cause any exception or abort or traceback. Is this new? Is it related to this issue (4-point vs 2-point)? Do we need to make a line before cropping? If it's not directly related to this issue, a new issue should be created.
2022-12-17 17:50:28,459 [INFO] crop: target=CW209B boundary=cropper
2022-12-17 17:50:28,962 [INFO] getUsedSuffixList: base=CW209B rval=[]
2022-12-17 17:50:28,994 [INFO] editFeature called
2022-12-17 17:50:28,995 [INFO] id specified: 33a63b2f-b41b-48e6-90ba-8a3eb8275a8a
2022-12-17 17:50:28,995 [INFO] sending post to http://localhost:8080/api/v1/map/HN7/Apptrack/33a63b2f-b41b-48e6-90ba-8a3eb8275a8a
2022-12-17 17:50:28,996 [INFO] {'json': '{"type": "Feature", "id": "33a63b2f-b41b-48e6-90ba-8a3eb8275a8a", "geometry": {"size": 56, "coordinates": "56 points", "incremental": true, "type": "LineString"}}'}
2022-12-17 17:50:29,026 [ERROR] sendRequest: response had no decodable json:<Response [200]>
Confirmed that cropping a line made of four-element vertices works fine. The line CW209Ba was made from Copy As Line in the GUI; it still had four-element vertices before the crop operation, and the crop did work visually.
...
...
[
-121.17803321231266,
39.27680332217298,
405,
1668202204061
],
[
-121.17806355480214,
39.27681245844744,
406,
1668202209059
]
],
"incremental": true,
"type": "LineString"
},
"id": "ca823f3f-3a45-43f4-9be2-5e1afe7b36a4",
"type": "Feature",
"properties": {
"stroke-opacity": 1,
"creator": "11UEE9",
"pattern": "solid",
"description": "",
"stroke-width": 2,
"fill": "#0000FF",
"title": "CW209Ba",
"stroke": "#0000FF",
"class": "Shape",
"updated": 0,
"timestamp": 1671342667436,
"gpstype": "TRACK"
}
}
]
}
}
2022-12-17 21:52:00,397 [INFO] crop: target=CW209Ba boundary=cropper
2022-12-17 21:52:00,779 [INFO] getUsedSuffixList: base=CW209Ba rval=[]
2022-12-17 21:52:00,825 [INFO] editFeature called
2022-12-17 21:52:00,825 [INFO] id specified: ca823f3f-3a45-43f4-9be2-5e1afe7b36a4
2022-12-17 21:52:00,825 [INFO] sending post to http://localhost:8080/api/v1/map/HN7/Shape/ca823f3f-3a45-43f4-9be2-5e1afe7b36a4
2022-12-17 21:52:00,825 [INFO] {'json': '{"type": "Feature", "id": "ca823f3f-3a45-43f4-9be2-5e1afe7b36a4", "geometry": {"size": 56, "coordinates": "56 points", "incremental": true, "type": "LineString"}}'}
2022-12-17 21:52:04,715 [INFO] processing 1 feature(s):['ca823f3f-3a45-43f4-9be2-5e1afe7b36a4']
2022-12-17 21:52:04,715 [INFO] response contained geometry for Shape:CW209Ba but it matched the cache, so no cache update or callback is performed
So, this is probably just a case of inability to crop apptracks. This kind of makes sense, because the apptrack is still in process, by definition - so cropping the middle would make no sense. The solution is probably to make a copy of the apptrack as a line, in code, and then crop that. Creating a separate issue to handle cropping of apptracks, and closing this issue since it was fixed at some point in the past, during work in the plans_console repo.
Apparently, each element of a feature's geometry list (each 'point') can be either a two-element list or a four-element list:
[lon,lat,elevation(meters),timestamp]
or
[lon,lat]
Apptracks (and maybe GPSIO tracks) use the four-element variety. Drawing features from the web page creates two-element 'points'.
Regardless, crop dies on the four-element variety. Apparently we have not tried to crop the four-element variety before - seems odd but believable.
So, the geom ops code needs to be redone to deal with four-element points as well as two-element points, and to preserve all four elements if possible.