Hi,
no, that's not correct. I create exactly one feature type with the
name and then I want to create two resources (later: two layer) of
this type. It's like
FeatureTypeBuilder featureBuilder
= FeatureTypeBuilder.newInstance(myFeatureTypeName);
// ... add attributes to this type
FeatureType featureType = featureBuilder.getFeatureType();
resource =
CatalogPlugin.getDefault().getLocalCatalog
().createTemporaryResource(featureType);
resource2 =
CatalogPlugin.getDefault().getLocalCatalog
().createTemporaryResource(featureType);
The second resource could not be build (see exception below). Either
it is not allowed to create more than one resource of a
featureType or
the implementaion in udig has a bug. I think it can be a common
usecase to have different layer containing features of the same
featuretype.
tony roth
Von: Jesse Eichar jeichar@xxxxxxxxxxxxxxx
Hi Tony,
I think that the problem is that the two feature types have
the same
name so the second can't be created.
Try something like:
FeatureTypeBuilder builder=new FeatureTypeBuilder();
builder.importType( oldType );
builder.setName( "newname" );
builder.getFeatureType();
Jesse
On Mar 23, 2007, at 9:08 AM, tony.roth@xxxxxx wrote:
Von: Jesse Eichar
On 20-Feb-07, at 4:38 AM, tony.roth@xxxxxx wrote:
Hi list,
in our project we are using jira plugins in our eclipse
rcp
application. It is used for the visualization of
different
facilities
on a map. The map is delivered by a wms server, the
facilities are
stored
in a database (mysql). To show these facilities a
temporary
shape file
is created. It was a funny thing writing mixed up big and
little
endian
variables with java but finally it works :-) (yes, I
suppose
somewhere
an api / lib exists but.. where?)
i) Is this the canonic way? Or is it somehow possible to
create an
in-memory layer instead of writing a shape file?
There are code snippets for just this sort of thing at:
http://svn.geotools.org/udig/branches/1.1.x/udig/tutorials/
net.refractions
.udig.code.examples/src/net/refractions/udig/code/examples/
I have a problem with reusing a generated featuretype:
At first I create the featuretype (this is done exactly
once):
FeatureTypeBuilder featureBuilder =
FeatureTypeBuilder.newInstance(myFeatureTypeName);
featureBuilder.addType(AttributeTypeFactory.newAttributeType
("geometry",
Point.class,true, Integer.MAX_VALUE, null,
DefaultGeographicCRS.WGS84));
featureBuilder.addType
(AttributeTypeFactory.newAttributeType("foo",
String.class, true, Integer.MAX_VALUE));
featureBuilder.addType
(AttributeTypeFactory.newAttributeType("bar",
String.class, true, Integer.MAX_VALUE));
FeatureType featureType = featureBuilder.getFeatureType();
then I create the ressource:
resource =
CatalogPlugin.getDefault().getLocalCatalog
().createTemporaryResource
(featureType);
I itereate through a list of values and add features to the
ressource:
GeometryFactory fac = new GeometryFactory();
FeatureStore fs = resource.resolve(FeatureStore.class,
null);
for (ListItem item : list) {
Coordinate pointCoordinate = new Coordinate(item.get...);
Point point = fac.createPoint(pointCoordinate);
String foo = item.get...
String bar = item.get...
Feature feature = featureType.create(new
Object[]{point,foo,bar});
fs.addFeatures(DataUtilities.collection(new
Feature[]{feature}));
}
finally I create the layer
LayerFactory layerFactory = map.getLayerFactory();
Layer layer = layerFactory.createLayer(resource);
...
This works and the layer is shown in the map
Later the application tries to create a new layer based on
a
resource of
this featuretype. It starts with
resource =
CatalogPlugin.getDefault().getLocalCatalog
().createTemporaryResource
(featureType);
(like above) but I get an exception:
java.lang.RuntimeException
at
net.refractions.udig.catalog.internal.CatalogImpl.createTemporaryReso
u
rce(CatalogImpl.java:749)
at ... the row with [resource = CatalogPlugin....] (see
above)
Caused by: java.lang.UnsupportedOperationException: Schema
modification not
supported
at
org.geotools.data.AbstractDataStore.updateSchema
(AbstractDataStore.java:228)
at
net.refractions.udig.catalog.memory.internal.TemporaryResourceFactory
.
createResource(TemporaryResourceFactory.java:48)
at
net.refractions.udig.catalog.internal.CatalogImpl.createTemporaryReso
u
rce(CatalogImpl.java:743)
... 54 more
What am I doing wrong? I'm not modifyfing the featureType
any more,
I just
want to create a new (a second) ressource based on the
featureType.
Isn't
it possible?
In
net.refractions.udig.catalog.memory.internal.TemporaryResourceFactory
.
createResource
udig wants to update the featureType but it seems to be not
allowed.
thanks for any help,
tony roth
ps At the moment we are using UDIG 1.1 RC8 in our project.
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
INVALID HTML
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel