From f906be36c6192a4cf3e1f97632c80d3491518a5c Mon Sep 17 00:00:00 2001 From: Liubov Galkovska Date: Sat, 15 Feb 2020 15:06:42 +0200 Subject: [PATCH] more fixes for issue #310 --- backend/promis/backend_api/serializer.py | 4 ++++ frontend/app/constants/Selection.js | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/promis/backend_api/serializer.py b/backend/promis/backend_api/serializer.py index cfbc616..cc03b73 100644 --- a/backend/promis/backend_api/serializer.py +++ b/backend/promis/backend_api/serializer.py @@ -294,6 +294,10 @@ def gen_selection(): # Intersection of search polygon and the orbit isect = obj.session.geo_line.intersection(poly) + #django docs say that GEOSGeometry.dims returns -1 for empty GeometryCollection + if isect.dims == -1: + return + # Making sure isect is a collection of geolines, not a single one if type(isect) is not MultiLineString: isect = [ isect ] diff --git a/frontend/app/constants/Selection.js b/frontend/app/constants/Selection.js index 914f0d8..e03373d 100644 --- a/frontend/app/constants/Selection.js +++ b/frontend/app/constants/Selection.js @@ -60,11 +60,20 @@ export function selectionToPolygon(selection) { case Types.Rect: let bounds = Leaflet.latLngBounds(selection.data[0], selection.data[1]); //let center = bounds.getCenter(); - points.push(bounds.getSouthWest()); points.push(bounds.getSouthEast()); + // had to add these two intermidiate points to overcome the bug + // "Antipodal (180 degrees long) edge detected!" + if (selection.data[0][0] == -90 && selection.data[1][0] == 90) + { + points.push({lat: 0, lng: bounds.getSouthEast().lng}) + } points.push(bounds.getNorthEast()); points.push(bounds.getNorthWest()); + if (selection.data[0][0] == -90 && selection.data[1][0] == 90) + { + points.push({lat: 0, lng: bounds.getNorthWest().lng}) + } break; case Types.Circle: