Statistics
| Revision:

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

History | View | Annotate | Download (17.2 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
 
144
EditingService (extends Service)
145
*****************************************************
146

    
147
At this moment delagates all functionality to providers.
148

    
149
* start() :: void 
150
* getNextParameter() :: EditingServiceParameter
151
* setValueParameter(EditingServiceParameter param, Object value) :: void
152
* drawOperation(Point mousePosition) :: Geometry
153
* stop() :: void
154
* Set<EditingServiceParameter> getParameters() :: Set<EditingServiceParameter
155
* void finishOperation(MapControl mapcontrol);
156
* isValidvalue(EditingServiceParameter param, Object value);
157

    
158

    
159
EditingServiceInfo
160
*****************************************************
161

    
162
* Provide read only information about a tool:
163

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

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

    
174
EditingServiceParameter
175
*****************************************************
176

    
177
* Provide read only information about a parameter:
178

    
179
  * Parameter name. getName() :: String
180

    
181
  * Parameter description (?use as contextual help?) getDescription :: String
182

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

    
186
  * equals(EditingServiceParameter param) :: boolean
187
    Compares two parameters.
188

    
189
EditingBehavior
190
*****************************************************
191

    
192
* activateTool(String name);
193
  Activates tool creating an EditingService and ask for the next parameter.
194

    
195
SPI
196
-----
197

    
198
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.spi
199
* Package: or.gvsig.vectorediting.lib.spi
200

    
201
EditingpProviderManager (extends ProviderManager)
202
*****************************************************
203

    
204
* No methods.
205

    
206
EditingProviderServices (extends ProviderServices)
207
*****************************************************
208

    
209
* Methods to create features / geometries.
210

    
211
  * insertFeatureIntoFeatureStore (Feature feature, FeatureStore featureStore) :: void
212
  * insertGeometryIntoFeatureStore(Geometry geometry, FeatureStore featureStore) :: void
213

    
214
* Methods to delete features / geometries.
215

    
216
  * deleteFeatureFromFeatureStore(Feature feature, FeatureStore featureStore) :: void
217
  * deleteGeometryFromFeatureStore(Geometry geometry, FeatureStore featureStore) :: void
218

    
219
* Methods to update features / geometries
220

    
221
  * updateFeatureInFeatureStore(Feature feature, FeatureStore featureStore) :: void
222
  * updateGeometryInFeatureStore(Geometry geometry, FeatureStore featureStore) :: void
223

    
224
* ?Get the Symbol to draw a Geometry?.
225

    
226
* Create new Features based on another ones, following the common criteria about the alphanumeric information:
227
  
228
  * splitFeatureAndInsertIntoFeatureStore(Feature featureToSplit, Geometry splitter, FeatureStore featureStore) :: void
229
    splitFeature(Feature featureToSplit, Geomety splitter) :: Collection<Feature>
230
    New Features created from an old one clone all data, but the primary keys.
231
  * unionFeaturesAndInsertIntoFeatureStore(Collecion<Feature> featuresToUnion, FeatureStore featureStore) :: void
232
    New Feature created from a set of Features (ex: Union): for every attribute, if the values are the same for all the source Features,
233
    ignoring null values, clone it. Otherwise leave as null.
234

    
235

    
236

    
237
DefaultEditingServiceInfo and DefaultEditingServiceParameter
238
**************************************************************
239

    
240
* Default implementations to be used by the tools.
241

    
242
EditingProviderFactory (ProviderFactory)
243
*****************************************************
244

    
245
* getServiceInfo() :: EditingServiceInfo 
246
  Provide information of the tool (see EditingManager's API).
247

    
248
* getServiceParameterInfo() :: EditingServiceParameter
249
  Provide information of a tool parameter (see EditingManager's API).
250

    
251
EditingProvider (Provider)
252
*****************************************************
253

    
254
* start() :: void 
255
  Starts service, initializing attibrutes.
256

    
257
* getNextParameter() :: EditingServiceParameter
258
  Returns the next parameter required by the tool. If all parameters have values return null.  
259

    
260
* setValueParameter(EditingServiceParameter param, Object value) :: void
261
  Sets parameter value whit it param.
262

    
263
* drawOperation(Point mousePosition) :: Geometry
264
  Provides a Geometry to draw the current editing context, taking into account the values previously provided by the user and a Point with the 
265
  current mouse cursor location.
266

    
267
* stop() :: void
268
  Cancels the execution of the tool.
269

    
270
* Set<EditingServiceParameter> getParameters() :: Set<EditingServiceParameter
271
  Returns a set with all parameters required by the tool
272

    
273
* finishOperation(MapControl mapcontrol) :: void
274
  Indicates that the tool doesn't need more values.
275

    
276
* isValidValue(EditingServiceParameter param, Object value) :: boolean
277
  Check if the value is valid for the param received.
278

    
279
* ?Ask for the Geometries or Features created, updated or removed by the tool?
280

    
281
.. admonition:: Doubt
282

    
283
   Not sure if this is neccessary. At this moment there is no methods to this.
284

    
285
AbstractEditingProvider extends AbstractProvider implements EditingProvider
286
****************************************************************************
287

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

    
290
Implementation
291
----------------
292

    
293
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl
294
* Package: or.gvsig.vectorediting.lib.impl
295

    
296
Provides the implementation of the library components, extending the related base tools implementations.
297

    
298
Editing Plugin
299
---------------
300

    
301
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin
302
* Package: or.gvsig.vectorediting.app.mainplugin
303

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

    
306
EditingExtension
307
*****************************************************
308

    
309

    
310
Registers the EditingBehavior in MapContext, as well as the actions to activate/deactivate editing.
311

    
312
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.
313

    
314

    
315

    
316
BaseEditingServiceExtension
317
*****************************************************
318

    
319
Default implementation to be used by editing tool plugins. Maybe BaseEditingServiceExtension implements execute action (activateTool) and each tool implements if it is enable or not.
320

    
321
.. admonition:: Doubt
322

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

    
325
Other themes to take into account
326
-----------------------------------
327

    
328
Geometry construction
329
***********************
330

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

    
333
Snappers
334
------------
335

    
336
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.
337

    
338
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.
339

    
340
Geometries composed of other geometries
341
-----------------------------------------
342

    
343
* 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.
344
  Two different approaches have been discussed:
345
  * The same EditingProvider should allow to create only Geometries instead of Features, with some kind of parameter or new methos.
346
  * Separate provider types, with the ones which create Features and other ones which create basic geometries.
347

    
348
Templates
349
----------------
350

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

    
353
* Alphanumeric attributes
354
* Type of geometry
355
* Editing tool to use
356
* Simbology to apply
357

    
358
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.
359

    
360
Toolbar button with many option
361
---------------------------------
362

    
363
* 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.
364

    
365
* 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.
366

    
367