Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [udig-devel] adding a feature to the current map

Hello!

I understand you..  Before getting my project from customer (last summer) I
spent 3 months only debugging UDIG, geotools, JTS, etc.. studying it.
Without implementation at all. There was no way to get know the architecture
and capabilities. I agree there are no good materials, docs, they are not
consistent and do not make the whole picture.. (but the progress during the
year is obvious in any way), API is changing.. etc.
>From my point of view there was no other way to do it for me.. I also was
tired hundred times when didn't understand something.. that's true. Now I
have much more clear picture.

I was thinking only to give a direction where to go (when trying to help)..
When in the example I start with ready ShapefileDataStore, I suppose you
know how to create a new ShapefileDataStore and write your features to it..

The same with MemoryDataStore.. I didn't work with it. But from the
experience of Catalog API, IResolve, IService, IGeoResource.. it is pretty
the same.

I have looked into the memory plugin.. Probably it would be something like
that:

....................
NewServiceConnectionFactory factory = new NewServiceConnectionFactory();
Map<String, Serializable> params = factory.createConnectionParameters(null);
MemoryServiceImpl service = new MemoryServiceImpl(MemoryService.URL);
AnotherMemoryDataStore dataStore =
service.resolve(AnotherMemoryDataStore.class,  new
NullProgressMonitor());

//Here is important step. You should create FeatureType for your layer
DefaultFeatureTypeFactory ftFactory = new DefaultFeatureTypeFactory();
AttributeType at = AttributeTypeFactory.newAttributeType("geom",
Polygon.class);
ftFactory.addType(at);

ftFactory.setName("myFeatureType");
FeatureType dbFeatureType = ftFactory.getFeatureType();
			
dataStore.createSchema(dbFeatureType);			

List<? extends IGeoResource>  geoResourceList =  (List<? extends
IGeoResource>)service.resolve(List.class,new NullProgressMonitor());
.........................

You have list of IGeoResource .. so you are able to create Map, Layer,
whatever (look into my previous examples)


I didn't test those things.. I just help to show the direction where to go..




I suppose you are able to create Layer from IGeoResource.
Then you can resolve AnotherMemoryDataStore from it (or from IService) and
use it to add features that conforms to created FeatureType before..

Regards, Vitali.





Back to the top