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

View differences:

GeoFile.java
1 1
/*
2 2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
5 3
 *
4
 * Copyright (C) 2004-5.
5
 *
6 6
 * This program is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU General Public License
8 8
 * as published by the Free Software Foundation; either version 2
......
18 18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19 19
 *
20 20
 * For more information, contact:
21
 * 
21
 *
22 22
 * cresques@gmail.com
23 23
 */
24 24
package org.cresques.io;
25 25

  
26
import java.util.Date;
27

  
28 26
import org.cresques.cts.ICoordTrans;
29 27
import org.cresques.cts.IProjection;
28

  
30 29
import org.cresques.geo.Projected;
31 30

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

  
34
import java.util.Date;
35

  
36

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

  
41 42
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() {	}
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;
50 49

  
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; }
50
    public GeoFile() {
51
    }
64 52

  
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
	}
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
    }
99 131
}

Also available in: Unified diff