Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / GeoFile.java @ 2312

History | View | Annotate | Download (2.59 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
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
 * For more information, contact:
21
 * 
22
 * cresques@gmail.com
23
 */
24
package org.cresques.io;
25

    
26
import java.util.Date;
27

    
28
import org.cresques.cts.ICoordTrans;
29
import org.cresques.cts.IProjection;
30
import org.cresques.geo.Projected;
31

    
32
import org.cresques.px.Extent;
33
import org.cresques.px.IObjList;
34

    
35
/**
36
 * Ancestro de todos los formatos geogr?ficos
37
 * 
38
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
39
 */
40

    
41
public abstract class GeoFile implements Projected, Extent.Has {
42
        IProjection proj = null;
43
        protected Extent extent = null;
44
        long fileSize = 0;
45
        protected long bytesReaded = 0;
46
        protected long lineCnt = 0;
47
        String name;
48
        
49
        public GeoFile() {        }
50

    
51
        public GeoFile(IProjection p, String n) {
52
                proj = p;
53
                name = n;
54
                if (name != null)
55
                        name = DataSource.normalize(name);
56
                extent = new Extent();
57
        }
58
        
59
        public String getName() { return name; }
60
        public void setName(String n) { name = n; }
61
        
62
        public long getFileSize() { return fileSize; }
63
        public void setFileSize(long sz) { fileSize = sz; }
64

    
65
        public IProjection getProjection() { return proj; }
66
        public void setProjection(IProjection p) { proj = p; }
67
        abstract public void reProject(ICoordTrans rp);
68
        
69
        public Extent getExtent() { return extent; }
70
        abstract public GeoFile load();
71
        abstract public void close();
72
        
73
        abstract public IObjList getObjects();
74
        
75
        /**
76
         * Filtra espacios en blanco. Deja solo uno por 
77
         */
78
        
79
        public static String filterWS(String buf) {
80
                boolean lastCharWhite = false;
81
                String str = "";
82
                buf = buf.trim();
83
                for (int i=0; i<buf.length(); i++) {
84
                        char c = buf.charAt(i); 
85
                        if (Character.isWhitespace(c)) {
86
                                if (lastCharWhite) continue;
87
                                lastCharWhite = true;
88
                                c = ' ';
89
                        } else
90
                                lastCharWhite = false;
91
                        str += c;
92
                }        
93
                return str;
94
        }
95
        
96
        protected long getTime() {
97
                return (new Date()).getTime();
98
        }
99
}