Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.core / src / main / java / es / unex / sextante / dataObjects / IVectorLayer.java @ 187

History | View | Annotate | Download (4.69 KB)

1
package es.unex.sextante.dataObjects;
2

    
3
import java.util.List;
4

    
5
import com.vividsolutions.jts.geom.Geometry;
6

    
7
import org.gvsig.tools.exception.BaseException;
8

    
9
import es.unex.sextante.dataObjects.vectorFilters.IVectorLayerFilter;
10

    
11
/**
12
 * This is the base interface that all vector layers have to implement to be able to be used by SEXTANTE algorithms.
13
 *
14
 * Instead of implementing this class directly, it is recommended to extend {@link AbstractVectorLayer}.
15
 *
16
 * @author Victor Olaya. volaya@unex.es
17
 *
18
 */
19
public interface IVectorLayer
20
         extends
21
            ILayer {
22

    
23
   public static final int SHAPE_TYPE_POINT        = 0;
24
   public static final int SHAPE_TYPE_LINE         = 1;
25
   public static final int SHAPE_TYPE_POLYGON      = 2;
26
   public static final int SHAPE_TYPE_MIXED        = 3;
27

    
28
   //Types to create a multilayer in gvSIG. Don't use for anything more
29
   public static final int SHAPE_TYPE_MULTIPOINT   = 4;
30
   public static final int SHAPE_TYPE_MULTILINE    = 5;
31
   public static final int SHAPE_TYPE_MULTIPOLYGON = 6;
32

    
33
   /**
34
    * this constant indicates that the shape type is not compatible with SEXTANTE (for example a layer with multiple types if that
35
    * is not supported), and should be used to filter out layers
36
    */
37
   public static final int SHAPE_TYPE_WRONG   = -1;
38

    
39

    
40
   /**
41
    * Adds a new feature to the layer
42
    *
43
    * @param geometry
44
    *                the geometry
45
    * @param attributes
46
    *                the attributes associated with the geometry
47
    */
48
   public void addFeature(Geometry geometry,
49
                          Object[] attributes);
50

    
51

    
52
   /**
53
    * Adds a new feature to the layer
54
    *
55
    * @param feature
56
    *                the feature to add
57
    */
58
   public void addFeature(IFeature feature);
59

    
60

    
61
   /**
62
    * Returns an iterator to iterate through the entities of this layer
63
    *
64
    * @return an iterator to iterate the layer
65
    */
66
   public IFeatureIterator iterator();
67

    
68

    
69
   /**
70
    * Returns the name of a given field in the attributes table
71
    *
72
    * @param index
73
    *                the zero-based field index
74
    * @return the name of the selected attribute field
75
    */
76
   public String getFieldName(int index);
77

    
78

    
79
   /**
80
    * Return a class representing the data type of a given field
81
    *
82
    * @param index
83
    *                the zero-based field index
84
    * @return the data type of the selected attribute field
85
    */
86
   public Class getFieldType(int index);
87

    
88

    
89
   /**
90
    *
91
    * @return the number of attributes associates to each geometry
92
    */
93
   public int getFieldCount();
94

    
95

    
96
   /**
97
    * Returns an array of classes representing the data types of the fields in the attributes table
98
    *
99
    * @return the data types of attribute fields
100
    */
101
   public Class[] getFieldTypes();
102

    
103

    
104
   /**
105
    * Returns the names of the fields in the attributes table
106
    *
107
    * @return the names of the attribute fields
108
    */
109
   public String[] getFieldNames();
110

    
111

    
112
   /**
113
    * Returns the number of features in this layer
114
    *
115
    * @return the number of features in this layer
116
    */
117
   public int getShapesCount();
118

    
119

    
120
   /**
121
    * Returns the type of geometries in this layer
122
    *
123
    * @return the type of geometries in this layer
124
    */
125
   public int getShapeType();
126

    
127
   /**
128
    * Returns the subtype of geometries in this layer
129
    *
130
    * @return the subtype of geometries in this layer
131
 * @throws ReadException
132
    */
133
   public int getSubType() throws BaseException;
134

    
135

    
136
   /**
137
    * Returns the index of a field from its name. Returns -1 if there is not a field with that name.
138
    *
139
    * @param fieldName
140
    *                the name of the field
141
    * @return the index of the given field
142
    */
143
   public int getFieldIndexByName(String fieldName);
144

    
145

    
146
   /**
147
    * Adds a new filter to this layer. When iterating the features in this layer, only those that pass the filter will be
148
    * returned.
149
    *
150
    * @param filter
151
    *                the filter to add
152
    */
153
   public void addFilter(IVectorLayerFilter filter);
154

    
155

    
156
   /**
157
    * Removes all filters previously added to this layer
158
    */
159
   public void removeFilters();
160

    
161

    
162
   /**
163
    * Returns a list of all the filters currently added to this layer
164
    *
165
    * @return a list of all the filters currently added to this layer
166
    */
167
   public List<IVectorLayerFilter> getFilters();
168

    
169

    
170
   /**
171
    * Returns true if the layer can be edited. This includes editing while the layer is being read, so it can be overwritten by
172
    * algorithms that allow overwriting of input layers
173
    *
174
    * @return true if the layer can be edited
175
    */
176
   public boolean canBeEdited();
177

    
178
}