[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: Problem with reusing a featuretype (was: Re: [udig-devel] two questions about using shapefiles for uncommon things)
|
Just to be clear it is the name of the feature type that determines
if the featuretype can be added. The feature type can have the same
signature.
But it cannot be the exact same feature type object. You do need
another one.
You can copy between feature types but in the iterator you have to
convert between the two feature types.
Jesse
On Mar 27, 2007, at 4:40 AM, Adrian Custer wrote:
Hey,
The issue is not with your use of featuretype which is reasonable.
The issue is with the in-memory data store,
*Simple*MemoryDataStore. The
data store was made to be *very* simple, so simple that it is using
the
featuretype to separate the different kinds of things it has in
storage.
This implies a limitation: you can't create two resources with exactly
the same type.
An easy solution is to keep the featuretype, changing only the name.
Another solution is to save each layer to disk as you make it before
putting another into the memory data store. Another solution is to
write
your own "MyNotSoSimpleMemoryDataStore". Another ... you get the
idea.
--all the best
On Tue, 2007-03-27 at 12:00 +0200, tony.roth@xxxxxx wrote:
HI. If it's the intention that one cannot reuse a featuretype in the
way I tried, then it's ok. I just thought that a featuretype is
nothing more than a pattern for features and a ressource a container
for features of a certain type. 1:n relation instead of 1:1.
@adrian: Yes I can save the first ressource, perhaps it's the best
way.
Thank you!
tony roth
Von: Jesse Eichar jeichar@xxxxxxxxxxxxxxx
What I was trying to say is that you can't have the same
resource
twice in the same datastore, if you change the name it is no
longer
the same so you can change the name of the resource.
Jesse
On Mar 26, 2007, at 1:32 AM, Adrian Custer wrote:
Hello,
Yes, I think your second assumption is correct: you probably
can't
create two resources with the same feature type in the
SimpleMemoryDataStore. (I say "I think" because I'm
remembering this
vaguely from some time ago.). However, Jesse or others will
confirm
this
when they get to work West North American Coast time.
Can you save the first resource to an in memory database or
to disk?
--adrian
On Mon, 2007-03-26 at 09:51 +0200, tony.roth@xxxxxx wrote:
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
_______________________________________________
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
_______________________________________________
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