Statistics
| Revision:

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

History | View | Annotate | Download (16.7 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 activates the CurveEditingTool.
100
* The EditingBehavior asks the tool for a mouse icon to use, or uses a default one.
101
* The EditingBehavior asks the tool for the first parameter.
102
* The CurveEditingTool responds with a parameter of type *List of Points*.
103
* The EditingBehavior activates a message in the console asking for the X,Y values of the next Point. 
104
* The user has then three options to provide the point: 
105
  * Click with the mouse left button in the map.
106
  * Write in the console the X,Y values of the point.
107
  * 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.
108
* 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.
109
* 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:
110
  * With a mouse left button double click.
111
  * With a value in the console (*?E?*)
112
  * With an option in the contextual menu.
113
* This process is repited until the user ends the list of points.
114
* The EditingBehavior notifies the tool the list of Points is finished.
115
* The tool creates a curve with the provided points, and a Feature is created and inserted into the current Layer FeatureStore.
116
* The tool ends and it is activated again by default. The user may create another Curve or activate another tool.
117
* 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?**
118

    
119
API
120
----
121

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

    
124
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.api
125
* Package: or.gvsig.vectorediting.lib.api
126

    
127
EditingManager (extends o.g.t.s.Manager)
128
*********************************************
129

    
130
The API will provide the following services:
131

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

    
135
* getServiceInfo(String serviceName) :: EditingServiceInfo
136
  Provides information of an editing tool
137

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

    
141
 
142
EditingService (extends Service)
143
*****************************************************
144

    
145
At this moment delagates all functionality to providers.
146

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

    
156

    
157
EditingServiceInfo
158
*****************************************************
159

    
160
* Provide read only information about a tool:
161

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

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

    
172
EditingServiceParameter
173
*****************************************************
174

    
175
* Provide read only information about a parameter:
176

    
177
  * Parameter name. getName() :: String
178

    
179
  * Parameter description (?use as contextual help?) getDescription :: String
180

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

    
184
  * equals(EditingServiceParameter param) :: boolean
185
    Compares two parameters.
186

    
187
EditingBehavior
188
*****************************************************
189

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

    
193
SPI
194
-----
195

    
196
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.spi
197
* Package: or.gvsig.vectorediting.lib.spi
198

    
199
EditingpProviderManager (extends ProviderManager)
200
*****************************************************
201

    
202
* No methods.
203

    
204
EditingProviderServices (extends ProviderServices)
205
*****************************************************
206

    
207
* Methods to create features / geometries.
208

    
209
  * createFeature (Feature feature, FeatureStore featureStore)
210
  * createGeometry(Geometry geometry, FeatureStore featureStore)
211
  * createGeometryAndSelect(Geometry geometry, FeatureStore featureStore)
212

    
213
* Methods to delete features / geometries.
214

    
215
  * deleteFeature(Feature feature, FeatureStore featureStore)
216
  * deleteGeometry(Geometry geometry, FeatureStore featureStore)
217

    
218
* Methods to update features / geometries
219

    
220
  * updateFeature(Feature feature, FeatureStore featureStore)
221
  * updateGeometry(Geometry geometry, FeatureStore featureStore)
222
  * updateGeometryAndSelect(Geometry geometry, FeatureStore featureStore)
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
  * New Features created from an old one (ex: Split): clone all data, but the primary keys.
228
  * New Feature created from a set of Features (ex: Union): for every attribute, if the values are the same for all the source Features, ignoring null values, clone it. Otherwise leave as null.
229
  
230
.. admonition:: Note
231

    
232
   There is no methods to this. 
233
  
234

    
235
DefaultEditingServiceInfo and DefaultEditingServiceParameter
236
**************************************************************
237

    
238
* Default implementations to be used by the tools.
239

    
240
EditingProviderFactory (ProviderFactory)
241
*****************************************************
242

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

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

    
249
EditingProvider (Provider)
250
*****************************************************
251

    
252
* start() :: void 
253
  Starts service, initializing attibrutes.
254

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

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

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

    
265
* stop() :: void
266
  Cancels the execution of the tool.
267

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

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

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

    
277
.. admonition:: Doubt
278

    
279
   Not sure if return a Set or a List.
280

    
281
* ?Ask for the Geometries or Features created, updated or removed by the tool?
282

    
283
.. admonition:: Doubt
284

    
285
   Not sure if this is neccessary. At this moment there is no methods to this.
286

    
287
AbstractEditingProvider extends AbstractProvider implements EditingProvider
288
****************************************************************************
289

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

    
292
Implementation
293
----------------
294

    
295
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl
296
* Package: or.gvsig.vectorediting.lib.impl
297

    
298
Provides the implementation of the library components, extending the related base tools implementations.
299

    
300
Editing Plugin
301
---------------
302

    
303
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin
304
* Package: or.gvsig.vectorediting.app.mainplugin
305

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

    
308
EditingExtension
309
*****************************************************
310

    
311

    
312
Registers the EditingBehavior in MapContext, as well as the actions to activate/deactivate editing.
313

    
314
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.
315

    
316

    
317

    
318
BaseEditingServiceExtension
319
*****************************************************
320

    
321
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.
322

    
323
.. admonition:: Doubt
324

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

    
327
Other themes to take into account
328
-----------------------------------
329

    
330
Geometry construction
331
***********************
332

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

    
335
Snappers
336
------------
337

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

    
340
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.
341

    
342
Geometries composed of other geometries
343
-----------------------------------------
344

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

    
350
Templates
351
----------------
352

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

    
355
* Alphanumeric attributes
356
* Type of geometry
357
* Editing tool to use
358
* Simbology to apply
359

    
360
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.
361

    
362
Toolbar button with many option
363
---------------------------------
364

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

    
367
* 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.
368

    
369