1 /*
2 * WKB4J - WKB reader for geographical mapping toolkits
3 * (C) 2002,2003, David Garnier, dgarnier@users.sourceforge.net
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation,
8 * version 2.1 of the License.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * or visit the web to http://www.gnu.org.
19 *
20 */
21 package org.wkb4j.openmap;
22
23 import java.sql.Connection;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import org.apache.log4j.Logger;
28 import org.wkb4j.engine.AbstractWKBGetter;
29 import org.wkb4j.jts.JTSFactory;
30
31 import com.bbn.openmap.omGraphics.OMGraphicList;
32
33 /***
34 * Retrieves PostGIS geometries from the specified database Connectiion and return them in a List.
35 * This is the simplest interface offered by WKB4J. If it does not match your needs, you will
36 * need to handle the WKBParser, WKBReader and WKBFactory yourself.
37 * <code>org.wkb4j.examples.SampleCode</code> is provided as an example.
38 *
39 */
40
41 public class OpenMapGetter extends AbstractWKBGetter {
42 protected static Logger log = Logger.getLogger(OpenMapGetter.class);
43
44 public OpenMapGetter() {
45 super(new OpenMapFactory());
46 }
47
48 public OMGraphicList getOMGraphicList(
49 Connection dbConn,
50 String geocolumn,
51 String table,
52 String whereClause) {
53 reader.readDataWithWhereClause(
54 dbConn,
55 geocolumn,
56 table,
57 whereClause,
58 parser);
59 return ((OpenMapFactory) factory).getGeometries();
60 }
61
62 public OMGraphicList getOMGraphicList(Connection dbConn, String sqlQuery) {
63 reader.readData(dbConn, sqlQuery, parser);
64 return ((OpenMapFactory) factory).getGeometries();
65 }
66
67 public List getData(
68 Connection dbConn,
69 String table,
70 String geocolumn,
71 String whereClause) {
72 OMGraphicList graphicList =
73 getOMGraphicList(dbConn, geocolumn, table, whereClause);
74 ArrayList retval = new ArrayList(graphicList.size());
75 for (int i = 0, size = graphicList.size(); i < size; i++) {
76 retval.add(graphicList.getOMGraphicAt(i));
77 }
78
79 return retval;
80 }
81
82 public List getData(Connection dbConn, String sqlQuery) {
83 OMGraphicList graphicList = getOMGraphicList(dbConn, sqlQuery);
84 ArrayList retval = new ArrayList(graphicList.size());
85 for (int i = 0, size = graphicList.size(); i < size; i++) {
86 retval.add(graphicList.getOMGraphicAt(i));
87 }
88
89 return retval;
90 }
91 }
This page was automatically generated by Maven