def from_dict(self, track_dict):
        """Populate this object's values with values from a dict, either from RCL's API or a file
        """

        self.start_finish_point = GeoPoint.fromPointJson(
            track_dict.get('start_finish'))
        self.finish_point = GeoPoint.fromPointJson(track_dict.get('finish'))
        self.country_code = track_dict.get('country_code', self.country_code)
        self.created = track_dict.get('created', self.created)
        self.updated = track_dict.get('updated', self.updated)
        self.name = track_dict.get('name', self.name)
        self.configuration = track_dict.get('configuration',
                                            self.configuration)
        self.length = track_dict.get('length', self.length)
        self.track_id = track_dict.get('id')

        map_points_array = track_dict.get('track_map_array')

        if map_points_array:
            for point in map_points_array:
                self.map_points.append(GeoPoint.fromPoint(point[0], point[1]))

        sector_array = track_dict.get('sector_points')

        if sector_array:
            for point in sector_array:
                self.sector_points.append(
                    GeoPoint.fromPoint(point[0], point[1]))

        if not self.short_id > 0:
            raise Warning("Could not parse trackMap: short_id is invalid")
    def from_dict(self, track_dict):
        """Populate this object's values with values from a dict, either from RCL's API or a file
        """

        self.start_finish_point = GeoPoint.fromPointJson(track_dict.get('start_finish'))
        self.finish_point = GeoPoint.fromPointJson(track_dict.get('finish'))
        self.country_code = track_dict.get('country_code', self.country_code)
        self.created = track_dict.get('created', self.created)
        self.updated = track_dict.get('updated', self.updated)
        self.name = track_dict.get('name', self.name)
        self.configuration = track_dict.get('configuration', self.configuration)
        self.length = track_dict.get('length', self.length)
        self.track_id = track_dict.get('id')

        map_points_array = track_dict.get('track_map_array')

        if map_points_array:
            for point in map_points_array:
                self.map_points.append(GeoPoint.fromPoint(point[0], point[1]))

        sector_array = track_dict.get('sector_points')

        if sector_array:
            for point in sector_array:
                self.sector_points.append(GeoPoint.fromPoint(point[0], point[1]))

        if not self.short_id > 0:
            raise Warning("Could not parse trackMap: short_id is invalid")
Пример #3
0
    def fromJson(self, trackJson):
        venueNode = trackJson.get('venue')
        if (venueNode):
            self.startFinishPoint = GeoPoint.fromPointJson(
                venueNode.get('start_finish'))
            self.finishPoint = GeoPoint.fromPointJson(venueNode.get('finish'))
            self.countryCode = venueNode.get('country_code', self.countryCode)
            self.updatedAt = venueNode.get('updated', self.updatedAt)
            self.name = venueNode.get('name', self.name)
            self.configuration = venueNode.get('configuration',
                                               self.configuration)
            self.length = venueNode.get('length', self.length)
            self.trackId = venueNode.get('id', self.trackId)

            mapPointsNode = venueNode.get('track_map_array')
            mapPoints = []
            if mapPointsNode:
                for point in mapPointsNode:
                    mapPoints.append(GeoPoint.fromPoint(point[0], point[1]))
            self.mapPoints = mapPoints

            sectorNode = venueNode.get('sector_points')
            sectorPoints = []
            if sectorNode:
                for point in sectorNode:
                    sectorPoints.append(GeoPoint.fromPoint(point[0], point[1]))
            self.sectorPoints = sectorPoints
Пример #4
0
 def fromJson(self, trackJson):
     venueNode = trackJson.get('venue')
     if (venueNode):
         self.startFinishPoint = GeoPoint.fromPointJson(venueNode.get('start_finish'))
         self.finishPoint = GeoPoint.fromPointJson(venueNode.get('finish'))
         self.countryCode = venueNode.get('country_code', self.countryCode)
         self.createdAt = venueNode.get('created', self.createdAt)
         self.updatedAt = venueNode.get('updated', self.updatedAt)
         self.name = venueNode.get('name', self.name)
         self.configuration = venueNode.get('configuration', self.configuration)
         self.length = venueNode.get('length', self.length)
         self.trackId = venueNode.get('id', self.trackId)
         self.shortId = self._createShortId()
         
         mapPointsNode = venueNode.get('track_map_array')
         mapPoints = []
         if mapPointsNode:
             for point in mapPointsNode:
                 mapPoints.append(GeoPoint.fromPoint(point[0], point[1]))
         self.mapPoints = mapPoints
                 
         sectorNode = venueNode.get('sector_points')
         sectorPoints = []
         if sectorNode:
             for point in sectorNode:
                 sectorPoints.append(GeoPoint.fromPoint(point[0], point[1]))
         self.sectorPoints = sectorPoints
         if not self.shortId > 0:
             raise Warning("Could not parse trackMap: shortId is invalid") 
Пример #5
0
    def fromJson(self, trackJson):
        venueNode = trackJson.get('venue')
        if (venueNode):
            self.startFinishPoint = GeoPoint.fromPointJson(
                venueNode.get('start_finish'))
            self.finishPoint = GeoPoint.fromPointJson(venueNode.get('finish'))
            self.countryCode = venueNode.get('country_code', self.countryCode)
            self.createdAt = venueNode.get('created', self.createdAt)
            self.updatedAt = venueNode.get('updated', self.updatedAt)
            self.name = venueNode.get('name', self.name)
            self.configuration = venueNode.get('configuration',
                                               self.configuration)
            self.length = venueNode.get('length', self.length)
            self.trackId = venueNode.get('id', self.trackId)
            self.shortId = self._createShortId()

            mapPointsNode = venueNode.get('track_map_array')
            mapPoints = []
            if mapPointsNode:
                for point in mapPointsNode:
                    mapPoints.append(GeoPoint.fromPoint(point[0], point[1]))
            self.mapPoints = mapPoints

            sectorNode = venueNode.get('sector_points')
            sectorPoints = []
            if sectorNode:
                for point in sectorNode:
                    sectorPoints.append(GeoPoint.fromPoint(point[0], point[1]))
            self.sectorPoints = sectorPoints
            if not self.shortId > 0:
                raise Warning("Could not parse trackMap: shortId is invalid")