Revision 42811 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/utils/SHPFile2.java

View differences:

SHPFile2.java
87 87

  
88 88
    private boolean useNullGeometry = false;
89 89

  
90
    private boolean allowInconsistenciesInGeometryTypeWarningShow = false;
91 90
    private SHPReader reader;
92 91

  
93 92
    public SHPFile2(SHPStoreParameters params) {
......
230 229

  
231 230
        switch (subType) {
232 231
        case SUBTYPES.GEOM2D:
233
            reader = new SHPReader2D();
232
            reader = new SHPReader2D(this.params);
234 233
            break;
235 234
        case SUBTYPES.GEOM2DM:
236
            reader = new SHPReader2DM();
235
            reader = new SHPReader2DM(this.params);
237 236
            break;
238 237
        case SUBTYPES.GEOM3DM:
239
            reader = new SHPReader3DM();
238
            reader = new SHPReader3DM(this.params);
240 239
            break;
241 240

  
242 241
        default:
......
391 390
         * huge (absurd) array, so it's safer to return a null geometry
392 391
         */
393 392
        if (shapeType != type) {
394
            if( !allowInconsistenciesInGeometryTypeWarningShow ) {
395
                logger.warn("Geometry type of Shape ("+type+") does not match the geometry found ("+shapeType+") in the shape '"+this.params.getSHPFileName()+".");
396
                allowInconsistenciesInGeometryTypeWarningShow = true;
397
            }
398 393
            if( ! this.params.getAllowInconsistenciesInGeometryType() ) {
399
                return getNullGeometry();
394
                throw new InconsistenciesInGeometryTypeException(shapeType);
400 395
            }
401 396
        }
402 397

  
403 398
        // retrieve that shape.
404
        // tempRecord.setShape(readShape(tempShapeType, tempContentLength, in));
405 399
        switch (type) {
406 400
        case (SHP.POINT2D):
407 401
        case (SHP.POINT3D):
......
430 424
        }
431 425
        return null;
432 426
    }
427
    
428
    private class InconsistenciesInGeometryTypeException extends ReadException {
433 429

  
430
        private final static String MESSAGE_FORMAT = "The geometry type  (%(geomTypeOfHeader)) of the shape file (%(fname)) does not match the type of the current geometry (%(geomTypeOfGeometry)).\nCheck 'Allow inconsistencies in geometry type' in the shape's properties of the add layer dialog to ignore it.";
431
        private final static String MESSAGE_KEY = "_InconsistenciesInGeometryTypeException";
432
        private static final long serialVersionUID = 8991813814092628916L;
433

  
434
        public InconsistenciesInGeometryTypeException(int geomTypeOfGeometry) {
435
            super(MESSAGE_FORMAT, null, MESSAGE_KEY, serialVersionUID);
436
            setValue("geomTypeOfHeader", SHP.getTypeName(type));
437
            setValue("geomTypeOfGeometry", SHP.getTypeName(geomTypeOfGeometry));
438
            setValue("fname", params.getSHPFile().getName());
439
            
440
        }
441
    }
442

  
434 443
    private long getPositionForRecord(long numRec) {
435 444
        // shx file has a 100 bytes header, then, records
436 445
        // 8 bytes length, one for each entity.

Also available in: Unified diff