Re: [Pymag-devel] IndexError when too many POIs
Status: Alpha
Brought to you by:
lhj
From: bp <bp...@po...> - 2009-11-02 09:45:48
|
Ok, after some day of debugging and trying to figure out how the code works, I found that layer.optimize is called for optimizing layers before closing them. Here cellelements could be moved to new cells. This method returns a dictionary with changes, however this result was not used after optimizing POI layer. Than when closing POI layer, POI features were referenced to the old cell numbers, causing index error. To update POI features, here are the differencies in Map.py. Henrik could you revise it? @@ -359,7 +359,7 @@ ## Optimize layers in groups logging.info('Optimizing cell structure of normal layers') - remaininglayers = list(self.layers + self._poiconfig.layers) + remaininglayers = list(self.layers) if self.groups != None: for group in self.groups: group.optimizeLayers() @@ -380,8 +380,16 @@ ## Optimize remaining layers + + for layer in self._poiconfig.layers: + remapdict = layer.optimize() + for feature in self._poigroup._features: + if len(remapdict) > 0: + feature.cellelementrefs = tuple([remapdict[ceref] for ceref in feature.cellelementrefs]) + if self.maptype == MapTypeStreetRoute: logging.info('Optimizing cell structure of routing layers') + for layer in remaininglayers: layer.optimize() Regards Peter > Hi, > > I have a datasource with a huge number of POIs > When I compile the map I get the following error: > IndexError: num_in_cell (1136) is outside the # of cellelements (0) in > cell 1, layer poi > If I limit the number of POIs by filtering out some types in rule file, > than map is compiled ok. > > Is this a limitation in the map format or a bug? > > ... > DEBUG Optimizing layer poi > DEBUG Max cell elements exceeded for layer poi. cellnum=1, # of cell > elements=18994 > DEBUG Max cell elements exceeded for layer poi. cellnum=1, # of cell > elements=18994 > DEBUG nlevels=2 for layer poi > INFO Closing map > Traceback (most recent call last): > File "pymagellan\osmmagellan\osmmag.py", line 260, in <module> > main() > File "pymagellan\osmmagellan\osmmag.py", line 256, in main > db=options.db > File "pymagellan\osmmagellan\osmmag.py", line 97, in osmmag > m.close() > File "d:\Python26\lib\site-packages\magellan\Map.py", line 413, in close > self._poigroup.close() > File "d:\Python26\lib\site-packages\magellan\POI.py", line 201, in close > for ref, e in zip(f.cellelementrefs, f.getCellElements(self.map)): > File "d:\Python26\lib\site-packages\magellan\POI.py", line 518, in > getCellElements > return [layer.getCellElement(ceref) for ceref in self.cellelementrefs] > File "d:\Python26\lib\site-packages\magellan\Layer.py", line 712, in > getCellElement > raise IndexError,"num_in_cell (%d) is outside the # of cellelements > (%d) in cell %d, layer %s"%(num_in_cell,len(cell),cellnum, self.name) > IndexError: num_in_cell (1136) is outside the # of cellelements (0) in > cell 1, layer poi > |