Ejemplo n.º 1
0
    def parseDecaux(js, city):

        for record in js['records']:
            properties = record['fields']
            station = Station()

            station.setName(properties.get('name'))
            st_id = properties.get('number')
            station.setId(int(st_id) if st_id else st_id)

            coords = properties.get('position')
            if coords:
                station.setLattitude(float(coords[0]))
                station.setLongitude(float(coords[1]))

            total = properties.get('bike_stands')
            station.setTotal(int(total) if total else total)
            avail = properties.get('available_bikes')
            station.setAvailable(int(avail) if avail else avail)
            free = properties.get('available_bike_stands')
            station.setFree(int(free) if free else free)
            card = properties.get('banking')
            station.setCardPaiement(card != "False" if card else card)

            city.addStation(station)
Ejemplo n.º 2
0
    def parseV1(js, city):

        for feature in js['features']:
            properties = feature['properties']
            station = Station()
            station.setName(properties.get('name'))
            st_id = properties.get('number')
            station.setId(int(st_id) if st_id else st_id)
            lat = properties.get('lat')
            station.setLattitude(float(lat) if lat else lat)
            lon = properties.get('lng')
            station.setLongitude(float(lon) if lon else lon)
            total = properties.get('bike_stands')
            station.setTotal(int(total) if total else total)
            avail = properties.get('available_bikes')
            station.setAvailable(int(avail) if avail else avail)
            free = properties.get('available_bike_stands')
            station.setFree(int(free) if free else free)
            card = properties.get('banking')
            station.setCardPaiement(card == "true" if card else card)

            city.addStation(station)