svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / GeoFile.java @ 9
History | View | Annotate | Download (1.43 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.geo.Projected; |
11 |
import org.cresques.geo.Projection; |
12 |
import org.cresques.geo.ReProjection; |
13 |
|
14 |
import org.cresques.px.Extent; |
15 |
import org.cresques.px.IExtent; |
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, IExtent { |
24 |
Projection proj = null;
|
25 |
protected Extent extent = null; |
26 |
long fileSize = 0; |
27 |
long bytesReaded = 0; |
28 |
long lineCnt = 0; |
29 |
|
30 |
public GeoFile() { }
|
31 |
|
32 |
public GeoFile(Projection proj) {
|
33 |
this.proj = proj;
|
34 |
extent = new Extent();
|
35 |
} |
36 |
|
37 |
public Projection getProjection() { return proj; } |
38 |
public void setProjection(Projection p) { proj = p; } |
39 |
abstract public void reProject(ReProjection rp); |
40 |
|
41 |
public Extent getExtent() { return extent; } |
42 |
abstract public GeoFile load(); |
43 |
|
44 |
/**
|
45 |
* Filtra espacios en blanco. Deja solo uno por
|
46 |
*/
|
47 |
|
48 |
public static String filterWS(String buf) { |
49 |
boolean lastCharWhite = false; |
50 |
String str = ""; |
51 |
buf = buf.trim(); |
52 |
for (int i=0; i<buf.length(); i++) { |
53 |
char c = buf.charAt(i);
|
54 |
if (Character.isWhitespace(c)) { |
55 |
if (lastCharWhite) continue; |
56 |
lastCharWhite = true;
|
57 |
c = ' ';
|
58 |
} else
|
59 |
lastCharWhite = false;
|
60 |
str += c; |
61 |
} |
62 |
return str;
|
63 |
} |
64 |
|
65 |
protected long getTime() { |
66 |
return (new Date()).getTime(); |
67 |
} |
68 |
} |