OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.utility.db_vendors.PostGis_types Class Reference
+ Inheritance diagram for com.mapd.utility.db_vendors.PostGis_types:
+ Collaboration diagram for com.mapd.utility.db_vendors.PostGis_types:

Public Member Functions

boolean isAutoCommitDisabledRequired ()
 
String get_wkt (ResultSet rs, int column_number, String gis_type_name) throws SQLException
 
GisType find_gis_type (Connection conn, ResultSetMetaData metadata, int column_number) throws SQLException
 

Protected Member Functions

 PostGis_types ()
 
- Protected Member Functions inherited from com.mapd.utility.db_vendors.Db_vendor_types
 Db_vendor_types ()
 

Private Member Functions

String wkt_point (PGpoint point)
 
GisType find_type_detail (Connection conn, String ref_table_name, String ref_column_name, String column_name, String table_name) throws SQLException
 

Static Private Attributes

static Hashtable< String, String > extra_types
 

Additional Inherited Members

- Static Public Member Functions inherited from com.mapd.utility.db_vendors.Db_vendor_types
static
com.mapd.utility.db_vendors.Db_vendor_types 
Db_vendor_factory (String connection_str)
 
static String gis_type_to_str (GisType type)
 
- Static Protected Attributes inherited from com.mapd.utility.db_vendors.Db_vendor_types
static HashSet< Integer > valid_srid
 

Detailed Description

Definition at line 117 of file Db_vendor_types.java.

Constructor & Destructor Documentation

com.mapd.utility.db_vendors.PostGis_types.PostGis_types ( )
inlineprotected

Definition at line 118 of file Db_vendor_types.java.

118 {}

Member Function Documentation

GisType com.mapd.utility.db_vendors.PostGis_types.find_gis_type ( Connection  conn,
ResultSetMetaData  metadata,
int  column_number 
) throws SQLException
inlinevirtual

Implements com.mapd.utility.db_vendors.Db_vendor_types.

Definition at line 176 of file Db_vendor_types.java.

References report.conn, com.mapd.utility.db_vendors.PostGis_types.extra_types, com.mapd.utility.db_vendors.PostGis_types.find_type_detail(), and run_benchmark_import.result.

178  {
179  String column_name = metadata.getColumnName(column_number);
180  String table_name = metadata.getTableName(column_number);
181  String column_type_name = metadata.getColumnTypeName(column_number);
182  if (column_type_name.equalsIgnoreCase("geography"))
183  return find_type_detail(
184  conn, "geography_columns", "f_geography_column", column_name, table_name);
185  else if (column_type_name.equalsIgnoreCase("geometry"))
186  return find_type_detail(
187  conn, "geometry_columns", "f_geometry_column", column_name, table_name);
188  if (!extra_types.containsKey(column_type_name))
189  throw new SQLException(
190  "type not supported: " + column_type_name + " for column " + column_name);
191  GisType result = new GisType();
192  result.type = extra_types.get(column_type_name);
193  return result;
194  }
GisType find_type_detail(Connection conn, String ref_table_name, String ref_column_name, String column_name, String table_name)
tuple conn
Definition: report.py:41
static Hashtable< String, String > extra_types

+ Here is the call graph for this function:

GisType com.mapd.utility.db_vendors.PostGis_types.find_type_detail ( Connection  conn,
String  ref_table_name,
String  ref_column_name,
String  column_name,
String  table_name 
) throws SQLException
inlineprivate

Definition at line 196 of file Db_vendor_types.java.

References com.mapd.utility.db_vendors.PostGis_types.extra_types, run_benchmark_import.result, and run_benchmark_import.type.

Referenced by com.mapd.utility.db_vendors.PostGis_types.find_gis_type().

200  {
201  Statement detail_st = conn.createStatement();
202  // Select for a specific column name from the ref table.
203  String select = "select type, srid from " + ref_table_name + " where "
204  + ref_column_name + " = '" + column_name + "'";
205  if (table_name.length() > 0) {
206  select += " and f_table_name"
207  + " = '" + table_name + "'";
208  }
209  ResultSet rs = detail_st.executeQuery(select);
210  GisType result = new GisType();
211  result.subtype = "GEOMETRY";
212  result.type = null;
213  result.srid = 0;
214  // The select statment above, can return multiple values qualified by schema/table
215  // If an outdated driver is used, the utility jar is positioned befor the driver in
216  // the classpath or for whatever reason the table_name isn't returned by the driver
217  while (rs.next()) {
218  String type = rs.getString(1);
219  int srid = rs.getInt(2);
220  if (result.type == null) {
221  result.type = type;
222  result.srid = srid;
223  } else {
224  if (!result.type.equalsIgnoreCase(type) || srid != result.srid) {
225  throw new SQLException("multiple column definitions [" + result.type + ":"
226  + type + "] found for column_name [" + column_name + "].\n"
227  + "You can try to switch the jar positions in the classpath "
228  + "or use a more recent postgreSQL driver.");
229  }
230  }
231  }
232  if (!extra_types.containsKey(result.type.toLowerCase()))
233  throw new SQLException("type not supported");
234  result.type = extra_types.get(result.type.toLowerCase()).toUpperCase();
235  return result;
236  }
static Hashtable< String, String > extra_types

