def step_to(pt, node): longls = LineString([(node.x, node.y), (pt.x, pt.y)]) ipt = longls.interpolate(30) ls = LineString([(ipt.x, ipt.y), (node.x, node.y)]) if collide_ln(ls) == False and lines_cross( ls, ipt, node) == False and ls.length > 20: return ls, ipt, True else: return ls, ipt, False
def step_to(pt, node, screen): longls = LineString([(node.x, node.y),(pt.x, pt.y)]) ipt = longls.interpolate(30) ls = LineString([(ipt.x, ipt.y),(node.x, node.y)]) if collide_ln(ls) == False and lines_cross(ls,ipt,node,screen) == False and ls.length > 20: circle(screen, YELLOW, [int(ipt.x), int(ipt.y)], 3, 0) return ls, ipt, True else: return ls, ipt, False
def calculate_over_fluxgate(start, vdata, surfdata, bdot, dhdt, beddata, end=None, offset=100, gamma=0.9, plotfig=None): startgate = LineString(start) # just to make sure... startpt = startgate.coords[0] flowLine1 = get_flowline(startpt, vdata, end=end) fluxDist = 0 gates = [] flowcellnumber = [] bed = np.empty(0) while (startgate.length - fluxDist) > offset: startpt = startgate.interpolate(fluxDist + offset).coords[0] flowLine2 = get_flowline(startpt, vdata, end=end) if plotfig is not None: plt.plot(flowLine1.x, flowLine1.y, 'b') plt.plot(flowLine2.x, flowLine2.y, 'b') thesegates, thisbed = calculate_bed_elevs(flowLine1, flowLine2, vdata, surfdata, bdot, dhdt, beddata, gamma, offset, plotfig) for j, x in enumerate(thesegates[0]): gates.append(Point(x, thesegates[1][j])) flowcellnumber.append(j) bed = np.append(bed, thisbed) flowLine1 = flowLine2 fluxDist += offset return gates, bed, flowcellnumber
def _write_boat_line(pier, stg_manager, coords_transform: co.Transformation): line_string = LineString(pier.nodes) right_line = line_string.parallel_offset(4, 'left', resolution=8, join_style=1, mitre_limit=10.0) if isinstance(right_line, LineString): # FIXME: what to do else? coords = right_line.coords for i in range(len(coords) - 1): segment = LineString(coords[i:i + 2]) boat_position = segment.interpolate(segment.length / 2) try: pos_global = coords_transform.to_global( (boat_position.x, boat_position.y)) direction = math.degrees( math.atan2(segment.coords[0][0] - segment.coords[1][0], segment.coords[0][1] - segment.coords[1][1])) if segment.length > 5: _write_model(segment.length, stg_manager, pos_global, direction, pier.elevation) except AttributeError as reason: logging.error(reason)