Beispiel #1
0
 def test_collin8(self):
     graph = Graph(
         [[Point(0, 0),
           Point(2, 0),
           Point(2, 2),
           Point(1, 1),
           Point(0, 2)]])
     pip = point_in_polygon(Point(0.5, 1), graph)
     assert pip > -1
    def point_in_polygon(self, point):
        """Return polygon_id if point in a polygon, -1 otherwise."""

        return point_in_polygon(point, self.graph)
Beispiel #3
0
    def point_in_polygon(self, point):
        """Return polygon_id if point in a polygon, -1 otherwise."""

        return point_in_polygon(point, self.graph)
Beispiel #4
0
    if nWithin >= threshold:
        # Centroid of all points & circle center
        g = np.mean(np.array(pts), axis=0)
        # Above often lands in polygons,
        # so now take the centroid between g and circle center
        g = np.mean(np.array([c, g]), axis=0)
        generated.append(g)

# Switch order (x, y) --> (y, x) to match visibility graph
evg = [vg.Point(g[1], g[0]) for g in generated]
# Add points to visgraph
added = []
for g in evg:
    try:
        for v in visible_vertices(g, graph.graph):
            if point_in_polygon(g, graph.graph) < 0 and point_in_polygon(
                    v, graph.graph) < 0:
                graph.visgraph.add_edge(Edge(g, v))
    except:
        continue
print("End extending visibility graph")

# Save evg
graph.save(graphFileOut)

# Plot points
ax = plt.subplot(111)
plt.scatter([c[0] for c in generated], [c[1] for c in generated],
            c='blue',
            alpha=1.0)
plt.scatter(gx, gy, c='red')