Debian Codegraph @

mysql-test/suite/gis/t/wkb.test

raw
1 # This test tests the GIS functions that take as arguments a BLOB containing
2 # a Well-Known Binary (WKB) representation and optionally, a spatial reference
3 # system identifier (SRID). They return the corresponding geometry.
4 #
5 # Creation Date : 2016-03-16
6 # Author : Pavan Naik
7 #
8
9 ##################################################################################
10 #
11 #
12 ##################################################################################
13
14 SET @wkb_pt = ST_AsWKB(ST_GeomFromText('POINT(0 1)'));
15 SET @wkb_ln = ST_AsWKB(ST_GeomFromText('LINESTRING(0 1,2 3,4 5,6 7,8 9, 10 11)'));
16 SET @wkb_py = ST_AsWKB(ST_GeomFromText('POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))'));
17 SET @wkb_mpt = ST_AsWKB(ST_GeomFromText('MULTIPOINT(0 1,2 3,4 5,6 7)'));
18 SET @wkb_mln = ST_AsWKB(ST_GeomFromText('MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))'));
19 SET @wkb_mpy = ST_AsWKB(ST_GeomFromText('MULTIPOLYGON(((0 1,0 10,10 11,10 0,0 1),(4 5,4 6,6 7,6 4,4 5)),'
20 '((10 11,10 12,12 13,12 10,10 11)))'));
21 SET @wkb_gc = ST_AsWKB(ST_GeomFromText('GEOMETRYCOLLECTION('
22 'POINT(0 1),'
23 'LINESTRING(0 1,10 11),'
24 'POLYGON((0 0,0 10,10 10,10 0, 0 0)),'
25 'MULTIPOINT(0 1,2 3,4 5,6 7,8 9,10 11),'
26 'MULTILINESTRING((0 1,10 11),(0 10,10 0)),'
27 'MULTIPOLYGON(((0 1,0 5,5 6,5 0,0 1)),((5 4,5 10,10 11,10 5,5 4))))'));
28
29 --echo #
30 --echo # Functions that accept a WKT value of any geometry type.
31 --echo #
32
33 --echo # ST_GeomFromWKB()
34 SELECT ST_AsText(ST_GeomFromWKB(@wkb_pt));
35 SELECT ST_AsText(ST_GeomFromWKB(@wkb_ln));
36 SELECT ST_AsText(ST_GeomFromWKB(@wkb_py));
37 SELECT ST_AsText(ST_GeomFromWKB(@wkb_mpt));
38 SELECT ST_AsText(ST_GeomFromWKB(@wkb_mln));
39 SELECT ST_AsText(ST_GeomFromWKB(@wkb_mpy));
40 SELECT ST_AsText(ST_GeomFromWKB(@wkb_gc));
41
42 --echo # ST_GeometryFromWKB()
43 SELECT ST_AsText(ST_GeometryFromWKB(@wkb_pt));
44 SELECT ST_AsText(ST_GeometryFromWKB(@wkb_ln));
45 SELECT ST_AsText(ST_GeometryFromWKB(@wkb_py));
46 SELECT ST_AsText(ST_GeometryFromWKB(@wkb_mpt));
47 SELECT ST_AsText(ST_GeometryFromWKB(@wkb_mln));
48 SELECT ST_AsText(ST_GeometryFromWKB(@wkb_mpy));
49 SELECT ST_AsText(ST_GeometryFromWKB(@wkb_gc));
50
51 --echo #
52 --echo # Function that accepts a WKT value of Point geometry
53 --echo #
54
55 --echo # ST_PointFromWKB()
56 SELECT ST_AsText(ST_PointFromWKB(@wkb_pt));
57
58 --echo #
59 --echo # Functions that accept a WKT value of LineString geometry
60 --echo #
61
62 --echo # ST_LineFromWKB()
63 SELECT ST_AsText(ST_LineFromWKB(@wkb_ln));
64
65 --echo # ST_LineStringFromWKB()
66 SELECT ST_AsText(ST_LineStringFromWKB(@wkb_ln));
67
68 --echo #
69 --echo # Functions that accept a WKT value of Polygon geometry
70 --echo #
71
72 --echo # ST_PolyFromWKB()
73 SELECT ST_AsText(ST_PolyFromWKB(@wkb_py));
74
75 --echo # ST_PolygonFromWKB()
76 SELECT ST_AsText(ST_PolygonFromWKB(@wkb_py));
77
78 --echo #
79 --echo # Functions that accept a WKT value of MultiPoint geometry
80 --echo #
81
82 --echo # ST_MPointFromWKB()
83 SELECT ST_AsText(ST_MPointFromWKB(@wkb_mpt));
84
85 --echo # ST_MultiPointFromWKB()
86 SELECT ST_AsText(ST_MultiPointFromWKB(@wkb_mpt));
87
88 --echo #
89 --echo # Functions that accept a WKT value of MultiLineString geometry
90 --echo #
91
92 --echo # ST_MLineFromWKB()
93 SELECT ST_AsText(ST_MLineFromWKB(@wkb_mln));
94
95 --echo # ST_MultiLineStringFromWKB()
96 SELECT ST_AsText(ST_MultiLineStringFromWKB(@wkb_mln));
97
98 --echo #
99 --echo # Functions that accept a WKT value of MultiPolygon geometry
100 --echo #
101
102 --echo # ST_MPolyFromWKB()
103 SELECT ST_AsText(ST_MPolyFromWKB(@wkb_mpy));
104
105 --echo # ST_MultiPolygonFromWKB()
106 SELECT ST_AsText(ST_MultiPolygonFromWKB(@wkb_mpy));
107
108 --echo #
109 --echo # Functions that accept a WKT value of GeometryCollection geometry
110 --echo #
111
112 --echo # ST_GeomCollFromWKB()
113 SELECT ST_AsText(ST_GeomCollFromWKB(@wkb_gc));
114
115 --echo # ST_GeometryCollectionFromWKB()
116 SELECT ST_AsText(ST_GeometryCollectionFromWKB(@wkb_gc));
117
118 --echo #
119 --echo # Invalid function calls
120 --echo #
121
122 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
123 SELECT ST_GeomFromWKB();
124
125 SELECT ST_GeomFromWKB(NULL);
126
127 --error ER_GIS_INVALID_DATA
128 SELECT ST_GeomFromWKB(ST_GeomFromText('POINT()'));
129
130 --error ER_GIS_INVALID_DATA
131 SELECT ST_GeomFromWKB(ST_GeomFromText('LINESTRING(0 0,! 10)'));
132
133 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
134 SELECT ST_GeometryFromWKB();
135
136 SELECT ST_GeometryFromWKB(NULL);
137
138 --error ER_GIS_INVALID_DATA
139 SELECT ST_GeometryFromWKB(ST_GeomFromText('POINT(! 0)'));
140
141 --error ER_GIS_INVALID_DATA
142 SELECT ST_GeometryFromWKB(ST_GeomFromText('POLYGON((0 0,0 10,10 10,10 0,0 0)'));
143
144 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
145 SELECT ST_PointFromWKB();
146
147 SELECT ST_PointFromWKB(NULL);
148
149 --error ER_GIS_INVALID_DATA
150 SELECT ST_PointFromWKB(ST_GeomFromText('POINT()'));
151
152 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
153 SELECT ST_LineFromWKB();
154
155 SELECT ST_LineFromWKB(NULL);
156
157 --error ER_GIS_INVALID_DATA
158 SELECT ST_LineFromWKB(ST_GeomFromText('LINESTRING(a a,b b)'));
159
160 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
161 SELECT ST_LineStringFromWKB();
162
163 SELECT ST_LineStringFromWKB(NULL);
164
165 --error ER_GIS_INVALID_DATA
166 SELECT ST_LineStringFromWKB(ST_GeomFromText('LINESTRING(1 1,1 b)'));
167
168 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
169 SELECT ST_PolyFromWKB();
170
171 SELECT ST_PolyFromWKB(NULL);
172
173 --error ER_GIS_INVALID_DATA
174 SELECT ST_PolyFromWKB(ST_GeomFromText('POLYGON(())'));
175
176 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
177 SELECT ST_PolygonFromWKB();
178
179 SELECT ST_PolygonFromWKB(NULL);
180
181 --error ER_GIS_INVALID_DATA
182 SELECT ST_PolygonFromWKB(ST_GeomFromText('POLYGON((0 0,0 5,5 5,5 0,0 0),())'));
183
184 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
185 SELECT ST_MPointFromWKB();
186
187 SELECT ST_MPointFromWKB(NULL);
188
189 --error ER_GIS_INVALID_DATA
190 SELECT ST_MPointFromWKB(ST_GeomFromText('MULTIPOINT(0 0,1)'));
191
192 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
193 SELECT ST_MultiPointFromWKB();
194
195 SELECT ST_MultiPointFromWKB(NULL);
196
197 --error ER_GIS_INVALID_DATA
198 SELECT ST_MultiPointFromWKB(ST_GeomFromText('MULTIPOINT(0 0,1 1 1)'));
199
200 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
201 SELECT ST_MLineFromWKB();
202
203 SELECT ST_MLineFromWKB(NULL);
204
205 --error ER_GIS_INVALID_DATA
206 SELECT ST_MLineFromWKB(ST_GeomFromText('MULTILINESTRING((0 0,1),())'));
207
208 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
209 SELECT ST_MultiLineStringFromWKB();
210
211 SELECT ST_MultiLineStringFromWKB(NULL);
212
213 --error ER_GIS_INVALID_DATA
214 SELECT ST_MultiLineStringFromWKB(ST_GeomFromText('MULTILINESTRING((0 0,1),(1 1,2 2)'));
215
216 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
217 SELECT ST_MPolyFromWKB();
218
219 SELECT ST_MPolyFromWKB(NULL);
220
221 --error ER_GIS_INVALID_DATA
222 SELECT ST_MPolyFromWKB(ST_GeomFromText('MULTIPOLYGON(((0 0,1)),(()))'));
223
224 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
225 SELECT ST_MultiPolygonFromWKB();
226
227 SELECT ST_MultiPolygonFromWKB(NULL);
228
229 --error ER_GIS_INVALID_DATA
230 SELECT ST_MultiPolygonFromWKB(ST_GeomFromText('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),(2 2,2 3,3 3,3 2,2 2))'));
231
232 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
233 SELECT ST_GeomCollFromWKB();
234
235 SELECT ST_GeomCollFromWKB(NULL);
236
237 --error ER_GIS_INVALID_DATA
238 SELECT ST_GeomCollFromWKB(ST_GeomFromText('GEOMETRYCOLLECTION(POINT(a a))'));
239
240 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
241 SELECT ST_GeometryCollectionFromWKB();
242
243 SELECT ST_GeometryCollectionFromWKB(NULL);
244
245 --error ER_GIS_INVALID_DATA
246 SELECT ST_GeometryCollectionFromWKB(ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,1 1)'));
247
248 --echo #
249 --echo # WL#8579 Spatial Reference Systems
250 --echo #
251
252 DELIMITER |;
253 CREATE PROCEDURE gis_wkb_funcs(IN srid INT)
254 BEGIN
255 SET @wkb_pt = ST_AsWKB(ST_GeomFromText('POINT(0 1)'));
256 SET @wkb_ln = ST_AsWKB(ST_GeomFromText('LINESTRING(0 1,2 3,4 5,6 7,8 9, 10 11)'));
257 SET @wkb_py = ST_AsWKB(ST_GeomFromText('POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))'));
258 SET @wkb_mpt = ST_AsWKB(ST_GeomFromText('MULTIPOINT(0 1,2 3,4 5,6 7)'));
259 SET @wkb_mln = ST_AsWKB(ST_GeomFromText('MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))'));
260 SET @wkb_mpy = ST_AsWKB(ST_GeomFromText('MULTIPOLYGON(((0 1,0 10,10 11,10 0,0 1),(4 5,4 6,6 7,6 4,4 5)),'
261 '((10 11,10 12,12 13,12 10,10 11)))'));
262 SET @wkb_gc = ST_AsWKB(ST_GeomFromText('GEOMETRYCOLLECTION('
263 'POINT(0 1),'
264 'LINESTRING(0 1,10 11),'
265 'POLYGON((0 0,0 10,10 10,10 0, 0 0)),'
266 'MULTIPOINT(0 1,2 3,4 5,6 7,8 9,10 11),'
267 'MULTILINESTRING((0 1,10 11),(0 10,10 0)),'
268 'MULTIPOLYGON(((0 1,0 5,5 6,5 0,0 1)),((5 4,5 10,10 11,10 5,5 4))))'));
269
270 # GIS WKB functions
271 DO ST_GeomFromWKB(@wkb_pt, srid);
272 DO ST_GeometryFromWKB(@wkb_pt, srid);
273
274 DO ST_PointFromWKB(@wkb_pt, srid);
275
276 DO ST_LineFromWKB(@wkb_ln, srid);
277 DO ST_LineStringFromWKB(@wkb_ln, srid);
278
279 DO ST_PolyFromWKB(@wkb_py, srid);
280 DO ST_PolygonFromWKB(@wkb_py, srid);
281
282 DO ST_MPointFromWKB(@wkb_mpt, srid);
283 DO ST_MultiPointFromWKB(@wkb_mpt, srid);
284
285 DO ST_MLineFromWKB(@wkb_mln, srid);
286 DO ST_MultiLineStringFromWKB(@wkb_mln, srid);
287
288 DO ST_MPolyFromWKB(@wkb_mpy, srid);
289 DO ST_MultiPolygonFromWKB(@wkb_mpy, srid);
290
291 DO ST_GeomCollFromWKB(@wkb_gc, srid);
292 DO ST_GeometryCollectionFromWKB(@wkb_gc, srid);
293 END |
294 DELIMITER ;|
295
296 --echo # SRID 0 (should pass)
297 CALL gis_wkb_funcs(0);
298
299 --echo # Projected SRS (should pass)
300 CALL gis_wkb_funcs(2000);
301
302 --echo # Geographic SRS (should pass)
303 CALL gis_wkb_funcs(4326);
304
305 --echo # Undefined SRS (should pass)
306 # Assume SRID 19000000 is undefined
307 --error ER_SRS_NOT_FOUND
308 CALL gis_wkb_funcs(19000000);
309
310 --echo ########################################################################
311 --echo # WL 9435 Axis order in WKB parsing functions
312 --echo # ST_GeomFromWKB
313 --echo # ST_GeometryFromWKB
314 --echo # ST_PointFromWKB
315 --echo # ST_LineFromWKB
316 --echo # ST_LineStringFromWKB
317 --echo # ST_PolyFromWKB
318 --echo # ST_PolygonFromWKB
319 --echo # ST_GeomCollFromWKB
320 --echo # ST_GeometryCollectionFromWKB
321 --echo # ST_MPointFromWKB
322 --echo # ST_MultiPointFromWKB
323 --echo # ST_MLineFromWKB
324 --echo # ST_MultiLineStringFromWKB
325 --echo # ST_MPolyFromWKB
326 --echo # ST_MultiPolygonFromWKB
327 --echo ########################################################################
328
329 --echo ########################################################################
330 --echo # Inserting testing SRS values in spatial reference table
331 --echo ########################################################################
332
333 --echo # Inserting geographical srs with long-lat ordering
334 CREATE SPATIAL REFERENCE SYSTEM 31000000 NAME 'TEST31000000' DEFINITION 'GEOGCS["SIRGAS 1995",DATUM["Sistema de Referencia Geocentrico para America del Sur 1995",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6170"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["LONG",EAST],AXIS["LAT",NORTH],AUTHORITY["EPSG","31000000"]]';
335
336 --echo # Inserting geographical srs with lat-long ordering
337 CREATE SPATIAL REFERENCE SYSTEM 31100000 NAME 'TEST31100000' DEFINITION 'GEOGCS["SIRGAS 1995",DATUM["Sistema de Referencia Geocentrico para America del Sur 1995",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6170"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["LAT",NORTH],AXIS["LONG",EAST],AUTHORITY["EPSG","31100000"]]';
338
339 --echo # Inserting projected srs with northing-easting ordering
340 CREATE SPATIAL REFERENCE SYSTEM 31200000 NAME 'TEST31200000' DEFINITION 'PROJCS["NAD83(NSRS2007) / Virginia Lambert",GEOGCS["NAD83(NSRS2007)",DATUM["NAD83 (National Spatial Reference System 2007)",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6759"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4759"]],PROJECTION["Lambert Conic Conformal (2SP)",AUTHORITY["EPSG","9802"]],PARAMETER["Latitude of false origin",36,AUTHORITY["EPSG","8821"]],PARAMETER["Longitude of false origin",-79.5,AUTHORITY["EPSG","8822"]],PARAMETER["Latitude of 1st standard parallel",37,AUTHORITY["EPSG","8823"]],PARAMETER["Latitude of 2nd standard parallel",39.5,AUTHORITY["EPSG","8824"]],PARAMETER["Easting at false origin",0,AUTHORITY["EPSG","8826"]],PARAMETER["Northing at false origin",0,AUTHORITY["EPSG","8827"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",NORTH],AXIS["Y",EAST],AUTHORITY["EPSG","31200000"]]';
341
342 --echo # Inserting projected srs with easting-northing ordering
343 CREATE SPATIAL REFERENCE SYSTEM 31300000 NAME 'TEST31300000' DEFINITION 'PROJCS["NAD83(NSRS2007) / Virginia Lambert",GEOGCS["NAD83(NSRS2007)",DATUM["NAD83 (National Spatial Reference System 2007)",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6759"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4759"]],PROJECTION["Lambert Conic Conformal (2SP)",AUTHORITY["EPSG","9802"]],PARAMETER["Latitude of false origin",36,AUTHORITY["EPSG","8821"]],PARAMETER["Longitude of false origin",-79.5,AUTHORITY["EPSG","8822"]],PARAMETER["Latitude of 1st standard parallel",37,AUTHORITY["EPSG","8823"]],PARAMETER["Latitude of 2nd standard parallel",39.5,AUTHORITY["EPSG","8824"]],PARAMETER["Easting at false origin",0,AUTHORITY["EPSG","8826"]],PARAMETER["Northing at false origin",0,AUTHORITY["EPSG","8827"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","31300000"]]';
344
345 --echo # When the geometry is in a projected spatial reference system,
346 --echo # the coordinates are interpreted as in the order they appear in the geometry.
347
348 --echo ########################################################################
349 --echo # Retrieving geometrycollections with the ST_GEOMFROMWKB function
350 --echo #
351 --echo ########################################################################
352
353 --echo # Retrieve values with long lat ordering.
354 SELECT ST_ASTEXT(ST_GEOMFROMWKB(ST_ASWKB(GEOMETRYCOLLECTION(POINT(3, 5))),
355 31000000, 'axis-order=long-lat'));
356
357 --echo # Retrieve values with lat-long ordering.
358 SELECT ST_ASTEXT(ST_GEOMFROMWKB(ST_ASWKB(GEOMETRYCOLLECTION(POINT(3, 5))),
359 31000000, 'axis-order=lat-long'));
360
361 --echo # Retrieve values with SRID-defined ordering.
362 SELECT ST_ASTEXT(ST_GEOMFROMWKB(ST_ASWKB(GEOMETRYCOLLECTION(POINT(3, 5))),
363 31000000, 'axis-order=srid-defined'));
364
365
366 --echo ########################################################################
367 --echo # Retrieving points with the ST_GEOMETRYFROMWKB function
368 --echo #
369 --echo ########################################################################
370
371 --echo # Retrieve values with long lat ordering.
372 SELECT ST_ASTEXT(ST_GEOMETRYFROMWKB(@wkb_pt,
373 31000000,'axis-order=long-lat'));
374
375 --echo # Retrieve values with lat-long ordering.
376 SELECT ST_ASTEXT(ST_GEOMETRYFROMWKB(@wkb_mpt,
377 31100000,'axis-order=lat-long'));
378
379 --echo # Retrieve values with SRID-defined ordering.
380 SELECT ST_ASTEXT(ST_GEOMETRYFROMWKB(@wkb_mpt,
381 31200000,'axis-order=srid-defined'));
382
383 --echo ########################################################################
384 --echo # Retrieving points with the ST_POINTFROMWKB function
385 --echo ########################################################################
386
387 --echo # Retrieve values with long lat ordering.
388 SELECT ST_ASTEXT(ST_POINTFROMWKB(St_AsWKB(point(1, 2)), 31000000, 'axis-order=long-lat'));
389
390 --echo # Retrieve values with lat-long ordering.
391 SELECT ST_ASTEXT(ST_POINTFROMWKB(St_AsWKB(point(1, 2)), 31000000, 'axis-order=lat-long'));
392
393 --echo # Retrieve values with SRID-defined ordering.
394 SELECT ST_ASTEXT(ST_POINTFROMWKB(St_AsWKB(point(1, 2)),31000000, 'axis-order=srid-defined'));
395 SELECT ST_ASTEXT(ST_POINTFROMWKB(St_AsWKB(point(1, 2)),31300000, 'axis-order=srid-defined'));
396
397 --echo ########################################################################
398 --echo # Retrieving linestrings with the ST_LineFromWKB function
399 --echo ########################################################################
400
401 --echo # Retrieve values with long lat ordering.
402 SELECT ST_ASTEXT(ST_LINEFROMWKB(@wkb_ln, 31000000,
403 'axis-order=long-lat'));
404
405 --echo # Retrieve values with lat-long ordering.
406 SELECT ST_ASTEXT(ST_LINEFROMWKB(@wkb_ln, 31000000,
407 'axis-order=lat-long'));
408
409 --echo # Retrieve values with SRID-defined ordering.
410 SELECT ST_ASTEXT(ST_LINEFROMWKB(@wkb_ln, 31100000,
411 'axis-order=srid-defined'));
412
413 SELECT ST_ASTEXT(ST_LINEFROMWKB(@wkb_ln, 31000000,
414 'axis-order=srid-defined'));
415
416
417 --echo ########################################################################
418 --echo # Retrieving linestrings with the ST_LineStringFromWKB function
419 --echo ########################################################################
420
421 --echo # Retrieve values with long lat ordering.
422 SELECT ST_ASTEXT(ST_LINESTRINGFROMWKB(@wkb_ln, 31000000,
423 'axis-order=long-lat'));
424
425 --echo # Retrieve values with lat-long ordering.
426 SELECT ST_ASTEXT(ST_LINESTRINGFROMWKB(@wkb_ln, 31000000,
427 'axis-order=lat-long'));
428
429 --echo # Retrieve values with SRID-defined ordering.
430 SELECT ST_ASTEXT(ST_LINESTRINGFROMWKB(@wkb_ln, 31100000,
431 'axis-order=srid-defined'));
432 SELECT ST_ASTEXT(ST_LINESTRINGFROMWKB(@wkb_ln, 31000000,
433 'axis-order=srid-defined'));
434
435
436 --echo ########################################################################
437 --echo # Retrieving polygons with the ST_POLYFROMWKB function
438 --echo #
439 --echo ########################################################################
440
441 --echo # Retrieve values with long lat ordering.
442 SELECT ST_ASTEXT(ST_POLYFROMWKB(@wkb_py, 31000000,
443 'axis-order=long-lat'));
444
445 --echo # Retrieve values with lat-long ordering.
446 SELECT ST_ASTEXT(ST_POLYFROMWKB(@wkb_py, 31000000,
447 'axis-order=lat-long'));
448
449 --echo # Retrieve values with SRID-defined ordering.
450 SELECT ST_ASTEXT(ST_POLYFROMWKB(@wkb_py, 31000000,
451 'axis-order=srid-defined'));
452 SELECT ST_ASTEXT(ST_POLYFROMWKB(@wkb_py, 31300000,
453 'axis-order=srid-defined'));
454
455
456 --echo ########################################################################
457 --echo # Retrieving polygons with the ST_POLYGONFROMWKB function
458 --echo #
459 --echo ########################################################################
460
461 --echo # Retrieve values with long lat ordering.
462 SELECT ST_ASTEXT(ST_POLYGONFROMWKB(@wkb_py, 31000000,
463 'axis-order=long-lat'));
464
465 --echo # Retrieve values with lat-long ordering.
466 SELECT ST_ASTEXT(ST_POLYGONFROMWKB(@wkb_py, 31000000,
467 'axis-order=lat-long'));
468
469 --echo # Retrieve values with SRID-defined ordering.
470 SELECT ST_ASTEXT(ST_POLYGONFROMWKB(@wkb_py, 31000000,
471 'axis-order=srid-defined'));
472 SELECT ST_ASTEXT(ST_POLYGONFROMWKB(@wkb_py, 31300000,
473 'axis-order=srid-defined'));
474
475
476 --echo ########################################################################
477 --echo # Retrieving geometrycollections with the ST_GEOMCOLLFROMWKB function
478 --echo #
479 --echo ########################################################################
480
481 --echo # Retrieve values with long lat ordering.
482 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc, 31000000,'axis-order=long-lat'));
483
484 --echo # Retrieve values with lat-long ordering.
485 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc, 31000000,'axis-order=lat-long'));
486
487 --echo # Retrieve values with SRID-defined ordering.
488 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc, 31000000,'axis-order=srid-defined'));
489
490 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc, 31300000,'axis-order=srid-defined'));
491
492
493 --echo ########################################################################
494 --echo # Retrieving geometrycollections with the ST_GEOMETRYCOLLECTIONFROMWKB function
495 --echo #
496 --echo ########################################################################
497
498 --echo # Retrieve values with long lat ordering.
499 SELECT ST_ASTEXT(ST_GEOMETRYCOLLECTIONFROMWKB(@wkb_gc,
500 31000000,'axis-order=long-lat'));
501
502 --echo # Retrieve values with lat-long ordering.
503 SELECT ST_ASTEXT(ST_GEOMETRYCOLLECTIONFROMWKB(@wkb_gc,
504 31000000,'axis-order=lat-long'));
505
506 --echo # Retrieve values with SRID-defined ordering.
507 SELECT ST_ASTEXT(ST_GEOMETRYCOLLECTIONFROMWKB(@wkb_gc,
508 31000000,'axis-order=srid-defined'));
509
510 SELECT ST_ASTEXT(ST_GEOMETRYCOLLECTIONFROMWKB(@wkb_gc,
511 31300000,'axis-order=srid-defined'));
512
513
514 --echo ########################################################################
515 --echo # Retrieving multipoints with the ST_MPOINTFROMWKB function
516 --echo #
517 --echo ########################################################################
518
519 --echo # Retrieve values with long lat ordering.
520 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(@wkb_mpt,
521 31000000,'axis-order=long-lat'));
522
523 --echo # Retrieve values with lat-long ordering.
524 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(@wkb_mpt,
525 31000000,'axis-order=lat-long'));
526
527 --echo # Retrieve values with SRID-defined ordering.
528 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(@wkb_mpt,
529 31000000,'axis-order=srid-defined'));
530 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(@wkb_mpt,
531 31300000,'axis-order=srid-defined'));
532
533
534 --echo ########################################################################
535 --echo # Retrieving multipoints with the ST_MULTIPOINTFROMWKB function
536 --echo #
537 --echo ########################################################################
538
539 --echo # Retrieve values with long lat ordering.
540 SELECT ST_ASTEXT(ST_MULTIPOINTFROMWKB(@wkb_mpt,
541 31000000,'axis-order=long-lat'));
542
543 --echo # Retrieve values with lat-long ordering.
544 SELECT ST_ASTEXT(ST_MULTIPOINTFROMWKB(@wkb_mpt,
545 31000000,'axis-order=lat-long'));
546
547 --echo # Retrieve values with SRID-defined ordering.
548 SELECT ST_ASTEXT(ST_MULTIPOINTFROMWKB(@wkb_mpt,
549 31000000,'axis-order=srid-defined'));
550 SELECT ST_ASTEXT(ST_MULTIPOINTFROMWKB(@wkb_mpt,
551 31300000,'axis-order=srid-defined'));
552
553
554 --echo ########################################################################
555 --echo # Retrieving multistrings with the ST_MLINEFROMWKB function
556 --echo #
557 --echo ########################################################################
558
559 --echo # Retrieve values with long lat ordering.
560 SELECT ST_ASTEXT(ST_MLINEFROMWKB(@wkb_mln, 31000000,'axis-order=long-lat'));
561
562 --echo # Retrieve values with lat-long ordering.
563 SELECT ST_ASTEXT(ST_MLINEFROMWKB(@wkb_mln, 31000000,'axis-order=lat-long'));
564
565 --echo # Retrieve values with SRID-defined ordering.
566 SELECT ST_ASTEXT(ST_MLINEFROMWKB(@wkb_mln, 31000000,'axis-order=srid-defined'));
567 SELECT ST_ASTEXT(ST_MLINEFROMWKB(@wkb_mln, 31300000,'axis-order=srid-defined'));
568
569
570 --echo ########################################################################
571 --echo # Retrieving multistrings with the ST_MULTILINESTRINGFROMWKB function
572 --echo #
573 --echo ########################################################################
574
575 --echo # Retrieve values with long lat ordering.
576 SELECT ST_ASTEXT(ST_MULTILINESTRINGFROMWKB(@wkb_mln,
577 31000000,'axis-order=long-lat'));
578
579 --echo # Retrieve values with lat-long ordering.
580 SELECT ST_ASTEXT(ST_MULTILINESTRINGFROMWKB(@wkb_mln,
581 31000000,'axis-order=lat-long'));
582
583 --echo # Retrieve values with SRID-defined ordering.
584 SELECT ST_ASTEXT(ST_MULTILINESTRINGFROMWKB(@wkb_mln,
585 31000000,'axis-order=srid-defined'));
586 SELECT ST_ASTEXT(ST_MULTILINESTRINGFROMWKB(@wkb_mln,
587 31300000,'axis-order=srid-defined'));
588
589
590 --echo ########################################################################
591 --echo # Retrieving multipolygons with the ST_MPOLYFROMWKB function
592 --echo #
593 --echo ########################################################################
594
595 --echo # Retrieve values with long lat ordering.
596 SELECT ST_ASTEXT(ST_MPOLYFROMWKB(@wkb_mpy, 31000000, 'axis-order=long-lat'));
597
598 --echo # Retrieve values with lat-long ordering.
599 SELECT ST_ASTEXT(ST_MPOLYFROMWKB(@wkb_mpy, 31000000, 'axis-order=lat-long'));
600
601 --echo # Retrieve values with SRID-defined ordering.
602 SELECT ST_ASTEXT(ST_MPOLYFROMWKB(@wkb_mpy,
603 31000000, 'axis-order=srid-defined'));
604 SELECT ST_ASTEXT(ST_MPOLYFROMWKB(@wkb_mpy,
605 31300000, 'axis-order=srid-defined'));
606
607
608 --echo ########################################################################
609 --echo # Retrieving multipolygons with the ST_MULTIPOLYGONFROMWKB function
610 --echo #
611 --echo ########################################################################
612
613 --echo # Retrieve values with long lat ordering.
614 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy, 31000000, 'axis-order=long-lat'));
615
616 --echo # Retrieve values with lat-long ordering.
617 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy, 31000000, 'axis-order=lat-long'));
618
619 --echo # Retrieve values with SRID-defined ordering.
620 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy,
621 31000000, 'axis-order=srid-defined'));
622 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy,
623 31300000, 'axis-order=srid-defined'));
624
625 --echo ########################################################################
626 --echo # Error testing
627 --echo ########################################################################
628
629 --echo # Test with too many options.
630
631 --error ER_DUPLICATE_OPTION_KEY
632 SELECT ST_ASTEXT(ST_MPOLYFROMWKB(@wkb_mpy, 31000000,
633 'axis-order=srid-defined, axis-order=lat-long'));
634
635 --echo # Test with invalid options key.
636 --error ER_INVALID_OPTION_KEY
637 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
638 31000000,'axix-order=srid-defined'));
639
640 --error ER_INVALID_OPTION_KEY
641 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
642 31000000,'axix-order=lat-long'));
643
644 --error ER_INVALID_OPTION_KEY
645 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
646 31000000,'axix-order=lat-long'));
647
648 --echo # Test with invalid options value
649 --error ER_INVALID_OPTION_VALUE
650 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
651 31300000,'axis-order=srid-dfined'));
652
653 --error ER_INVALID_OPTION_VALUE
654 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
655 31000000,'axis-order=lat-bong'));
656
657 --error ER_INVALID_OPTION_VALUE
658 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
659 31000000,'axis-order=lat-shwong'));
660
661 --echo # Test with both invalid option and invalid value
662 --error ER_INVALID_OPTION_KEY
663 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
664 31000000,'axis-border=lat-shwong'));
665
666 --echo # Testing for badly formed options argument.
667 --error ER_INVALID_OPTION_KEY_VALUE_PAIR
668 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
669 31000000,'axis-order srid-defined'));
670
671 --error ER_INVALID_OPTION_START_CHARACTER
672 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
673 31000000,'=axis-order srid-defined'));
674
675 --error ER_INVALID_OPTION_END_CHARACTER
676 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
677 31000000,'axis-order=srid-defined='));
678
679 --error ER_INVALID_OPTION_CHARACTERS
680 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
681 31000000,'axis-order== srid-defined'));
682
683 --echo # ######################################################################
684 --echo # Empty string and white space testing
685 --echo # ######################################################################
686
687 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc, 31000000,''));
688
689 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc, 31000000,' '));
690
691 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(@wkb_gc,
692 31000000,' axis-order = srid-defined '));
693
694
695 --echo ########################################################################
696 --echo # Case insensitive testing in otions argument
697 --echo # (both option keys and values)
698 --echo ########################################################################
699
700 --echo # Retrieve values with long lat ordering.
701 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy, 31000000, 'aXis-Order=LONG-LAT'));
702
703 --echo # Retrieve values with lat-long ordering.
704 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy, 31000000, 'AXis-OrdEr=Lat-Long'));
705
706 --echo # Retrieve values with SRID-defined ordering.
707 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy,
708 31000000, 'Axis-Order=sRid-dEfined'));
709 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy,
710 31300000, 'aXiS-oRdeR=sriD-dEfinEd'));
711
712 --echo # ######################################################################
713 --echo # NULL value and 0 value srid testing
714 --echo # ######################################################################
715
716 --echo # NULL value testing: Should return NULL if either or both parameters is NULL
717
718 SELECT ST_ASTEXT(ST_POINTFROMWKB(NULL,31000000, 'axis-order=long-lat'));
719 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(@wkb_mpt, NULL, 'axis-order=lat-long'));
720 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(@wkb_mpt, 31000000, NULL));
721 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(@wkb_mpt, NULL, NULL));
722 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(NULL, NULL, NULL));
723
724 --echo # Coordinates are interpreted as in the order they appear in the geometry
725 SELECT ST_ASTEXT(ST_MULTIPOLYGONFROMWKB(@wkb_mpy, 0, 'axis-order=srid-defined'));
726
727 ######################################################################
728 # WL#9449 Restrict range of geographic coordinates in import functions
729 ######################################################################
730
731 --echo ##########################################################
732 --echo # Inserting testing SRS values in spatial reference table
733 --echo ##########################################################
734
735 --echo # Inserting geographical srs with long-lat ordering
736 CREATE SPATIAL REFERENCE SYSTEM 32000000 NAME 'TEST32000000' DEFINITION 'GEOGCS["SIRGAS 1995",DATUM["Sistema de Referencia Geocentrico para America del Sur 1995",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6170"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["LONG",EAST],AXIS["LAT",NORTH],AUTHORITY["EPSG","32000000"]]';
737
738 --echo # Inserting geographical srs with lat-long ordering
739 CREATE SPATIAL REFERENCE SYSTEM 32100000 NAME 'TEST32100000' DEFINITION 'GEOGCS["SIRGAS 1995",DATUM["Sistema de Referencia Geocentrico para America del Sur 1995",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6170"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["LAT",NORTH],AXIS["LONG",EAST],AUTHORITY["EPSG","32100000"]]';
740
741 --echo # Inserting projected srs with northing-easting ordering
742 CREATE SPATIAL REFERENCE SYSTEM 32200000 NAME 'TEST32200000' DEFINITION 'PROJCS["NAD83(NSRS2007) / Virginia Lambert",GEOGCS["NAD83(NSRS2007)",DATUM["NAD83 (National Spatial Reference System 2007)",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6759"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4759"]],PROJECTION["Lambert Conic Conformal (2SP)",AUTHORITY["EPSG","9802"]],PARAMETER["Latitude of false origin",36,AUTHORITY["EPSG","8821"]],PARAMETER["Longitude of false origin",-79.5,AUTHORITY["EPSG","8822"]],PARAMETER["Latitude of 1st standard parallel",37,AUTHORITY["EPSG","8823"]],PARAMETER["Latitude of 2nd standard parallel",39.5,AUTHORITY["EPSG","8824"]],PARAMETER["Easting at false origin",0,AUTHORITY["EPSG","8826"]],PARAMETER["Northing at false origin",0,AUTHORITY["EPSG","8827"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",NORTH],AXIS["Y",EAST],AUTHORITY["EPSG","32200000"]]';
743
744 --echo #########################################################################
745 --echo # Test with geometries with geographic SRS with long-lat ordering outside
746 --echo # valid range.
747 --echo #########################################################################
748
749 --error ER_LONGITUDE_OUT_OF_RANGE
750 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-200 10)', 0)), 32000000);
751 --error ER_LONGITUDE_OUT_OF_RANGE
752 SELECT ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(0 5,194 10,10 15)', 0)), 32000000);
753 --error ER_LONGITUDE_OUT_OF_RANGE
754 SELECT ST_POLYFROMWKB(ST_ASWKB(ST_POLYFROMTEXT('POLYGON((0 0,5 0,5 5,-300 5,0 0))',0)), 32000000);
755 --error ER_LONGITUDE_OUT_OF_RANGE
756 SELECT ST_MPOINTFROMWKB(ST_ASWKB(ST_MPOINTFROMTEXT('MULTIPOINT((0 2), (5 7), (798 2), (-344 9))',0)),32000000);
757 --error ER_LONGITUDE_OUT_OF_RANGE
758 SELECT ST_MLINEFROMWKB(ST_ASWKB(ST_MLINEFROMTEXT('MULTILINESTRING((0 2,2 4,4 6),(744 11,11 14,14 17))',0)),32000000);
759 --error ER_LONGITUDE_OUT_OF_RANGE
760 SELECT ST_MPOLYFROMWKB(ST_ASWKB(ST_MPOLYFROMTEXT('MULTIPOLYGON(((0 0,350 0,350 350,0 350,0 0),(4 4,4 6,6 6,6 4, 4 4)),((0 0,-2 -2,0 -2, 0 0)))',0)),32000000);
761 --error ER_LONGITUDE_OUT_OF_RANGE
762 SELECT ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(-199 5), POLYGON((0 0,10 0,10 10,0 10,0 0)), MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4,4 6,6 6,6 4, 4 4)),((0 0,-2 -2,0 -2, 0 0))))',0)), 32000000);
763
764 --echo #########################################################################
765 --echo # Test with geometries with geographic SRS with lat-long ordering outside
766 --echo # valid range (same geometries as above, but with different error since
767 --echo # coordinates are flipped).
768 --echo #########################################################################
769
770 --error ER_LATITUDE_OUT_OF_RANGE
771 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-200 10)',0)),32100000);
772 --error ER_LATITUDE_OUT_OF_RANGE
773 SELECT ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(0 5,194 10,10 15)',0)),32100000);
774 --error ER_LATITUDE_OUT_OF_RANGE
775 SELECT ST_POLYFROMWKB(ST_ASWKB(ST_POLYFROMTEXT('POLYGON((0 0,5 0,5 5,-300 5,0 0))',0)),32100000);
776 --error ER_LATITUDE_OUT_OF_RANGE
777 SELECT ST_MPOINTFROMWKB(ST_ASWKB(ST_MPOINTFROMTEXT('MULTIPOINT((0 2), (5 7), (798 2), (4 9))',0)),32100000);
778 --error ER_LATITUDE_OUT_OF_RANGE
779 SELECT ST_MLINEFROMWKB(ST_ASWKB(ST_MLINEFROMTEXT('MULTILINESTRING((0 2,2 4,4 6),(744 11,11 14,14 17))',0)),32100000);
780 --error ER_LATITUDE_OUT_OF_RANGE
781 SELECT ST_MPOLYFROMWKB(ST_ASWKB(ST_MPOLYFROMTEXT('MULTIPOLYGON(((0 0,350 0,350 350,0 350,0 0),(4 4,4 6,6 6,6 4, 4 4)),((0 0,-2 -2,0 -2, 0 0)))',0)),32100000);
782 --error ER_LATITUDE_OUT_OF_RANGE
783 SELECT ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(-199 5), POLYGON((0 0,10 0,10 10,0 10,0 0)), MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4,4 6,6 6,6 4, 4 4)),((0 0,-2 -2,0 -2, 0 0))))',0)), 32100000);
784
785 --echo ##############################
786 --echo # Miscellaneous error testing
787 --echo ##############################
788
789 --error ER_LATITUDE_OUT_OF_RANGE
790 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-91 10)',0)),32100000);
791 --error ER_LONGITUDE_OUT_OF_RANGE
792 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(10 -182)',0)),32100000);
793 --error ER_LONGITUDE_OUT_OF_RANGE
794 SELECT ST_MLINEFROMWKB(ST_ASWKB(ST_MLINEFROMTEXT('MULTILINESTRING((0 2,2 4,4 6),(744 11,11 91,14 17))',0)),32000000);
795 --error ER_LATITUDE_OUT_OF_RANGE
796 SELECT ST_MLINEFROMWKB(ST_ASWKB(ST_MLINEFROMTEXT('MULTILINESTRING((0 95,2 4,4 6),(744 11,11 91,14 17))',0)),32000000);
797
798 --echo ###################
799 --echo # Edge case testing
800 --echo ###################
801
802 SELECT ST_ASTEXT(ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-90.0000000 10)',0)),32100000));
803 SELECT ST_ASTEXT(ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(10 -180.0000000)',0)),32100000));
804
805 SELECT ST_ASTEXT(ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(90.0000000 10)',0)),32100000));
806 SELECT ST_ASTEXT(ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(10 180.0000000)',0)),32100000));
807
808 --error ER_LATITUDE_OUT_OF_RANGE
809 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-90.0000001 10)',0)),32100000);
810 --error ER_LONGITUDE_OUT_OF_RANGE
811 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(10 -180.0000001)',0)),32100000);
812
813 --error ER_LATITUDE_OUT_OF_RANGE
814 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(90.0000001 10)',0)),32100000);
815 --error ER_LONGITUDE_OUT_OF_RANGE
816 SELECT ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(10 180.0000001)',0)),32100000);
817
818 --echo #################################################################
819 --echo # Test that range restriction does not apply to projected spatial
820 --echo # reference systems
821 --echo #################################################################
822
823 SELECT ST_ASTEXT(ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-200 10)',0)),32200000));
824 SELECT ST_ASTEXT(ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(0 5,194 10,10 15)',0)),32200000));
825 SELECT ST_ASTEXT(ST_POLYFROMWKB(ST_ASWKB(ST_POLYFROMTEXT('POLYGON((0 0,5 0,5 5,-300 5,0 0))',0)),32200000));
826 SELECT ST_ASTEXT(ST_MPOINTFROMWKB(ST_ASWKB(ST_MPOINTFROMTEXT('MULTIPOINT((0 2), (5 7), (798 2), (4 9))',0)),32200000));
827 SELECT ST_ASTEXT(ST_MLINEFROMWKB(ST_ASWKB(ST_MLINEFROMTEXT('MULTILINESTRING((0 2,2 4,4 6),(744 11,11 14,14 17))',0)),32200000));
828 SELECT ST_ASTEXT(ST_MPOLYFROMWKB(ST_ASWKB(ST_MPOLYFROMTEXT('MULTIPOLYGON(((0 0,350 0,350 350,0 350,0 0),(4 4,4 6,6 6,6 4, 4 4)),((0 0,-2 -2,0 -2, 0 0)))',0)),32200000));
829 SELECT ST_ASTEXT(ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(-199 5), POLYGON((0 0,10 0,10 10,0 10,0 0)), MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4,4 6,6 6,6 4, 4 4)),((0 0,-2 -2,0 -2, 0 0))))',0)), 32200000));
830
831 --echo # Clean up
832 DROP PROCEDURE gis_wkb_funcs;
833 DROP SPATIAL REFERENCE SYSTEM 31000000;
834 DROP SPATIAL REFERENCE SYSTEM 31100000;
835 DROP SPATIAL REFERENCE SYSTEM 31200000;
836 DROP SPATIAL REFERENCE SYSTEM 31300000;
837 DROP SPATIAL REFERENCE SYSTEM 32000000;
838 DROP SPATIAL REFERENCE SYSTEM 32100000;
839 DROP SPATIAL REFERENCE SYSTEM 32200000;
840
841 --echo #
842 --echo # WL#11096 Don't do Cartesian computations on geographic geometries
843 --echo #
844
845 --echo # Assume SRID 10 is not defined. Should raise warning.
846 DO ST_ASBINARY(x'0A000000010100000000000000000000000000000000000000');
847 DO ST_ASWKB(x'0A000000010100000000000000000000000000000000000000');