Revision 575

View differences:

org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.store.dgn.DGNLibrary
2
org.gvsig.fmap.dal.store.dgn.legend.DGNLegendLibrary
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/resources/org/gvsig/fmap/dal/store/dgn/DGNMetadata.xml
1
<?xml version="1.0"?>
2
<!--
3
Definitions of metadata fields of a shp file.  
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    
9
    <class name="DGN" namespace="Metadata">
10
      <extends>
11
      	<class namespace="Metadata" name="SpatialProvider"/>
12
      </extends>
13
      <description>Metadata of a DGN store</description>
14
      <fields>
15
      </fields>
16
    </class>
17

  
18
  </classes>
19
</definitions>  
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/resources/org/gvsig/fmap/dal/store/dgn/DGNParameters.xml
1
<?xml version= "1.0 "?>
2
<definitions>
3
  <version>1.0.0</version>
4
  <classes>
5
    <class name="DGN">
6
      <extends>
7
      	<class namespace="dal" name="ProviderParameters"/>
8
      </extends>
9
      <description>Store the parameters need to open a dgn file</description>
10
      <fields>
11
        
12
        <!-- General -->
13
        <field name="file" type="file" mandatory="true">
14
          <description>dgn file</description>
15
        </field>
16
        <field name="CRS" type="crs" mandatory="true">
17
          <description>The coordinate reference system used in this dgn file</description>
18
        </field>
19
        <field name="LoadMode" label="Load mode" defaultValue="0" type="integer" mandatory="false">
20
          <description>Set the strategy to use for loading DGN elements</description>
21
     	  <availableValues>
22
            <value label="Plain">0</value>
23
            <value label="Group elements (1)">1</value>
24
     	  </availableValues>
25
        </field>
26
        <field name="sortByGeometryType" label="Sort by geometry type" type="Boolean" defaultValue="true" mandatory="false">
27
          <description>If checked sort the rows of table by the geometry type (none,suface,curve,point)</description>
28
        </field>
29
        <field name="force2d" label="Force 2D" type="Boolean" defaultValue="false" mandatory="false">
30
          <description>If checked and DGN has Z dimension create all geometry in 2D and ignore the Zs.</description>
31
        </field>
32
        <field name="Reload" label="Reload" type="Boolean" defaultValue="false" mandatory="false">
33
          <description>Reload an already loaded DGN as a new layer</description>
34
        </field>
35
        <field name="groupby" label="Field for group" type="String" defaultValue="" mandatory="false">
36
          <description>The field name to use for grouping rows</description>
37
        </field>
38
        <field name="GroupGeometriesOperation" label="Group geometries as" type="integer" defaultValue="0" mandatory="false">
39
          <description>If a 'group by' is applied, apply this operation to the resultant geometries</description>
40
     	  <availableValues>
41
            <value label="None, return the agregate">0</value>
42
            <value label="Convexhull">1</value>
43
            <value label="Union">2</value>
44
            <value label="Intersection">3</value>
45
            <value label="Convert to points">4</value>
46
            <value label="Convert to line">5</value>
47
            <value label="Convert to poligon">7</value>
48
            <value label="Convert to poligon and fix it">7</value>
49
     	  </availableValues>
50
        </field>
51

  
52
        <!-- Advanced -->
53
        <field name="ignoreZ" label="Ignore Z" type="Boolean" defaultValue="false" mandatory="false">
54
          <description>If checked and DGN has Z dimension, set all Zs to 0.</description>
55
        </field>
56
        <field name="useZAsElevation" label="Use Z as elevation" type="Boolean" defaultValue="false" mandatory="false" group="Advanced">
57
          <description>If set, use the Z value to fill the field elevation.</description>
58
        </field>
59
        <field name="elevationFactor" label="Elevation factor" type="Double" defaultValue="1" mandatory="false" group="Advanced">
60
          <description>Factor to apply to elevation when is retrived from the Z coordinate.</description>
61
        </field>
62
        <field name="roundElevation" label="Round elevation" type="Boolean" defaultValue="false" mandatory="false" group="Advanced">
63
          <description>If set, round the elevation to a integer value. This only apply when get elevation from the coordinete Z.</description>
64
        </field>
65
        <field name="LinkFilterIndex" label="Link filter index" type="integer" defaultValue="0" mandatory="false" group="Advanced">
66
          <description>If set, return the link with this index</description>
67
        </field>
68
        <field name="LinkFilterType" label="Link filter type" type="integer" defaultValue="" mandatory="false" group="Advanced">
69
          <description>If set, return the link with this type</description>
70
        </field>
71
        <field name="LinkFilterEntity" label="Link filter entity" type="integer" defaultValue="" mandatory="false" group="Advanced">
72
          <description>If set, return the link with this entity</description>
73
        </field>
74
        <field name="LinkFilterMS" label="Link filter MSLink" type="integer" defaultValue="" mandatory="false" group="Advanced">
75
          <description>If set, return the link with this MSLink</description>
76
        </field>
77
        <field name="LinkFilterData" label="Link filter Data" type="string" defaultValue="" mandatory="false" group="Advanced">
78
          <description>This is a regular expresion. If set, return the link that match this regular expresion in the data of link represented in hexadecimal value</description>
79
        </field>
80

  
81
        <!-- Filter -->
82
        <field name="levelFilter" label="Level" group="Filter" type="String" defaultValue="" mandatory="false">
83
          <description>If specified load only elements with this level. Can use regular expresion to specify the filter.</description>
84
        </field>
85
        <field name="colorFilter" label="Color" group="Filter" type="String" defaultValue="" mandatory="false">
86
          <description>If specified load only elements with this color. Can use regular expresion to specify the filter.</description>
87
        </field>
88
        <field name="styleFilter" label="Style" group="Filter" type="String" defaultValue="" mandatory="false">
89
          <description>If specified load only elements with this style. Can use regular expresion to specify the filter.</description>
90
        </field>
91
        <field name="weightFilter" label="Weight" group="Filter" type="String" defaultValue="" mandatory="false">
92
          <description>If specified load only elements with this weight. Can use regular expresion to specify the filter.</description>
93
        </field>
94
        <field name="typeFilter" label="Type" group="Filter" type="String" defaultValue="" mandatory="false">
95
          <description>If specified load only elements with this type</description>
