Statistics
| Revision:

gvsig-vectorediting / org.gvsig.vectorediting / trunk / docs / dt-gvsig-edicion.rst @ 32

History | View | Annotate | Download (18.3 KB)

1
=================================================================
2
 New gvSIG 2.1+ vector editing support
3
=================================================================
4

    
5
-------------------
6
 Technical design
7
-------------------
8

    
9
:Company:   gvSIG Association 
10
:Author:    DiSiD Corporation, S.L.
11
:Revision:  $Rev: $
12
:Date:      $Date: $
13
:Copyright: 
14

    
15
.. contents::
16
   :depth: 2
17
   :backlinks: none
18

    
19
.. sectnum::
20
   :depth: 2
21
   :start: 1
22

    
23
.. |year| date:: %Y
24

    
25
.. header:: 
26
      
27
   .. class:: headertable
28

    
29
   +-----------------------+-------------------------+
30
   |.. class:: left        |.. class:: right         |
31
   |                       |                         |
32
   | Requisitos            |###Page###               |
33
   +-----------------------+-------------------------+ 
34

    
35

    
36
.. footer:: 
37

    
38
    .. include:: <isonum.txt>
39

    
40
    .. class:: left
41

    
42
    *New gvSIG 2.1+ vector editing support - Technical design*
43

    
44
    |copy| |year| ** 
45

    
46

    
47
Introduction
48
=============
49

    
50
gvSIG 2.1 provides vector editing support, which was already available since gvSIG 1.9, and has been migrated and adapted to the newer versions. But from the user point of view it lacks usability and an uniform way of interacting with the user. A lot of the editing tools provided in gvSIG are lacking from the usability point of view, as well as the limitations they have.
51

    
52
From the point of view of a developer, it is a bit cumbersome to develop new vector editing tools, with too much responsability given to each tool implementation. Also there is not a well defined API to be able to use the vector editing support out of the user interface.
53

    
54
To be able to solve those problems, a new project has been started to create a new vector editing implementation, from the core editing support to each of the editing tools. To make the most of it, a new list of funtional and technical requirements have been gathered, and a new functional analysis has been performed.
55

    
56
This document is the technical design of the new vector editing library and support for gvSIG 2.1+, taking into account the new requirements and the functional analysis.
57

    
58
First, a list of new technical requirements gathered while creating the technical design will be listed to have a bit of context of the proposed design. Next, the APIs and implementations of the different modules of the editing support will be defined.
59

    
60
Technical requirements
61
=======================
62

    
63
* As this may be a mid/long term project, a way to be able to coexist the old vector editing implementation with the new one must be provided. The idea is for the user to be able to install the new editing support and disable the old one, without needing another gvSIG desktop installation. That means no changes to gvSIG core projects need to be performed, or the ones to perform must be compatible with the old vector editing.
64

    
65
* The way to integrate de editing support in gvSIG, taking into account the previous requirement is to use MapControl Behavior objects.
66

    
67
* Andami Extension objects will be used to register the vector editing tools, managing also the status (enabled, active, ...) required by Andami while being added as toolbar buttons and menu entries.
68

    
69
* An editing tool library must be implemented which allows to use it not only from the user interface, like for example a gvSIG personalization, an addon or a script.
70

    
71
Technical design
72
=====================
73

    
74
To have a bit of context of the proposed design, we will first provide a description of how should work the new editing support for an example tool, and some needs for the editing library API and SPI. Next, the API, SPI, implementation and other packages will be defined.
75

    
76
Example use case description
77
-------------------------------
78

    
79
When gvSIG is launched, a EditingExtension registers an EditingBehavior in MapControl to provide user interaction with the editing tools. When an EditingTool is started, the EditingBehavior will interact with the tool to:
80

    
81
* Get the first/next parameter required by the tool
82
* Get the information of a parameter: type, description, ...
83
* Get a Geometry to represent the current editing status.
84

    
85
The EditingBehavior responsability will be to interact with the user to provide the EditingTool with the required parameters. That interaction will be performed through three different ways:
86

    
87
* Left button mouse clicks: mainly used to get map locations.
88
* Contextual menu options: to select between available options or open a dialog with a form to fill the required parameter values.
89
* Through the text console.
90

    
91
Each editing tool or group of tools have an Extension which registers the related toolbar buttons and menu entries, as well as register the editing tools in the editing library SPI. Also the Extension must be able to activate the editing tool when the user clicks in the related toolbar button or menu entry. That means an Extension will require to interact with the editing library for the following actions:
92

    
93
* Register an editing tool.
94
* Ask if an editing tool is enabled or active for the current context.
95
* Start an editing tool.
96

    
97
With this context, an example use case of a editing tool to create a Curve geometry will be as follows:
98

    
99
* The user clicks on the create Curve button, and the related Extension calls EditingManager and execute activateTool("CreateCurve", mapControl);
100
* Manager gets the EditingBehavior associated with MapControl and calls activateTool("CreateCurve");
101
* The EditingVBehavior creates a EditingService with the rigth provider.
102
* The EditingBehavior asks the service for a mouse icon to use, or uses a default one.
103
* The EditingBehavior asks the service for the first parameter.
104
* The EditingService responds with a parameter of type *List of Points*.
105
* The EditingBehavior activates a message in the console asking for the X,Y values of the next Point. 
106
* The user has then three options to provide the point: 
107
  * Click with the mouse left button in the map.
