def build(self):
        logger.debug("Building maps for conversion between real and image space")

        self.imagetree = {}
        self.imagemap = {}
        self.realtree = KDTree([x.realcoords for x in self.patches])
        self.realmapping = {}

        for num, patch in enumerate(self.patches):
            if num % 1000 == 0:
                logger.debug("Built maps for {0} of {1} patches".format(num, len(self.patches)))

            resp = {}
            for _, projection in self.projections.items():
                inimage = patch.project(projection)
                if projection.id not in self.imagetree:
                    self.imagetree[projection.id] = []
                    self.imagemap[projection.id] = {}
                self.imagetree[projection.id].append(inimage)
                self.imagemap[projection.id][tuple(inimage)] = patch.realcoords
                resp[projection.id] = inimage
                
            self.realmapping[tuple(patch.realcoords)] = resp

        logger.debug("Done building maps for {0} patches".format(len(self.patches)))

        logger.debug("Building image KD tree")
        for key, imagecoords in self.imagetree.items():
            self.imagetree[key] = KDTree(imagecoords)
dataset/ETHPy150Open cvondrick/pyvision/vision/reconstruction/pmvs.py/RealWorldMap.build/original