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.
  • Loading branch information
rldhont authored and nyalldawson committed May 5, 2018
1 parent 684b367 commit a11db8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 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 @@ -188,6 +190,10 @@ def testPoints(self):
self.assertEqual(features[1].geometry().asWkt(), 'PointZ (1 2 3)')
self.assertEqual(features[2].geometry().asWkt(), 'MultiPointZ ((1 2 3),(4 5 6))')
self.assertEqual(features[3].geometry().asWkt(), 'MultiPoint ((1 2),(3 4))')
self.assertEqual(features[4].geometry().asWkt(), 'MultiPointZ ((1 2 3),(4 5 6))')
self.assertEqual(features[5].geometry().asWkt(), 'Point (1 2)')
self.assertEqual(features[6].geometry().asWkt(), 'Point (3 4)')
self.assertEqual(features[7].geometry().asWkt(), 'Point (5 6)')

def testCurves(self):
vl = QgsVectorLayer('%s table="QGIS"."LINE_DATA" (GEOM) srid=4326 type=LINESTRING sql=' %
Expand Down
23 changes: 13 additions & 10 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 Down Expand Up @@ -52,12 +61,6 @@ INSERT INTO QGIS.POLY_DATA ("pk", GEOM)
UNION ALL SELECT 11, SDO_UTIL.FROM_WKTGEOMETRY('CurvePolygon(CompoundCurve ((-1 -5, 1 2),CircularString (1 2, 5 4, 7 2.20, 10 0.1, 13 4),(13 4, 17 -6),CircularString (17 -6, 5 -7, -1 -5)))') from dual
UNION ALL SELECT 12, SDO_UTIL.FROM_WKTGEOMETRY('MultiSurface (CURVEPOLYGON(CIRCULARSTRING(1 3, 3 5, 4 7, 7 3, 1 3)), CURVEPOLYGON(CIRCULARSTRING(11 3, 13 5, 14 7, 17 3, 11 3)))') 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 a11db8b

Please sign in to comment.