def _points(self): points_coord = {} base_points = {} points = [] pid = 0 for row in self.rows: rec = _record(row) # Get angle and distance units if rec['type'] == 'MO': angle_unit = UNITS["angle"][rec['AU']] dist_unit = UNITS["distance"][rec['UN']] # Look for point coordinates if rec['type'] == 'SP': point_name = rec['PN'] northing = float(rec['N ']) # extra whitespace easting = float(rec['E ']) # extra whitespace elevation = float(rec['EL']) point = Point(easting, northing, elevation) attrib = [rec['note']] f = Feature(point, desc='PT', id=pid, point_name=point_name, dist_unit=dist_unit, attrib=attrib) points.append(f) pid += 1 points_coord[point_name] = point # Look for station coordinates if rec['type'] == 'OC': station_name = rec['OP'] northing = float(rec['N ']) # extra whitespace easting = float(rec['E ']) # extra whitespace elevation = float(rec['EL']) station_point = Point(easting, northing, elevation) points_coord[station_name] = station_point bp = BasePoint(x=easting, y=northing, z=elevation, ih=0, b_zero_st=0.0) base_points[station_name] = bp # Look for line of sight values # Finalize station computing if rec['type'] == 'LS': ih = float(rec['HI']) th = float(rec['HR']) attrib = [rec['note']] try: station_point except NameError: station_point = UNKNOWN_STATION stf = Feature(station_point, desc='ST', id=pid, point_name=station_name, dist_unit=dist_unit, attrib=attrib) bp = base_points[station_name] bp.ih = ih # Do not add station if previous station record is the same try: last_stf except NameError: last_stf = stf points.append(stf) pid += 1 else: if stf.point_name != last_stf.point_name or \ stf.geometry.x != last_stf.geometry.x or \ stf.geometry.y != last_stf.geometry.y or \ stf.geometry.z != last_stf.geometry.z: points.append(stf) pid += 1 last_stf = stf # Look for polar data if rec['type'] in ('SS', 'TR', 'BD', 'BR', 'FD', 'FR'): point_name = rec['FP'] attrib = [rec['note']] # Angle is recorded as azimuth or horizontal angle try: azimuth = float(rec['AZ']) except KeyError: azimuth = None # Angle is either Bearing, Angle Right or Left, Deflection Right or Left try: angle = float(rec['BR']) except KeyError: try: angle = float(rec['AR']) except KeyError: try: angle = float(rec['AL']) except KeyError: try: angle = float(rec['DR']) except KeyError: try: angle = float(rec['DL']) except KeyError: angle = None # Vertical angle is either Zenith, Vertical angle or Change elevation try: z_angle = float(rec['ZE']) except KeyError: try: z_angle = float(rec['VA']) except KeyError: try: z_angle = float(rec['CE']) except KeyError: z_angle = None try: dist = float(rec['SD']) except KeyError: try: dist = float(rec['HD']) except KeyError: dist = None else: dist = horizontal_to_slope(dist, z_angle, angle_unit) attrib = [rec['note']] p = PolarPoint(angle_unit=angle_unit, dist=dist, angle=angle, z_angle=z_angle, th=th, base_point=bp, pid=pid, text=point_name, coordorder='ENZ') point = p.to_point() f = Feature(point, desc='PT', id=pid, point_name=point_name, dist_unit=dist_unit, attrib=attrib) points.append(f) pid += 1 return points
def _points(self): '''Extract all RW5 data. This parser is based on the information in :ref:`if_carlson_rw5` Returns: A list of GeoJSON-like Feature object representing points coordinates. Raises: Notes: Sometimes needed records are commented so it is needed to parse also comments ''' points_coord = {} base_points = {} points = [] pid = 0 for row in self.rows: rec = _record(row) # Get angle and distance units if rec['type'] == 'MO': angle_unit = UNITS["angle"][rec['AU']] dist_unit = UNITS["distance"][rec['UN']] # Look for point coordinates if rec['type'] == 'SP': point_name = rec['PN'] northing = float(rec['N ']) # extra whitespace easting = float(rec['E ']) # extra whitespace elevation = float(rec['EL']) point = Point(easting, northing, elevation) attrib = [rec['note']] f = Feature(point, desc='PT', id=pid, point_name=point_name, dist_unit=dist_unit, attrib=attrib) points.append(f) pid += 1 points_coord[point_name] = point # Look for station coordinates if rec['type'] == 'OC': station_name = rec['OP'] northing = float(rec['N ']) # extra whitespace easting = float(rec['E ']) # extra whitespace elevation = float(rec['EL']) station_point = Point(easting, northing, elevation) points_coord[station_name] = station_point bp = BasePoint(x=easting, y=northing, z=elevation, ih=0, b_zero_st=0.0) base_points[station_name] = bp # Look for line of sight values # Finalize station computing if rec['type'] == 'LS': ih = float(rec['HI']) th = float(rec['HR']) attrib = [rec['note']] try: station_point except NameError: station_point = UNKNOWN_STATION stf = Feature(station_point, desc='ST', id=pid, point_name=station_name, dist_unit=dist_unit, attrib=attrib) bp = base_points[station_name] bp.ih = ih # Do not add station if previous station record is the same try: last_stf except NameError: last_stf = stf points.append(stf) pid += 1 else: if stf.point_name != last_stf.point_name or \ stf.geometry.x != last_stf.geometry.x or \ stf.geometry.y != last_stf.geometry.y or \ stf.geometry.z != last_stf.geometry.z: points.append(stf) pid += 1 last_stf = stf # Look for polar data if rec['type'] in ('SS', 'TR', 'BD', 'BR', 'FD', 'FR'): point_name = rec['FP'] attrib = [rec['note']] # Angle is recorded as azimuth or horizontal angle try: azimuth = float(rec['AZ']) except KeyError: azimuth = None # Angle is either Bearing, Angle Right or Left, Deflection Right or Left try: angle = float(rec['BR']) except KeyError: try: angle = float(rec['AR']) except KeyError: try: angle = float(rec['AL']) except KeyError: try: angle = float(rec['DR']) except KeyError: try: angle = float(rec['DL']) except KeyError: angle = None # Vertical angle is either Zenith, Vertical angle or Change elevation try: z_angle = float(rec['ZE']) except KeyError: try: z_angle = float(rec['VA']) except KeyError: try: z_angle = float(rec['CE']) except KeyError: z_angle = None try: dist = float(rec['SD']) except KeyError: try: dist = float(rec['HD']) except KeyError: dist = None else: dist = horizontal_to_slope(dist, z_angle, angle_unit) attrib = [rec['note']] p = PolarPoint(angle_unit=angle_unit, dist=dist, angle=angle, z_angle=z_angle, th=th, base_point=bp, pid=pid, text=point_name, coordorder='ENZ') point = p.to_point() f = Feature(point, desc='PT', id=pid, point_name=point_name, dist_unit=dist_unit, attrib=attrib) points.append(f) pid += 1 return points
def _points(self): '''Extract all GSI data. This parser is based on the information in :ref:`if_leica_gsi` Returns: A list of GeoJSON-like Feature object representing points coordinates. Raises: KeyError: An error occured during line read, this line could not be computed as the WI does not exist. KeyError: An error occured during computation, the data does not exist. Notes: Information needed are: - station : 11, 84, 85, 86, 88 - direct point : 11, 81, 82, 83 - computed point : 11, 21, 22, 31 or 32, 87 [, 88] [, 81, 82, 83] ''' points = [] bp = None ldata = len(self.line[0].split()[0].lstrip('*')[7:]) for line in self.line: tokens = line.split() self.tdict = {} for t in tokens: t = t.lstrip('*') data = { 'wordindex': t[0:2], 'info': t[2:6], 'sign': t[6], 'data': t[7:], } self.tdict[data['wordindex']] = data try: pid = int(self.tdict['11']['info']) text = self.tdict['11']['data'].lstrip('0') except KeyError: pass else: # Get angle and distance units try: angle_code = list(UNITS['angle'] & set(self.tdict.keys()))[0] angle_unit = UNITS[self.tdict[angle_code]['info'][3]] except IndexError: pass try: dist_code = list(UNITS['distance'] & set(self.tdict.keys()))[0] dist_unit = UNITS[self.tdict[dist_code]['info'][3]] except IndexError: pass # Beginning of the parsing try: # Look for point coordinates x, y, z = self.tdict['81'], self.tdict['82'], self.tdict[ '83'] except KeyError: try: angle, z_angle = self.tdict['21'], self.tdict['22'] # 31 or/and 32 try: slope_dist = self.tdict['31'] except KeyError: slope_dist = None try: horizontal_dist = self.tdict['32'] except KeyError: horizontal_dist = None if horizontal_dist is None and slope_dist is None: raise KeyError th = self.tdict['87'] except KeyError: try: # Look for a station x, y, z = self.tdict['84'], self.tdict[ '85'], self.tdict['86'] ih = self.tdict['88'] except KeyError: pass else: # Compute station data x, y, z = self._get_coordinates( "84", UNITS[dist_unit]) ih = self._get_value("88", UNITS[dist_unit]) bp = BasePoint(x=x, y=y, z=z, ih=ih, b_zero_st=0.0) p = Point(x, y, z) f = Feature(p, desc='ST', id=pid, point_name=text, dist_unit=dist_unit) points.append(f) else: angle = self._get_angle("21", UNITS[angle_unit]) z_angle = self._get_angle("22", UNITS[angle_unit]) if slope_dist: slope_dist = self._get_value( "31", UNITS[dist_unit]) if horizontal_dist: horizontal_dist = self._get_value( "32", UNITS[dist_unit]) # Need to convert horizontal distance to slope distance slope_dist = horizontal_to_slope( horizontal_dist, z_angle, angle_unit) th = self._get_value("87", UNITS[dist_unit]) # Polar data may have point coordinates (not used) x, y, z = self._get_coordinates("81", UNITS[dist_unit]) # Polar data may have instrument height ih = self._get_value("88", UNITS[dist_unit]) if ih is None: ih = 0.0 if bp is None: bp = BasePoint(x=0.0, y=0.0, z=0.0, ih=ih, b_zero_st=0.0) p = PolarPoint(angle_unit=angle_unit, dist=slope_dist, angle=angle, z_angle=z_angle, th=th, base_point=bp, pid=pid, text=text, coordorder='ENZ') f = Feature(p.to_point(), desc='PT', id=pid, point_name=text) points.append(f) else: x, y, z = self._get_coordinates("81", UNITS[dist_unit]) p = Point(x, y, z) f = Feature(p, desc='PT', id=pid, point_name=text) points.append(f) return points
def _points(self): points = [] bp = None ldata = len(self.line[0].split()[0].lstrip('*')[7:]) for line in self.line: tokens = line.split() self.tdict = {} for t in tokens: t = t.lstrip('*') data = { 'wordindex': t[0:2], 'info': t[2:6], 'sign': t[6], 'data': t[7:], } self.tdict[data['wordindex']] = data try: pid = int(self.tdict['11']['info']) text = self.tdict['11']['data'].lstrip('0') except KeyError: pass else: # Get angle and distance units try: angle_code = list(UNITS['angle'] & set(self.tdict.keys()))[0] angle_unit = UNITS[self.tdict[angle_code]['info'][3]] except IndexError: pass try: dist_code = list(UNITS['distance'] & set(self.tdict.keys()))[0] dist_unit = UNITS[self.tdict[dist_code]['info'][3]] except IndexError: pass # Beginning of the parsing try: # Look for point coordinates x, y, z = self.tdict['81'], self.tdict['82'], self.tdict['83'] except KeyError: try: angle, z_angle = self.tdict['21'], self.tdict['22'] # 31 or/and 32 try: slope_dist = self.tdict['31'] except KeyError: slope_dist = None try: horizontal_dist = self.tdict['32'] except KeyError: horizontal_dist = None if horizontal_dist is None and slope_dist is None: raise KeyError th = self.tdict['87'] except KeyError: try: # Look for a station x, y, z = self.tdict['84'], self.tdict['85'], self.tdict['86'] ih = self.tdict['88'] except KeyError: pass else: # Compute station data x, y, z = self._get_coordinates("84", UNITS[dist_unit]) ih = self._get_value("88", UNITS[dist_unit]) bp = BasePoint(x=x, y=y, z=z, ih=ih, b_zero_st=0.0) p = Point(x, y, z) f = Feature(p, desc='ST', id=pid, point_name=text, dist_unit=dist_unit) points.append(f) else: angle = self._get_angle("21", UNITS[angle_unit]) z_angle = self._get_angle("22", UNITS[angle_unit]) if slope_dist: slope_dist = self._get_value("31", UNITS[dist_unit]) if horizontal_dist: horizontal_dist = self._get_value("32", UNITS[dist_unit]) # Need to convert horizontal distance to slope distance slope_dist = horizontal_to_slope(horizontal_dist, z_angle, angle_unit) th = self._get_value("87", UNITS[dist_unit]) # Polar data may have point coordinates (not used) x, y, z = self._get_coordinates("81", UNITS[dist_unit]) # Polar data may have instrument height ih = self._get_value("88", UNITS[dist_unit]) if ih is None: ih = 0.0 if bp is None: bp = BasePoint(x=0.0, y=0.0, z=0.0, ih=ih, b_zero_st=0.0) p = PolarPoint(angle_unit=angle_unit, dist=slope_dist, angle=angle, z_angle=z_angle, th=th, base_point=bp, pid=pid, text=text, coordorder='ENZ') f = Feature(p.to_point(), desc='PT', id=pid, point_name=text) points.append(f) else: x, y, z = self._get_coordinates("81", UNITS[dist_unit]) p = Point(x, y, z) f = Feature(p, desc='PT', id=pid, point_name=text) points.append(f) return points