96
        </field>
97
        <field name="stypeFilter" label="SType" group="Filter" type="String" defaultValue="" mandatory="false">
98
          <description>If specified load only elements with this stype</description>
99
        </field>
100
        <field name="groupFilter" label="Group" group="Filter" type="String" defaultValue="" mandatory="false">
101
          <description>If specified load only elements with this group</description>
102
        </field>
103
        <field name="idFilter" label="Id" group="Filter" type="String" defaultValue="" mandatory="false">
104
          <description>If specified load only elements with this id</description>
105
        </field>
106
        <field name="textFilter" label="Text" group="Filter" type="String" defaultValue="" mandatory="false">
107
          <description>If specified load only elements that match this text</description>
108
        </field>
109
        <field name="geomtypeFilter" label="Geometry type" group="Filter" defaultValue="0" type="Integer" mandatory="false">
110
          <description>If specified load only elements with this type of geometry</description>
111
     	  <availableValues>
112
            <value label="All">0</value>
113
            <value label="Points">1</value>
114
            <value label="Lines">2</value>
115
            <value label="Poligons">3</value>
116
     	  </availableValues>
117
        </field>
118
        <field name="skipCorruptGeometries" label="Skip corrupt geometries" group="Filter" type="Boolean" defaultValue="false" mandatory="false">
119
          <description>If specified skip corrupt geometries</description>
120
        </field>
121
        <field name="cropOperationFilter" label="Crop operation" group="Filter" defaultValue="1" type="Integer" mandatory="false">
122
          <description>If specified load only elements with this type of geometry</description>
123
     	  <availableValues>
124
            <value label="None">0</value>
125
            <value label="Contains">1</value>
126
            <value label="Covered by">2</value>
127
            <value label="Covers">3</value>
128
            <value label="Crosses">4</value>
129
            <value label="Disjoint">5</value>
130
            <value label="Intersect">6</value>
131
            <value label="Overlaps">7</value>
132
            <value label="Touches">8</value>
133
            <value label="With in">9</value>
134
     	  </availableValues>
135
        </field>
136
        <field name="cropFilter" label="Crop to" group="Filter" type="Geometry" defaultValue="" mandatory="false">
137
          <description>Crop the result to this value</description>
138
        </field>
139
        
140
                        
141
        <!-- Debug -->
142
        <field name="XMLFile" label="Output XML file" type="file" group="Debug" mandatory="false">
143
          <description>Generate XML file with DGN dump in this file</description>
144
        </field>
145
        <!--
146
        <field name="debugOptions" label="Debug options" type="String" group="Debug" mandatory="false">
147
          <description></description>
148
        </field>
149
        -->
150
        <field name="logErrors" label="log errors" group="Debug" type="Boolean" defaultValue="false" mandatory="false">
151
          <description>If checked the log of errors are enabled</description>
152
        </field>
153

  
154
      </fields>
155
    </class>
156
  </classes>
