def __init__(self):
        super(AarhusTrafficWrapper, self).__init__()
        metadatafile = AbstractComposedWrapper.getFileObject(__file__, "aarhus-traffic-points.json", "rU")
        metadata = JOb(metadatafile)

        basesensordescription = SensorDescription()
        basesensordescription.source = "http://www.odaa.dk/api/action/datastore_search?resource_id=b3eeb0ff-c8a8-4824-99d6-e0a3747c8b0d"
        basesensordescription.namespace = "http://ict-citypulse.eu/"
        basesensordescription.author = "cityofaarhus" #or id of user profile
        basesensordescription.sensorType = "Aarhus_Road_Traffic" #serviceCategory
        basesensordescription.graphName = "aarhus_road_traffic#"
        basesensordescription.sourceType = "pull_http"
        basesensordescription.sourceFormat = "application/json" #MIMEs
        basesensordescription.information = "Road traffic for the City of Aarhus"
        # basesensordescription.cityName = "Aarhus"
        # basesensordescription.countryName = "Denmark"
        basesensordescription.movementBuffer = 3 # in meter, 0 means stationary
        basesensordescription.maxLatency = 2
        basesensordescription.updateInterval = 60 * 5  # with push an interval to send a keep alive message
        basesensordescription.fields = "TIMESTAMP, avgSpeed, vehicleCount, avgMeasuredTime".split(", ")

        basesensordescription.field.avgSpeed.propertyName = "AverageSpeed"
        basesensordescription.field.avgSpeed.propertyURI = basesensordescription.namespace + "city#AverageSpeed"
        basesensordescription.field.avgSpeed.unit = basesensordescription.namespace + "unit:km-per-hour"
        basesensordescription.field.avgSpeed.min = 0
        basesensordescription.field.avgSpeed.max = 250
        basesensordescription.field.avgSpeed.dataType = "float"
        basesensordescription.field.avgSpeed.showOnCityDashboard = True
        basesensordescription.field.avgSpeed.aggregationMethod = "sax"
        basesensordescription.field.avgSpeed.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 4}


        basesensordescription.field.vehicleCount.propertyName = "StreetVehicleCount"
        basesensordescription.field.vehicleCount.propertyURI = basesensordescription.namespace + "city#StreetVehicleCount"
        basesensordescription.field.vehicleCount.unit = basesensordescription.namespace + "unit:number-of-vehicle-per-5min"
        basesensordescription.field.vehicleCount.min = 0
        basesensordescription.field.vehicleCount.max = 1000
        basesensordescription.field.vehicleCount.dataType = "int"
        basesensordescription.field.vehicleCount.showOnCityDashboard = True
        basesensordescription.field.vehicleCount.aggregationMethod = "sax"
        basesensordescription.field.vehicleCount.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 4}


        basesensordescription.field.avgMeasuredTime.propertyName = "MeasuredTime"
        # basesensordescription.field.avgMeasuredTime.propertyName = "Property"
        # basesensordescription.field.avgMeasuredTime.propertyPrefix = "ssn"
        basesensordescription.field.avgMeasuredTime.propertyURI = basesensordescription.namespace + "city#AvgMeasuredTime"
        basesensordescription.field.avgMeasuredTime.unit = "http://purl.oclc.org/NET/muo/ucum/unit/time/minute" # basesensordescription.namespace + "unit:minutes"
        basesensordescription.field.avgMeasuredTime.min = 0
        basesensordescription.field.avgMeasuredTime.max = 1000
        basesensordescription.field.avgMeasuredTime.dataType = "int"

        basesensordescription.field.TIMESTAMP.propertyName = "MeasuredTime"
        basesensordescription.field.TIMESTAMP.propertyURI = basesensordescription.namespace + "city#MeasuredTime"
        basesensordescription.field.TIMESTAMP.unit = "http://purl.oclc.org/NET/muo/ucum/unit/time/minute" # basesensordescription.namespace + "unit:time#minutes"
        basesensordescription.field.TIMESTAMP.min = "2012-01-01T00:00:00"
        basesensordescription.field.TIMESTAMP.max = "2099-12-31T23:59:59"
        basesensordescription.field.TIMESTAMP.dataType = "datetime.datetime"
        basesensordescription.field.TIMESTAMP.format = "%Y-%m-%dT%H:%M:%S"
        basesensordescription.field.TIMESTAMP.skip_annotation = True

        basesensordescription.timestamp.inField = "TIMESTAMP"
        basesensordescription.timestamp.format = "%Y-%m-%dT%H:%M:%S"

        for point in metadata.result.records:
            sensordescription = basesensordescription.deepcopy()
            sensordescription.sensorName = "aarhus_road_traffic_" + str(point.REPORT_ID)
            sensordescription.sensorID = point.REPORT_ID
            sensordescription.fullSensorID = basesensordescription.namespace + "sensor/" + str(point.REPORT_ID)
            sensordescription.location = "LINESTRING(%s %s, %s %s)" % (point.POINT_1_LNG, point.POINT_1_LAT, point.POINT_2_LNG, point.POINT_2_LAT)
            sensordescription.cityName = [self.__getattr(point, "POINT_1_CITY", "n/a"), self.__getattr(point, "POINT_1_CITY", "n/a")]
            sensordescription.countryName = [self.__getattr(point, "POINT_1_COUNTRY", "n/a"), self.__getattr(point, "POINT_2_COUNTRY", "n/a")]
            sensordescription.streetName = [self.__getattr(point, "POINT_1_STREET", "n/a"), self.__getattr(point, "POINT_2_STREET", "n/a")]
            sensordescription.postalCode = [self.__getattr(point, "POINT_1_POSTAL_CODE", "n/a"), self.__getattr(point, "POINT_2_POSTAL_CODE", "n/a")]
            sensordescription.messagebus.routingKey = "Aarhus.Road.Traffic." + str(point.REPORT_ID)
            self.addWrapper(InternalWrapper(sensordescription))

        self.splitter = AarhusTrafficSplitter(self)
        self.connection = AarhusTrafficConnection(self)
    def __init__(self):
        super(ComposedAarhusPollutionWrapper, self).__init__()
        metadatafile = AbstractComposedWrapper.getFileObject(__file__, "metadata.json", "rU")
        metadata = JOb(metadatafile)

        basesensordescription = SensorDescription()
        basesensordescription.source = "???" # TODO
        basesensordescription.namespace = "http://ict-citypulse.eu/"
        basesensordescription.author = "cityofaarhus"
        basesensordescription.sensorType = "Aarhus_Pollution"
        basesensordescription.graphName = "aarhus_pollution#"
        basesensordescription.sourceType = "pull_http"
        basesensordescription.sourceFormat = "application/json"
        basesensordescription.information = "Pollution data for the City of Aarhus"
        basesensordescription.cityName = "Aarhus"
        basesensordescription.countryName = "Denmark"
        basesensordescription.movementBuffer = 3
        basesensordescription.maxLatency = 2
        basesensordescription.updateInterval = 5 * 60
        basesensordescription.fields = ["ozone", "particullate_matter", "carbon_monoxide", "sulfure_dioxide",
                                        "nitrogen_dioxide", "longitude", "latitude", "timestamp"]

        basesensordescription.field.ozone.propertyName = "Property"
        basesensordescription.field.ozone.propertyPrefix = "ssn"
        basesensordescription.field.ozone.propertyURI = basesensordescription.namespace + "city#Ozone"
        basesensordescription.field.ozone.unit = basesensordescription.namespace + "unit:km-per-hour"
        basesensordescription.field.ozone.min = 0
        basesensordescription.field.ozone.max = 150
        basesensordescription.field.ozone.dataType = "int"
        basesensordescription.field.ozone.showOnCityDashboard = True
        basesensordescription.field.vehicleCount.aggregationMethod = "sax"
        basesensordescription.field.vehicleCount.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 1}


        basesensordescription.field.particullate_matter.propertyName = "Property"
        basesensordescription.field.particullate_matter.propertyPrefix = "ssn"
        basesensordescription.field.particullate_matter.propertyURI = basesensordescription.namespace + "city#ParticleMatter"
        basesensordescription.field.particullate_matter.unit = basesensordescription.namespace + "unit:number-of-vehicle-per-5min"
        basesensordescription.field.particullate_matter.min = 0
        basesensordescription.field.particullate_matter.max = 10000
        basesensordescription.field.particullate_matter.dataType = "int"
        basesensordescription.field.particullate_matter.showOnCityDashboard = True
        basesensordescription.field.vehicleCount.aggregationMethod = "sax"
        basesensordescription.field.vehicleCount.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 1}


        basesensordescription.field.carbon_monoxide.propertyName = "Property"
        basesensordescription.field.carbon_monoxide.propertyPrefix = "ssn"
        basesensordescription.field.carbon_monoxide.propertyURI = basesensordescription.namespace + "city#CarbonMonoxide"
        basesensordescription.field.carbon_monoxide.unit = basesensordescription.namespace + "unit:minutes"
        basesensordescription.field.carbon_monoxide.min = 0
        basesensordescription.field.carbon_monoxide.max = 1000
        basesensordescription.field.carbon_monoxide.dataType = "int"
        basesensordescription.field.vehicleCount.aggregationMethod = "sax"
        basesensordescription.field.vehicleCount.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 1}


        basesensordescription.field.sulfure_dioxide.propertyName = "Property"
        basesensordescription.field.sulfure_dioxide.propertyPrefix = "ssn"
        basesensordescription.field.sulfure_dioxide.propertyURI = basesensordescription.namespace + "city#SulfureDioxide"
        basesensordescription.field.sulfure_dioxide.unit = basesensordescription.namespace + "unit:minutes"
        basesensordescription.field.sulfure_dioxide.min = 0
        basesensordescription.field.sulfure_dioxide.max = 1000
        basesensordescription.field.sulfure_dioxide.dataType = "int"
        basesensordescription.field.vehicleCount.aggregationMethod = "sax"
        basesensordescription.field.vehicleCount.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 1}


        basesensordescription.field.nitrogen_dioxide.propertyName = "Property"
        basesensordescription.field.nitrogen_dioxide.propertyPrefix = "ssn"
        basesensordescription.field.nitrogen_dioxide.propertyURI = basesensordescription.namespace + "city#NitrogenDioxide"
        basesensordescription.field.nitrogen_dioxide.unit = basesensordescription.namespace + "unit:minutes"
        basesensordescription.field.nitrogen_dioxide.min = 0
        basesensordescription.field.nitrogen_dioxide.max = 1000
        basesensordescription.field.nitrogen_dioxide.dataType = "int"
        basesensordescription.field.vehicleCount.aggregationMethod = "sax"
        basesensordescription.field.vehicleCount.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 1}


        basesensordescription.field.longitude.propertyName = "Property"
        basesensordescription.field.longitude.propertyPrefix = "ssn"
        basesensordescription.field.longitude.propertyURI = basesensordescription.namespace + "city#Longitude"
        basesensordescription.field.longitude.unit = basesensordescription.namespace + "unit:degrees"
        basesensordescription.field.longitude.min = 0
        basesensordescription.field.longitude.max = 180
        basesensordescription.field.longitude.dataType = "float"
        basesensordescription.field.vehicleCount.aggregationMethod = None


        basesensordescription.field.latitude.propertyName = "Property"
        basesensordescription.field.latitude.propertyPrefix = "ssn"
        basesensordescription.field.latitude.propertyURI = basesensordescription.namespace + "city#Latitude"
        basesensordescription.field.latitude.unit = basesensordescription.namespace + "unit:degrees"
        basesensordescription.field.latitude.min = 0
        basesensordescription.field.latitude.max = 180
        basesensordescription.field.latitude.dataType = "float"
        basesensordescription.field.vehicleCount.aggregationMethod = None


        basesensordescription.field.timestamp.propertyName = "MeasuredTime"
        basesensordescription.field.timestamp.propertyURI = basesensordescription.namespace + "city#MeasuredTime"
        basesensordescription.field.timestamp.unit = basesensordescription.namespace + "unit:time"
        basesensordescription.field.timestamp.min = "2012-01-01T00:00:00"
        basesensordescription.field.timestamp.max = "2099-12-31T23:59:59"
        basesensordescription.field.timestamp.dataType = "datetime.datetime"
        basesensordescription.field.timestamp.format = "%Y-%m-%d %H:%M:%S"
        basesensordescription.field.timestamp.skip_annotation = True

        basesensordescription.timestamp.inField = "timestamp"
        basesensordescription.timestamp.format = "%Y-%m-%d %H:%M:%S"

        for point in metadata:
            sensordescription = basesensordescription.deepcopy()
            sensordescription.sensorName = "aarhus_pollution_" + point["id"]
            sensordescription.sensorID = str(point["id"])
            sensordescription.fullSensorID = basesensordescription.namespace + "sensor/Aarhus-Pollution-" + sensordescription.sensorID
            sensordescription.location = "POINT(%(long)s %(lat)s)" % point
            sensordescription.messagebus.routingKey = "Aarhus.Pollution." + sensordescription.sensorID
            self.addWrapper(AarhusPollutionWrapper(sensordescription))
    def __init__(self):
        super(AarhusParkingWrapper, self).__init__()
        metadatafile = AbstractComposedWrapper.getFileObject(__file__, "aarhus_parking-address.csv", "rU")

        basesensordescription = SensorDescription()
        basesensordescription.source = "http://www.odaa.dk/api/action/datastore_search?resource_id=2a82a145-0195-4081-a13c-b0e587e9b89c"
        basesensordescription.namespace = "http://ict-citypulse.eu/"
        basesensordescription.author = "cityofaarhus"
        basesensordescription.sensorType = "Aarhus_Road_Parking"
        basesensordescription.graphName = "aarhus_road_parking#"
        basesensordescription.sourceType = "pull_http"
        basesensordescription.sourceFormat = "application/xml"
        basesensordescription.information = "Parking data for the City of Aarhus"
        basesensordescription.cityName = "Aarhus"
        basesensordescription.countryName = "Denmark"
        basesensordescription.movementBuffer = 3
        basesensordescription.maxLatency = 2
        basesensordescription.updateInterval = 60
        # basesensordescription.fields = ["vehicleCount", "totalSpaces", "garageCode"]
        basesensordescription.fields = ["vehicleCount", "totalSpaces"]

        # basesensordescription.field.garageCode.propertyName = "Property"
        # basesensordescription.field.garageCode.propertyPrefix = "ssn"
        # basesensordescription.field.garageCode.propertyURI = basesensordescription.namespace + "city#Garagecode"
        # basesensordescription.field.garageCode.min = ""
        # basesensordescription.field.garageCode.max = ""
        # basesensordescription.field.garageCode.dataType = "str"

        basesensordescription.field.totalSpaces.propertyName = "ParkingCapacity"
        basesensordescription.field.totalSpaces.propertyURI = basesensordescription.namespace + "city#TotalSpaces"
        # basesensordescription.field.totalSpaces.unit = "http://muo.net/Number"
        basesensordescription.field.totalSpaces.min = 0
        basesensordescription.field.totalSpaces.max = 10000
        basesensordescription.field.totalSpaces.dataType = "int"
        basesensordescription.field.totalSpaces.showOnCityDashboard = True
        basesensordescription.field.totalSpaces.aggregationMethod = None

        basesensordescription.field.vehicleCount.propertyName = "ParkingVehicleCount"
        basesensordescription.field.vehicleCount.propertyURI = basesensordescription.namespace + "city#ParkingVehicleCount"
        basesensordescription.field.vehicleCount.unit = basesensordescription.namespace + "unit:number-of-vehicle-per-1min"
        basesensordescription.field.vehicleCount.min = 0
        basesensordescription.field.vehicleCount.max = "@totalSpaces"
        basesensordescription.field.vehicleCount.dataType = "int"
        basesensordescription.field.vehicleCount.showOnCityDashboard = True
        basesensordescription.field.vehicleCount.aggregationMethod = "sax"
        basesensordescription.field.vehicleCount.aggregationConfiguration = {"alphabet_size": 5, "word_length": 3,
                                                                        "unit_of_window": "hours", "window_duration": 1}

        # basesensordescription.timestamp.inField = "updatetime"
        basesensordescription.timestamp.format = "%Y-%m-%d %H:%M:%S"

        metadata = csv.DictReader(metadatafile)

        for row in metadata:
            sensordescription = basesensordescription.deepcopy()
            sensordescription.sensorName = "aarhus_road_parking_" + nicename(row['garagecode'])
            sensordescription.sensorID = nicename(row['garagecode'])
            sensordescription.fullSensorID = basesensordescription.namespace + "sensor/" + sensordescription.sensorID
            sensordescription.location = "POINT(%s %s)" % (row['longitude'], row['latitude'])
            sensordescription.messagebus.routingKey = "Aarhus.Road.Parking." + sensordescription.sensorID
            sensordescription.streetName = self.__getattr(row, "street", "n/a")
            sensordescription.postalCode = self.__getattr(row, "postalcode", "n/a")

            # garage code only as sensorID embedded in an URI. Possibilities to read it unknown at this point.
            # sensordescription.staticproperties.garageCode.propertyName = "Property"
            # sensordescription.staticproperties.garageCode.propertyPrefix = "ssn"
            # sensordescription.staticproperties.garageCode.propertyURI = basesensordescription.namespace + "city#Garagecode"
            # sensordescription.staticproperties.garageCode.dataType = "str"
            # sensordescription.staticproperties.garageCode.value = sensordescription.sensorID

            self.addWrapper(InternalWrapper(sensordescription))

        self.connection = HttpPullConnection(self, basesensordescription.source)
        self.splitter = AarhusParkingSplitterJson(self)