Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2055 / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / shp / utils / SHPFile.java @ 38963

History | View | Annotate | Download (21.1 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.PointGeometryType;
62
import org.gvsig.fmap.geom.primitive.Surface;
63
import org.gvsig.fmap.geom.type.GeometryType;
64
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException;
65
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException;
66
import org.gvsig.utils.bigfile.BigByteBuffer2;
67

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

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

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

    
87
    private SHPStoreParameters params;
88

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

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

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

    
113
        } catch (GeometryTypeNotSupportedException e) {
114
            throw new RuntimeException(
115
                "Unable to get the 2D geometry types to use", e);
116
        } catch (GeometryTypeNotValidException e) {
117
            throw new RuntimeException(
118
                "Unable to get the 2D geometry types to use", e);
119
        }
120
    }
121

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

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

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

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

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

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

    
171
        // long size = channel.size();
172

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

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

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

    
190
        // long sizeShx = channelShx.size();
191

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

    
201
        }
202
        bbShx.order(ByteOrder.BIG_ENDIAN);
203

    
204
        // create a new header.
205
        ShapeFileHeader2 myHeader = new ShapeFileHeader2();
206

    
207
        bb.position(0);
208

    
209
        // read the header
210
        myHeader.readHeader(bb);
211

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

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

    
230
        type = myHeader.myShapeType;
231
        subType = getGeometrySubType();
232

    
233
        this.initSupportedGeometryTypes();
234

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

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

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

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

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

    
272
        } else {
273
            this.srsParameters = null;
274
        }
275
    }
276

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

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

    
287
    public int getGeometryType() throws ReadException {
288
        int auxType = 0;
289

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

    
295
            break;
296

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

    
301
            break;
302

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

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

    
312
            break;
313
        }
314

    
315
        return auxType;
316
    }
317

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

    
337
        return SUBTYPES.UNKNOWN;
338
    }
339

    
340
    public Geometry getGeometry(long position)
341
        throws ReadException, CreateGeometryException {
342
        int shapeType;
343

    
344
        bb.position(getPositionForRecord(position));
345
        bb.order(ByteOrder.LITTLE_ENDIAN);
346

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

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

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

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

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

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

    
387
        case (SHP.MULTIPOINT2D):
388

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

    
396
            Point[] points = new Point[numPoints];
397

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

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

    
413
            return multipoint;
414

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

    
419
            double[] temX = new double[numPoints];
420
            double[] temY = new double[numPoints];
421
            double[] temZ = new double[numPoints];
422

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

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

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

    
446
        return null;
447
    }
448

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

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

    
466
        bb.position(bb.position() + 32);
467
        numParts = bb.getInt();
468
        numPoints = bb.getInt();
469

    
470
        int[] tempParts = new int[numParts];
471

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

    
476
        j = 0;
477

    
478
        for (i = 0; i < numPoints; i++) {
479
            p = readPoint(bb);
480

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

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

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

    
501
        bb.position(bb.position() + 32);
502
        numParts = bb.getInt();
503
        numPoints = bb.getInt();
504

    
505
        int[] tempParts = new int[numParts];
506

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

    
511
        partIndex = 0;
512

    
513
        for (i = 0; i < numPoints; i++) {
514
            p = readPoint(bb);
515

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

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

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

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

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

    
552
        return pos;
553
    }
554

    
555
    /**
556
     * Reads the Point from the shape file.
557
     * 
558
     * @param in
559
     *            ByteBuffer.
560
     * 
561
     * @return Point2D.
562
     * @throws ReadException
563
     * @throws CreateGeometryException
564
     */
565
    private Point readPoint(BigByteBuffer2 in)
566
        throws CreateGeometryException, ReadException {
567
        // bytes 1 to 4 are the type and have already been read.
568
        // bytes 4 to 12 are the X coordinate
569
        in.order(ByteOrder.LITTLE_ENDIAN);
570

    
571
        return Geometry.SUBTYPES.GEOM2D == subType ? gtypePoint2D.createPoint(
572
            in.getDouble(), in.getDouble()) : gManager.createPoint(
573
            in.getDouble(),
574
            in.getDouble(), subType);
575
    }
576

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

    
594
        double x2 = in.getDouble();
595

    
596
        if (x2 - x == 0) {
597
            x2 += 0.2;
598
            x -= 0.1;
599
        }
600

    
601
        double y2 = in.getDouble();
602

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

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

    
625
        int tipoShape = bb.getInt();
626

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

    
632
        // }
633

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

    
646
            break;
647

    
648
        case (SHP.POLYLINE2D):
649
        case (SHP.POLYGON2D):
650
        case (SHP.MULTIPOINT2D):
651
        case (SHP.POLYLINE3D):
652
        case (SHP.POLYGON3D):
653
        case (SHP.MULTIPOINT3D):
654

    
655
            // BoundingBox
656
            BoundingBox = readRectangle(bb);
657

    
658
            break;
659
        }
660

    
661
        return BoundingBox;
662
    }
663

    
664
    /**
665
     * @return
666
     */
667
    public String getSRSParameters() {
668
        return this.srsParameters;
669
    }
670

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

    
695
        default:
696
            supportedGeometryTypes = new int[] {};
697
        }
698
    }
699

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