[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[udig-devel] adding a layer from the memory store in rc10
|
Hey all,
Code that used to work now breaks and I'm not sure why although I have
discovered where. After creating a memory layer I'd like to add it to
the map. The layer builds fine and I can manually add it to the map
correctly. The code which works to create the Layer is:
IGeoResource newIGR = CatalogPlugin.getDefault().getLocalCatalog().
createTemporaryResource( myBufferFT );
FeatureStore newFS = null;
if (newIGR.canResolve(FeatureStore.class)) {
try {
newFS = newIGR.resolve(FeatureStore.class, monitor);;
} catch (Exception e) {
System.err.println(
"Resolving the IGeoResource failed with exception " + e);
// TODO: re-emit the exception, bail from the operation.
}
}
final Iterator<Feature> iter = Arrays.asList(myBufferF).iterator();
newFS.addFeatures( (FeatureReader) new FeatureReader(){
public boolean hasNext(){ return iter.hasNext(); }
public Feature next() { return iter.next(); }
// TODO: what should this be?
public void close() { ; }
public void remove() {throw new UnsupportedOperationException();}
public FeatureType getFeatureType(){return this.getFeatureType();}
}
);
// WHY? Creating the Layer is what adds it to the catalog!?
LayerFactoryImpl myLF = LayerFactoryImpl.create();
However the next line, fails:
myLF.createLayer(newIGR);
it fails in line 451 of LayerFactoryImpl which is:
ColourScheme colourScheme = getMap().getColourScheme();
because the getMap() returns null and so the .getColourScheme() doesn't
work which leads to the catch block at line 181 of OpAction.class.
Any ideas what I should be doing?
--adrian