Statistics
| Revision:

svn-gvsig-desktop / tags / Root_CqCMSGisPlanet / libraries / libCq CMS for java.old / src / org / cresques / io / GeoFile.java @ 1933

History | View | Annotate | Download (1.8 KB)

1
/*
2
 * Created on 30-abr-2004
3
 *
4
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
5
 */
6
package org.cresques.io;
7

    
8
import java.util.Date;
9

    
10
import org.cresques.cts.ICoordTrans;
11
import org.cresques.cts.IProjection;
12
import org.cresques.geo.Projected;
13

    
14
import org.cresques.px.Extent;
15
import org.cresques.px.IObjList;
16

    
17
/**
18
 * Ancestro de todos los formatos geogr?ficos
19
 * 
20
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
21
 */
22

    
23
public abstract class GeoFile implements Projected, Extent.Has {
24
        IProjection proj = null;
25
        protected Extent extent = null;
26
        long fileSize = 0;
27
        protected long bytesReaded = 0;
28
        protected long lineCnt = 0;
29
        String name;
30
        
31
        public GeoFile() {        }
32

    
33
        public GeoFile(IProjection p, String n) {
34
                proj = p;
35
                name = n;
36
                if (name != null)
37
                        name = DataSource.normalize(name);
38
                extent = new Extent();
39
        }
40
        
41
        public String getName() { return name; }
42
        public void setName(String n) { name = n; }
43
        
44
        public long getFileSize() { return fileSize; }
45
        public void setFileSize(long sz) { fileSize = sz; }
46

    
47
        public IProjection getProjection() { return proj; }
48
        public void setProjection(IProjection p) { proj = p; }
49
        abstract public void reProject(ICoordTrans rp);
50
        
51
        public Extent getExtent() { return extent; }
52
        abstract public GeoFile load();
53
        abstract public void close();
54
        
55
        abstract public IObjList getObjects();
56
        
57
        /**
58
         * Filtra espacios en blanco. Deja solo uno por 
59
         */
60
        
61
        public static String filterWS(String buf) {
62
                boolean lastCharWhite = false;
63
                String str = "";
64
                buf = buf.trim();
65
                for (int i=0; i<buf.length(); i++) {
66
                        char c = buf.charAt(i); 
67
                        if (Character.isWhitespace(c)) {
68
                                if (lastCharWhite) continue;
69
                                lastCharWhite = true;
70
                                c = ' ';
71
                        } else
72
                                lastCharWhite = false;
73
                        str += c;
74
                }        
75
                return str;
76
        }
77
        
78
        protected long getTime() {
79
                return (new Date()).getTime();
80
        }
81
}