Example #1
0
def is_contain(query_point, vertex_lst):
  if len(vertex_lst) == 4:
    vertex_box = copy.deepcopy(vertex_lst)
    vertex_box = clockwise_sort(vertex_box)
    polygon = Polygon(vertex_box)
  else:
    polygon = Polygon(vertex_lst)
  point = Point(query_point[0], query_point[1])
  if not polygon.is_convex:
    return False
  return polygon.contains_point(point)
Example #2
0
def is_contain(query_point, vertex_lst):
    if len(vertex_lst) == 4:
        vertex_box = copy.deepcopy(vertex_lst)
        vertex_box = clockwise_sort(vertex_box)
        polygon = Polygon(vertex_box)
    else:
        polygon = Polygon(vertex_lst)
    point = Point(query_point[0], query_point[1])
    if not polygon.is_convex:
        return False
    return polygon.contains_point(point)
        #           f_ff.write(json.dumps(AllList))

        if os.path.isfile('PolyList.txt'):
            with open('PolyList.txt', 'w') as f_f:
                f_f.write(json.dumps(PolyList))
        else:
            with open('PolyList.txt', 'w') as f_f:
                f_f.write(json.dumps(PolyList))

from planar import Polygon
innerPolyList = []
for f in PolyList:
    for d in PolyList:
        if d != f:
            polyg = Polygon(d)
            if polyg.contains_point(f[0]):
                innerPolyList.append(f)
#print(innerPolyList)
#Get alist of External Polygons only
PolyListNoInner = []
for dd in PolyList:
    if dd not in innerPolyList:
        PolyListNoInner.append(dd)

print("len polylistNoInner", len(PolyListNoInner))

from shapely.geometry import Polygon
# get a list on polygon areas and the index in its ExternPoly
polyArea = []
for jj in range(len(PolyListNoInner)):
    myPoly = Polygon(PolyListNoInner[jj])