Statistics
| Revision:

root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / GeoFile.java @ 2669

History | View | Annotate | Download (2.98 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 org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

    
29
import org.cresques.geo.Projected;
30

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

    
34
import java.util.Date;
35

    
36

    
37
/**
38
 * Ancestro de todos los formatos geogr?ficos
39
 *
40
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
41
 */
42
public abstract class GeoFile implements Projected, Extent.Has {
43
    IProjection proj = null;
44
    protected Extent extent = null;
45
    long fileSize = 0;
46
    protected long bytesReaded = 0;
47
    protected long lineCnt = 0;
48
    String name;
49

    
50
    public GeoFile() {
51
    }
52

    
53
    public GeoFile(IProjection p, String n) {
54
        proj = p;
55
        name = n;
56

    
57
        if (name != null) {
58
            name = DataSource.normalize(name);
59
        }
60

    
61
        extent = new Extent();
62
    }
63

    
64
    public String getName() {
65
        return name;
66
    }
67

    
68
    public void setName(String n) {
69
        name = n;
70
    }
71

    
72
    public long getFileSize() {
73
        return fileSize;
74
    }
75

    
76
    public void setFileSize(long sz) {
77
        fileSize = sz;
78
    }
79

    
80
    public IProjection getProjection() {
81
        return proj;
82
    }
83

    
84
    public void setProjection(IProjection p) {
85
        proj = p;
86
    }
87

    
88
    abstract public void reProject(ICoordTrans rp);
89

    
90
    public Extent getExtent() {
91
        return extent;
92
    }
93

    
94
    abstract public GeoFile load();
95

    
96
    abstract public void close();
97

    
98
    abstract public IObjList getObjects();
99

    
100
    /**
101
     * Filtra espacios en blanco. Deja solo uno por
102
     */
103
    public static String filterWS(String buf) {
104
        boolean lastCharWhite = false;
105
        String str = "";
106
        buf = buf.trim();
107

    
108
        for (int i = 0; i < buf.length(); i++) {
109
            char c = buf.charAt(i);
110

    
111
            if (Character.isWhitespace(c)) {
112
                if (lastCharWhite) {
113
                    continue;
114
                }
115

    
116
                lastCharWhite = true;
117
                c = ' ';
118
            } else {
119
                lastCharWhite = false;
120
            }
121

    
122
            str += c;
123
        }
124

    
125
        return str;
126
    }
127

    
128
    protected long getTime() {
129
        return (new Date()).getTime();
130
    }
131
}