Revision 22290
trunk/libraries/lib3DMap/src/org/gvsig/gvsig3d/drivers/OSGDriver.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.drivers; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URI; |
|
5 |
|
|
6 |
import org.gvsig.gpe.osg.OSGParser; |
|
7 |
import org.gvsig.gpe.parser.IGPEContentHandler; |
|
8 |
|
|
9 |
import com.hardcode.gdbms.driver.exceptions.CloseDriverException; |
|
10 |
import com.hardcode.gdbms.driver.exceptions.OpenDriverException; |
|
11 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
12 |
import com.hardcode.gdbms.driver.exceptions.WriteDriverException; |
|
13 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
|
14 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
15 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
|
16 |
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver; |
|
17 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
|
18 |
|
|
19 |
public class OSGDriver extends MemoryDriver implements VectorialFileDriver{ |
|
20 |
|
|
21 |
private File m_Fich; |
|
22 |
private DriverAttributes attr = new DriverAttributes(); |
|
23 |
private OSGDriver _osgDriver; |
|
24 |
|
|
25 |
|
|
26 |
public String getName() { |
|
27 |
return "gvSIG OSG Driver"; |
|
28 |
} |
|
29 |
|
|
30 |
public int getShapeType() { |
|
31 |
return FShape.MULTI; |
|
32 |
} |
|
33 |
|
|
34 |
public boolean accept(File f) { |
|
35 |
if ((f.getName().toUpperCase().endsWith("OSG")) || |
|
36 |
(f.getName().toUpperCase().endsWith("IVE"))){ |
|
37 |
return true; |
|
38 |
} |
|
39 |
return false; |
|
40 |
} |
|
41 |
|
|
42 |
public void close() throws CloseDriverException { |
|
43 |
// TODO Auto-generated method stub |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
public File getFile() { |
|
48 |
return m_Fich; |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
public void initialize() throws ReadDriverException { |
|
54 |
this.parseStream(); |
|
55 |
// addGeometry(_osgDriver.getRootFeature(),null); |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
public void parseStream() { |
|
61 |
|
|
62 |
_osgDriver = new OSGDriver(); |
|
63 |
OSGParser parser = new OSGParser("OSG", "OSG File Formats Parser"); |
|
64 |
// URI uri = new URI("d:/modelos/coke.ive"); |
|
65 |
|
|
66 |
URI uri = m_Fich.toURI(); |
|
67 |
parser.parse((IGPEContentHandler) _osgDriver, null, uri); |
|
68 |
} |
|
69 |
|
|
70 |
public void open(File f) throws OpenDriverException { |
|
71 |
m_Fich = f; |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
public DriverAttributes getDriverAttributes() { |
|
76 |
return attr; |
|
77 |
} |
|
78 |
|
|
79 |
public boolean isWritable() { |
|
80 |
return m_Fich.canWrite(); |
|
81 |
} |
|
82 |
|
|
83 |
public int[] getPrimaryKeys() throws ReadDriverException { |
|
84 |
return null; |
|
85 |
} |
|
86 |
|
|
87 |
public void write(DataWare arg0) throws WriteDriverException, |
|
88 |
ReadDriverException { |
|
89 |
// TODO Auto-generated method stub |
|
90 |
|
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
} |
trunk/libraries/lib3DMap/src/org/gvsig/gvsig3d/drivers/gvsigDriverOSG.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.drivers; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URI; |
|
5 |
import java.net.URISyntaxException; |
|
6 |
|
|
7 |
import org.gvsig.driver.OSGDriver; |
|
8 |
import org.gvsig.gpe.osg.OSGParser; |
|
9 |
|
|
10 |
import com.hardcode.gdbms.driver.exceptions.CloseDriverException; |
|
11 |
import com.hardcode.gdbms.driver.exceptions.OpenDriverException; |
|
12 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
13 |
import com.hardcode.gdbms.driver.exceptions.WriteDriverException; |
|
14 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
|
15 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
16 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
|
17 |
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver; |
|
18 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
|
19 |
|
|
20 |
public class gvsigDriverOSG extends MemoryDriver implements VectorialFileDriver{ |
|
21 |
|
|
22 |
private File m_Fich; |
|
23 |
private DriverAttributes attr = new DriverAttributes(); |
|
24 |
// private gvsigDriverOSG _osgDriver; |
|
25 |
// private IGPEContentHandler osgDriver; |
|
26 |
private OSGDriver _osgDriver; |
|
27 |
|
|
28 |
|
|
29 |
public String getName() { |
|
30 |
return "gvSIG OSG Driver"; |
|
31 |
} |
|
32 |
|
|
33 |
public int getShapeType() { |
|
34 |
return FShape.MULTI; |
|
35 |
} |
|
36 |
|
|
37 |
public boolean accept(File f) { |
|
38 |
if ((f.getName().toUpperCase().endsWith("OSG")) || |
|
39 |
(f.getName().toUpperCase().endsWith("IVE"))){ |
|
40 |
return true; |
|
41 |
} |
|
42 |
return false; |
|
43 |
} |
|
44 |
|
|
45 |
public void close() throws CloseDriverException { |
|
46 |
// TODO Auto-generated method stub |
|
47 |
|
|
48 |
} |
|
49 |
|
|
50 |
public File getFile() { |
|
51 |
return m_Fich; |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
public void initialize() throws ReadDriverException { |
|
57 |
this.parseStream(); |
|
58 |
// addGeometry(_osgDriver.getRootFeature(),null); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
public void parseStream() { |
|
64 |
|
|
65 |
_osgDriver = new OSGDriver(); |
|
66 |
OSGParser parser = new OSGParser("OSG", "OSG File Formats Parser"); |
|
67 |
URI uri = null; |
|
68 |
try { |
|
69 |
uri = new URI(m_Fich.getAbsolutePath()); |
|
70 |
uri.normalize(); |
|
71 |
} catch (URISyntaxException e) { |
|
72 |
// TODO Auto-generated catch block |
|
73 |
e.printStackTrace(); |
|
74 |
} |
|
75 |
|
|
76 |
// URI uri = m_Fich.toURI(); |
|
77 |
// String cad = |
|
78 |
|
|
79 |
parser.parse(_osgDriver, null, uri); |
|
80 |
} |
|
81 |
|
|
82 |
public void open(File f) throws OpenDriverException { |
|
83 |
m_Fich = f; |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
public DriverAttributes getDriverAttributes() { |
|
88 |
return attr; |
|
89 |
} |
|
90 |
|
|
91 |
public boolean isWritable() { |
|
92 |
return m_Fich.canWrite(); |
|
93 |
} |
|
94 |
|
|
95 |
public int[] getPrimaryKeys() throws ReadDriverException { |
|
96 |
return null; |
|
97 |
} |
|
98 |
|
|
99 |
public void write(DataWare arg0) throws WriteDriverException, |
|
100 |
ReadDriverException { |
|
101 |
// TODO Auto-generated method stub |
|
102 |
|
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
} |
|
0 | 107 |
Also available in: Unified diff