108
  * Write in the console the X,Y values of the point.
109
  * Opens the contextual menu and select the option to provide the X,Y values, which will open a dialog with a form to write the two values.
110
* Each time the user moves the mouse cursor, the EditingBehavior requests the tool a Geometry to draw with the current context and the map location of the mouse cursor. In this case, the Geometry will be a Curve created with the user already defined points and, as the last point, the current mouse cursor location.
111
* Once the value of the point is provided by the user to the EditingBehavior (through mouse, dialog or console), it creates a Point and provides the value to the tool and asks for another Point to the user, with an option to allow the user to end the Curve:
112
  * With a mouse left button double click.
113
  * With a value in the console (*?E?*)
114
  * With an option in the contextual menu.
115
* This process is repited until the user ends the list of points.
116
* The EditingBehavior notifies the tool the list of Points is finished.
117
* The service creates a curve with the provided points, and a Feature is created and inserted into the current Layer FeatureStore.
118
* The service ends and it is activated again by default. The user may create another Curve or activate another tool.
119
* In any point of the process, the user may activate another tool o pulse the *Esc* to finish the current tool execution and start again. **NOTE: if the user has already provided some data, ?ask him to confirm the cancelation and lose the data?** I think that we have to show a dialog to ask him to confirm the cancelation and lose data. Editing pluging has to allow user to disable this.
120

    
121
API
122
----
123

    
124
This is the API of the vector editing library, which wil be based on the gvSIG tools PBI model (Provider Based Implementation).
125

    
126
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.api
127
* Package: or.gvsig.vectorediting.lib.api
128

    
129
EditingManager (extends o.g.t.s.Manager)
130
*********************************************
131

    
132
The API will provide the following services:
133

    
134
* getEditingService( Strin serviceName, FeatureStore featureStore) :: EditingService 
135
  Creates a DynObject with the necessary service parameters, set featureStore value to dynobject and creates an EditingService.
136

    
137
* getServiceInfo(String serviceName) :: EditingServiceInfo
138
  Provides information of an editing tool
139

    
140
* activateTool(String name, MapControl mapControl) :: void
141
  If mapControl has EditingBehavior added as tool, this method calls activateTool of EditingBehavior.
142

    
143
* beginEdition(FLyrVect layer, DefaultViewPanel view) throws DataException :: void
144
  Notifies observers before and after to set store in edit mode. Checks if there is a EditingBehavior registered at MapControl. If there is not a EditingBehavior registered, it will instance one and it will add it to MapControl. Moreover, shows console at of view, set caret at console, adds observers and refresh menus.
145

    
146
 
147
EditingService (extends Service)
148
*****************************************************
149

    
150
At this moment delagates all functionality to providers.
151

    
152
* start() :: void 
153
* getNextParameter() :: EditingServiceParameter
154
* setValueParameter(EditingServiceParameter param, Object value) :: void
155
* drawOperation(Point2D mousePosition) :: Geometry
156
* stop() :: void
157
* List<EditingServiceParameter> getParameters() :: List<EditingServiceParameter
158
* void finishOperation(MapControl mapcontrol);
159

    
160

    
161
EditingServiceInfo
162
*****************************************************
163

    
164
* Provide read only information about a tool:
165

    
166
  * Tool name getName :: String
167
  * Tool description (?use as contextual help?) getDescription :: String
168
  * Mouse icon. getMouseIcon() :: Image
