forked from geodmms/xdgnjobs

?? ?
2008-04-09 dbfea79a63f7e3357901ae55cb4e69034629e5f0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package com.ximple.io.dgn7;
 
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
 
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
 
import com.vividsolutions.jts.geom.Coordinate;
import com.ximple.util.PrintfFormat;
import oracle.jdbc.OracleConnection;
 
/**
 * Dgn7OracleReaderTest
 * User: Ulysses
 * Date: 2007/10/24
 * Time: 上午 10:49:54
 */
public class Dgn7OracleReaderTest
{
    @BeforeTest
    public void setUp()
    {
 
    }
 
    @Test
    public void testOracleReader() throws SQLException, IOException
    {
        OracleConnection connection = OracleTarget.getInstance().getOracleConnection();
        // String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" ORDER BY ROWID";
        String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" WHERE TAG_SFSC=106 ORDER BY ROWID";
        PrintfFormat spf = new PrintfFormat(fetchSrcStmtFmt);
        String srcschema = "SPATIALDB";
        String srctable = "IGSET_1";
        String fetchSrcStmt = spf.sprintf(new Object[]{srcschema, srctable});
 
        Dgn7OracleReader reader = new Dgn7OracleReader(fetchSrcStmt, "IGDSELM", connection);
        int count = 0;
        while (reader.hasNext())
        {
            Element element = reader.next();
 
            if (element instanceof ComplexChainElement)
            {
                ComplexChainElement complexChain = (ComplexChainElement) element;
                FrammeAttributeData frammeLinkage = null;
 
                List<UserAttributeData> attrs = complexChain.getUserAttributeData();
                for (int k = 0; k < attrs.size(); k++)
                {
                    UserAttributeData userAttr = attrs.get(k);
                    if (userAttr instanceof FrammeAttributeData)
                    {
                        frammeLinkage = (FrammeAttributeData) userAttr;
                        break;
                    }
                }
 
                System.out.print("complexChain:");
                if (frammeLinkage != null)
                    System.out.print(":FSC-" + frammeLinkage.getFsc() +
                                       ":UFID-" + frammeLinkage.getUfid() +
                                       ":COMP-" + frammeLinkage.getComponentID());
                else
                    System.out.print("Linkage is null");
 
                for (int i = 0; i < complexChain.size(); i++)
                {
                    Element elm = (Element) complexChain.get(i);
                    if (elm instanceof LineStringElement)
                    {
                        LineStringElement lineStringElement = (LineStringElement) elm;
                        int size = lineStringElement.getVerticeSize();
                        System.out.print("size=" + size + ":");
                        Coordinate[] coords = lineStringElement.getVertices();
                        for (int j = 0; j < coords.length; j++)
                            System.out.print("[" + j + "]" + coords[j].toString());
                    }
                }
 
                System.out.println();
            } else if (element instanceof TextNodeElement)
            {
                TextNodeElement textNode = (TextNodeElement) element;
 
                FrammeAttributeData frammeLinkage = null;
 
                List<UserAttributeData> attrs = textNode.getUserAttributeData();
                for (int k = 0; k < attrs.size(); k++)
                {
                    UserAttributeData userAttr = attrs.get(k);
                    if (userAttr instanceof FrammeAttributeData)
                    {
                        frammeLinkage = (FrammeAttributeData) userAttr;
                        break;
                    }
                }
 
                Coordinate coord = textNode.getOrigin();
                System.out.print("TextNode:origin=" + coord.toString());
                if (frammeLinkage != null)
                    System.out.print(":FSC-" + frammeLinkage.getFsc() +
                                       ":UFID-" + frammeLinkage.getUfid() +
                                       ":COMP-" + frammeLinkage.getComponentID());
                else
                    System.out.print("Linkage is null");
                for (int i = 0; i < textNode.size(); i++)
                {
                    Element elm = (Element) textNode.get(i);
                    if (elm instanceof TextElement)
                    {
                        TextElement textElm = (TextElement) elm;
                        System.out.print("---");
                        String text = textElm.getText();
                        System.out.print("'" + text + "'");
                    }
                }
                System.out.println();
            }
        }
    }
 
}