On 17/11/2016 14:27, aruns...@gmail.com wrote:
I am working with following code in which I am trying to output co ordinates
of overlapping rectangles.. However the code fails to output the co ordinates.
I am customizing the following code This is the input
1.6 1.2 7.9 3.1
1.2 1.6 3.4 7.2
2.6 11.6 6.8 14.0
9.6 1.2 11.4 7.5
9.6 1.7 14.1 2.8
(Is there a line count at the start of the file?)
sign = -1
area = sum( map( lambda x: x.area, rectangles) )
for i in range(2,len(rectangles)+1):
for rects in combinations( rectangles, i ):
intersections = [rects[0]]
rects = rects[1:]
for rectangle in rects:
newintersections = []
for otherR in intersections:
newintersections.extend( rectangle.intersect(otherR) )
intersections = newintersections
print intersections
#intersectingArea = sum( map( lambda x: x.area, intersections ) )
#rea = area + (sign * intersectingArea)
sign = sign*-1
Where I need to change the code to output all overlapping rectangles and its co
ordinates?
I tried your code and got a bunch of output, mostly [] lines like this:
[]
[]
[]
[]
[]
[[Point(x=1.6, y=1.6),Point(x=3.4, y=3.1)]]
[]
[]
[[Point(x=1.6, y=1.6),Point(x=3.4, y=3.1)]]
[]
What output did you expect for this input data?
(I plotted your data and out of five rectangles A,B,C,D,E (not in the
same order as your data), then A and B overlap, as do C and D, while E
is by itself.
Did you want the output to be, for example, A and B, with the
coordinates of the common region, and the same for C and D?
What happens if 3 or more rectangles overlap?
What about if A overlaps B; B overlaps C; C overlaps D; and D overlaps
A? Suppose then that all those are contained within E?
You need some specifications. I assume all rectangles are horizontally
aligned (they have to be with just 4 coordinates), and the input data
normalised so that the top-left corner appears first.)
--
Bartc
--
https://mail.python.org/mailman/listinfo/python-list