Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Read/Writeable Layers with Mapgraphics ...and a Comment


Many thanks Jesse - exactly what I needed!

Pete


Jesse Eichar wrote:
> 
> For 1. here is a modified version:
> 
>                  IMap map = ApplicationGIS.getActiveMap();
>                  IGeoResource resource = null;
>                  try
>                  {
>                      /* code to construct the underlying feature type  
> for a layer */
>                      AttributeType geom =  
> AttributeTypeFactory.newAttributeType("the_geom",
>      Geometry.class);
>                      AttributeType idType =  
> AttributeTypeFactory.newAttributeType("theid",
>      Integer.class);
>                      AttributeType nameType =
>      AttributeTypeFactory.newAttributeType("thename", String.class);
>                      AttributeType descriptionType =
>      AttributeTypeFactory.newAttributeType("thedescription",  
> String.class);
>                      /* add other attribute types here */
>                      FeatureType featureType =  
> FeatureTypeBuilder.newFeatureType(new
>      AttributeType[] {geom, idType, nameType, descriptionType}, "2D  
> Area Layer");
>                      resource = CatalogPlugin.getDefault 
> ().getLocalCatalog()
>                      .createTemporaryResource(featureType);
>                  } catch (FactoryRegistryException e1)
>                  {
>                      // TODO Auto-generated catch block
>                      e1.printStackTrace();
>                  } catch (IllegalArgumentException e1)
>                  {
>                      // TODO Auto-generated catch block
>                      e1.printStackTrace();
>                  } catch (SchemaException e1)
>                  {
>                      // TODO Auto-generated catch block
>                      e1.printStackTrace();
>                  }
>                  ApplicationGIS.addLayersToMap(map,  
> Collections.singletonList(resource), 0);
> 
> 
> for 2:
> I'm not totally sure what you mean for this.  You want to create a  
> Map Graphic for drawing on the layer?  I'm assuming you want to draw  
> anything but they are just drawing and won't be added as features.   
> Correct?  For this you need 2 layers.  One for the Map Graphic and  
> another for the layer with the data.  The reason is that each layer  
> has exactly one renderer for the layer.  It sounds like you want  
> two.  We have a bug report:
> 
> http://jira.codehaus.org/browse/UDIG-1192
> 
> that will allow the layers view to be configured so it doesn't show  
> MapGraphics.  But for now you can do something like:
> 
>          TreeViewer viewer = (TreeViewer) LayersView.getViewer();
>          IContentProvider provider = viewer.getContentProvider();
>          viewer.setContentProvider(new  
> YourCustomFilteringContentProviderDecorator(provider));
> 
> where YourCustomFilteringContentProviderDecorator will filter out all  
> the layers that Resolve to MapGraphics.
> 
> Jesse
> 
> 
> On 14-Jan-07, at 4:10 PM, ukpete wrote:
> 
>>
>> A couple of questions (and thanks for taking the time to read them!).
>>
>> (1) How do I create a layer that isnt read-only?  Where I can use  
>> all the
>> standard tools in the UDig menu?
>>
>>   I have some code that works, but it uses a deprecated geotools  
>> method
>> (FeatureTypeFactory.newFeatureType):
>>
>> try
>> 		{
>> 			Map map = ApplicationGISInternal.getActiveMap();
>> 			IGeoResource resource = null;
>> 			try
>> 			{
>> 				/* code to construct the underlying feature type for a layer */
>> 				AttributeType geom = AttributeTypeFactory.newAttributeType 
>> ("the_geom",
>> Geometry.class);
>> 				AttributeType idType = AttributeTypeFactory.newAttributeType 
>> ("theid",
>> Integer.class);
>> 				AttributeType nameType =
>> AttributeTypeFactory.newAttributeType("thename", String.class);
>> 				AttributeType descriptionType =
>> AttributeTypeFactory.newAttributeType("thedescription", String.class);
>> 				/* add other attribute types here */
>> 				FeatureType featureType = FeatureTypeFactory.newFeatureType(new
>> AttributeType[] {geom, idType, nameType, descriptionType}, "2D Area  
>> Layer");			
>> 				resource = CatalogPlugin.getDefault().getLocalCatalog()
>> 				.createTemporaryResource(featureType);
>> 			} catch (FactoryRegistryException e1)
>> 			{
>> 				// TODO Auto-generated catch block
>> 				e1.printStackTrace();
>> 			} catch (IllegalArgumentException e1)
>> 			{
>> 				// TODO Auto-generated catch block
>> 				e1.printStackTrace();
>> 			} catch (SchemaException e1)
>> 			{
>> 				// TODO Auto-generated catch block
>> 				e1.printStackTrace();
>> 			}
>> 			Layer layer = map.getLayerFactory().createLayer(resource);
>>
>> ...is there a better (i.e. non-deprecated) way to do this?
>>
>> (2) I'd like to create a layer with two resources - first a  
>> writeable layer
>> as above, that supports all geometries, and also associate a  
>> mapgraphic
>> extension with that layer to draw on said layer - is there a way to  
>> add both
>> of these resources to the same layer?  I can get one or the other  
>> to work
>> but not both.
>>
>> ..and finally my comment.  What a superb piece of work uDig is,  
>> just truly
>> amazing ... I cant begin to thank you for the effort you have  
>> expended and
>> the effort it has saved me!
>>
>> Kind Regards,
>>
>> Pete Cornwell
>>
>> -- 
>> View this message in context: http://www.nabble.com/Read-Writeable- 
>> Layers-with-Mapgraphics-...and-a-Comment-tf3011852.html#a8364678
>> Sent from the udig-devel mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> 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
> 
> 

-- 
View this message in context: http://www.nabble.com/Read-Writeable-Layers-with-Mapgraphics-...and-a-Comment-tf3011852.html#a8392273
Sent from the udig-devel mailing list archive at Nabble.com.



Back to the top