예제 #1
0
파일: nerrs_wsdl.py 프로젝트: CowanSM/pyoos
	def parse_station(self, metadata, data):
		"""
			Creates a Station object from metadata and data for the station
			- metadata: NerrStation object
			- data: list of NerrData objects
			returns a Station object
		"""
		if not isinstance(metadata, NerrStation) or not isinstance(data, list) or len(data) < 1:
			return None

		retval = Station()
		retval.uid = metadata.code
		retval.name = metadata.name
		retval.description = str('%s-%s' % (metadata.id,metadata.code))
		point_dict = dict()
		for d in data:
			for value_date in d.value_and_utc():
				if value_date[0] is not None:
					param = d.get_top_param()
					if value_date[1] not in point_dict:
						point_dict[value_date[1]] = Point()
						point_dict[value_date[1]].time = value_date[1]
					if param.upper() == 'DEPTH':
						point_dict[value_date[1]].location = Location(metadata.location.longitude, metadata.location.latitude, float(value_date[0]))
					else:
						point_dict[value_date[1]].add_member(dict(name=param,value=value_date[0],unit=unit(param)))

		for point in point_dict.values():
			retval.add_element(point)

		retval.set_location(Location(metadata.location.longitude, metadata.location.latitude))

		return retval
예제 #2
0
    def __init__(self, wqx_metadata, wqx_data):
        if not isinstance(wqx_metadata, WqxOutbound):
            wqx_metadata = WqxOutbound(wqx_metadata)

        if not isinstance(wqx_data, WqxOutbound):
            wqx_data = WqxOutbound(wqx_data)

        if wqx_data.failed or wqx_metadata.failed:
            self.feature = None
        else:
            s = Station()
            s.uid = wqx_metadata.location.id
            s.name = wqx_metadata.location.name
            s.set_property("station_type", wqx_metadata.location.type)
            s.set_property("location_description", wqx_metadata.location.description)
            s.set_property("huc", wqx_metadata.location.huc)
            s.set_property("county", wqx_metadata.location.county)
            s.set_property("state", wqx_metadata.location.state)
            s.set_property("country", wqx_metadata.location.country)
            s.set_property("organization_id", wqx_metadata.organization.id)
            s.set_property("organization_name", wqx_metadata.organization.name)
            s.set_property("vertical_units", wqx_metadata.location.vertical_measure_units)
            s.set_property("horizontal_crs", wqx_metadata.location.horizontal_crs_name)
            s.set_property("vertical_crs", wqx_metadata.location.vertical_crs_name)

            for a in wqx_data.activities:
                p = Point()
                p.time = a.start_time

                for r in a.results:
                    p.add_member(Member(value=r.value, unit=r.units, name=r.name, description=r.short_name, standard=None, quality=r.quality, method_id=a.method_id, method_name=a.method_name))

                s.add_element(p)

            # Now set the station's location
            vertical = 0
            try:
                vertical = float(wqx_metadata.location.vertical_measure_value)
            except:
                pass

            # convert the vertical to meters if it is ft (which it always is)
            if wqx_metadata.location.vertical_measure_units == "ft":
                vertical /= 3.28084
                s.set_property("vertical_units", "m")
            s.location = sPoint(float(wqx_metadata.location.longitude), float(wqx_metadata.location.latitude), vertical)

            self.feature = s