z = 0 for path in tiger.paths: for vertices, closed in path.vertices: if len(vertices) < 3: continue if path.style.stroke is not None: vertices[:, 2] = z + 0.5 if path.style.stroke_width: stroke_width = path.style.stroke_width.value else: stroke_width = 2.0 paths.append(vertices, closed=closed, color=path.style.stroke.rgba, linewidth=stroke_width) if path.style.fill is not None: if path.style.stroke is None: vertices[:, 2] = z + 0.25 paths.append(vertices, closed=closed, color=path.style.fill.rgba, linewidth=1) vertices[:, 2] = z polygons.append(vertices, color=path.style.fill.rgba) z += 1 window.attach(paths["transform"]) window.attach(paths["viewport"]) app.run()
elif state["type"] == "MultiPolygon": for P in geometry(state, arcs, scale, translate)["coordinates"]: V = np.zeros((len(P[0]), 3)) V[:, :2] = P[0] paths.append(V, closed=True, color=color, linewidth=linewidth) linewidth = 0.5 color = 0.5, 0.5, 0.5, 1.0 for county in topology["objects"]["counties"]["geometries"]: if county["type"] == "Polygon": P = geometry(county, arcs, scale, translate)["coordinates"][0] V = np.zeros((len(P), 3)) V[:, :2] = P paths.append(V, closed=True, color=color, linewidth=linewidth) if len(V) > 3: rgba = 1, 1, 1, 1 polys.append(V[:-1], color=rgba) elif county["type"] == "MultiPolygon": for P in geometry(county, arcs, scale, translate)["coordinates"]: V = np.zeros((len(P[0]), 3)) V[:, :2] = P[0] paths.append(V, closed=True, color=color, linewidth=linewidth) if len(V) > 3: rgba = 1, 1, 1, 1 polys.append(V[:-1], color=rgba) window.attach(paths["transform"]) window.attach(paths["viewport"]) app.run()
elif state["type"] == "MultiPolygon": for P in geometry(state, arcs, scale, translate)["coordinates"]: V = np.zeros((len(P[0]), 3)) V[:, :2] = P[0] paths.append(V, closed=True, color=color, linewidth=linewidth) linewidth = 0.5 color = 0.5, 0.5, 0.5, 1.0 for county in topology["objects"]["counties"]["geometries"]: if county["type"] == "Polygon": P = geometry(county, arcs, scale, translate)["coordinates"][0] V = np.zeros((len(P), 3)) V[:, :2] = P paths.append(V, closed=True, color=color, linewidth=linewidth) if len(V) > 3: rgba = 1, 1, 1, 1 polys.append(V[:-1], color=rgba) elif county["type"] == "MultiPolygon": for P in geometry(county, arcs, scale, translate)["coordinates"]: V = np.zeros((len(P[0]), 3)) V[:, :2] = P[0] paths.append(V, closed=True, color=color, linewidth=linewidth) if len(V) > 3: rgba = 1, 1, 1, 1 polys.append(V[:-1], color=rgba) window.attach(paths["transform"]) window.attach(paths["viewport"]) app.run()
transform = PanZoom(OrthographicProjection(Position(), yinvert=True), aspect=None) paths = PathCollection("agg+", transform=transform, linewidth="shared", color="shared") polygons = PolygonCollection("agg", transform=transform) z = 0 for path in tiger.paths: for vertices, closed in path.vertices: if len(vertices) < 3: continue if path.style.stroke is not None: vertices[:, 2] = z + 0.5 if path.style.stroke_width: stroke_width = path.style.stroke_width.value else: stroke_width = 2.0 paths.append(vertices, closed=closed, color=path.style.stroke.rgba, linewidth=stroke_width) if path.style.fill is not None: if path.style.stroke is None: vertices[:, 2] = z + 0.25 paths.append(vertices, closed=closed, color=path.style.fill.rgba, linewidth=1) vertices[:, 2] = z polygons.append(vertices, color=path.style.fill.rgba) z += 1 window.attach(paths["transform"]) window.attach(paths["viewport"]) app.run()