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

I've been following this thread and we have 2 things in the works right now.

1.  A method in Catalog which is essentially:

public IGeoResource catalog.createTempResource( Object type ); 2. Cory is now working on a wizard so if a temporary layer exists in a map a wizard will automatically be opened prompting the user to save the layer.

The method in point 1 will be in tonight's nightly build.

Other than that Vitali has good advice. Here is some pseudo code for how to open a new map with you layer.

DefaultFeatureTypeFactory ftFactory = new DefaultFeatureTypeFactory();
AttributeType at = AttributeTypeFactory.newAttributeType("geom",
Polygon.class);
ftFactory.addType(at);

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


IGeoResource resource=CatalogPlugin.getDefault().getLocalCatalog.createTempResource( dbFeatureType );

CreateMapCommand command=new CreateMapCommand( "New Map", Collections.singletonList(resource), null );

ApplicationGIS.getActiveProject( ).sendASync( command );


(The last two lines can be combined if you don't care about the map name with ApplicationGIS.createAndOpenMap() )

Jesse

Vitali Diatchkov wrote:
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.



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel



Back to the top