169
  * The geometry types being managed. getSupportedPrimitiveGeometryType() :: int[]
170
  * If the tool creates new geometries. createsNewGeometries() :: boolean
171
  * The list of the parameters. getParameters() :: List<EditingServiceParameter>
172

    
173
* getParameterInfo(String name) :: EditingServiceParameter 
174
  Provide read only information about a tool parameter :: EditingServiceParameter
175

    
176
EditingServiceParameter
177
*****************************************************
178

    
179
* Provide read only information about a parameter:
180

    
181
  * Parameter name. getName() :: String
182

    
183
  * Parameter description (?use as contextual help?) getDescription :: String
184

    
185
  * Parameter type: There are 6 types of parameters: point, list of points, option, value, selection and geometry. None typed, EditingService 
186
    checks if the parameter value is correct before put it at colection values.
187

    
188
  * equals(EditingServiceParameter param) :: boolean
189
    Compares two parameters.
190

    
191
  * getConsoleMenssage()
192
    Get message to show on console.
193

    
194
EditingBehavior
195
*****************************************************
196

    
197
* activateTool(String name);
198
  Activates tool creating an EditingService and ask for the next parameter.
199

    
200
* void cleanBehavior();
201
  Set activeService and currentParam to null and show a message on console to warn user that has to active a new tool. This operation will be called when user changes active layer or set layer in edit mode.
202

    
203
SPI
204
-----
205

    
206
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.spi
207
* Package: or.gvsig.vectorediting.lib.spi
208

    
209
EditingpProviderManager (extends ProviderManager)
210
*****************************************************
211

    
212
* getServiceInfo(String name) throws ServiceException :: EditingServiceInfo
213
  Return information about one service. (see EditingServiceInfo) 
214

    
215
EditingProviderServices (extends ProviderServices)
216
*****************************************************
217

    
218
* Methods to create features / geometries.
219

    
220
  * insertFeatureIntoFeatureStore (Feature feature, FeatureStore featureStore) :: void
221
  * insertGeometryIntoFeatureStore(Geometry geometry, FeatureStore featureStore) :: void
222

    
223
* Methods to delete features / geometries.
224

    
225
  * deleteFeatureFromFeatureStore(Feature feature, FeatureStore featureStore) :: void
226
  * deleteGeometryFromFeatureStore(Geometry geometry, FeatureStore featureStore) :: void
227

    
228
* Methods to update features / geometries
229

    
230
  * updateFeatureInFeatureStore(Feature feature, FeatureStore featureStore) :: void
231
  * updateGeometryInFeatureStore(Geometry geometry, FeatureStore featureStore) :: void
232

    
233
* ?Get the Symbol to draw a Geometry?.
234

    
235
* Create new Features based on another ones, following the common criteria about the alphanumeric information:
236
  
237
  * splitFeatureAndInsertIntoFeatureStore(Feature featureToSplit, Geometry splitter, FeatureStore featureStore) :: void
238
    splitFeature(Feature featureToSplit, Geomety splitter) :: Collection<Feature>
239
    New Features created from an old one clone all data, but the primary keys.
240
  * unionFeaturesAndInsertIntoFeatureStore(Collecion<Feature> featuresToUnion, FeatureStore featureStore) :: void
241
    New Feature created from a set of Features (ex: Union): for every attribute, if the values are the same for all the source Features,
242
    ignoring null values, clone it. Otherwise leave as null.