+ Here is the caller graph for this function:

String com.mapd.utility.db_vendors.PostGis_types.get_wkt ( ResultSet  rs,
int  column_number,
String  gis_type_name 
) throws SQLException
inlinevirtual

Implements com.mapd.utility.db_vendors.Db_vendor_types.

Definition at line 137 of file Db_vendor_types.java.

References Fragmenter_Namespace.indexOf(), substring(), and com.mapd.utility.db_vendors.PostGis_types.wkt_point().

138  {
139  if (gis_type_name.equalsIgnoreCase("geometry")
140  || gis_type_name.equalsIgnoreCase("geography")) {
141  Object gis_object = rs.getObject(column_number);
142  PGgeometry pGeometry = (PGgeometry) gis_object;
143  if (pGeometry == null) throw new SQLException("unknown type");
144  // Try and trim the front SRID=nnnn; value from the string returned from the db.
145  // If there isn't a SRID=nnnn; string (marked by the ';') then simply
146  // return the whole string
147  int semi_colon_indx = pGeometry.getValue().indexOf(';');
148  if (-1 != semi_colon_indx && semi_colon_indx < pGeometry.getValue().length()) {
149  return pGeometry.getValue().substring(semi_colon_indx + 1);
150  }
151  return pGeometry.getValue();
152  }
153  StringBuffer WKT_string = new StringBuffer();
154  if (gis_type_name.equalsIgnoreCase("point")) {
155  PGpoint point = (PGpoint) rs.getObject(column_number);
156  WKT_string.append(extra_types.get(gis_type_name) + "(" + wkt_point(point) + ")");
157 
158  } else if (gis_type_name.equalsIgnoreCase("polygon")) {
159  PGpolygon polygon = (PGpolygon) rs.getObject(column_number);
160  WKT_string.append(extra_types.get(gis_type_name) + "((");
161  for (PGpoint p : polygon.points) {
162  WKT_string.append(wkt_point(p) + ",");
163  }
164  WKT_string.replace(WKT_string.length() - 1, WKT_string.length(), "))");
165  } else if (gis_type_name.equalsIgnoreCase("lseg")) {
166  PGlseg lseg = (PGlseg) rs.getObject(column_number);
167  WKT_string.append(extra_types.get(gis_type_name) + "(");
168  for (PGpoint p : lseg.point) {
169  WKT_string.append(wkt_point(p) + ",");
170  }
171  WKT_string.replace(WKT_string.length() - 1, WKT_string.length(), ")");
172  }
173  return WKT_string.toString();
174  }
String wkt_point(PGpoint point)
size_t indexOf(std::vector< T > &vec, T val)
std::pair< std::string_view, const char * > substring(const std::string &str, size_t substr_length)
return substring of str with postfix if str.size() &gt; substr_length

+ Here is the call graph for this function:

boolean com.mapd.utility.db_vendors.PostGis_types.isAutoCommitDisabledRequired ( )
inlinevirtual

Implements com.mapd.utility.db_vendors.Db_vendor_types.

Definition at line 119 of file Db_vendor_types.java.

119  {
120  return true;
121  }
String com.mapd.utility.db_vendors.PostGis_types.wkt_point ( PGpoint  point)
inlineprivate

Definition at line 133 of file Db_vendor_types.java.

Referenced by com.mapd.utility.db_vendors.PostGis_types.get_wkt().

133  {
134  return new String("" + point.x + " " + point.y);
135  }

+ Here is the caller graph for this function:

Member Data Documentation

Hashtable<String, String> com.mapd.utility.db_vendors.PostGis_types.extra_types
staticprivate
Initial value:
= new Hashtable() {
{
put("point", "POINT");
put("lseg", "linestring");
put("linestring", "linestring");
put("polygon", "polygon");
put("multipolygon", "multipolygon");
}
}

Definition at line 124 of file Db_vendor_types.java.

Referenced by com.mapd.utility.db_vendors.PostGis_types.find_gis_type(), and com.mapd.utility.db_vendors.PostGis_types.find_type_detail().


The documentation for this class was generated from the following file: