def __init__(self, **kwargs): super(SweTimeSeries,self).__init__(**kwargs) # Parse out GML point. Defaults to 0 depth if none specified self.geo_srs = Crs(testXMLAttribute(self._location.find(nsp("Point", self.GML_NS)), 'srsName')) geo = [float(v) for v in testXMLValue(self._location.find(nsp("Point/pos", self.GML_NS))).split(" ")] if self.geo_srs.axisorder == "yx": self.geo = sPoint(geo[1], geo[0]) else: self.geo = sPoint(geo[0], geo[1]) try: self.geo.z = geo[2] except: pass pc = PointCollection() for row in self.results.data: p = Point() time = None z = None lat = None lon = None for field in row: if field.axis == "time": t = dateutil.parser.parse(field.value) p.time = t.astimezone(dateutil.tz.tzutc()) elif field.axis == "Long": lon = field elif field.axis == "Lat": lat = field elif field.axis == "h": z = field else: m = Member(value=field.value, unit=field.units, units_definition=field.units_url, name=field.name, definition=field.definition, standard=field.definition) p.add_member(m) # Set the spatial point if lon.srs != lat.srs: raise ValueError("Longitude and Latitude need to have the same SRS/CRS!") p.location = sPoint(float(lon.value), float(lat.value), float(z.value)) pc.add_element(p) self.data = pc
def calculate_bounds(self): """ Calculate the time_range, bbox, and size of this collection. Will scan all data. Ensures that .size, .bbox and .time_range return non-null. If the collection already knows its bbox; time_range; and/or size, they are recomputed. """ single_point_collection = PointCollection(elements=list(AsaList.flatten(self))) single_point_collection.calculate_bounds() self.bbox = single_point_collection.bbox self.time_range = single_point_collection.time_range self.depth_range = single_point_collection.depth_range self._point_size = single_point_collection.size self.size = len(self._elements)