def create_dxf(measurement, temp): series_id, series_name, profile = retrieve_profile.retrieve( measurement.filename, measurement.scheduled.location.location_code) filename = "{id}.dxf".format( id=measurement.scheduled.location.location_code) filepath = os.path.join(temp, filename) success = dxf.save_as_dxf(profile, filepath) return filepath if success else None
def create_csv(measurement, temp): location_code = measurement.scheduled.location.location_code series_id, series_name, profile = retrieve_profile.retrieve( measurement.filename, location_code) base_line = profile.line midpoint = profile.midpoint if base_line is None or midpoint is None: # No base line. Skip! return # Get a tmp dir temp = tempfile.mkdtemp() filename = "{id}.csv".format(id=location_code) filepath = os.path.join(temp, filename) with open(filepath, 'w') as f: writer = csv.writer(f) writer.writerow(["Location:", location_code]) writer.writerow(["X-coordinaat:", profile.midpoint.x]) writer.writerow(["Y-coordinaat:", profile.midpoint.y]) writer.writerow(["Streefpeil:", -999]) writer.writerow(["Gemeten waterstand:", profile.waterlevel]) writer.writerow([]) writer.writerow([ "Afstand tot midden (m)", "Hoogte (m NAP)", "Hoogte zachte bodem (m NAP)"]) for m in profile.sorted_measurements: distance = base_line.distance_to_midpoint(m.point) writer.writerow([ "{0:.2f}".format(distance), "{0:.2f}".format(m.z1), "{0:.2f}".format(m.z2)]) return filepath