Commit adef5d6f by Alexander Kryklia

polygon is created from points via convex_hull

parent 72f9358f
...@@ -23,7 +23,7 @@ import abc ...@@ -23,7 +23,7 @@ import abc
import os import os
import subprocess import subprocess
import xml.sax.saxutils as saxutils import xml.sax.saxutils as saxutils
from shapely.geometry import Polygon, Point from shapely.geometry import Point, MultiPoint
# specific library imports # specific library imports
from calc import evaluator, UndefinedVariable from calc import evaluator, UndefinedVariable
...@@ -1796,16 +1796,20 @@ class ImageResponse(LoncapaResponse): ...@@ -1796,16 +1796,20 @@ class ImageResponse(LoncapaResponse):
break break
# import ipdb; ipdb.set_trace() # import ipdb; ipdb.set_trace()
if correct_map[aid]['correctness'] != 'correct' and regions[aid]: if correct_map[aid]['correctness'] != 'correct' and regions[aid]:
import ipdb; ipdb.set_trace() # import ipdb; ipdb.set_trace()
parsed_region = json.loads(regions[aid]) parsed_region = json.loads(regions[aid])
if parsed_region: if parsed_region:
if type(parsed_region[0][0]) != list: if type(parsed_region[0][0]) != list:
# we have [[1,2],[3,4],[5,6] - single region # we have [[1,2],[3,4],[5,6]] - single region
# instead of [[[1,2],[3,4],[5,6], [[1,2],[3,4],[5,6]] # instead of [[[1,2],[3,4],[5,6], [[1,2],[3,4],[5,6]]]
# or [[[1,2],[3,4],[5,6]] - multiple regions syntax # or [[[1,2],[3,4],[5,6]]] - multiple regions syntax
parsed_region = [parsed_region] parsed_region = [parsed_region]
# if aid =='1_3_6':
# import ipdb; ipdb.set_trace()
for region in parsed_region: for region in parsed_region:
if Polygon(region).contains(Point(gx, gy)): polygon = MultiPoint(region).convex_hull
if (polygon.type == 'Polygon' and
polygon.contains(Point(gx, gy))):
correct_map.set(aid, 'correct') correct_map.set(aid, 'correct')
break break
return correct_map return correct_map
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment