Revision 43355 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCHelperBase.java

View differences:

JDBCHelperBase.java
70 70
    
71 71
    protected OperationsFactory operationsFactory = null;
72 72
    
73
    protected JDBCSRSs srss;
74
    
73 75
    public JDBCHelperBase(JDBCConnectionParameters connectionParameters) {
74 76
        this.connectionParameters = connectionParameters;
77
        
78
        // If a particular treatment is required to convert SRS to the 
79
        // BBDD format, overwrite JDBCSRSsBase and use it instead of JDBCSRSsDumb.
80
        this.srss = new JDBCSRSsDumb(this);
75 81
    }
76 82

  
77 83
    protected void initialize(
......
323 329

  
324 330
    @Override
325 331
    public int getSRSCode(IProjection crs) {
326
        // Dumb implementation
327
        String abrev = crs.getAbrev();
328
        if( StringUtils.isEmpty(abrev) ) {
329
            return -1;
330
        }
331
        String[] ss = abrev.split(":");
332
        if( ss.length < 2 ) {
333
            return -1;
334
        } 
335
        int id = Integer.parseInt(ss[1]);
336
        return id;
332
        String databaseCode = this.srss.getDatabaseCode(crs.getAbrev());
333
        return Integer.parseInt(databaseCode);
337 334
    }
338 335

  
339 336
    @Override
340 337
    public IProjection getProjectionFromSRSId(int srsid) {
341
        // Dumb implementation
342
        if( srsid < 2000 ) {
338
        return getProjectionFromDatabaseCode(String.valueOf(srsid));
339
    }
340

  
341
    @Override
342
    public String getDatabaseCodeFromProyection(IProjection proj) {
343
        String[] s = proj.getAbrev().split(":");
344
        return this.srss.getDatabaseCode(proj.getAbrev());
345
    }
346
    
347
    @Override
348
    public IProjection getProjectionFromDatabaseCode(String databaseCode) {
349
        String abbrev = this.srss.getApplicationAbbrev(databaseCode);
350
        if( StringUtils.isEmpty(abbrev) ) {
343 351
            return null;
344 352
        }
345
        IProjection proj = CRSFactory.getCRS("EPSG:"+srsid);
353
        IProjection proj = CRSFactory.getCRS(abbrev);
346 354
        return proj;
347 355
    }
348 356
    

Also available in: Unified diff