예제 #1
0
 def getTransformations(self, xmin, xmax, ymin, ymax, inputData, padding):
     xmin, xmax, ymin, ymax = self.computeInnerBoundingBox(xmin, xmax, ymin, ymax, inputData, padding)
     convertX = util.intervalMapping(self.xmin, self.xmax, xmin, xmax)
     convertY = util.intervalMapping(self.ymin, self.ymax, ymin, ymax)
     #         # new version: projection is integrated
     #         if self.projection is None:
     #             convertX = util.intervalMapping(self.xmin, self.xmax, xmin, xmax)
     #             convertY = util.intervalMapping(self.ymin, self.ymax, ymin, ymax)
     #         else:
     #             if projection == 'Mercator':
     #                 # Mercator cylindric projection
     #                 projX = lambda x: x
     #                 projY = lambda y: \
     #                     log( (1 + sin(y * pi / 180.0)) / cos(y * pi / 180.0))
     #             else:
     #                 pass
     #             # project first, then convert the projected value
     #             tmpX = util.intervalMapping(projX(self.xmin), projX(self.xmax),
     #                                         xmin, xmax)
     #             tmpY = util.intervalMapping(projY(self.ymin), projY(self.ymax),
     #                                         ymin, ymax)
     #             convertX = lambda x: tmpX(projX(x))
     #             convertY = lambda y: tmpY(projY(y))
     # in any case, return the transformations
     return convertX, convertY
예제 #2
0
    def getTransformations(self, xmin, xmax, ymin, ymax, inputData, padding):
        xmin, xmax, ymin, ymax = self.computeInnerBoundingBox(xmin, xmax,
                                                              ymin, ymax,
                                                              inputData,
                                                              padding)
        convertX = util.intervalMapping(self.xmin, self.xmax, xmin, xmax)
        convertY = util.intervalMapping(self.ymin, self.ymax, ymin, ymax)
#         # new version: projection is integrated
#         if self.projection is None:
#             convertX = util.intervalMapping(self.xmin, self.xmax, xmin, xmax)
#             convertY = util.intervalMapping(self.ymin, self.ymax, ymin, ymax)
#         else:
#             if projection == 'Mercator':
#                 # Mercator cylindric projection
#                 projX = lambda x: x
#                 projY = lambda y: \
#                     log( (1 + sin(y * pi / 180.0)) / cos(y * pi / 180.0))
#             else:
#                 pass
#             # project first, then convert the projected value
#             tmpX = util.intervalMapping(projX(self.xmin), projX(self.xmax),
#                                         xmin, xmax)
#             tmpY = util.intervalMapping(projY(self.ymin), projY(self.ymax),
#                                         ymin, ymax)
#             convertX = lambda x: tmpX(projX(x))
#             convertY = lambda y: tmpY(projY(y))
        # in any case, return the transformations
        return convertX, convertY
예제 #3
0
 def setParameter(self, parameterName, parameterValue):
     Style.setParameter(self, parameterName, parameterValue)
     if parameterName == 'width':
         self.timeToX = util.intervalMapping(self.earliest,
                                             self.latest,
                                             0.0,
                                             self.parameterValue['width'])
예제 #4
0
 def process(self):
     # pre-compute differences between consecutive colours
     self.colourDifference = [
         style.Colour(c2.red - c1.red, c2.green - c1.green,
                      c2.blue - c1.blue, c2.alpha - c1.alpha)
         for c1, c2 in zip(self.colours[:-1], self.colours[1:])
     ]
     # map input values to some index in the list of colours
     self.mapping = util.intervalMapping(min(self.values), max(self.values),
                                         0, float(len(self.colours) - 1))
예제 #5
0
 def process(self):
     # pre-compute differences between consecutive colours
     self.colourDifference = [ style.Colour(c2.red - c1.red,
                                            c2.green - c1.green,
                                            c2.blue - c1.blue,
                                            c2.alpha - c1.alpha)
                               for c1, c2 in zip(self.colours[:-1],
                                                 self.colours[1:])
                               ]
     # map input values to some index in the list of colours
     self.mapping = util.intervalMapping(min(self.values), max(self.values),
                                         0, float(len(self.colours) - 1) )
예제 #6
0
 def __init__(self, vrpData):
     # create a (n, n) matrix used as an approximation map to locate nodes:
     # each cell is either -1 (no node) or the index value of the closest node
     # in this region
     dimension = mapDimension  #max(len(self.nodes), 100)
     self.map = [[-1 for i in range(dimension)] for j in range(dimension)]
     # functions to convert coordinates to cells
     self.xCoordToRow = util.intervalMapping(vrpData.xmin, vrpData.xmax, 0,
                                             dimension - 1)
     self.yCoordToRow = util.intervalMapping(vrpData.ymin, vrpData.ymax, 0,
                                             dimension - 1)
     # now we fill it!
     for node in vrpData.nodes:
         i = int(round(self.xCoordToRow(node['x'])))
         j = int(round(self.yCoordToRow(node['y'])))
         for ioffset in range(1 - cellRangeInMap, cellRangeInMap):
             if i + ioffset < 0 or i + ioffset >= dimension:
                 continue
             for joffset in range(1 - cellRangeInMap, cellRangeInMap):
                 if j + joffset < 0 or j + joffset >= dimension:
                     continue
                 self.map[i + ioffset][j + joffset] = node['index']
