[udig-devel] basic methods to write a udig-plugin
Jody Garnett
jgarnett at refractions.net
Thu May 8 08:51:01 PDT 2008
gaghi wrote:
> Hi everybody, I'm new to the gis world and in particular to Udig .
> I'm going to, actually i would, but I'm not sure if I will be able to do
> this, develop some plugins for gis application. I worked a few on gvSIG. By
> the way I'm a newbie.
>
Welcome; don't worry we are all new at something :-)
> What i would do is get the active layers in a map, and ,for every single
> layer, get the the coordinates system in use and the bounds from which I
> should deduce the correct coordinates system. For example, I know that if
> (MinX > 4 && MaxX() < 20) the coordinates system is EPSG:4326.
> At this point I would be able to apply this projection to the layer.
> Surfing on the forum's threads I've found this code:
>
> Map map = ApplicationGISInternal.getActiveMap();//
> List <ILayer> layers = map.getMapLayers();//maybe i'm wrong somewhere, but
> my eclipse says "type List is not generic; it cannot be parametrized with
> arguments <ILayer> "
>
You probably just have the "wrong" list imported at the top of your
file; please change it to "import java.util.List;"
> ILayer layer = null;
> //here i'd start a for cycle to read every layer in the map, therefore
> execute the operations to the layers
> //something like this
> for (int i=0; i<layers.size(); i++) {
> layer = (ILayer)layers.get(i);
> if (layer is active) {
> //getBounds, calculate and apply new PROJECTION,
> refresh the view
> }
> }
>
So it looks like you found a Layer; so now you are going to try and see
what data is hooked up to that...
if( layer.isVisible() ){
IGeoResource resource = layer.getGeoResource();
IGeoResoruceInfo info = resource.getInfo( new NullProgressMonitor() );
...
}
The "info" above has the bounds and crs information.
> Could you tell which are the principal methods i should know to develop this
> and others plugin(it would be better if you got a complete example to
> explain me this)?
> I am NOT asking to you for a development of my idea,but instead just any
> suggestion useful for the future too.
> Thank you in advance and forgive me if my english is not so good.
>
> P.S.:the plugin should start once the user clicks on the button in the
> toolbar. Therefore it shouldn't be sensitive to an event like the pression
> of a button, but just start.
>
The toolbar is often not the best place for that kind of stuff (it gets
crowded!) One interesting idea is to make it an "operation" on a Map.
"operation"s show up when you right click on something.
Jody
More information about the udig-devel
mailing list