Skip to content

Commit

Permalink
[Oracle][Tests] Enhance Point convertion test
Browse files Browse the repository at this point in the history
Instead of using 'SDO_UTIL.FROM_WKTGEOMETRY' to generate `SDO_GEOMETRY` object
for Point, the `testdata` generate Point and MultiPoint with `SDO_POINT_TYPE`
or `SDO_ELEM_INFO_ARRAY` and `SDO_ORDINATE_ARRAY`.

With this way of creating Point and MultiPoint, we can test the way Point and
MultiPoint are converting to WKB.

(cherry-picked from 4bc315e)
  • Loading branch information
rldhont authored and nyalldawson committed May 24, 2018
1 parent b35696f commit 8f9c1d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions tests/src/python/test_provider_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def setUpClass(cls):

cls.conn = QSqlDatabase.addDatabase('QOCISPATIAL', "oracletest")
cls.conn.setDatabaseName('10.0.0.2/orcl')
if 'QGIS_ORACLETEST_DBNAME' in os.environ:
cls.conn.setDatabaseName('QGIS_ORACLETEST_DBNAME')
cls.conn.setUserName('QGIS')
cls.conn.setPassword('qgis')
assert cls.conn.open()
Expand Down Expand Up @@ -151,6 +153,10 @@ def testPoints(self):
self.assertEqual(features[1].geometry().exportToWkt(), 'PointZ (1 2 3)')
self.assertEqual(features[2].geometry().exportToWkt(), 'MultiPointZ ((1 2 3),(4 5 6))')
self.assertEqual(features[3].geometry().exportToWkt(), 'MultiPoint ((1 2),(3 4))')
self.assertEqual(features[4].geometry().exportToWkt(), 'MultiPointZ ((1 2 3),(4 5 6))')
self.assertEqual(features[5].geometry().exportToWkt(), 'Point (1 2)')
self.assertEqual(features[6].geometry().exportToWkt(), 'Point (3 4)')
self.assertEqual(features[7].geometry().exportToWkt(), 'Point (5 6)')

def testCurves(self):
vl = QgsVectorLayer('%s table="QGIS"."LINE_DATA" (GEOM) srid=4326 type=LINESTRING sql=' %
Expand Down
22 changes: 13 additions & 9 deletions tests/testdata/provider/testdata_oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ INSERT INTO QGIS.SOME_POLY_DATA ("pk", GEOM)
UNION ALL SELECT 3, SDO_GEOMETRY( 2003,4326,NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(-68.4,75.8 , -67.5,72.6 , -68.6,73.7 , -70.2,72.9 , -68.4,75.8)) from dual
UNION ALL SELECT 4, NULL from dual;

INSERT INTO user_sdo_geom_metadata (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES ( 'SOME_POLY_DATA', 'GEOM', sdo_dim_array(sdo_dim_element('X',-80,-55,0.005),sdo_dim_element('Y',65,85,0.005)),4326);

CREATE INDEX some_poly_data_spatial_idx ON QGIS.SOME_POLY_DATA(GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX;


CREATE TABLE QGIS.POINT_DATA ( "pk" INTEGER PRIMARY KEY, GEOM SDO_GEOMETRY);
INSERT INTO QGIS.POINT_DATA ("pk", GEOM)
SELECT 1, SDO_UTIL.FROM_WKTGEOMETRY('POINT(1 2)') from dual
UNION ALL SELECT 2, SDO_UTIL.FROM_WKTGEOMETRY('POINT(1 2 3)') from dual
UNION ALL SELECT 3, SDO_UTIL.FROM_WKTGEOMETRY('MULTIPOINT(1 2 3, 4 5 6)') from dual
UNION ALL SELECT 4, SDO_UTIL.FROM_WKTGEOMETRY('MULTIPOINT(1 2, 3 4)') from dual;
SELECT 1, SDO_GEOMETRY( 2001,4326,SDO_POINT_TYPE(1, 2, NULL), NULL, NULL) from dual
UNION ALL SELECT 2, SDO_GEOMETRY( 3001,4326,SDO_POINT_TYPE(1, 2, 3), NULL, NULL) from dual
UNION ALL SELECT 3, SDO_GEOMETRY( 3005,4326,NULL, sdo_elem_info_array (1,1,1, 4,1,1), sdo_ordinate_array (1,2,3, 4,5,6)) from dual
UNION ALL SELECT 4, SDO_GEOMETRY( 2005,4326,NULL, sdo_elem_info_array (1,1,1, 3,1,1), sdo_ordinate_array (1,2, 3,4)) from dual
UNION ALL SELECT 5, SDO_GEOMETRY( 3005,4326,NULL, sdo_elem_info_array (1,1,2), sdo_ordinate_array (1,2,3, 4,5,6)) from dual
UNION ALL SELECT 6, SDO_GEOMETRY( 2001,4326,NULL, sdo_elem_info_array (1,1,1), sdo_ordinate_array (1,2)) from dual
UNION ALL SELECT 7, SDO_GEOMETRY( 2001,4326, SDO_POINT_TYPE(3, 4, NULL), NULL, NULL) from dual
UNION ALL SELECT 8, SDO_GEOMETRY( 2001,4326,NULL, sdo_elem_info_array (1,1,1), sdo_ordinate_array (5,6)) from dual;

CREATE TABLE QGIS.LINE_DATA ( "pk" INTEGER PRIMARY KEY, GEOM SDO_GEOMETRY);
INSERT INTO QGIS.LINE_DATA ("pk", GEOM)
Expand All @@ -43,11 +52,6 @@ INSERT INTO QGIS.POLY_DATA ("pk", GEOM)
UNION ALL SELECT 7, SDO_UTIL.FROM_WKTGEOMETRY('MULTIPOLYGON (((1.0 2.0, 11.0 2.0, 11.0 22.0, 1.0 22.0, 1.0 2.0)),((1.0 2.0, 11.0 2.0, 11.0 22.0, 1.0 22.0, 1.0 2.0),(5.0 6.0, 8.0 9.0, 8.0 6.0, 5.0 6.0),(3.0 4.0, 5.0 6.0, 3.0 6.0, 3.0 4.0)))') from dual
UNION ALL SELECT 8, SDO_UTIL.FROM_WKTGEOMETRY('MULTIPOLYGON (((1.0 2.0 3.0, 11.0 2.0 13.0, 11.0 22.0 15.0, 1.0 22.0 7.0, 1.0 2.0 3.0)),((1.0 2.0 3.0, 11.0 2.0 13.0, 11.0 22.0 15.0, 1.0 22.0 7.0, 1.0 2.0 3.0),(5.0 6.0 1.0, 8.0 9.0 -1.0, 8.0 6.0 2.0, 5.0 6.0 1.0)))') from dual

INSERT INTO user_sdo_geom_metadata (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES ( 'SOME_POLY_DATA', 'GEOM', sdo_dim_array(sdo_dim_element('X',-80,-55,0.005),sdo_dim_element('Y',65,85,0.005)),4326);

CREATE INDEX some_poly_data_spatial_idx ON QGIS.SOME_POLY_DATA(GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX;


CREATE TABLE QGIS.DATE_TIMES ( "id" INTEGER PRIMARY KEY, "date_field" DATE, "datetime_field" TIMESTAMP );

INSERT INTO QGIS.DATE_TIMES ("id", "date_field", "datetime_field" ) VALUES (1, DATE '2004-03-04', TIMESTAMP '2004-03-04 13:41:52' );
Expand Down

0 comments on commit 8f9c1d4

Please sign in to comment.