Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Problems adding a layer programmatically

You really shouldn't need the 


FeatureReader fReader = new
CollectionFeatureReader(myFeatures,f.getFeatureType());

if you are adding the features using a featurestore.  

Also FYI the FeatureType you pass in determines the CRS of the layer.  The default geometry's Projection is used.  So when you are creating the default geometry attribute type set the CRS as the metadata parameter of the createAttribute method:

AttributeType.createAttributeType( "defaultGeom", Polygon.class, false, Filter.NONE, null, crs).

Something like that.  In this case the AttributeType will have the crs in its definition and the layer can then determine what CRS it is supposed to have,

Jesse

On 25-Jan-07, at 11:41 AM, David Fleig wrote:

I made a change to the code and I think I have it working now:

Feature f = createLocationFeature(CMH, "cmh1");
resource =
CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource(f.getFe
atureType());
FeatureStore mds;
try
{
mds = resource.resolve(FeatureStore.class,
null);
List myFeatures = new LinkedList();
myFeatures.add(f);
FeatureReader fReader = new
CollectionFeatureReader(myFeatures,f.getFeatureType());
mds.setFeatures(fReader);
}
catch (Exception e)
{
e.printStackTrace();
}



_______________________________________________
User-friendly Desktop Internet GIS (uDig)


Back to the top