예제 #7
0
 def __init__(self, vrpData):
 # create a (n, n) matrix used as an approximation map to locate nodes:
 # each cell is either -1 (no node) or the index value of the closest node
 # in this region
     dimension = mapDimension#max(len(self.nodes), 100)
     self.map = [ [ -1 for i in range(dimension) ]
                  for j in range(dimension) ]
     # functions to convert coordinates to cells
     self.xCoordToRow = util.intervalMapping(vrpData.xmin, vrpData.xmax,
                                             0, dimension-1)
     self.yCoordToRow = util.intervalMapping(vrpData.ymin, vrpData.ymax,
                                             0, dimension-1)
     # now we fill it!
     for node in vrpData.nodes:
         i = int(round(self.xCoordToRow(node['x'])))
         j = int(round(self.yCoordToRow(node['y'])))
         for ioffset in range(1 - cellRangeInMap, cellRangeInMap):
             if i + ioffset < 0 or i + ioffset >= dimension:
                 continue
             for joffset in range(1 - cellRangeInMap, cellRangeInMap):
                 if j + joffset < 0 or j + joffset >= dimension:
                     continue
                 self.map[i + ioffset][j + joffset] = node['index']
예제 #8
0
 def paint(self, inputData, solutionData,
           canvas, convertX, convertY,
           nodePredicate, routePredicate, arcPredicate,
           boundingBox):
     # first-time-only block
     if self.timeToX is None:
         self.earliest = \
             min( [ x['release time']
                    for x in inputData.nodes ], 0 )
         self.latest = max( [ x['due date']
                              for x in inputData.nodes ] )
         self.timeToX = util.intervalMapping(self.earliest, self.latest,
                                             0.0,
                                             self.parameterValue['width'])
     noDepotPred = lambda node: not node['is depot']
     if nodePredicate:
         newPredicate = \
             lambda node: nodePredicate(node) and noDepotPred(node)
     else:
         newPredicate = noDepotPred
     # now we can display everything we want
     # for each node display its background
     allX, allY, allW, allH = [], [], [], []
     style = DrawingStyle(self.parameterValue['background colour'],
                          self.parameterValue['background colour'],
                          lineThickness=self.parameterValue['thickness'])
     for node in inputData.nodes:
         if not newPredicate(node):
             continue
         allX.append(convertX(node['x']) + self.parameterValue['x offset'])
         allY.append(convertY(node['y']) + self.parameterValue['y offset'])
         allW.append(self.parameterValue['width'])
         allH.append(self.parameterValue['height'])
     canvas.drawRectangles(allX, allY, allW, allH, style,
                           referencePoint='southwest')
     # then display the TWs
     allX, allY, allW, allH = self.computeRectangles(inputData,
                                                     solutionData,
                                                     convertX,
                                                     convertY,
                                                     'release time',
                                                     'due date',
                                                     newPredicate)
     style = DrawingStyle(self.parameterValue['time window colour'],
                          self.parameterValue['time window colour'])
     canvas.drawRectangles(allX, allY, allW, allH, style,
                           referencePoint='southwest')
     # show waiting time if required
     visited = set([ x['index'] for x in solutionData.nodes if x['used'] ])
     if self.parameterValue['show waiting time']:
         allX, allY, allW, allH = self.computeRectangles(inputData,
                                                         solutionData,
                                                         convertX,
                                                         convertY,
                                                         '+arrival time',
                                                         '+start of service',
                                                         newPredicate,
                                                         .6)
         style = DrawingStyle(self.parameterValue['waiting time colour'],
                              self.parameterValue['waiting time colour'])
         canvas.drawRectangles(allX, allY, allW, allH, style,
                               referencePoint='southwest')
     # show service time if required
     if self.parameterValue['show service time']:
         allX, allY, allW, allH = self.computeRectangles(inputData,
                                                         solutionData,
                                                         convertX,
                                                         convertY,
                                                         '+start of service',
                                                         '+end of service',
                                                         newPredicate,
                                                         .6,
                                                         1)
         style = DrawingStyle(self.parameterValue['service time colour'],
                              self.parameterValue['service time colour'])
         canvas.drawRectangles(allX, allY, allW, allH, style,
                               referencePoint='southwest')
         
     # then the border around
     allX, allY, allW, allH = [], [], [], []
     style = DrawingStyle(self.parameterValue['contour colour'],
                          lineThickness=self.parameterValue['thickness'])
     for node in inputData.nodes:
         if not newPredicate(node):
             continue
         allX.append(convertX(node['x']) + self.parameterValue['x offset'])
         allY.append(convertY(node['y']) + self.parameterValue['y offset'])
         allW.append(self.parameterValue['width'])
         allH.append(self.parameterValue['height'])
     canvas.drawRectangles(allX, allY, allW, allH, style,
                           referencePoint='southwest')