Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / shp / utils / SHPFile.java @ 36201

History | View | Annotate | Download (21 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 IVER T.I   {{Task}}
26
 */
27

    
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.dal.store.shp.utils;
32

    
33
import java.io.BufferedReader;
34
import java.io.File;
35
import java.io.FileInputStream;
36
import java.io.FileReader;
37
import java.io.IOException;
38
import java.nio.ByteOrder;
39
import java.nio.channels.FileChannel;
40

    
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

    
44
import org.gvsig.fmap.dal.exception.CloseException;
45
import org.gvsig.fmap.dal.exception.DataException;
46
import org.gvsig.fmap.dal.exception.FileNotFoundException;
47
import org.gvsig.fmap.dal.exception.ReadException;
48
import org.gvsig.fmap.dal.store.shp.SHPStoreParameters;
49
import org.gvsig.fmap.geom.Geometry;
50
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
51
import org.gvsig.fmap.geom.Geometry.TYPES;
52
import org.gvsig.fmap.geom.GeometryLocator;
53
import org.gvsig.fmap.geom.GeometryManager;
54
import org.gvsig.fmap.geom.aggregate.MultiPoint;
55
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
56
import org.gvsig.fmap.geom.exception.CreateGeometryException;
57
import org.gvsig.fmap.geom.primitive.Curve;
58
import org.gvsig.fmap.geom.primitive.Envelope;
59
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
60
import org.gvsig.fmap.geom.primitive.Point;
61
import org.gvsig.fmap.geom.primitive.Surface;
62
import org.gvsig.fmap.geom.type.GeometryType;
63
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException;
64
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException;
65
import org.gvsig.utils.bigfile.BigByteBuffer2;
66

    
67
/**
68
 * @author jmvivo
69
 * 
70
 */
71
public class SHPFile {
72

    
73
    private static final Logger logger = LoggerFactory.getLogger(SHPFile.class);
74
    private Envelope extent;
75
    private int type;
76
    private int subType;
77
    private String srsParameters;
78

    
79
    private FileInputStream fin;
80
    private FileChannel channel;
81
    private BigByteBuffer2 bb;
82
    private FileInputStream finShx;
83
    private FileChannel channelShx;
84
    private BigByteBuffer2 bbShx;
85

    
86
    private SHPStoreParameters params;
87

    
88
    private int[] supportedGeometryTypes;
89
    private final GeometryManager gManager = GeometryLocator
90
        .getGeometryManager();
91

    
92
    private GeometryType gtypeNull;
93
    private GeometryType gtypePoint2D;
94
    private GeometryType gtypeCurve2D;
95
    private GeometryType gtypeSurface2D;
96
    private GeometryType gtypeMultiPoint2D;
97

    
98
    public SHPFile(SHPStoreParameters params) {
99
        this.params = params;
100
        try {
101
            gtypeNull = gManager.getGeometryType(TYPES.NULL, SUBTYPES.GEOM2D);
102
            gtypePoint2D =
103
                gManager.getGeometryType(TYPES.POINT, SUBTYPES.GEOM2D);
104
            gtypeCurve2D =
105
                gManager.getGeometryType(TYPES.CURVE, SUBTYPES.GEOM2D);
106
            gtypeSurface2D =
107
                gManager.getGeometryType(TYPES.SURFACE, SUBTYPES.GEOM2D);
108
            gtypeMultiPoint2D =
109
                gManager.getGeometryType(TYPES.MULTIPOINT, SUBTYPES.GEOM2D);
110

    
111
        } catch (GeometryTypeNotSupportedException e) {
112
            // TODO Auto-generated catch block
113
            e.printStackTrace();
114
        } catch (GeometryTypeNotValidException e) {
115
            // TODO Auto-generated catch block
116
            e.printStackTrace();
117
        }
118
    }
119

    
120
    /*
121
     * (non-Javadoc)
122
     * 
123
     * @see org.gvsig.fmap.dal.Resource#doClose()
124
     */
125
    public void close() throws CloseException {
126
        CloseException ret = null;
127

    
128
        // FIXME: Arreglar esto para que se acumulen los errores
129
        try {
130
            channel.close();
131
            channelShx.close();
132
        } catch (IOException e) {
133
            ret = new CloseException("SHPFile.close", e);
134
        } finally {
135
            try {
136
                fin.close();
137
                finShx.close();
138
            } catch (IOException e1) {
139
                ret = new CloseException("SHPFile.close", e1);
140
            }
141
        }
142

    
143
        if (ret != null) {
144
            throw ret;
145
        }
146
        bb = null;
147
        bbShx = null;
148
        fin = null;
149
        finShx = null;
150
        channel = null;
151
        channelShx = null;
152
        srsParameters = null;
153
    }
154

    
155
    public boolean isOpen() {
156
        return this.fin != null;
157
    }
158

    
159
    public void open() throws DataException {
160
        try {
161
            fin = new FileInputStream(this.params.getSHPFile());
162
        } catch (java.io.FileNotFoundException e) {
163
            throw new FileNotFoundException(this.params.getSHPFileName());
164
        }
165

    
166
        // Open the file and then get a channel from the stream
167
        channel = fin.getChannel();
168

    
169
        // long size = channel.size();
170

    
171
        // Get the file's size and then map it into memory
172
        // bb = channel.map(FileChannel.MapMode.READ_ONLY, 0, size);
173
        try {
174
            bb = new BigByteBuffer2(channel, FileChannel.MapMode.READ_ONLY);
175
        } catch (IOException e) {
176
            throw new ReadException(this.params.getSHPFileName(), e);
177

    
178
        }
179
        try {
180
            finShx = new FileInputStream(this.params.getSHXFile());
181
        } catch (java.io.FileNotFoundException e) {
182
            throw new FileNotFoundException(this.params.getSHXFileName());
183
        }
184

    
185
        // Open the file and then get a channel from the stream
186
        channelShx = finShx.getChannel();
187

    
188
        // long sizeShx = channelShx.size();
189

    
190
        // Get the file's size and then map it into memory
191
        // bb = channel.map(FileChannel.MapMode.READ_ONLY, 0, size);
192
        // bbShx = channelShx.map(FileChannel.MapMode.READ_ONLY, 0, sizeShx);
193
        try {
194
            bbShx =
195
                new BigByteBuffer2(channelShx, FileChannel.MapMode.READ_ONLY);
196
        } catch (IOException e) {
197
            throw new ReadException(this.params.getSHXFileName(), e);
198

    
199
        }
200
        bbShx.order(ByteOrder.BIG_ENDIAN);
201

    
202
        // create a new header.
203
        ShapeFileHeader2 myHeader = new ShapeFileHeader2();
204

    
205
        bb.position(0);
206

    
207
        // read the header
208
        myHeader.readHeader(bb);
209

    
210
        double[] min = new double[2];
211
        min[0] = myHeader.myXmin;
212
        min[1] = myHeader.myYmin;
213
        double[] max = new double[2];
214
        max[0] = myHeader.myXmax;
215
        max[1] = myHeader.myYmax;
216

    
217
        try {
218
            extent =
219
                gManager.createEnvelope(min[0], min[1], max[0], max[1],
220
                    SUBTYPES.GEOM2D);
221
        } catch (CreateEnvelopeException e1) {
222
            logger.error("Error creating the envelope", e1);
223
        }
224
        // extent = new Rectangle2D.Double(myHeader.myXmin, myHeader.myYmin,
225
        // myHeader.myXmax - myHeader.myXmin,
226
        // myHeader.myYmax - myHeader.myYmin);
227

    
228
        type = myHeader.myShapeType;
229
        subType = getGeometrySubType();
230

    
231
        this.initSupportedGeometryTypes();
232

    
233
        double x = myHeader.myXmin;
234
        double y = myHeader.myYmin;
235
        double w = myHeader.myXmax - myHeader.myXmin;
236
        double h = myHeader.myYmax - myHeader.myYmin;
237

    
238
        if (w == 0) {
239
            x -= 0.1;
240
            w = 0.2;
241
        }
242

    
243
        if (h == 0) {
244
            y -= 0.1;
245
            h = 0.2;
246
        }
247

    
248
        // TODO: SRS
249
        File prjFile = SHP.getPrjFile(this.params.getSHPFile());
250
        if (prjFile.exists()) {
251
            BufferedReader input = null;
252
            try {
253
                input = new BufferedReader(new FileReader(prjFile));
254
            } catch (java.io.FileNotFoundException e) {
255
                throw new FileNotFoundException(prjFile.getAbsolutePath());
256
            }
257

    
258
            try {
259
                this.srsParameters = input.readLine();
260
            } catch (IOException e) {
261
                throw new ReadException("SHPFile.open prj", e);
262
            } finally {
263
                try {
264
                    input.close();
265
                } catch (IOException e) {
266
                    // TODO ???
267
                }
268
            }
269

    
270
        } else {
271
            this.srsParameters = null;
272
        }
273
    }
274

    
275
    public Envelope getFullExtent() throws ReadException {
276
        return this.extent;
277
    }
278

    
279
    public boolean isEditable() {
280
        return this.params.getDBFFile().canWrite()
281
            && this.params.getSHPFile().canWrite()
282
            && this.params.getSHXFile().canWrite();
283
    }
284

    
285
    public int getGeometryType() throws ReadException {
286
        int auxType = 0;
287

    
288
        switch (type) {
289
        case (SHP.POINT2D):
290
        case (SHP.POINT3D):
291
            auxType = auxType | Geometry.TYPES.POINT;
292

    
293
            break;
294

    
295
        case (SHP.POLYLINE2D):
296
        case (SHP.POLYLINE3D):
297
            auxType = auxType | Geometry.TYPES.MULTICURVE;
298

    
299
            break;
300

    
301
        case (SHP.POLYGON2D):
302
        case (SHP.POLYGON3D):
303
            auxType = auxType | Geometry.TYPES.MULTISURFACE;
304

    
305
            break;
306
        case (SHP.MULTIPOINT2D):
307
        case (SHP.MULTIPOINT3D):
308
            auxType = auxType | Geometry.TYPES.MULTIPOINT;
309

    
310
            break;
311
        }
312

    
313
        return auxType;
314
    }
315

    
316
    public int getGeometrySubType() throws ReadException {
317
        switch (type) {
318
        case (SHP.POINT2D):
319
        case (SHP.POLYLINE2D):
320
        case (SHP.POLYGON2D):
321
        case (SHP.MULTIPOINT2D):
322
            return SUBTYPES.GEOM2D;
323
        case (SHP.POINT3D):
324
        case (SHP.POLYLINE3D):
325
        case (SHP.POLYGON3D):
326
        case (SHP.MULTIPOINT3D):
327
            return SUBTYPES.GEOM3D;
328
        case (SHP.POINTM):
329
        case (SHP.POLYLINEM):
330
        case (SHP.POLYGONM):
331
        case (SHP.MULTIPOINTM):
332
            return SUBTYPES.GEOM2DM;
333
        }
334

    
335
        return SUBTYPES.UNKNOWN;
336
    }
337

    
338
    public synchronized Geometry getGeometry(long position)
339
        throws ReadException, CreateGeometryException {
340
        int shapeType;
341

    
342
        bb.position(getPositionForRecord(position));
343
        bb.order(ByteOrder.LITTLE_ENDIAN);
344

    
345
        shapeType = bb.getInt();
346
        // el shape tal con tema tal y n?mro tal es null
347
        if (shapeType == SHP.NULL) {
348
            return gtypeNull.create();
349
        }
350

    
351
        // retrieve that shape.
352
        // tempRecord.setShape(readShape(tempShapeType, tempContentLength, in));
353
        switch (type) {
354
        case (SHP.POINT2D):
355
        case (SHP.POINT3D):
356
        case (SHP.POINTM):
357
            Point point = readPoint(bb);
358
            fillPoint(point);
359
            return point;
360

    
361
        case (SHP.POLYLINE2D):
362
            Curve curve = (Curve) gtypeCurve2D.create();
363
            fillCurve(curve);
364
            return curve;
365

    
366
        case (SHP.POLYGON2D):
367
            Surface surface = (Surface) gtypeSurface2D.create();
368
            fillSurface(surface);
369
            return surface;
370

    
371
        case (SHP.POLYLINE3D):
372
            Curve curve3D =
373
                (Curve) gManager.create(TYPES.CURVE, SUBTYPES.GEOM3D);
374
            fillCurve(curve3D);
375
            fillZ(curve3D);
376
            return curve3D;
377

    
378
        case (SHP.POLYGON3D):
379
            Surface surface3D =
380
                (Surface) gManager.create(TYPES.SURFACE, SUBTYPES.GEOM3D);
381
            fillSurface(surface3D);
382
            fillZ(surface3D);
383
            return surface3D;
384

    
385
        case (SHP.MULTIPOINT2D):
386

    
387
            Point p = null;
388
            int numPoints;
389
            int i;
390
            int j;
391
            bb.position(bb.position() + 32);
392
            numPoints = bb.getInt();
393

    
394
            Point[] points = new Point[numPoints];
395

    
396
            for (i = 0; i < numPoints; i++) {
397
                points[i] =
398
                    (Point) gManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
399
                points[i].setX(bb.getDouble());
400
                points[i].setY(bb.getDouble());
401
            }
402

    
403
            MultiPoint multipoint = (MultiPoint) gtypeMultiPoint2D.create();
404
            // MultiPoint multipoint =
405
            // (MultiPoint)GeometryLocator.getGeometryManager().create(TYPES.MULTIPOINT,
406
            // SUBTYPES.GEOM2D);
407
            for (int k = 0; k < points.length; k++) {
408
                multipoint.addPoint(points[k]);
409
            }
410

    
411
            return multipoint;
412

    
413
        case (SHP.MULTIPOINT3D):
414
            bb.position(bb.position() + 32);
415
            numPoints = bb.getInt();
416

    
417
            double[] temX = new double[numPoints];
418
            double[] temY = new double[numPoints];
419
            double[] temZ = new double[numPoints];
420

    
421
            for (i = 0; i < numPoints; i++) {
422
                temX[i] = bb.getDouble();
423
                temY[i] = bb.getDouble();
424
                // temZ[i] = bb.getDouble();
425
            }
426

    
427
            for (i = 0; i < numPoints; i++) {
428
                temZ[i] = bb.getDouble();
429
            }
430

    
431
            MultiPoint multipoint3D =
432
                (MultiPoint) gManager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM3D);
433
            for (int k = 0; k < temX.length; k++) {
434
                Point pointAux =
435
                    (Point) gManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
436
                pointAux.setX(temX[k]);
437
                pointAux.setY(temY[k]);
438
                pointAux.setCoordinateAt(2, temZ[k]);
439
                multipoint3D.addPoint(pointAux);
440
            }
441
            return multipoint3D;
442
        }
443

    
444
        return null;
445
    }
446

    
447
    private synchronized void fillPoint(Point point) throws ReadException {
448
        if (subType == Geometry.SUBTYPES.GEOM3D) {
449
            point.setCoordinateAt(Geometry.DIMENSIONS.Z, bb.getDouble());
450
        } else
451
            if (subType == Geometry.SUBTYPES.GEOM2DM) {
452
                point.setCoordinateAt(2, bb.getDouble());
453
            }
454
    }
455

    
456
    private synchronized void fillCurve(Curve curve)
457
        throws CreateGeometryException, ReadException {
458
        Point p = null;
459
        int numParts;
460
        int numPoints;
461
        int i;
462
        int j;
463

    
464
        bb.position(bb.position() + 32);
465
        numParts = bb.getInt();
466
        numPoints = bb.getInt();
467

    
468
        int[] tempParts = new int[numParts];
469

    
470
        for (i = 0; i < numParts; i++) {
471
            tempParts[i] = bb.getInt();
472
        }
473

    
474
        j = 0;
475

    
476
        for (i = 0; i < numPoints; i++) {
477
            p = readPoint(bb);
478

    
479
            if (i == tempParts[j]) {
480
                curve.addMoveToVertex(p);
481

    
482
                if (j < (numParts - 1)) {
483
                    j++;
484
                }
485
            } else {
486
                curve.addVertex(p);
487
            }
488
        }
489
    }
490

    
491
    private synchronized void fillSurface(Surface surface)
492
        throws CreateGeometryException, ReadException {
493
        Point p = null;
494
        int numParts;
495
        int numPoints;
496
        int i;
497
        int partIndex;
498

    
499
        bb.position(bb.position() + 32);
500
        numParts = bb.getInt();
501
        numPoints = bb.getInt();
502

    
503
        int[] tempParts = new int[numParts];
504

    
505
        for (i = 0; i < numParts; i++) {
506
            tempParts[i] = bb.getInt();
507
        }
508

    
509
        partIndex = 0;
510

    
511
        for (i = 0; i < numPoints; i++) {
512
            p = readPoint(bb);
513

    
514
            if (i == tempParts[partIndex]) {
515
                surface.addMoveToVertex(p);
516
                if (partIndex < (numParts - 1)) {
517
                    partIndex++;
518
                }
519
            } else {
520
                if ((i == tempParts[partIndex] - 1) || (i == numPoints - 1)) {
521
                    surface.closePrimitive();
522
                } else {
523
                    surface.addVertex(p);
524
                }
525
            }
526
        }
527
    }
528

    
529
    private synchronized void fillZ(OrientablePrimitive orientablePrimitive)
530
        throws CreateGeometryException, ReadException {
531
        double[] boxZ = new double[2];
532
        boxZ[0] = bb.getDouble();
533
        boxZ[1] = bb.getDouble();
534

    
535
        for (int i = 0; i < orientablePrimitive.getNumVertices(); i++) {
536
            orientablePrimitive.setCoordinateAt(i, 2, bb.getDouble());
537
        }
538
    }
539

    
540
    private long getPositionForRecord(long numRec) {
541
        // shx file has a 100 bytes header, then, records
542
        // 8 bytes length, one for each entity.
543
        // first 4 bytes are the offset
544
        // next 4 bytes are length
545

    
546
        int posIndex = 100 + ((int) numRec * 8);
547
        // bbShx.position(posIndex);
548
        long pos = 8 + 2 * bbShx.getInt(posIndex);
549

    
550
        return pos;
551
    }
552

    
553
    /**
554
     * Reads the Point from the shape file.
555
     * 
556
     * @param in
557
     *            ByteBuffer.
558
     * 
559
     * @return Point2D.
560
     * @throws ReadException
561
     * @throws CreateGeometryException
562
     */
563
    private synchronized Point readPoint(BigByteBuffer2 in)
564
        throws CreateGeometryException, ReadException {
565
        // create a new point
566
        // Point2D.Double tempPoint = new Point2D.Double();
567

    
568
        // bytes 1 to 4 are the type and have already been read.
569
        // bytes 4 to 12 are the X coordinate
570
        in.order(ByteOrder.LITTLE_ENDIAN);
571
        return gManager.createPoint(in.getDouble(), in.getDouble(), subType);
572
    }
573

    
574
    /**
575
     * Lee un rect?ngulo del fichero.
576
     * 
577
     * @param in
578
     *            ByteBuffer.
579
     * 
580
     * @return Rect?ngulo.
581
     * @throws CreateEnvelopeException
582
     * 
583
     * @throws IOException
584
     */
585
    private synchronized Envelope readRectangle(BigByteBuffer2 in)
586
        throws CreateEnvelopeException {
587
        in.order(ByteOrder.LITTLE_ENDIAN);
588
        double x = in.getDouble();
589
        double y = in.getDouble();
590

    
591
        double x2 = in.getDouble();
592

    
593
        if (x2 - x == 0) {
594
            x2 += 0.2;
595
            x -= 0.1;
596
        }
597

    
598
        double y2 = in.getDouble();
599

    
600
        if (y2 - y == 0) {
601
            y2 += 0.2;
602
            y -= 0.1;
603
        }
604
        Envelope tempEnvelope =
605
            gManager.createEnvelope(x, y, x2, y2, SUBTYPES.GEOM2D);
606
        return tempEnvelope;
607
    }
608

    
609
    public Envelope getBoundingBox(long featureIndex) throws ReadException,
610
        CreateEnvelopeException, CreateGeometryException {
611
        Point p = null;
612
        Envelope BoundingBox = null;
613
        try {
614
            bb.position(getPositionForRecord(featureIndex));
615
        } catch (Exception e) {
616
            throw new ReadException("getBondingBox (" + featureIndex + ")", e);
617
            // logger.error(" Shapefile is corrupted. Drawing aborted. ="+e+
618
            // "  "+"index = "+index);
619
        }
620
        bb.order(ByteOrder.LITTLE_ENDIAN);
621

    
622
        int tipoShape = bb.getInt();
623

    
624
        // AZABALA: si tipoShape viene con valores erroneos deja de funcionar
625
        // el metodo getShape(i)
626
        // if (tipoShape != SHP.NULL) {
627
        // type = tipoShape;
628

    
629
        // }
630

    
631
        // retrieve that shape.
632
        // tempRecord.setShape(readShape(tempShapeType, tempContentLength, in));
633
        switch (tipoShape) {
634
        case (SHP.POINT2D):
635
        case (SHP.POINT3D):
636
            p = readPoint(bb);
637
            BoundingBox =
638
                gManager.createEnvelope(p.getX() - 0.1, p.getY() - 0.1,
639
                    p.getX() + 0.2, p.getY() + 0.2, SUBTYPES.GEOM2D);
640
            // new Rectangle2D.Double(p.getX() - 0.1,
641
            // p.getY() - 0.1, 0.2, 0.2);
642

    
643
            break;
644

    
645
        case (SHP.POLYLINE2D):
646
        case (SHP.POLYGON2D):
647
        case (SHP.MULTIPOINT2D):
648
        case (SHP.POLYLINE3D):
649
        case (SHP.POLYGON3D):
650
        case (SHP.MULTIPOINT3D):
651

    
652
            // BoundingBox
653
            BoundingBox = readRectangle(bb);
654

    
655
            break;
656
        }
657

    
658
        return BoundingBox;
659
    }
660

    
661
    /**
662
     * @return
663
     */
664
    public String getSRSParameters() {
665
        return this.srsParameters;
666
    }
667

    
668
    private void initSupportedGeometryTypes() throws ReadException {
669
        switch (this.getGeometryType()) {
670
        case Geometry.TYPES.POINT:
671
            supportedGeometryTypes =
672
                new int[] { Geometry.TYPES.POINT, Geometry.TYPES.NULL };
673
            break;
674
        case Geometry.TYPES.MULTIPOINT:
675
            supportedGeometryTypes =
676
                new int[] { Geometry.TYPES.MULTIPOINT, Geometry.TYPES.NULL };
677
            break;
678
        case Geometry.TYPES.MULTICURVE:
679
            supportedGeometryTypes =
680
                new int[] { Geometry.TYPES.CURVE, Geometry.TYPES.ELLIPSE,
681
                    Geometry.TYPES.ARC, Geometry.TYPES.CIRCLE,
682
                    Geometry.TYPES.SURFACE, Geometry.TYPES.NULL,
683
                    Geometry.TYPES.MULTICURVE };
684
            break;
685
        case Geometry.TYPES.MULTISURFACE:
686
            supportedGeometryTypes =
687
                new int[] { Geometry.TYPES.ELLIPSE, Geometry.TYPES.CIRCLE,
688
                    Geometry.TYPES.SURFACE, Geometry.TYPES.NULL,
689
                    Geometry.TYPES.MULTISURFACE };
690
            break;
691

    
692
        default:
693
            supportedGeometryTypes = new int[] {};
694
        }
695
    }
696

    
697
    public boolean canWriteGeometry(int gvSIGgeometryType) {
698
        for (int i = 0; i < supportedGeometryTypes.length; i++) {
699
            if (gvSIGgeometryType == supportedGeometryTypes[i]) {
700
                return true;
701
            }
702
        }
703
        return false;
704
    }
705
}