uDig SDK Tutorial: Integrating Maps and Plugins — Step-by-Step
Overview
A concise, practical tutorial to set up uDig SDK, create a basic map application, and extend it with plugins. Assumes Java and Eclipse familiarity.
Prerequisites
- Java JDK 11+ installed and JAVAHOME set
- Eclipse IDE for RCP and RAP Developers (or Eclipse IDE with PDE)
- uDig SDK distribution or uDig source (latest stable release)
- Basic knowledge of OGC formats (WMS, WFS, Shapefile)
1. Set up the uDig SDK in Eclipse
- Install Eclipse PDE/RCP package.
- Download the uDig SDK or add the uDig update site to Eclipse: Help → Install New Software → add uDig update URL.
- Install uDig features and SDK tooling, then restart Eclipse.
- Import uDig projects if using source: File → Import → Existing Projects into Workspace.
2. Create a new uDig RCP application
- File → New → Other → Plug-in Project.
- Choose an ID (e.g., com.example.udigapp), target platform Eclipse RCP.
- In the plugin manifest, require uDig core bundles (org.locationtech.udig.or org.location.udig.* depending on distribution).
- Create an application extension that uses the uDig map frame or reuse uDig product templates.
3. Add a map and layers
- Programmatically create a Map instance or use the provided MapEditor.
- Add data stores:
- Shapefile: use ShapefileDataStore and create FeatureSource.
- WMS: create a WMS service and request layers.
- Create Style objects (SLD or uDig styling APIs) and attach to layers.
- Add layers to the Map’s LayerManager and refresh the map canvas.
Code sketch (conceptual; adapt to uDig SDK APIs):
java
Map map = CatalogPlugin.getDefault().getMapManager().createMap(“MyMap”); ILayer layer = map.getLayerFactory().createLayer(featureSource, style); map.getLayerManager().getLayersInternal().add(layer); map.getViewportModel().setExtent(layer.getBounds());
4. Implement basic interaction
- Zoom/pan: hook into IViewportModel or map commands.
- Feature selection: use selection tools provided by uDig or implement IToolAdvisor extensions.
- Attribute display: open a simple SWT dialog or view showing selected feature attributes.
5. Build a plugin
- In plugin.xml add extensions:
- org.eclipse.ui.views for custom views (attribute table).
- org.eclipse.ui.commands and handlers for toolbar/menu actions.
- uDig-specific extension points for tools and menus (check SDK docs for exact IDs).
- Implement handlers to interact with Map and Layer APIs.
6. Packaging and running
- Use Eclipse product export or launch configuration to run an Eclipse application instance.
- Test loading remote services, large shapefiles, and plugin commands.
7. Debugging and performance tips
- Enable Eclipse remote debugging for runtime issues.
- Profile rendering hotspots; reduce symbol complexity and use simplified geometries for large datasets.
- Cache WMS tiles where possible.
Resources
- uDig SDK documentation and API Javadocs (use the SDK distribution or update site).
- Examples in the uDig sample projects (import into workspace).
- OGC service docs for WMS/WFS integration.
If you want, I can produce a concrete example project with exact plugin.xml entries and working Java code for a simple Shapefile layer application.
Leave a Reply