[udig-devel] About creating temporary resources in uDIG 1.0.5
Jesse Eichar
jeichar at refractions.net
Thu Aug 24 10:54:18 PDT 2006
Hi I can't really see too much that is wronge here. The only thing I
don't see is a call to ds.createSchema(ftType) if the MemoryDataStore
doesn't have the feature type declared already.
Jesse
On 21-Aug-06, at 12:39 PM, Schmitt, Magna (CIP) wrote:
> Hello:
> I am using the stable 1.0.5 uDIg version but I would like to know
> how can I create a temporary Resource giving a Feature Type
>
> In this part there is a code that runs ok in uDig 1.1
> /
> **********************************************************************
> ***************/
> features=utils.getStringsAsPointFeatures(tempString,1,2,3,taxon);
> if (chunkCounter==1)
> {
>
> FeatureType ftType=features
> [0].getFeatureType();
> resource = CatalogPlugin.getDefault
> ().getLocalCatalog().createTemporaryResource(ftType);
> featureStore= resource.resolve
> (FeatureStore.class,null);
> FeatureReader aReader =
> DataUtilities.reader(features);
> featureStore.addFeatures(aReader);
> IMap map =
> PlatformGIS.getActiveMap();
> int index = map.getMapLayers
> ().size();
> ApplicationGIS.addLayersToMap(map, Collections.singletonList
> (resource), index, null);
>
> }
> else {
> FeatureReader aReader =
> DataUtilities.reader(features);
> featureStore.addFeatures(aReader);
> }
>
> }
> /
> **********************************************************************
> ******/
> In this part, I tried to create a MemoryDataStore to have the same
> results as the last one but I do not know what should I do in
> order to add a collection of Resources to a Map
>
>
> features=utils.getStringsAsPointFeatures(tempString,1,2,3,taxon);
> if (chunkCounter==1)
> {
> FeatureType ftType=features
> [0].getFeatureType();
>
> IGeoResource resource1 =null;
> ICatalog catalog =
> CatalogPlugin.getDefault().getLocalCatalog();
> List<IService> services =
> catalog.findService(MemoryService.URL);
> IService service=null;
> if( services.isEmpty() ){
> service = createService(catalog); //
> createService method is already implemented
> }else{
> IResolve resolve=services.get(0);
> if (resolve instanceof IGeoResource) {
> resource1 = (IGeoResource) resolve;
> service=resource1.service(null);
> }else if (resolve instanceof IService) {
> service=(IService) services.get(0);
> }
> }
>
>
> MemoryDataStore ds=service.resolve
> (MemoryDataStore.class, null);
> try{
> ds.getSchema(ftType.getTypeName());
> }catch( SchemaNotFoundException exception){
> // verified that schema does not yet exist.
> }
> ds.addFeatures(features);
>
>
> resource = resource1;//I am not sure in
> this part
> featureStore= resource.resolve
> (FeatureStore.class,null);
> FeatureReader aReader =
> DataUtilities.reader(features);
> featureStore.addFeatures(aReader);
> IMap map =
> PlatformGIS.getActiveMap();
> int index = map.getMapLayers
> ().size();
> PlatformGIS.addLayersToActiveMap
> (Collections.singletonList(resource));
> /
> **********************************************************************
> ************************************/
> Thank you in advance for any help
> Magna
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
More information about the udig-devel
mailing list