243

    
244

    
245

    
246
DefaultEditingServiceInfo and DefaultEditingServiceParameter
247
**************************************************************
248

    
249
* Default implementations to be used by the tools.
250

    
251
EditingProviderFactory (ProviderFactory)
252
*****************************************************
253

    
254
* getServiceInfo() :: EditingServiceInfo 
255
  Provide information of the tool (see EditingManager's API).
256

    
257
* getServiceParameterInfo() :: EditingServiceParameter
258
  Provide information of a tool parameter (see EditingManager's API).
259

    
260
EditingProvider (Provider)
261
*****************************************************
262

    
263
* start() :: void 
264
  Starts service, initializing attibrutes.
265

    
266
* getNextParameter() :: EditingServiceParameter
267
  Returns the next parameter required by the tool. If all parameters have values return null.  
268

    
269
* setValueParameter(EditingServiceParameter param, Object value) :: void
270
  Sets parameter value whit it param.
271

    
272
* drawOperation(Point mousePosition) :: Geometry
273
  Provides a Geometry to draw the current editing context, taking into account the values previously provided by the user and a Point with the 
274
  current mouse cursor location.
275

    
276
* stop() :: void
277
  Cancels the execution of the tool.
278

    
279
* List<EditingServiceParameter> getParameters() :: List<EditingServiceParameter
280
  Returns a list with all parameters required by the tool
281

    
282
* finishOperation(MapControl mapcontrol) :: void
283
  Indicates that the tool doesn't need more values.
284

    
285
* ?Ask for the Geometries or Features created, updated or removed by the tool?
286

    
287
.. admonition:: Doubt
288

    
289
   Not sure if this is neccessary. At this moment there is no methods to this.
290

    
291
AbstractEditingProvider extends AbstractProvider implements EditingProvider
292
****************************************************************************
293

    
294
Implements all creation common operations of providers such as createPoint, createCurve, createMultiCurve, createArc, createCircle...
295

    
296
Implementation
297
----------------
298

    
299
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl
300
* Package: or.gvsig.vectorediting.lib.impl
301

    
302
Provides the implementation of the library components, extending the related base tools implementations.
303

    
304
Editing Plugin
305
---------------
306

    
307
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin
308
* Package: or.gvsig.vectorediting.app.mainplugin
309

    
310
Provides the implementation of the main editing plugin, and integrates the editing library API, SPI and implementation in gvSIG.
311

    
312
EditingExtension
313
*****************************************************
314

    
315

    
316
Registers the EditingBehavior in MapContext, as well as the actions to activate/deactivate editing.
317

    
318
Also activates the console when editing is started, puts the selected layer store in editing mode, and notifies about the begin and end of editing mode.
319

    
320

    
321

    
322
BaseEditingServiceExtension
323
*****************************************************
324

    
325
Provides utils to extensions.
326

    
327
* protected getActiveView() :: DefaultViewPanel
328
  Returns active view.
329

    
330
* protected canBeEdited(FLyrVect layer) :: boolean
331
  Returns true if layer can be edited. Return false if layer can not be edited.
332

    
333
* protected getActiveLayer(DefaultViewPanel vista) :: FLyrVect
334
  Returns active layer from view that receives as parameter.
335

    
336
* protected isApplicable(GeometryType[] supportedTypes, int shapeType) :: boolean
337
  Returns true if extension can be applied to that shapetype.
338

    
339
* protected loadGeometryTypes(int[] types) :: GeometryType[]
340
  Return a collection of geo types from a collection of geometry.types.
341

    
342
.. admonition:: Doubt
343

    
344
   Not sure if there is a mechanism to be able to have a single final implementation, or each extension must extend this one.
345

    
346
Other themes to take into account
347
-----------------------------------
348

    
349
Geometry construction
350
***********************
351

    
352
All geometries being constructed, not already available in the Geometry Library, must be added as operations.
353

    
354
Snappers
355
------------
356

    
357
Snapper support is defined in MapControl, with the current snappers available in the gvSIG main plugin. The current editing plugin only activates them and provides a configuration panel.
358

    
359
That panel should be moved out of the editing plugin to a new one, which also adds actions to enable or activate snappers by the user, also with a key shortcut.
360

    
361
Geometries composed of other geometries
362
-----------------------------------------
363

    
364
* A mechanism must be defined to allow a way for a tool to ask for new geometries, and the editing manager to be able to call other tools which create the required geometry type, in a kind of "reentering" mode.
365
  Two different approaches have been discussed:
366
  * The same EditingProvider should allow to create only Geometries instead of Features, with some kind of parameter or new methos.
367
  * Separate provider types, with the ones which create Features and other ones which create basic geometries.
368

    
369
Templates
370
----------------
371

    
372
As a future functionality, the user would be able to define templates for creating new Features, with default values for:
373

    
374
* Alphanumeric attributes
375
* Type of geometry
376
* Editing tool to use
377
* Simbology to apply
378

    
379
Now we are not going to implement this, but it would be nice if we could take this improvement into account so it could be implemented in the future without much changes.
380

    
381
Toolbar button with many option
382
---------------------------------
383

    
384
* As this needs support in Andami, for now all editing tools will be implemented simple. Ex: create a circle now asks first if the user wants to create it with center and radios or with three points. It should be implemented as two separated tools.
385

    
386
* In Andami it could be implemented as a way to group toolbar buttons in button menus, which could be defined through the config.xml file.
387

    
388