def resetPos(): # Ramp both motors up to max speed backwards xMotor.setDirection(-1) xMotor.setSpeed(maxSpeed) yMotor.setDirection(-1) yMotor.setSpeed(maxSpeed) # Run until we can't go any further oldX, oldY = xCounter, yCounter xDone, yDone = False, False newX, newY = -1, -1 sleepTime = 0 while not xDone or not yDone: if oldX - newX == 0 and not xDone: xDone = True xMotor.run(Adafruit_MotorHAT.RELEASE) if oldY - newY == 0 and not yDone: yDone = True yMotor.run(Adafruit_MotorHAT.RELEASE) newX, newY = oldX, oldY sleepTime += 0.02 sleep(0.02) oldX, oldY = xCounter, yCounter # Offset to accommodate for round edges of frying pan currentPos = Coordinate(0, 0) moveTo(Coordinate(100, 200)) global currentPos currentPos = Coordinate(0, 0) print("Reset to (0,0) complete")
def rectangle(breadth, height): return [ Coordinate(currentPos.x, currentPos.y), Coordinate(breadth + currentPos.x, currentPos.y), Coordinate(breadth + currentPos.x, height + currentPos.y), Coordinate(currentPos.x, height + currentPos.y), Coordinate(currentPos.x, currentPos.y) ]
def get_travel_information(origin, destination): directions_result = gmaps.directions(origin, destination, mode="driving", departure_time=datetime.now()) distance_in_meters = directions_result[0]['legs'][0]['distance']['value'] duration_in_seconds = directions_result[0]['legs'][0]['duration']['value'] steps = directions_result[0]['legs'][0]['steps'] steps_filtered = [{'start_location':Coordinate(**i['start_location']), 'end_location':Coordinate(**i['end_location']), 'duration':i['duration']['value']} for i in steps] return steps_filtered, distance_in_meters, duration_in_seconds
def load_limit(self): mode_doc = self.mission.document("routes").get().to_dict() print("LIMITE DE INTERNET") r = [] a = Coordinate(mode_doc["a"].latitude, mode_doc["a"].longitude) b = Coordinate(mode_doc["b"].latitude, mode_doc["b"].longitude) for point in mode_doc["limit"]: wgsp = Coordinate(point.latitude, point.longitude) r.append(wgsp) return r, a, b
def move(LatLon): global old_pos, init, old_bearing, mesh, bearings, tractor utm_pos = Coordinate(x=LatLon.x, y=LatLon.y) if init is False: tractor.m_p_s = 2 tractor.run() init = True old_pos = utm_pos scene.camera.pos = vec(utm_pos.x, 4, utm_pos.y - 50) scene.camera.axis = vec(0, -4, -50) obj = [] for x in range(-50, 50): for y in range(-50, 50): a = Coordinate(x=utm_pos.x + x * 500, y=utm_pos.y + y * 500 + 500) b = Coordinate(x=utm_pos.x + x * 500 + 500, y=utm_pos.y + y * 500 + 500) c = Coordinate(x=utm_pos.x + x * 500 + 500, y=utm_pos.y + y * 500) d = Coordinate(x=utm_pos.x + x * 500, y=utm_pos.y + y * 500) Q = quad( canvas=None, v0=vertex(pos=vec(a.x, -1, a.y)), v1=vertex(pos=vec(b.x, -1, b.y)), v2=vertex(pos=vec(c.x, -1, c.y)), v3=vertex(pos=vec(d.x, -1, d.y)), ) obj.append(Q) compound(obj, canvas=scene, color=vec(0, .60, 0)) else: curso = utils.bearing(utm_pos, old_pos) a = utils.offset(utm_pos, curso - 90, distance / 2) b = utils.offset(utm_pos, curso + 90, distance / 2) c = utils.offset(old_pos, old_bearing + 90, distance / 2) d = utils.offset(old_pos, old_bearing - 90, distance / 2) Q = quad( v0=vertex(pos=vec(a.x, .5, a.y), color=color.yellow), v1=vertex(pos=vec(b.x, .5, b.y), color=color.yellow), v2=vertex(pos=vec(c.x, .5, c.y), color=color.yellow), v3=vertex(pos=vec(d.x, .5, d.y), color=color.yellow), ) qobj.append(Q) left.append(vec(a.x, .5, a.y)) right.append(vec(b.x, .5, b.y)) old_bearing = curso old_pos = utm_pos bearings.pop() bearings.insert(0, curso) curso = sum(bearings) / len(bearings) camera = utils.offset(utm_pos, curso, 300) x, z = utils.vector(curso + 180) #scene.camera.pos=vec(camera.x, 100, camera.y) #scene.camera.axis=200*vec(x, -0.3 , z) tractor_3d.pos = tractor.get_vec(1.5)
def load_route(self): mode_doc = self.mission.document("routes").get().to_dict() print("RUTA DE INTERNET") r = [] a = Coordinate(mode_doc["a"].latitude, mode_doc["a"].longitude) b = Coordinate(mode_doc["b"].latitude, mode_doc["b"].longitude) for point in mode_doc["nav"]: wgsp = Coordinate(point.latitude, point.longitude) utmp = utils.to_utm(wgsp) r.append(Point(utmp.x, utmp.y)) print(utmp) return r, a, b
def __init__(self): Player.__init__(self) self.coords = [Coordinate(-1,-1), #Coordinate( 0,-1), Coordinate( 1, 0), #Coordinate( 1,-1), Coordinate(-1, 0), #Coordinate( 0, 0), Coordinate(-1, 1), #Coordinate( 0, 1), #Coordinate( 1, 1) ]
def __init__(self): Player.__init__(self) self.coords = [#Coordinate(-1,-1), #Coordinate( 0,-1), Coordinate( 1, 0), Coordinate( 1,-1), #Coordinate(-1, 0), #Coordinate( 0, 0), #Coordinate(-1, 1), #Coordinate( 0, 1), Coordinate( 1, 1)] self.n_moves = len(self.coords)
def count_trees(*slopes): lines = read_lines("3.txt") mod = len(lines[0]) pos = Coordinate(0, 0) trees = [] for slope in slopes: count = 0 while pos.y < len(lines): if lines[pos.y][pos.x % mod] == '#': count += 1 pos = pos + slope pos = Coordinate(0, 0) trees.append(count) return numpy.prod(trees)
def __init__(self, seed, colors): self.random = Random(seed) self.specimens = {} self.next_specimens = {} self.changed_cells = set() self.out_of_bounds = Square(OUT_OF_BOUNDS_COLOR) self.out_of_bounds.killer = True self.all_colors = [color for color in colors] self.traps = [Trap(Coordinate(0, 0))] * len(colors) for trap_type in trap_types: if trap_type is TeleportationTrap: used_traps = [] for i in range(trap_type.max_traps): if i % 2: used_traps.append(-used_traps[-1]) else: used_traps.append( self.random.choice(trap_type.possible_directions)) else: used_traps = [ self.random.choice(trap_type.possible_directions) for i in range(trap_type.max_traps) ] coloring = zip(used_traps, colors) colors = colors[len(used_traps):] for direction, color in coloring: self.traps[color] = trap_type(direction) safe_colors = colors self.squares = [[ Square( self.random.choice(self.all_colors if x < UNSAFE_BOARD_WIDTH else safe_colors)) for x in xrange(BOARD_EXTENDED_WIDTH) ] for __ in xrange(BOARD_HEIGHT)] self.starting_squares = [] for y in xrange(BOARD_HEIGHT): for x in xrange(BOARD_EXTENDED_WIDTH): coordinate = Coordinate(x, y) self.changed_cells.add(coordinate) trap = self.traps[self.get_square(coordinate).color] if trap.is_killer(): self.get_square(trap.direction + coordinate).killer = True if trap.is_mover(): self.get_square(coordinate).teleport = trap.direction if trap.is_wall(): self.get_square(coordinate).killer = True self.get_square(coordinate).wall = True
class Tractor: location = Coordinate(x=0, y=0) bearing = 0 m_p_s = 0 pid = PID(.7, .2, .02, setpoint=0) pid.output_limits = (-20, 20) direccion = 0 def move(self): while True: self.bearing += self.direccion * -0.1 l = utils.offset(self.location, self.bearing, self.m_p_s / 10) self.location = l time.sleep(.01) def run(self): t1 = threading.Thread(target=self.move) t1.start() def get_vec(self, z): return vec(self.location.x, z, self.location.y) def doblar(self, v): self.direccion = self.pid(v) print("PID: ", self.direccion) def juego_en_la_direccion(self): self.bearing += randrange(-10, 10)
def avoid_walls_and_others(self, valid_moves): snake = {} body = {} me = self.__game_state['you']['body'] # list of {'x', 'y'} # check walls self.check_wall_left(me, valid_moves) self.check_wall_right(me, valid_moves) self.check_wall_bottom(me, valid_moves) self.check_wall_top(me, valid_moves) print("VALID MOVES AFTER CHECKING WALLS: ", valid_moves) # loop through 'snakes' seeing if a move is invalid for snake in self.__game_state['board']['snakes']: # for each snake for body in snake['body']: coordinate = Coordinate({'x': body['x'], 'y': body['y']}) # test to see if each move in valid_moves will turn into an occupide coordinate if (valid_moves.count("left") > 0): self.check_left(valid_moves, me, coordinate) if (valid_moves.count("right") > 0): self.check_right(valid_moves, me, coordinate) if (valid_moves.count("up") > 0): print( f"checking up with ME: {me[0]['x']} and other as {coordinate}") self.check_up(valid_moves, me, coordinate) if (valid_moves.count("down") > 0): self.check_down(valid_moves, me, coordinate)
def non_overlapping_squares(in_list_lines): covered = dict() id_set = set() for line in in_list_lines: line_id = int(line.split('@')[0].strip().replace('#', '')) left = int(line.split('@')[1].split(':')[0].strip().split(',')[0]) top = int(line.split('@')[1].split(':')[0].strip().split(',')[1]) wide = int(line.split(':')[1].strip().split('x')[0]) tall = int(line.split(':')[1].strip().split('x')[1]) id_set.add(line_id) c = Coordinate(x=left, y=top) for point_x in range(1, wide + 1): for point_y in range(1, tall + 1): x = c.x + point_x y = c.y + point_y xy_str = '{},{}'.format(x, y) # Save id lines = covered.get(xy_str, []) lines.append(line_id) covered[xy_str] = lines for coord, ids in covered.items(): if len(ids) > 1: for id_str in ids: if id_str in id_set: id_set.remove(id_str) return id_set
def get_coord_from_step(step, location): """ Get coordinates from journey step and convert to Coordninate instances. """ return Coordinate(step[location]['lng'], step[location]['lat'], coord_type="geographic", strict=True)
def move(self, origin: C, destination: C) -> str: """moves a piece form origin to destination. Does validiy checks. Returns a nicely formatted string message""" if not self.is_valid_move(origin, destination): raise InvalidMoveException piece = self.board[origin] print("moving from {} to {}".format(origin, destination)) self.board.pop(origin) self.board[destination] = piece return "Moved {} fom {} to {}".format(unicodeMappings[piece], origin.as_chess_notation(), destination.as_chess_notation())
def Data_Processing(In_Data): Processed_Data = [] for row in In_Data: Split_Coordinates = row[1:-1].split(', ') x_coord = int(Split_Coordinates[0][2:]) y_coord = int(Split_Coordinates[1][2:]) z_coord = int(Split_Coordinates[2][2:]) coord = Coordinate(x=x_coord,y=y_coord,z=z_coord,x_velocity=0,y_velocity=0,z_velocity=0) Processed_Data.append(coord) return Processed_Data
def find_padding(sample=default_sample): unpadded = CremiFile(cremi_path(sample=sample), "r") unpadded_raw = unpadded.read_raw() unpadded_shape_px = Coordinate(unpadded_raw.data.shape) padded = CremiFile(cremi_path(sample=sample, padded=True), "r") padded_raw = padded.read_raw() padded_shape_px = Coordinate(padded_raw.data.shape) fafb_res = Coordinate(unpadded_raw.resolution) data_shape_nm = unpadded_shape_px * fafb_res padding_px = math.ceil((padded_shape_px - unpadded_shape_px) / 2) padding_nm = padding_px * fafb_res print("shape (nm): {}".format(data_shape_nm)) print("padding (nm): {}".format(padding_nm)) print("l1 shape (px): {}".format(math.ceil(data_shape_nm / L1_RES))) print("l1 padding (px): {}".format(math.ceil(padding_nm / L1_RES)))
def b_action(b): global left, right, qtemp, qobj qtemp.visible = False left.visible = False right.visible = False del left, right left = curve(color=color.orange, radius=0.3, retain=500) right = curve(color=color.orange, radius=0.3, retain=500) tractor.location = Coordinate(x=(path[0].x - 50), y=(path[0].y - 20)) for obj in qobj: obj.visible = False del obj qobj = []
def overlapping_squares(in_list_lines): covered = dict() for line in in_list_lines: line_id = int(line.split('@')[0].strip().replace('#', '')) left = int(line.split('@')[1].split(':')[0].strip().split(',')[0]) top = int(line.split('@')[1].split(':')[0].strip().split(',')[1]) wide = int(line.split(':')[1].strip().split('x')[0]) tall = int(line.split(':')[1].strip().split('x')[1]) c = Coordinate(x=left, y=top) for point_x in range(1, wide + 1): for point_y in range(1, tall + 1): x = c.x + point_x y = c.y + point_y xy_str = '{},{}'.format(x, y) # Increase counter on every point. If the point is missing initialize it. covered[xy_str] = covered.get(xy_str, 0) + 1 return {coord for coord, freq in covered.items() if freq >= 2}
def draw_cell(self, coordinates, board): square = board.get_square(coordinates) if not square.teleport == Coordinate(0, 0): color = TELEPORT_COLOR elif square.wall: color = WALL_COLOR elif square.killer: color = DEATH_COLOR else: color = EMPTY_COLOR # color_code = board.get_color(coordinates) # if color_code not in self.colors: # color = [random.randrange(256) for __ in range(3)] # self.colors[color_code] = color # else: # color = self.colors[color_code] self.rectangle(color, coordinates.x * CELL_SCALAR, coordinates.y * CELL_SCALAR, CELL_SCALAR, CELL_SCALAR) if coordinates in board.specimens and board.specimens[coordinates]: self.rectangle(SPECIMEN_COLOR, coordinates.x * CELL_SCALAR + 1, coordinates.y * CELL_SCALAR + 1, CELL_SCALAR - 2, CELL_SCALAR - 2)
def to_utm(c): xx, yy = UTM(c.x, c.y) return Coordinate(x=xx, y=yy)
from multiprocessing import Pool from CarSimulator import CarSim from coordinates import Coordinate from datetime import datetime from pprint import pprint cars = [ CarSim(home_coord=Coordinate(-22.255119, -45.709408), work_coord=Coordinate(-22.257200, -45.696122), work_start=6, work_end=16, weekend_coord=Coordinate(-21.677732, -45.920903), traveled_distance=110795, car_number=1), CarSim(home_coord=Coordinate(-23.564407, -46.671967), work_coord=Coordinate(-23.538597, -46.657996), work_start=7, work_end=17, weekend_coord=Coordinate(-23.964221, -46.326848), traveled_distance=26357, car_number=2), CarSim(home_coord=Coordinate(-23.200130, -45.894011), work_coord=Coordinate(-23.196123, -45.906720), work_start=8, work_end=18, weekend_coord=Coordinate(-22.921429, -47.073315), traveled_distance=165469, car_number=3), CarSim(home_coord=Coordinate(-22.911632, -47.043178), work_coord=Coordinate(-22.907581, -47.097748), work_start=9,
def pos(self): return Coordinate(self.lat, self.lon)
x, z = utils.vector(curso + 180) #scene.camera.pos=vec(camera.x, 100, camera.y) #scene.camera.axis=200*vec(x, -0.3 , z) tractor_3d.pos = tractor.get_vec(1.5) coords2 = coords.coords() puntoA = coords.N puntoB = coords.S dir2 = 0 for c in coords2: xx, yy = transform(wgs84, UTM, c.y, c.x) limit_line.append(vec(xx, .5, yy)) xx, yy = transform(wgs84, UTM, puntoA.y, puntoA.x) puntoA_UTM = Coordinate(x=xx, y=yy) qtemp = box(color=color.red, size=vec(10, 10, 10), pos=vec(xx, .5, yy)) xx, yy = transform(wgs84, UTM, puntoB.y, puntoB.x) puntoB_UTM = Coordinate(x=xx, y=yy) qtemp = box(color=color.red, size=vec(10, 10, 10), pos=vec(xx, .5, yy)) path = nav.create_path(puntoA, puntoB, coords2, 19, dir=dir2) for c in path: ab.append(vec(c.x, .5, c.y)) tractor.location = path[0] print( "AB COURSE", utils.bearing(puntoA_UTM, puntoB_UTM), 'dir', dir2, )
def coords(): c=[] it = iter(a2) for x in it: c.append(Coordinate(next(it),x)) return c
from coordinates import Coordinate Coordinate.default_order = 'yx' #LatLng a2=[-57.60292066257994,-32.50611756255547, -57.60297205739347,-32.50615205268225, -57.60301025882248,-32.50617470213633, -57.60306136074531,-32.50620900052363, -57.60311229179947,-32.50624318409665, -57.60315100280482,-32.50627808294304, -57.60320161110209,-32.50631203538786, -57.60324003717562,-32.50634669867563, -57.60327907811094,-32.50639354568394, -57.60330524684887,-32.50642874110989, -57.60334327112344,-32.50646300064111, -57.60338116446476,-32.50649711295513, -57.60343148481905,-32.50654193763789, -57.60349347550722,-32.50658579619365, -57.60353147742442,-32.50663108191755, -57.60358115020527,-32.5066753847905, -57.60361879345019,-32.50672027558904, -57.60365576583118,-32.50675323218182, -57.60369261922703,-32.50678608322988, -57.60370487740799,-32.50679701018622, -57.60376641040818,-32.50686309155864, -57.60381461340532,-32.50689482727132, -57.60385095855327,-32.50692722505864, -57.60389888046767,-32.50695876230078, -57.6039349781674,-32.50699095684453, -57.60397096067656,-32.50702304926471, -57.6040301190629,-32.50705354381842, -57.60407743552719,-32.50708491496439, -57.60410110364376,-32.50710654019912, -57.60415983039528,-32.50714910105806, -57.60421808420042,-32.50718037135181, -57.60425301204436,-32.50721301039808, -57.60429930134742,-32.50724498169188, -57.60435692746297,-32.50728760325015, -57.6044142607694,-32.50731875140785, -57.60448276095867,-32.50736046122292, -57.60450553610863,-32.5073705858876, -57.6045622162694,-32.50741257500166, -57.60459602237726,-32.50744433264639, -57.60460726275155,-32.50745489188055, -57.60465208582236,-32.50749699869215, -57.60469668640189,-32.50753889633991, -57.60471871826886,-32.5075707171429, -57.60476285617047,-32.50761251213643, -57.60480669103636,-32.50764400073192, -57.60483899444759,-32.50768642385164, -57.60487139939696,-32.50771788100744, -57.60490367051711,-32.50774920805741, -57.60494681114196,-32.5077801213795, -57.60498942168594,-32.50782151550147, -57.60503179802583,-32.50786268302199, -57.60505251781228,-32.50789370129613, -57.60508364415924,-32.5079347718176, -57.60511502358758,-32.50796521066311, -57.60515710572817,-32.50799522842882, -57.60520981365291,-32.50802482129387, -57.60525151579373,-32.50805458482627, -57.60528332118493,-32.50806397705107, -57.60533548560858,-32.50809326897593, -57.60540825252043,-32.50813202587126, -57.60544920754511,-32.50816132831082, -57.60548999176404,-32.50819050791178, -57.60553060639796,-32.50821956612789, -57.60557105250412,-32.50824850376839, -57.60561203205308,-32.50826731307744, -57.60566272128473,-32.50829573612782, -57.6057124360955,-32.50833396988432, -57.60578206043886,-32.50838123137872, -57.60582151392375,-32.50840949578853, -57.60586080592301,-32.50843764483679, -57.60589038269826,-32.50845623943521, -57.60592852568421,-32.50849392193576, -57.60595611433727,-32.50853173281213, -57.60599403638049,-32.50856889735331, -57.60602154829765,-32.50860613107622, -57.60604805232057,-32.50865266704123, -57.60606504646452,-32.50868982920262, -57.60606240724726,-32.50871808759277, -57.60606734397274,-32.50877398903109, -57.60607400479321,-32.50881093597959, -57.60607049380203,-32.50884805719344, -57.6060560100489,-32.50889457583278, -57.60605255477169,-32.50893133751012, -57.60603903942224,-32.50896828742567, -57.60601552499374,-32.50900543321588, -57.60599128136464,-32.50905147962025, -57.60595823400654,-32.50908845082301, -57.60591595218944,-32.50912519951262, -57.60588302046018,-32.50917042330983, -57.60585212822738,-32.50918896779346, -57.60582003604149,-32.50922512981924, -57.60577935675509,-32.50925230518323, -57.60573820983854,-32.5092965529943, -57.60569784476625,-32.50932350788839, -57.60567752014289,-32.50934126154741, -57.60562741087308,-32.50936845181924, -57.60559731227287,-32.50938646228867, -57.60554658558998,-32.50941407542671, -57.60550617296011,-32.50943272098203, -57.60545587915299,-32.50945171653005, -57.6054057797846,-32.50947059406134, -57.60535552174647,-32.5094979419495, -57.60531573363688,-32.50950785197326, -57.60527594763595,-32.50951776132931, -57.60523616391929,-32.509527670321, -57.60518648857471,-32.50953792592626, -57.6051666945081,-32.50953862104631, -57.60511700062349,-32.50954888010376, -57.6050571392179,-32.50955968595873, -57.60503708515496,-32.50956056675024, -57.60497670263447,-32.50957179411335, -57.60491636019614,-32.50958301414227, -57.60487610116531,-32.50959334457715, -57.60480593913005,-32.50959643040338, -57.60475580766703,-32.50959863478435, -57.60469563255798,-32.50960128012459, -57.60462540460853,-32.50960436826561, -57.60458527994101,-32.50959756498846, -57.60453506636661,-32.50959977190318, -57.60451496029179,-32.50959207780318, -57.6044445979342,-32.50959516843048, -57.60435390214044,-32.50958196482426, -57.60429335841993,-32.50957601387474, -57.60425275849406,-32.509560551786, -57.6042124016865,-32.50956232002244, -57.60416156339548,-32.50954726719146, -57.60413104715912,-32.50953994910893, -57.6040804938532,-32.50954216081801, -57.60401963496675,-32.50954522104995, -57.60396888790387,-32.50954788597964, -57.60392861187146,-32.50955865056937, -57.60386913346291,-32.50959627685618, -57.60383949317133,-32.50961502732607, -57.60380056235128,-32.50965135409943, -57.6037715489942,-32.50967821227535, -57.60374301955476,-32.50971342931813, -57.60370498601286,-32.50975743984498, -57.60367666277288,-32.50979249406594, -57.60366710228622,-32.50980135630433, -57.60363935932022,-32.50984459233077, -57.60361129101292,-32.50987932065036, -57.60358332740261,-32.50991391966245, -57.60355544890486,-32.50994857393851, -57.60351829130011,-32.50999183981931, -57.60348132808044,-32.51003487907185, -57.60346317768803,-32.51006040622615, -57.60343579344737,-32.51009447469336, -57.60340852321777,-32.51012840137111, -57.60338192173453,-32.51017026230242, -57.60336463941423,-32.51020340955052, -57.60333769905208,-32.51023688305241, -57.60331083582943,-32.51027011038992, -57.60330287938858,-32.51029438286103, -57.60328644124239,-32.5103348351422, -57.60326888275556,-32.51035937437091, -57.60326222720261,-32.51039908100743, -57.60325379335212,-32.51041518002366, -57.60323819129465,-32.51046285343837, -57.60322140367195,-32.51049473583377, -57.60321486668538,-32.51053378259339, -57.60320835814269,-32.5105726635574, -57.60320187750612,-32.51061137863948, -57.60319542396014,-32.51064992789945, -57.60318837989697,-32.51068073757669, -57.60317249440383,-32.51071943397936, -57.60315667444671,-32.51075796986817, -57.6031409198771,-32.51079634727822, -57.60313405110765,-32.51082666629432, -57.6031184893065,-32.51086474070483, -57.6031117130724,-32.5108948110944, -57.60309560921576,-32.51092520889165, -57.60308889922661,-32.51095505940175, -57.60307289604833,-32.51098523547907, -57.60305695194545,-32.51101530137606, -57.60304106590367,-32.51104525690138, -57.60302523745961,-32.51107510317708, -57.60300021863583,-32.51110526865735, -57.60297458893504,-32.51112814079161, -57.60293909128002,-32.51114420674261, -57.60289444730812,-32.51116066751647, -57.6028491346291,-32.51116994913323, -57.60281230086277,-32.51117165100828, -57.60275706176574,-32.51117420314086, -57.60273025697762,-32.5111826208039, -57.60267506219323,-32.51118517022264, -57.60261154616578,-32.51119527500241, -57.6025747828422,-32.5111969720684, -57.6025380257932,-32.51119866923312, -57.60248290073631,-32.51120121408447, -57.60243603451612,-32.51119620952741, -57.60239928250989,-32.51119790679682, -57.60236156424541,-32.51119247488294, -57.60230543487038,-32.51118788876866, -57.60226765643309,-32.51118244948664, -57.60222881808458,-32.51116985692428, -57.60219096726992,-32.51116440484277, -57.60216123147794,-32.51115135586181, -57.60211192461152,-32.51113195589215, -57.60208206156228,-32.51111885324705, -57.60204991478025,-32.51109129460909, -57.60203617476079,-32.51106277923277, -57.60203166175672,-32.51103373109716, -57.60202713253285,-32.51100457837806, -57.60203189694916,-32.51097488668607, -57.60203440784156,-32.51093036352417, -57.60203807020766,-32.51089300224874, -57.60203465446412,-32.51087076728315, -57.60203947138922,-32.51084058672205, -57.60203490252712,-32.51081073585211, -57.6020363003656,-32.51075779186665, -57.60203170281278,-32.51072763994042, -57.60203425137324,-32.51068175788537, -57.60202731148066,-32.51063607029641, -57.60203102368059,-32.51059735377742, -57.60203475274992,-32.51055845613162, -57.60203849923079,-32.5105193771678, -57.60203150279757,-32.51047279127408, -57.60202564275217,-32.51043377104563, -57.60202704215412,-32.51037837506291, -57.60201995452731,-32.51033100071815, -57.60201401791154,-32.51029131865755, -57.60200445746586,-32.51022743771745, -57.60201197669531,-32.5101459633198, -57.60201214927937,-32.51008050697182, -57.60202579159169,-32.51003868357326, -57.60202963293094,-32.50999713835733, -57.6020248108431,-32.50996414502902, -57.60203857664023,-32.50992175566721, -57.60204126815204,-32.50987129693236, -57.6020451843596,-32.5098289422093, -57.60205032753188,-32.50979481120154, -57.602054283123,-32.50975208389585, -57.60206708449484,-32.50970013786038, -57.60207110262959,-32.50965694733407, -57.60206747693033,-32.50963123099461, -57.60208161278735,-32.5095871994964, -57.60209461559852,-32.50953427386187, -57.60209753483058,-32.50948153897245, -57.60212085578107,-32.50942747106199, -57.60212507017238,-32.50938293187562, -57.60215003981929,-32.50933741597336, -57.60216384921429,-32.50928348684957, -57.6021788672463,-32.5092381766358, -57.60218345165117,-32.50919295344223, -57.60219728812701,-32.50913801833322, -57.60220307871693,-32.50910136720462, -57.60221004816135,-32.50907367684269, -57.60221588265678,-32.50903677911397, -57.60222173990128,-32.50899973960082, -57.60223927440573,-32.50897131776127, -57.60225343112563,-32.50891511027526, -57.60224884577307,-32.50887804282539, -57.60226538678226,-32.50883995306579, -57.60227253761424,-32.50881150401883, -57.60228786660767,-32.50876346027672, -57.60229266484377,-32.50871566232956, -57.60230812457683,-32.50866712427628, -57.60231415443501, -32.50862841035677, -57.60232020925937,-32.50858953572033, -57.60232628929163,-32.50855050066701, -57.60233248451335,-32.50851148530633, -57.60232684216707,-32.50846315508095, -57.60233195106866,-32.50841408647894, -57.60233595307974,-32.50835497953806, -57.60232913523623,-32.5082960154931, -57.60233429330816,-32.5082461062089, -57.60232857889443,-32.50819644637161, -57.60233248026156,-32.5081357030532, -57.60233753965789,-32.50808461365762, -57.6023437977092,-32.5080434295574, -57.60233674939641,-32.50798219671804, -57.60234421615846,-32.50795084786313, -57.60233950051204,-32.50790967441669, -57.60234345650848,-32.50784699199792, -57.60234862189004,-32.507794346145, -57.60234506549087,-32.50776297885449, -57.60236022132783,-32.50769874061753, -57.60236428790623,-32.5076346814667, -57.60235953817902,-32.5075921450269, -57.60236361691904,-32.50752736189926, -57.60235751526611,-32.50747319634464, -57.60235014708229,-32.50740778931968, -57.60235528969287,-32.50735222248319, -57.60236169534654,-32.5073073905866, -57.60235922803784,-32.50728525755272, -57.6023745966253,-32.5072170919838, -57.60238866737895,-32.50713657895911, -57.60241412619165,-32.50705376921716, -57.60242054092079,-32.50700664912976, -57.60244759805388,-32.5069343496389, -57.60245288023356,-32.5068748193367, -57.60246072366174,-32.5068386014141, -57.6024777603909,-32.50677765466997, -57.60249615897571,-32.50672828543738, -57.60250415281912,-32.50669147993925, -57.60252271038582,-32.50664164212189, -57.60253891382458,-32.5065671817592, -57.60255891230478,-32.50652891369061, -57.60258726133985,-32.50645271580659, -57.60261824662556,-32.50640085558179, -57.60264954865946,-32.50634948473545, -57.60268214634118,-32.50631025761272, -57.60271372200426,-32.50625816660981, -57.60275860057106,-32.50621737374578, -57.60279265228153,-32.50618980192746, -57.60280472951798,-32.50618896390775, -57.60292066257994,-32.50611756255547] def coords(): c=[] it = iter(a2) for x in it: c.append(Coordinate(next(it),x)) return c -32.50833971604509,-57.60371689069293 -32.50892990458863,-57.60319591094504 -32.5092751551263,-57.60379329378993 -32.5087316327793,-57.60421818978364 a= Coordinate( -32.5088816417372, -57.6041626632114 ) b= Coordinate( -32.5081807825576, -57.6032648107830 ) N= Coordinate(-32.50833971604509,-57.60371689069293) E= Coordinate(-32.50892990458863,-57.60319591094504) S= Coordinate(-32.5092751551263,-57.60379329378993) W= Coordinate(-32.5087316327793,-57.60421818978364)
import math from pathlib import Path from cremi.io import CremiFile from coordinates import Coordinate Coordinate.default_order = "zyx" default_sample = "A" l1_n5 = Path("/home/barnesc/shares/nearline/barnesc/data.n5") L1_RES = Coordinate(z=50, y=3.8, x=3.8) cremi_root = Path("/home/barnesc/work/synapse_detection/clefts/cremi/data") cremi_date = "20160501" cremi_fstr = "sample_{sample_id}_{padded}{date}.hdf" def cremi_path(root=cremi_root, sample=default_sample, padded=False, date=cremi_date): fname = cremi_fstr.format(sample_id=sample, padded="padded_" if padded else "", date=date) return Path(root) / fname def find_padding(sample=default_sample): unpadded = CremiFile(cremi_path(sample=sample), "r")
def to_wgs84(c): yy, xx = transform(UTM, wgs84, c.x, c.y) return Coordinate(xx, yy)
import json import requests import time client = get_mongo_client() db = client.carChain cursor = db.raw_sim_data.find({}) to_save = {} for document in cursor: plate = document['car_plate'] if not plate in to_save: to_save[plate] = [] trip = [(Coordinate.Get_coordinate_from_json(obj['location']), str(obj['time']).split('.')[0]) for obj in document['trip']] total_meters = [(round(Coordinate.Distance(trip[i - 1][0], trip[i][0])), trip[i][1]) for i in range(1, len(trip))] to_save[plate].extend(total_meters) correct_plates = { '1': 'TST-0001', '2': 'TST-0002', '3': 'TST-0003', '4': 'TST-0004', '5': 'TST-0005' } jsons = []
def toCoord(point): return Coordinate(x=point[0], y=point[1])