157
</definitions>  
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/PostProcessGroupOperation.java
1
package org.gvsig.fmap.dal.store.dgn;
2

  
3
import java.util.ArrayList;
4
import java.util.HashMap;
5
import java.util.Iterator;
6
import java.util.List;
7
import java.util.Map;
8
import org.gvsig.fmap.dal.feature.FeatureType;
9
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
10
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_CONVEXHULL;
11
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_INTERSECTION;
12
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_NONE;
13
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_TOLINES;
14
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_TOPOINTS;
15
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_TOPOLYGONS;
16
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_TOPOLYGONS_FIX;
17
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.GROUP_GEOMETRIES_UNION;
18
import org.gvsig.fmap.dal.store.dgn.lib.DGNReader;
19
import org.gvsig.fmap.geom.Geometry;
20
import org.gvsig.fmap.geom.GeometryLocator;
21
import org.gvsig.fmap.geom.GeometryManager;
22
import org.gvsig.fmap.geom.aggregate.Aggregate;
23
import org.gvsig.fmap.geom.aggregate.MultiLine;
24
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
25
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
26
import org.gvsig.fmap.geom.exception.CreateGeometryException;
27
import org.gvsig.fmap.geom.primitive.Curve;
28
import org.gvsig.fmap.geom.primitive.Envelope;
29
import org.gvsig.fmap.geom.primitive.Line;
30
import org.gvsig.fmap.geom.primitive.Point;
31
import org.gvsig.fmap.geom.primitive.Polygon;
32
import org.gvsig.fmap.geom.primitive.Primitive;
33
import org.gvsig.fmap.geom.primitive.Surface;
34
import org.gvsig.tools.logger.FilteredLogger;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38
public class PostProcessGroupOperation {
39

  
40
    private static final Logger logger = LoggerFactory.getLogger(PostProcessGroupOperation.class);
41

  
42
    private int groupByFieldIndex = -1;
43
    private Map<Object, FeatureProvider> groupedFeatures = null;
44
    private GeometryManager geomManager = null;
45
    private int ID_FIELD_GEOMETRY = -1;
46
    private int MAX_FIELD_ID = -1;
47
    private int groupGeometriesOperation = -1;
48
    private Envelope envelope = null;
49

  
50
    public PostProcessGroupOperation(FeatureType featureType, String groupfield, int groupGeometriesOperation) {
51
        this.groupByFieldIndex = featureType.getIndex(groupfield);
52
        if (groupByFieldIndex < 0) {
53
            throw new IllegalArgumentException("Can't group by field '" + groupfield + ", the field don't exists.");
54
        }
55
        this.geomManager = GeometryLocator.getGeometryManager();
56
        this.ID_FIELD_GEOMETRY = featureType.getDefaultGeometryAttribute().getIndex();
57
        this.MAX_FIELD_ID = featureType.size() - 1;
58
        this.groupGeometriesOperation = groupGeometriesOperation;
59
    }
60

  
61
    public void add(FeatureProvider data) {
62
        if (groupedFeatures == null) {
63
            groupedFeatures = new HashMap<Object, FeatureProvider>();
64
        }
65
        Object groupbyValue = data.get(groupByFieldIndex);
66
        FeatureProvider group = groupedFeatures.get(groupbyValue);
67
        if (group == null) {
68
            groupedFeatures.put(groupbyValue, data);
69
            MultiPrimitive multi = getMultiPrimitive((Geometry) data.get(ID_FIELD_GEOMETRY));
70
            if (multi == null) {
71
                data.set(ID_FIELD_GEOMETRY, null);
72
            } else {
73
                data.set(ID_FIELD_GEOMETRY, multi);
74
            }
75
            return;
76
        }
77
        for (int i = 0; i <= MAX_FIELD_ID; i++) {
78
            Object value = group.get(i);
79
            if (i == ID_FIELD_GEOMETRY) {
80
                Geometry newgeom = (Geometry) data.get(i);
81
                if (newgeom != null) {
82
                    if (value == null) {
83
                        group.set(ID_FIELD_GEOMETRY, getMultiPrimitive(newgeom));
84
                    } else {
85
                        try {
86
                            ((MultiPrimitive) value).addPrimitive((Primitive) newgeom);
87
                        } catch (Exception ex) {
88
                            logger.warn("Can't group geoemtry '" + newgeom.toString() + "' in '" + value.toString() + "'.", ex);
89
                        }
90
                    }
91
                }
92
            } else if (value == null) {
93
                group.set(i, data.get(i));
94
            } else if (value instanceof String) {
95
                String s = (String) value;
96
                if (s.trim().length() == 0) {
97
                    group.set(i, data.get(i));
98
                }
99
            }
100
        }
101

  
102
    }
103

  
104
    private MultiPrimitive getMultiPrimitive(Geometry geom) {
105
        if (geom == null) {
106
            return null;
107
        }
108
        if (geom instanceof MultiPrimitive) {
109
            return (MultiPrimitive) geom;
110
        }
111
        MultiPrimitive multi = null;
112
        try {
113
            if (geom instanceof Point) {
114
                multi = (MultiPrimitive) geomManager.create(
115
                        Geometry.TYPES.MULTIPOINT,
116
                        geom.getGeometryType().getSubType()
117
                );
118
            } else if (geom instanceof Curve) {
119
                multi = (MultiPrimitive) geomManager.create(
120
                        Geometry.TYPES.MULTICURVE,
121
                        geom.getGeometryType().getSubType()
122
                );
123
            } else if (geom instanceof Surface) {
124
                multi = (MultiPrimitive) geomManager.create(
125
                        Geometry.TYPES.MULTISURFACE,
126
                        geom.getGeometryType().getSubType()
127
                );
128
            }
129
            if (multi != null) {
130
                multi.addPrimitive((Primitive) geom);
131
            }
132
        } catch (CreateGeometryException ex) {
133
            logger.warn("Can't create multi-geometry to group", ex);
134
        }
135
        return multi;
136
    }
137

  
138
    public List<FeatureProvider> getRows() {
139
        if (this.groupGeometriesOperation < 0) {
140
            Iterator<FeatureProvider> rowsIterator = this.groupedFeatures.values().iterator();
141
            while( rowsIterator.hasNext() ) {
142
                FeatureProvider feature = rowsIterator.next();
143
                Geometry geometry = feature.getDefaultGeometry();
144
                if (geometry != null) {
145
                    if (this.envelope == null) {
146
                        this.envelope = geometry.getEnvelope();
147
                    } else {
148
                        this.envelope.add(geometry.getEnvelope());
149
                    }
150
                }
151
            }
152
            return (List<FeatureProvider>) this.groupedFeatures.values();
153
        }
154

  
155
        List<FeatureProvider> result = new ArrayList<FeatureProvider>();
156
        
157
        FilteredLogger log = new FilteredLogger(logger, "ConsolideGroupBy", 10);
158

  
159
        Iterator<Map.Entry<Object, FeatureProvider>> it = groupedFeatures.entrySet().iterator();
160
        while (it.hasNext()) {
161
            Map.Entry<Object, FeatureProvider> entry = it.next();
162
            String groupValue = "<null>";
163
            if (entry.getKey() != null) {
164
                groupValue = entry.getKey().toString();
165
            }
166
            try {
167
                FeatureProvider data = entry.getValue();
168
                Geometry geometry = data.getDefaultGeometry();
169
                if (geometry != null) {
170
                    switch (this.groupGeometriesOperation) {
171
                        case GROUP_GEOMETRIES_NONE:
172
                            break;
173
                        case GROUP_GEOMETRIES_CONVEXHULL:
174
                            try {
175
                                geometry = geometry.convexHull();
176
                                data.set(ID_FIELD_GEOMETRY, geometry);
177
                            } catch (Exception ex) {
178
                                log.warn("Can't create convex-hull with geometries of the group '" + groupValue + "'.", ex);
179
                            }
180
                            break;
181
                        case GROUP_GEOMETRIES_UNION:
182
                            if (geometry instanceof Aggregate) {
183
                                try {
184
                                    geometry = ((Aggregate) geometry).union();
185
                                    data.set(ID_FIELD_GEOMETRY, geometry);
186
                                } catch (Exception ex) {
187
                                    log.warn("Can't create a union with geometries of the group '" + groupValue + "'.", ex);
188
                                }
189
                            }
190
                            break;
191
                        case GROUP_GEOMETRIES_INTERSECTION:
192
                            if (geometry instanceof Aggregate) {
193
                                try {
194
                                    geometry = ((Aggregate) geometry).intersection();
195
                                    data.set(ID_FIELD_GEOMETRY, geometry);
196
                                } catch (Exception ex) {
197
                                    log.warn("Can't create a intersection with geometries of the group '" + groupValue + "'.", ex);
198
                                }
199
                            }
200
                            break;
201

  
202
                        case GROUP_GEOMETRIES_TOPOINTS:
203
                            try {
204
                                if (geometry instanceof Line) {
205
                                    geometry = ((Line) geometry).toPoints();
206
                                    data.set(ID_FIELD_GEOMETRY, geometry);
207

  
208
                                } else if (geometry instanceof Polygon) {
209
                                    geometry = ((Polygon) geometry).toPoints();
210
                                    data.set(ID_FIELD_GEOMETRY, geometry);
211

  
212
                                } else if (geometry instanceof Point) {
213
                                    geometry = ((Point) geometry).toPoints();
214
                                    data.set(ID_FIELD_GEOMETRY, geometry);
215

  
216
                                } else if (geometry instanceof MultiLine) {
217
                                    geometry = ((MultiLine) geometry).toPoints();
218
                                    data.set(ID_FIELD_GEOMETRY, geometry);
219

  
220
                                } else if (geometry instanceof MultiPolygon) {
221
                                    geometry = ((MultiPolygon) geometry).toPoints();
222
                                    data.set(ID_FIELD_GEOMETRY, geometry);
223

  
224
                                }
225
                            } catch (Exception ex) {
226
                                log.warn("Can't convert to points the geometries of the group '" + groupValue + "'.", ex);
227
                            }
228
                            break;
229

  
230
                        case GROUP_GEOMETRIES_TOLINES:
231
                            try {
232
                                if (geometry instanceof Polygon) {
233
                                    geometry = ((Polygon) geometry).toLines();
234
                                    data.set(ID_FIELD_GEOMETRY, geometry);
235

  
236
                                } else if (geometry instanceof MultiPolygon) {
237
                                    geometry = ((MultiPolygon) geometry).toLines();
238
                                    data.set(ID_FIELD_GEOMETRY, geometry);
239

  
240
                                }
241
                            } catch (Exception ex) {
242
                                log.warn("Can't convert to lines the geometries of the group '" + groupValue + "'.", ex);
243
                            }
244
                            break;
245

  
246
                        case GROUP_GEOMETRIES_TOPOLYGONS:
247
                            try {
248
                                if (geometry instanceof Line) {
249
                                    geometry = ((Line) geometry).toPolygons();
250
                                    data.set(ID_FIELD_GEOMETRY, geometry);
251

  
252
                                } else if (geometry instanceof MultiLine) {
253
                                    geometry = ((MultiLine) geometry).toPolygons();
254
                                    data.set(ID_FIELD_GEOMETRY, geometry);
255

  
256
                                } else {
257
                                    geometry = null;
258
                                    data.set(ID_FIELD_GEOMETRY, geometry);
259
                                }
260
                            } catch (Exception ex) {
261
                                log.warn("Can't convert to polygons the geometries of the group '" + groupValue + "'.", ex);
262
                            }
263
                            break;
264

  
265
                        case GROUP_GEOMETRIES_TOPOLYGONS_FIX:
266
                            try {
267
                                if (geometry instanceof Line) {
268
                                    geometry = ((Line) geometry).toPolygons();
269
                                    geometry = geometry.buffer(0);
270
                                    data.set(ID_FIELD_GEOMETRY, geometry);
271

  
272
                                } else if (geometry instanceof MultiLine) {
273
                                    geometry = ((MultiLine) geometry).toPolygons();
274
                                    geometry = geometry.buffer(0);
275
                                    data.set(ID_FIELD_GEOMETRY, geometry);
276

  
277
                                } else {
278
                                    geometry = null;
279
                                    data.set(ID_FIELD_GEOMETRY, geometry);
280
                                }
281
                            } catch (Exception ex) {
282
                                log.warn("Can't convert to polygons the geometries of the group '" + groupValue + "'.", ex);
283
                            }
284
                            break;
285
                    }
286
                    if (geometry != null) {
287
                        if (this.envelope == null) {
288
                            this.envelope = geometry.getEnvelope();
289
                        } else {
290
                            this.envelope.add(geometry.getEnvelope());
291
                        }
292
                    }
293
                }
294
                result.add(data);
295
            } catch (Exception ex) {
296
                log.warn("Problem adding data from group '" + groupValue + "'.", ex);
297
            }
298
        }
299
        return result;
300
    }
301

  
302
    public Envelope getEnvelope() {
303
        if( this.envelope == null ) {
304
            
305
        }
306
        return this.envelope;
307
    }
308

  
309
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/PostProcessFeatures.java
1
package org.gvsig.fmap.dal.store.dgn;
2

  
3
import java.util.ArrayList;
4
import java.util.Collections;
5
import java.util.Comparator;
6
import java.util.Iterator;
7
import java.util.List;
8
import org.gvsig.fmap.dal.feature.FeatureType;
9
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
10
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.TimeCounter;
11
import org.gvsig.fmap.geom.Geometry;
12
import org.gvsig.fmap.geom.GeometryLocator;
13
import org.gvsig.fmap.geom.GeometryManager;
14
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
15
import org.gvsig.fmap.geom.primitive.Envelope;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18

  
19
public class PostProcessFeatures {
20

  
21
    private static final Logger logger = LoggerFactory.getLogger(PostProcessFeatures.class);
22

  
23
    private final FeatureType featureType;
24
    private final DGNOpenStoreParameters parameters;
25
    private Envelope envelope;
26
    private final int geomSubtype;
27
    private PostProcessFilterOperation filter = null;
28

  
29
    public PostProcessFeatures(DGNOpenStoreParameters parameters, FeatureType featureType) {
30
        this.featureType = featureType;
31
        this.parameters = parameters;
32
        if (parameters.ignoreZs()) {
33
            this.geomSubtype = Geometry.SUBTYPES.GEOM2D;
34
        } else {
35
            this.geomSubtype = featureType.getDefaultGeometryAttribute().getGeomType().getSubType();
36
        }
37
    }
38

  
39
    private DGNOpenStoreParameters getDGNParameters() {
40
        return this.parameters;
41
    }
42

  
43
    private PostProcessFilterOperation getFilter() {
44
        if (this.filter == null) {
45
            this.filter = new PostProcessFilterOperation(
46
                    getDGNParameters(),
47
                    featureType
48
            );
49
        }
50
        return this.filter;
51
    }
52

  
53
    public List<FeatureProvider> apply(List<FeatureProvider> rows) throws CreateEnvelopeException {
54

  
55
        TimeCounter tc_total = new TimeCounter();
56
        TimeCounter tc_accept = new TimeCounter();
57

  
58
        PostProcessFilterOperation filter = this.getFilter();
59

  
60
        List<FeatureProvider> result = null;
61

  
62
        Iterator<FeatureProvider> rowsIterator = rows.iterator();
63

  
64
        int rowCount = 0;
65
        int rowFitereds = 0;
66
        if (parameters.getGroupBy() == null) {
67
            GeometryManager geomManager = GeometryLocator.getGeometryManager();
68
            this.envelope = geomManager.createEnvelope(this.geomSubtype);
69

  
70
            tc_total.start();
71
            result = new ArrayList<FeatureProvider>();
72
            while (rowsIterator.hasNext()) {
73
                FeatureProvider feature = rowsIterator.next();
74
                rowCount++;
75

  
76
                tc_accept.start();
77
                boolean accept = filter.accept(feature);
78
                tc_accept.stop();
79

  
80
                if (!accept) {
81
                    continue;
82
                }
83
                rowFitereds++;
84
                Geometry geom = feature.getDefaultGeometry();
85
                if (geom != null) {
86
                    this.envelope.add(geom.getEnvelope());
87
                }
88
                result.add(feature);
89
            }
90
            tc_total.stop();
91
            tc_accept.log("Accepts time filter");
92
            tc_total.log("Total time filer, rows input "+rowCount+", output "+rowFitereds );
93

  
94
        } else {
95
            tc_total.start();
96

  
97
            PostProcessGroupOperation groupOperation = new PostProcessGroupOperation(
98
                    this.featureType,
99
                    parameters.getGroupBy(),
100
                    parameters.getGroupGeometriesOperation()
101
            );
102
            while (rowsIterator.hasNext()) {
103
                FeatureProvider feature = rowsIterator.next();
104
                rowCount++;
105

  
106
                tc_accept.start();
107
                boolean accept = filter.accept(feature);
108
                tc_accept.stop();
109

  
110
                if (!accept) {
111
                    continue;
112
                }
113
                rowFitereds++;
114
                groupOperation.add(feature);
115
            }
116
            result = groupOperation.getRows();
117
            this.envelope = groupOperation.getEnvelope();
118

  
119
            tc_total.stop();
120
            tc_accept.log("Accepts time filter+group");
121
            tc_total.log("Total time filer+group, rows input "+rowCount+", output "+rowFitereds );
122
        }
123

  
124
        if (parameters.sortByGeometryType()) {
125
            this.sortRows(result);
126
        }
127
        return result;
128
    }
129

  
130
    public Envelope getEnvelope() {
131
        return this.envelope;
132
    }
133

  
134
    private void sortRows(List<FeatureProvider> rows) {
135
        TimeCounter tc = new TimeCounter();
136
        tc.start();
137
        Collections.sort(rows, new Comparator<FeatureProvider>() {
138
            public int compare(FeatureProvider o1, FeatureProvider o2) {
139
                Geometry g1 = o1.getDefaultGeometry();
140
                Geometry g2 = o2.getDefaultGeometry();
141
                if (g1 == null) {
142
                    if (g2 == null) {
143
                        return 0;
144
                    } else {
145
                        return -1;
146
                    }
147
                } else if (g2 == null) {
148
                    return 1;
149
                }
150
                return g2.getType() - g1.getType();
151
            }
152
        });
153
        tc.stop();
154
        tc.log("sort data, rows "+rows.size());
155
    }
156

  
157
    public boolean hasOperations() {
158
        PostProcessFilterOperation filter = this.getFilter();
159
        if (filter.hasFilter()) {
160
            return true;
161
        }
162
        if (parameters.getGroupBy() != null) {
163
            return true;
164
        }
165
        return false;
166
    }
167

  
168
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/LegendBuilder.java
1
package org.gvsig.fmap.dal.store.dgn;
2

  
3
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
4
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
5
import org.gvsig.fmap.dal.store.dgn.lib.DGNReader;
6

  
7

  
8
public interface LegendBuilder {
9

  
10
	final public static String DYNMETHOD_BUILDER_NAME = "getLegendBuilder";
11
	final public static String DYNMETHOD_GETLEGEND_NAME = "getLegend";
12
	final public static String DYNMETHOD_GETLABELING_NAME = "getLabeling";
13

  
14
	public LegendBuilder initialize(FeatureStoreProvider store);
15

  
16
	public void begin();
17

  
18
	public void process(FeatureProvider feature, DGNReader dgnReader);
19

  
20
	public void end();
21

  
22
	public Object getLegend();
23
	public Object getLabeling();
24

  
25
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/DGNElemTCB.java
1
/*
2
 * Created on 17-jul-2003
3
 *
4
 * Copyright (c) 2003
5
 * Francisco José Peñarrubia Martínez
6
 * IVER Tecnologías de la Información S.A.
7
 * Salamanca 50
8
 * 46005 Valencia (        SPAIN )
9
 * +34 963163400
10
 * mailto:fran@iver.es
11
 * http://www.iver.es
12
 */
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
package org.gvsig.fmap.dal.store.dgn.lib;
54

  
55
/**
56
 * Clase utilizada para guardar un elemento de tipo TCB.
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class DGNElemTCB extends DGNElemCore {
61

  
62
	public int dimension; /*!< Dimension (2 or 3) */
63
	public double origin_x; /*!< X origin of UOR space in master units(?)*/
64
	public double origin_y; /*!< Y origin of UOR space in master units(?)*/
65
	public double origin_z; /*!< Z origin of UOR space in master units(?)*/
66
	public double uor_per_subunit; /*!< UOR per subunit. */
67
	public char[] sub_units = new char[3];
68

  
69
	//3      /*!< User name for subunits (2 chars)*/
70
	public double subunits_per_master; /*!< Subunits per master unit. */
71
	public char[] master_units = new char[3];
72

  
73
	//3   /*!< User name for master units (2 chars)*/
74
	public DGNViewInfo[] views = new DGNViewInfo[8]; //8
75
        
76
        public DGNElemTCB(DGNReader dgnreader) {
77
            super(dgnreader);
78
        }
79
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/DGNElemTagValue.java
1
/*
2
 * Created on 21-jul-2003
3
 *
4
 * Copyright (c) 2003
5
 * Francisco José Peñarrubia Martínez
6
 * IVER Tecnologías de la Información S.A.
7
 * Salamanca 50
8
 * 46005 Valencia (        SPAIN )
9
 * +34 963163400
10
 * mailto:fran@iver.es
11
 * http://www.iver.es
12
 */
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
package org.gvsig.fmap.dal.store.dgn.lib;
54

  
55
/**
56
 * Clase utilizada para guardar un elemento de tipo TagValue.
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class DGNElemTagValue extends DGNElemCore {
61
	public int tagType; /*!< Tag type indicator, DGNTT_* */
62
	public int tagSet; /*!< Which tag set does this relate to? */
63
	public int tagIndex; /*!< Tag index within tag set. */
64
	public int tagLength; /*!< Length of tag information (text) */
65
	public tagValueUnion tagValue = new tagValueUnion();
66
        
67
        
68
        public DGNElemTagValue(DGNReader dgnreader) {
69
            super(dgnreader);
70
        }
71

  
72
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/DGNElemComplexHeader.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 */
21
package org.gvsig.fmap.dal.store.dgn.lib;
22

  
23
/**
24
 * Clase utilizada para guardar un elemento de tipo ComplexHeader.
25
 *
26
 * @author Vicente Caballero Navarro
27
 */
28
public class DGNElemComplexHeader extends DGNElemCore {
29
	public int totlength; /*!< Total length of surface */
30
	public int numelems; /*!< # of elements in surface */
31
        
32
        public DGNElemComplexHeader(DGNReader dgnreader) {
33
            super(dgnreader);
34
        }
35
        
36
        public int getNumElements() {
37
            return this.numelems;
38
        }
39
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/DGNViewInfo.java
1
/*
2
 * Created on 17-jul-2003
3
 *
4
 * Copyright (c) 2003
5
 * Francisco José Peñarrubia Martínez
6
 * IVER Tecnologías de la Información S.A.
7
 * Salamanca 50
8
 * 46005 Valencia (        SPAIN )
9
 * +34 963163400
10
 * mailto:fran@iver.es
11
 * http://www.iver.es
12
 */
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
package org.gvsig.fmap.dal.store.dgn.lib;
54

  
55
/**
56
 * Informaci?n sobre la vista.
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class DGNViewInfo {
61
	public int flags;
62
	public short[] levels = new short[8]; //8
63
	public DGNPoint origin = new DGNPoint();
64
	public DGNPoint delta = new DGNPoint();
65
	public double[] transmatrx = new double[9]; //9
66
	public double conversion;
67
	public double activez;
68
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/DGNElemText.java
1
/*
2
 * Created on 17-jul-2003
3
 *
4
 * Copyright (c) 2003
5
 * Francisco José Peñarrubia Martínez
6
 * IVER Tecnologías de la Información S.A.
7
 * Salamanca 50
8
 * 46005 Valencia (        SPAIN )
9
 * +34 963163400
10
 * mailto:fran@iver.es
11
 * http://www.iver.es
12
 */
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
package org.gvsig.fmap.dal.store.dgn.lib;
54

  
55
/**
56
 * Clase utilizada para guardar un elemento de tipo Text.
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class DGNElemText extends DGNElemCore {
61
	public int font_id; /*!< Microstation font id, no list available*/
62
	public int justification; /*!< Justification, see DGNJ_* */
63
	public double length_mult; /*!< Char width in master (if square) */
64
	public double height_mult; /*!< Char height in master units */
65
	public double height_raw;
66
	public double rotation; /*!< Counterclockwise rotation in degrees */
67
	public DGNPoint origin = new DGNPoint(); // Bottom left corner of text. 
68
	public String string; //Actual text (length varies, \0 terminated
69

  
70
        public DGNElemText(DGNReader dgnreader) {
71
            super(dgnreader);
72
        }
73

  
74
        public DGNPoint getPoint() {
75
            return this.origin;
76
        }
77
        
78
        public double getHeight() {
79
            return this.height_mult;
80
        }
81
        
82
        public double getRawHeight() {
83
            return this.height_raw;
84
        }
85
        
86
        public double getRotation() {
87
            return this.rotation;
88
        }
89
        
90
        public String getText() {
91
            return this.string;
92
        }
93
}
94

  
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/tagValueUnion.java
1
/*
2
 * Created on 21-jul-2003
3
 *
4
 * Copyright (c) 2003
5
 * Francisco José Peñarrubia Martínez
6
 * IVER Tecnologías de la Información S.A.
7
 * Salamanca 50
8
 * 46005 Valencia (        SPAIN )
9
 * +34 963163400
10
 * mailto:fran@iver.es
11
 * http://www.iver.es
12
 */
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
package org.gvsig.fmap.dal.store.dgn.lib;
54

  
55
/**
56
 * Uni?n del valor del tag.
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class tagValueUnion {
61
	public char[] string;
62
	public long integer;
63
	public double real;
64
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.120/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/DGNFileHeader.java
1
/*
2
 * Created on 16-jul-2003
3
 *
4
 * Copyright (c) 2003
5
 * Francisco José Peñarrubia Martínez
6
 * IVER Tecnologías de la Información S.A.
7
 * Salamanca 50
8
 * 46005 Valencia (        SPAIN )
9
 * +34 963163400
10
 * mailto:fran@iver.es
11
 * http://www.iver.es
12
 */
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
package org.gvsig.fmap.dal.store.dgn.lib;
54

  
55
import java.nio.MappedByteBuffer;
56

  
57

  
58
/**
59
 * Clase Header del DGN.
60
 *
61
 * @author Vicente Caballero Navarro
62
 */
63
public class DGNFileHeader {
64
	/** DGNElemCore style: Element uses DGNElemCore structure */
65
	public static final int DGNST_CORE = 1;
66

  
67
	/** DGNElemCore style: Element uses DGNElemMultiPoint structure */
68
	public static final int DGNST_MULTIPOINT = 2;
69

  
70
	/** DGNElemCore style: Element uses DGNElemColorTable structure */
71
	public static final int DGNST_COLORTABLE = 3;
72

  
73
	/** DGNElemCore style: Element uses DGNElemTCB structure */
74
	public static final int DGNST_TCB = 4;
75

  
76
	/** DGNElemCore style: Element uses DGNElemArc structure */
77
	public static final int DGNST_ARC = 5;
78

  
79
	/** DGNElemCore style: Element uses DGNElemText structure */
80
	public static final int DGNST_TEXT = 6;
81

  
82
	/** DGNElemCore style: Element uses DGNElemComplexHeader structure */
83
	public static final int DGNST_COMPLEX_HEADER = 7;
84

  
85
	/** DGNElemCore style: Element uses DGNElemCellHeader structure */
86
	public static final int DGNST_CELL_HEADER = 8;
87

  
88
	/** DGNElemCore style: Element uses DGNElemTagValue structure */
89
	public static final int DGNST_TAG_VALUE = 9;
90

  
91
	/** DGNElemCore style: Element uses DGNElemTagSet structure */
92
	public static final int DGNST_TAG_SET = 10;
93

  
94
	/** DGNElemCore style: Element uses DGNElemCellLibrary structure */
95
	public static final int DGNST_CELL_LIBRARY = 11;
96

  
97
	/** DGNElemCore style: Element uses DGNElemGroup structure */
98
	public static final int DGNST_GROUP_DATA = 12;
99
	public static final int DGNST_SHARED_CELL_DEFN = 13;
100

  
101
	/* -------------------------------------------------------------------- */
102
	/*      Element types                                                   */
103
	/* -------------------------------------------------------------------- */
104
	public static final int DGNT_NULL = 0;
105
	public static final int DGNT_CELL_LIBRARY = 1;
106
	public static final int DGNT_CELL_HEADER = 2;
107
	public static final int DGNT_LINE = 3;
108
	public static final int DGNT_LINE_STRING = 4;
109
	public static final int DGNT_GROUP_DATA = 5;
110
	public static final int DGNT_SHAPE = 6;
111
	public static final int DGNT_TEXT_NODE = 7;
112
	public static final int DGNT_DIGITIZER_SETUP = 8;
113
	public static final int DGNT_TCB = 9;
114
	public static final int DGNT_LEVEL_SYMBOLOGY = 10;
115
	public static final int DGNT_CURVE = 11;
116
	public static final int DGNT_COMPLEX_CHAIN_HEADER = 12;
117
	public static final int DGNT_COMPLEX_SHAPE_HEADER = 14;
118
	public static final int DGNT_ELLIPSE = 15;
119
	public static final int DGNT_ARC = 16;
120
	public static final int DGNT_TEXT = 17;
121
	public static final int DGNT_BSPLINE = 21;
122
	public static final int DGNT_SHARED_CELL_DEFN = 34;
123
	public static final int DGNT_SHARED_CELL_ELEM = 35; // REVISAR
124
	public static final int DGNT_TAG_VALUE = 37;
125
	public static final int DGNT_APPLICATION_ELEM = 66;
126

  
127
	/* -------------------------------------------------------------------- */
128
	/*      Line Styles                                                     */
129
	/* -------------------------------------------------------------------- */
130
	public static final int DGNS_SOLID = 0;
131
	public static final int DGNS_DOTTED = 1;
132
	public static final int DGNS_MEDIUM_DASH = 2;
133
	public static final int DGNS_LONG_DASH = 3;
134
	public static final int DGNS_DOT_DASH = 4;
135
	public static final int DGNS_SHORT_DASH = 5;
136
	public static final int DGNS_DASH_DOUBLE_DOT = 6;
137
	public static final int DGNS_LONG_DASH_SHORT_DASH = 7;
138

  
139
	/* -------------------------------------------------------------------- */
140
	/*      Class                                                           */
141
	/* -------------------------------------------------------------------- */
142
	public static final int DGNC_PRIMARY = 0;
143
	public static final int DGNC_PATTERN_COMPONENT = 1;
144
	public static final int DGNC_CONSTRUCTION_ELEMENT = 2;
145
	public static final int DGNC_DIMENSION_ELEMENT = 3;
146
	public static final int DGNC_PRIMARY_RULE_ELEMENT = 4;
147
	public static final int DGNC_LINEAR_PATTERNED_ELEMENT = 5;
148
	public static final int DGNC_CONSTRUCTION_RULE_ELEMENT = 6;
149

  
150
	/* -------------------------------------------------------------------- */
151
	/*      Group Data level numbers.                                       */
152
	/*                                                                      */
153
	/*      These are symbolic values for the typ 5 (DGNT_GROUP_DATA)       */
154
	/*      level values that have special meanings.                        */
155
	/* -------------------------------------------------------------------- */
156
	public static final int DGN_GDL_COLOR_TABLE = 1;
157
	public static final int DGN_GDL_NAMED_VIEW = 3;
158
	public static final int DGN_GDL_REF_FILE = 9;
159

  
160
	/* -------------------------------------------------------------------- */
161
	/*      Word 17 property flags.                                         */
162
	/* -------------------------------------------------------------------- */
163
	public static final int DGNPF_HOLE = 0x8000;
164
	public static final int DGNPF_SNAPPABLE = 0x4000;
165
	public static final int DGNPF_PLANAR = 0x2000;
166
	public static final int DGNPF_ORIENTATION = 0x1000;
167
	public static final int DGNPF_ATTRIBUTES = 0x0800;
168
	public static final int DGNPF_MODIFIED = 0x0400;
169
	public static final int DGNPF_NEW = 0x0200;
170
	public static final int DGNPF_LOCKED = 0x0100;
171
	public static final int DGNPF_CLASS = 0x000f;
172

  
173
	/* -------------------------------------------------------------------- */
174
	/*      DGNElementInfo flag values.                                     */
175
	/* -------------------------------------------------------------------- */
176
	public static final int DGNEIF_DELETED = 0x01;
177
	public static final int DGNEIF_COMPLEX = 0x02;
178

  
179
	/* -------------------------------------------------------------------- */
180
	/*      Justifications                                                  */
181
	/* -------------------------------------------------------------------- */
182
	public static final int DGNJ_LEFT_TOP = 0;
183
	public static final int DGNJ_LEFT_CENTER = 1;
184
	public static final int DGNJ_LEFT_BOTTOM = 2;
185
	public static final int DGNJ_LEFTMARGIN_TOP = 3;
186

  
187
	/* text node header only */
188
	public static final int DGNJ_LEFTMARGIN_CENTER = 4;
189

  
190
	/* text node header only */
191
	public static final int DGNJ_LEFTMARGIN_BOTTOM = 5;
192

  
193
	/* text node header only */
194
	public static final int DGNJ_CENTER_TOP = 6;
195
	public static final int DGNJ_CENTER_CENTER = 6;
196
	public static final int DGNJ_CENTER_BOTTOM = 8;
197
	public static final int DGNJ_RIGHTMARGIN_TOP = 9;
198

  
199
	/* text node header only */
200
	public static final int DGNJ_RIGHTMARGIN_CENTER = 10;
201

  
202
	/* text node header only */
203
	public static final int DGNJ_RIGHTMARGIN_BOTTOM = 11;
204

  
205
	/* text node header only */
206
	public static final int DGNJ_RIGHT_TOP = 12;
207
	public static final int DGNJ_RIGHT_CENTER = 13;
208
	public static final int DGNJ_RIGHT_BOTTOM = 14;
209

  
210
	/* -------------------------------------------------------------------- */
211
	/*      DGN file reading options.                                       */
212
	/* -------------------------------------------------------------------- */
213
	public static final int DGNO_CAPTURE_RAW_DATA = 0x01;
214

  
215
	/* -------------------------------------------------------------------- */
216
	/*      Known attribute linkage types, including my synthetic ones.     */
217
	/* -------------------------------------------------------------------- */
218
	public static final int DGNLT_DMRS = 0x0000;
219
	public static final int DGNLT_INFORMIX = 0x3848;
220
	public static final int DGNLT_ODBC = 0x5e62;
221
	public static final int DGNLT_ORACLE = 0x6091;
222
	public static final int DGNLT_RIS = 0x71FB;
223
	public static final int DGNLT_SYBASE = 0x4f58;
224
	public static final int DGNLT_XBASE = 0x1971;
225
	public static final int DGNLT_SHAPE_FILL = 0x0041;
226
	public static final int DGNLT_ASSOC_ID = 0x7D2F;
227

  
228
	/* -------------------------------------------------------------------- */
229
	/*      File creation options.                                          */
230
	/* -------------------------------------------------------------------- */
231
	public static final int DGNCF_USE_SEED_UNITS = 0x01;
232
	public static final int DGNCF_USE_SEED_ORIGIN = 0x02;
233
	public static final int DGNCF_COPY_SEED_FILE_COLOR_TABLE = 0x04;
234
	public static final int DGNCF_COPY_WHOLE_SEED_FILE = 0x08;
235
	public static final int SIZE_LONG = 4;
236

  
237
        
238
        public static final String DGNT_CELL_LIBRARY_NAME = "Cell Library";
239
        public static final String DGNT_CELL_HEADER_NAME = "Cell Header";
240
        public static final String DGNT_POINT_NAME = "Point";
241
        public static final String DGNT_LINE_NAME = "Line";
242
        public static final String DGNT_LINE_STRING_NAME = "Line String";
243
        public static final String DGNT_GROUP_DATA_NAME = "Group Data";
244
        public static final String DGNT_SHAPE_NAME = "Shape";
245
        public static final String DGNT_TEXT_NODE_NAME = "Text Node";
246
        public static final String DGNT_DIGITIZER_SETUP_NAME = "Digitizer Setup";
247
        public static final String DGNT_TCB_NAME = "TCB";
248
        public static final String DGNT_LEVEL_SYMBOLOGY_NAME = "Level Symbology";
249
        public static final String DGNT_CURVE_NAME = "Curve";
250
        public static final String DGNT_COMPLEX_CHAIN_HEADER_NAME = "Complex Chain Header";
251
        public static final String DGNT_COMPLEX_SHAPE_HEADER_NAME = "Complex Shape Header";
252
        public static final String DGNT_ELLIPSE_NAME = "Ellipse";
253
        public static final String DGNT_ARC_NAME = "Arc";
254
        public static final String DGNT_TEXT_NAME ="Text";
255
        public static final String DGNT_BSPLINE_NAME = "B-Spline";
256
        public static final String DGNT_APPLICATION_ELEM_NAME = "Application Element";
257
        public static final String DGNT_SHARED_CELL_DEFN_NAME = "Shared Cell Definition";
258
        public static final String DGNT_SHARED_CELL_ELEM_NAME = "Shared Cell Element";
259
        public static final String DGNT_TAG_VALUE_NAME = "Tag Value";
260
        public static final String DGNT_UNKNOWN_NAME = "Unknown";
261
        
262
	/*
263
	   int         offset;
264
	   int         size;
265
	   int         element_id;
266
	   int         stype;
267
	   int                level;
268
	   int                type;
269
	   int                complex;
270
	   int                deleted;
271
	   int                graphic_group;
272
	   int                properties;
273
	   int         color;
274
	   int         weight;
275
	   int         style;
276
	   int                attr_bytes;
277
	   byte attr_data;
278
	   int         raw_bytes;
279
	   byte raw_data;
280
	   //} DGNElemCore;
281
	 */
282

  
283
	/** File Length; */
284
	int myFileLength = 0;
285

  
286
	/** Version of the file. */
287
	int myVersion = 1000;
288

  
289
	/*
290
	   public static final int SHAPE_NULL = 0;
291
	    public static final int SHAPE_POINT = 1;
292
	    public static final int SHAPE_POLYLINE = 3;
293
	    public static final int SHAPE_POLYGON = 5;
294
	    public static final int SHAPE_MULTIPOINT = 8;
295
	    public static final int SHAPE_POINTZ = 11;
296
	    public static final int SHAPE_POLYLINEZ = 13;
297
	    public static final int SHAPE_POLYGONZ = 15;
298
	    public static final int SHAPE_MULTIPOINTZ = 18;
299
	    public static final int SHAPE_POINTM = 21;
300
	    public static final int SHAPE_POLYLINEM = 23;
301
	    public static final int SHAPE_POLYGONM = 25;
302
	    public static final int SHAPE_MULTIPOINTM = 28;
303
	    public static final int SHAPE_MULTIPATCH = 31;
304
	 */
305
	int myDGNType = 0;
306
	double myXmin = 0;
307
	double myYmin = 0;
308
	double myXmax = 0;
309
	double myYmax = 0;
310
	double myZmin = 0;
311
	double myZmax = 0;
312
	double myMmin = 0;
313
	double myMmax = 0;
314

  
315
	// notify about warnings.
316
	private boolean myWarning = true;
317

  
318
	/**
319
	 * ShapeFileHeader constructor comment.
320
	 */
321
	public DGNFileHeader() {
322
		super();
323
	}
324

  
325
	/**
326
	 * Return the version of the file.
327
	 *
328
	 * @return DOCUMENT ME!
329
	 */
330
	public int getVersion() {
331
		return myVersion;
332
	}
333

  
334
	/**
335
	 * Devuelve el rect?ngulo del fichero.
336
	 *
337
	 * @return DOCUMENT ME!
338
	 */
339
	public java.awt.geom.Rectangle2D.Double getFileExtents() {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff