Check-in [c7f67038bf]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:implementing CurvosityIndex() and UphillHeight() / DownhillHeight()
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c7f67038bf06d98d675440322fd857a50d8cb685
User & Date: sandro 2020-03-31 15:19:14
Context
2020-07-03
14:34
implementing TemporaryGeometries and supporting SHP and DBF import directly from within a compressed zipfile check-in: 56d41a1593 user: sandro tags: trunk
2020-03-31
15:19
implementing CurvosityIndex() and UphillHeight() / DownhillHeight() check-in: c7f67038bf user: sandro tags: trunk
2020-03-12
19:45
implementing support for Temporary Geometries check-in: 8530392951 user: sandro tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to spatialite-sql-latest.html.

987
988
989
990
991
992
993
994

995
996
997



998
999
1000

1001
1002
1003



1004
1005
1006

1007
1008
1009



1010
1011
1012

1013
1014
1015



1016
1017
1018
1019
1020
1021
1022
....
1917
1918
1919
1920
1921
1922
1923


















































1924
1925
1926
1927
1928
1929
1930
				<td>MbrMaxY( geom <i>Geometry</i>) : <i>Double precision</i><hr>
				    ST_MaxY( geom <i>Geometry</i>) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the y-coordinate for <i>geom</i> MBR's <u>uppermost side</u> as a double precision number.<hr>
                                NULL will be returned if <i>geom</i> isn't a valid Geometry.</td></tr>
			<tr><td><b>MinZ</b></td>
				<td>ST_MinZ( geom <i>Geometry</i>) : <i>Double precision</i></td>

				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the minimum Z-coordinate value for <i>geom</i> as a double precision number.<hr>



                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no Z dimension.</td></tr>
			<tr><td><b>MaxZ</b></td>
				<td>ST_MaxZ( geom <i>Geometry</i>) : <i>Double precision</i></td>

				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the maximum Z-coordinate value for <i>geom</i> as a double precision number.<hr>



                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no Z dimension.</td></tr>
			<tr><td><b>MinM</b></td>
				<td>ST_MinM( geom <i>Geometry</i>) : <i>Double precision</i></td>

				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the minimum M-coordinate value for <i>geom</i> as a double precision number.<hr>



                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no M dimension.</td></tr>
			<tr><td><b>MaxM</b></td>
				<td>ST_MaxM( geom <i>Geometry</i>) : <i>Double precision</i></td>

				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the maximum M-coordinate value for <i>geom</i> as a double precision number.<hr>



                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no M dimension.</td></tr>
			<tr><td colspan="5" align="center" bgcolor="#f0f0c0">
				<h3><a name="p1">SQL functions for constructing a geometric object given its Well-known Text Representation</a></h3></td></tr>
			<tr><th bgcolor="#d0d0d0">Function</th>
				<th bgcolor="#d0d0d0">Syntax</th>
				<th bgcolor="#d0d0d0">OGC<br>defined</th>
				<th bgcolor="#d0d0d0">required<br>module</th>
................................................................................
				<td>LinestringAvgSegmentLength( line <i>LineString</i> ) : <i>Double precision</i><hr>
					ST_LinestringAvgSegmentLength( line <i>LineString</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>returns the average length of segments in the Linestring.<br>
                                <b>NULL</b> will be returned if any error is encountered.<hr>
                                <b>Note</b>: this function only accepts simple Linestrings; Geometries containing any Point or Polygon, or containing more than a single Linesting will be considered invalid.</td></tr>


















































			<tr><td colspan="5" align="center" bgcolor="#f0f0c0">
				<h3><a name="p8">SQL functions on type Surface [Polygon or Ring]</a></h3></td></tr>
			<tr><th bgcolor="#d0d0d0">Function</th>
				<th bgcolor="#d0d0d0">Syntax</th>
				<th bgcolor="#d0d0d0">OGC<br>defined</th>
				<th bgcolor="#d0d0d0">required<br>module</th>
				<th bgcolor="#d0d0d0">Summary</th></tr>







|
>


|
>
>
>


|
>


|
>
>
>


|
>


|
>
>
>


|
>


|
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
....
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
				<td>MbrMaxY( geom <i>Geometry</i>) : <i>Double precision</i><hr>
				    ST_MaxY( geom <i>Geometry</i>) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the y-coordinate for <i>geom</i> MBR's <u>uppermost side</u> as a double precision number.<hr>
                                NULL will be returned if <i>geom</i> isn't a valid Geometry.</td></tr>
			<tr><td><b>MinZ</b></td>
				<td>ST_MinZ( geom <i>Geometry</i>) : <i>Double precision</i><hr>
				    ST_MinZ( geom <i>Geometry</i> , nodata-value <i>Double</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the minimum Z-coordinate value for <i>geom</i> as a double precision number.
					<ul>
						<li>if the optional argument <b>nodata-value</b> is set, then any NODATA value eventually found will be ignored.</li>
					</ul><hr>
                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no Z dimension.</td></tr>
			<tr><td><b>MaxZ</b></td>
				<td>ST_MaxZ( geom <i>Geometry</i>) : <i>Double precision</i><hr>
				    ST_MaxZ( geom <i>Geometry</i> , nodata-value <i>Double</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the maximum Z-coordinate value for <i>geom</i> as a double precision number.
					<ul>
						<li>if the optional argument <b>nodata-value</b> is set, then any NODATA value eventually found will be ignored.</li>
					</ul><hr>
                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no Z dimension.</td></tr>
			<tr><td><b>MinM</b></td>
				<td>ST_MinM( geom <i>Geometry</i>) : <i>Double precision</i><hr>
				    ST_MinM( geom <i>Geometry</i> , nodata-value <i>Double</i> ): <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the minimum M-coordinate value for <i>geom</i> as a double precision number.
					<ul>
						<li>if the optional argument <b>nodata-value</b> is set, then any NODATA value eventually found will be ignored.</li>
					</ul><hr>
                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no M dimension.</td></tr>
			<tr><td><b>MaxM</b></td>
				<td>ST_MaxM( geom <i>Geometry</i>) : <i>Double precision</i><hr>
				    ST_MaxM( geom <i>Geometry</i> , nodata-value <i>Double</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>return the maximum M-coordinate value for <i>geom</i> as a double precision number.
					<ul>
						<li>if the optional argument <b>nodata-value</b> is set, then any NODATA value eventually found will be ignored.</li>
					</ul><hr>
                                NULL will be returned if <i>geom</i> isn't a valid Geometry or if <i>geom</i> has no M dimension.</td></tr>
			<tr><td colspan="5" align="center" bgcolor="#f0f0c0">
				<h3><a name="p1">SQL functions for constructing a geometric object given its Well-known Text Representation</a></h3></td></tr>
			<tr><th bgcolor="#d0d0d0">Function</th>
				<th bgcolor="#d0d0d0">Syntax</th>
				<th bgcolor="#d0d0d0">OGC<br>defined</th>
				<th bgcolor="#d0d0d0">required<br>module</th>
................................................................................
				<td>LinestringAvgSegmentLength( line <i>LineString</i> ) : <i>Double precision</i><hr>
					ST_LinestringAvgSegmentLength( line <i>LineString</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>returns the average length of segments in the Linestring.<br>
                                <b>NULL</b> will be returned if any error is encountered.<hr>
                                <b>Note</b>: this function only accepts simple Linestrings; Geometries containing any Point or Polygon, or containing more than a single Linesting will be considered invalid.</td></tr>
			<tr><td><b>CurvosityIndex</b></td>
				<td>CurvosityIndex( line <i>LineString</i> ) : <i>Double precision</i><hr>
					CurvosityIndex( line <i>LineString</i> , extra-points <i>Integer</i> ) : <i>Double precision</i><hr>
					ST_CurvosityIndex( line <i>LineString</i> ) : <i>Double precision</i><hr>
					ST_CurvosityIndex( line <i>LineString</i> , extra-points <i>Integer</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>returns the Curvosity Index of a generic simple Linestring:
				    <ul>
						<li>the Index will range between <b>1.0</b> (<i>in the case of a perfectly straight line</i>) and 
				             <b>0.0</b> (<i>in the case of a closed line with coincident start and end points</i>).</li>
				        <li>if the optional argument <b>extra-points</b> is explicitly set, then the given number of equidistant points will be interpolated into the <i>reference line</i> used to calculate the Index.</li>
				    </ul>
                                <b>NULL</b> will be returned if any error is encountered.<hr>
                                <b>Note</b>: this function only accepts simple Linestrings; Geometries containing any Point or Polygon, or containing more than a single Linesting will be considered invalid.</td></tr>
			<tr><td><b>UphillHeight</b></td>
				<td>UphillHeight( line <i>LineString</i> ) : <i>Double precision</i><hr>
					ST_UphillHeight( line <i>LineString</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>returns the total Uphill Height of a generic simple Linestring:
				    <ul>
						<li><b>0.0</b> will be always returned for any <b>2D</b> Linestring not containing <b>Z</b> coordinates.</li>
				    </ul>
                                <b>NULL</b> will be returned if any error is encountered.<hr>
                                <b>Note</b>: this function only accepts simple Linestrings; Geometries containing any Point or Polygon, or containing more than a single Linesting will be considered invalid.</td></tr>
			<tr><td><b>DownhillHeight</b></td>
				<td>DownhillHeight( line <i>LineString</i> ) : <i>Double precision</i><hr>
					ST_DownhillHeight( line <i>LineString</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>returns the total Downhill Height of a generic simple Linestring:
				    <ul>
						<li><b>0.0</b> will be always returned for any <b>2D</b> Linestring not containing <b>Z</b> coordinates.</li>
				    </ul>
                                <b>NULL</b> will be returned if any error is encountered.<hr>
                                <b>Note</b>: this function only accepts simple Linestrings; Geometries containing any Point or Polygon, or containing more than a single Linesting will be considered invalid.</td></tr>
			<tr><td><b>UpDownHeight</b></td>
				<td>UpDownHeight( line <i>LineString</i> ) : <i>Double precision</i><hr>
					ST_UpDownHeight( line <i>LineString</i> ) : <i>Double precision</i></td>
				<td></td>
				<td align="center" bgcolor="#d0f0d0">base</td>
				<td>returns the sum of total UpHill and DownHill Heights of a generic simple Linestring:
				    <ul>
						<li>this is just a <i>convenience method</i>; calling <b>ST_UpDownHeight(line)</b> is exactly the same than calling <b>ST_UphillHeight(geom) + ST_DownhillHeight(geom)</b></li>
						<li><b>0.0</b> will be always returned for any <b>2D</b> Linestring not containing <b>Z</b> coordinates.</li>
				    </ul>
                                <b>NULL</b> will be returned if any error is encountered.<hr>
                                <b>Note</b>: this function only accepts simple Linestrings; Geometries containing any Point or Polygon, or containing more than a single Linesting will be considered invalid.</td></tr>
                                
			<tr><td colspan="5" align="center" bgcolor="#f0f0c0">
				<h3><a name="p8">SQL functions on type Surface [Polygon or Ring]</a></h3></td></tr>
			<tr><th bgcolor="#d0d0d0">Function</th>
				<th bgcolor="#d0d0d0">Syntax</th>
				<th bgcolor="#d0d0d0">OGC<br>defined</th>
				<th bgcolor="#d0d0d0">required<br>module</th>
				<th bgcolor="#d0d0d0">Summary</th></tr>

Changes to src/gaiageo/gg_advanced.c.

300
301
302
303
304
305
306






























































































































































307
308
309
310
311
312
313
      }
    area /= 2.0;
    if (area >= 0.0)
	p->Clockwise = 0;
    else
	p->Clockwise = 1;
}































































































































































GAIAGEO_DECLARE int
gaiaIsPointOnRingSurface (gaiaRingPtr ring, double pt_x, double pt_y)
{
/* tests if a POINT falls inside a RING */
    int isInternal = 0;
    int cnt;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
      }
    area /= 2.0;
    if (area >= 0.0)
	p->Clockwise = 0;
    else
	p->Clockwise = 1;
}

GAIAGEO_DECLARE double
gaiaCurvosityIndex (const void *p_cache, gaiaLinestringPtr ln, int extra_points)
{
/* calculates the Curvosity Index of some Linestring */
    double x;
    double y;
    double z;
    double m;
    int iv;
    int ov;
    gaiaGeomCollPtr geo = NULL;
    gaiaLinestringPtr refln;
    double refline_length;
    double line_length =
	gaiaMeasureLength (ln->DimensionModel, ln->Coords, ln->Points);

/* building the Reference Line */
    refln = gaiaAllocLinestring (2 + extra_points);
/* inserting the first vertex of Line into the Reference Line */
    iv = 0;
    ov = 0;
    if (ln->DimensionModel == GAIA_XY_Z)
      {
	  gaiaGetPointXYZ (ln->Coords, iv, &x, &y, &z);
      }
    else if (ln->DimensionModel == GAIA_XY_M)
      {
	  gaiaGetPointXYM (ln->Coords, iv, &x, &y, &m);
      }
    else if (ln->DimensionModel == GAIA_XY_Z_M)
      {
	  gaiaGetPointXYZM (ln->Coords, iv, &x, &y, &z, &m);
      }
    else
      {
	  gaiaGetPoint (ln->Coords, iv, &x, &y);
      }
    gaiaSetPoint (refln->Coords, 0, x, y);
    ov++;
    if (extra_points > 0)
      {
	  /* inserting all interpolated points into the Reference Line */
	  int i;
	  double perc = 1.0 / (double) (extra_points + 1);
	  double progr = perc;
	  gaiaGeomCollPtr geo;
	  gaiaGeomCollPtr result;
	  gaiaPointPtr pt;
	  if (ln->DimensionModel == GAIA_XY_Z)
	      geo = gaiaAllocGeomCollXYZ ();
	  else if (ln->DimensionModel == GAIA_XY_M)
	      geo = gaiaAllocGeomCollXYM ();
	  else if (ln->DimensionModel == GAIA_XY_Z_M)
	      geo = gaiaAllocGeomCollXYZM ();
	  else
	      geo = gaiaAllocGeomColl ();
	  gaiaInsertLinestringInGeomColl (geo, ln);
	  for (i = 0; i < extra_points; i++)
	    {
		if (p_cache != NULL)
		    result = gaiaLineInterpolatePoint_r (p_cache, geo, progr);
		else
		    result = gaiaLineInterpolatePoint (geo, progr);
		if (result == NULL)
		    goto error;
		pt = result->FirstPoint;
		if (pt == NULL)
		    goto error;
		x = pt->X;
		y = pt->Y;
		gaiaFreeGeomColl (result);
		gaiaSetPoint (refln->Coords, ov, x, y);
		ov++;
		progr += perc;
	    }
	  geo->FirstLinestring = NULL;	/* releasing ownership on Line */
	  geo->LastLinestring = NULL;
	  gaiaFreeGeomColl (geo);
      }
/* inserting the last vertex of Line into the Reference Line */
    iv = ln->Points - 1;
    if (ln->DimensionModel == GAIA_XY_Z)
      {
	  gaiaGetPointXYZ (ln->Coords, iv, &x, &y, &z);
      }
    else if (ln->DimensionModel == GAIA_XY_M)
      {
	  gaiaGetPointXYM (ln->Coords, iv, &x, &y, &m);
      }
    else if (ln->DimensionModel == GAIA_XY_Z_M)
      {
	  gaiaGetPointXYZM (ln->Coords, iv, &x, &y, &z, &m);
      }
    else
      {
	  gaiaGetPoint (ln->Coords, iv, &x, &y);
      }
    gaiaSetPoint (refln->Coords, ov, x, y);
    refline_length =
	gaiaMeasureLength (refln->DimensionModel, refln->Coords, refln->Points);
    return (refline_length / line_length);

  error:
    if (geo != NULL)
      {
	  geo->FirstLinestring = NULL;	/* releasing ownership on Line */
	  geo->LastLinestring = NULL;
	  gaiaFreeGeomColl (geo);
      }
    return -1.0;
}

GAIAGEO_DECLARE void
gaiaUpDownHeight (gaiaLinestringPtr ln, double *up, double *down)
{
/* calculates the Uphill and Downhill Height of some Linestring */
    double x;
    double y;
    double z;
    double m;
    int iv;
    double prev_z;
    double tot_up = 0.0;
    double tot_down = 0.0;

/* inserting the last vertex of Line into the Reference Line */
    if (ln->DimensionModel == GAIA_XY || ln->DimensionModel == GAIA_XY_M)
      {
	  *up = 0.0;
	  *down = 0.0;
	  goto stop;
      }
    for (iv = 0; iv < ln->Points; iv++)
      {
	  if (ln->DimensionModel == GAIA_XY_Z)
	    {
		gaiaGetPointXYZ (ln->Coords, iv, &x, &y, &z);
	    }
	  else if (ln->DimensionModel == GAIA_XY_Z_M)
	    {
		gaiaGetPointXYZM (ln->Coords, iv, &x, &y, &z, &m);
	    }
	  if (iv == 0)
	    {
		prev_z = z;
		continue;
	    }
	  if (z > prev_z)
	      tot_up += z - prev_z;
	  else
	      tot_down += prev_z - z;
	  prev_z = z;
      }
  stop:
    *up = tot_up;
    *down = tot_down;
}

GAIAGEO_DECLARE int
gaiaIsPointOnRingSurface (gaiaRingPtr ring, double pt_x, double pt_y)
{
/* tests if a POINT falls inside a RING */
    int isInternal = 0;
    int cnt;

Changes to src/gaiageo/gg_geometries.c.

2611
2612
2613
2614
2615
2616
2617








































2618
2619
2620
2621
2622
2623
2624
....
2648
2649
2650
2651
2652
2653
2654







































2655
2656
2657
2658
2659
2660
2661
....
2670
2671
2672
2673
2674
2675
2676




























2677
2678
2679
2680
2681
2682
2683
....
2722
2723
2724
2725
2726
2727
2728


















































2729
2730
2731
2732
2733
2734
2735
....
2754
2755
2756
2757
2758
2759
2760









































2761
2762
2763
2764
2765
2766
2767
....
2798
2799
2800
2801
2802
2803
2804








































2805
2806
2807
2808
2809
2810
2811
....
2820
2821
2822
2823
2824
2825
2826




























2827
2828
2829
2830
2831
2832
2833
....
2866
2867
2868
2869
2870
2871
2872


















































2873
2874
2875
2876
2877
2878
2879
	    }
	  if (m < *min)
	      *min = m;
	  if (m > *max)
	      *max = m;
      }
}









































GAIAGEO_DECLARE void
gaiaMRangeRing (gaiaRingPtr rng, double *min, double *max)
{
/* computes the M-range [min/max] for this ring */
    int iv;
    double x;
................................................................................
	    }
	  if (m < *min)
	      *min = m;
	  if (m > *max)
	      *max = m;
      }
}








































GAIAGEO_DECLARE void
gaiaMRangePolygon (gaiaPolygonPtr polyg, double *min, double *max)
{
/* computes the M-range [min/max] for this polygon */
    gaiaRingPtr rng;
    int ib;
................................................................................
    if (r_max > *max)
	*max = r_max;
    for (ib = 0; ib < polyg->NumInteriors; ib++)
      {
	  rng = polyg->Interiors + ib;
	  gaiaMRangeRing (rng, &r_min, &r_max);
	  if (r_min < *min)




























	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
      }
}

GAIAGEO_DECLARE void
................................................................................
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  polyg = polyg->Next;
      }
}



















































GAIAGEO_DECLARE void
gaiaZRangeLinestring (gaiaLinestringPtr line, double *min, double *max)
{
/* computes the Z-range [min/max] for this linestring */
    int iv;
    double x;
................................................................................
	    {
		gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m);
	    }
	  else
	    {
		gaiaGetPoint (line->Coords, iv, &x, &y);
	    }









































	  if (z < *min)
	      *min = z;
	  if (z > *max)
	      *max = z;
      }
}

................................................................................
	    }
	  if (z < *min)
	      *min = z;
	  if (z > *max)
	      *max = z;
      }
}









































GAIAGEO_DECLARE void
gaiaZRangePolygon (gaiaPolygonPtr polyg, double *min, double *max)
{
/* computes the Z-range [min/max] for this polygon */
    gaiaRingPtr rng;
    int ib;
................................................................................
    if (r_max > *max)
	*max = r_max;
    for (ib = 0; ib < polyg->NumInteriors; ib++)
      {
	  rng = polyg->Interiors + ib;
	  gaiaZRangeRing (rng, &r_min, &r_max);
	  if (r_min < *min)




























	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
      }
}

GAIAGEO_DECLARE void
................................................................................
	  line = line->Next;
      }
    polyg = geom->FirstPolygon;
    while (polyg)
      {
	  gaiaZRangePolygon (polyg, &r_min, &r_max);
	  if (r_min < *min)


















































	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  polyg = polyg->Next;
      }
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
....
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
....
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
....
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
....
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
....
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
....
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
....
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
	    }
	  if (m < *min)
	      *min = m;
	  if (m > *max)
	      *max = m;
      }
}

GAIAGEO_DECLARE void
gaiaMRangeLinestringEx (gaiaLinestringPtr line, double nodata, double *min,
			double *max)
{
/* computes the M-range [min/max] for this linestring (NODATA flavor) */
    int iv;
    double x;
    double y;
    double z;
    double m;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    for (iv = 0; iv < line->Points; iv++)
      {
	  m = 0.0;
	  if (line->DimensionModel == GAIA_XY_Z)
	    {
		gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z);
	    }
	  else if (line->DimensionModel == GAIA_XY_M)
	    {
		gaiaGetPointXYM (line->Coords, iv, &x, &y, &m);
	    }
	  else if (line->DimensionModel == GAIA_XY_Z_M)
	    {
		gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m);
	    }
	  else
	    {
		gaiaGetPoint (line->Coords, iv, &x, &y);
	    }
	  if (m == nodata)
	      continue;
	  if (m < *min)
	      *min = m;
	  if (m > *max)
	      *max = m;
      }
}

GAIAGEO_DECLARE void
gaiaMRangeRing (gaiaRingPtr rng, double *min, double *max)
{
/* computes the M-range [min/max] for this ring */
    int iv;
    double x;
................................................................................
	    }
	  if (m < *min)
	      *min = m;
	  if (m > *max)
	      *max = m;
      }
}

GAIAGEO_DECLARE void
gaiaMRangeRingEx (gaiaRingPtr rng, double nodata, double *min, double *max)
{
/* computes the M-range [min/max] for this ring (NODATA flavor) */
    int iv;
    double x;
    double y;
    double z;
    double m;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    for (iv = 0; iv < rng->Points; iv++)
      {
	  m = 0.0;
	  if (rng->DimensionModel == GAIA_XY_Z)
	    {
		gaiaGetPointXYZ (rng->Coords, iv, &x, &y, &z);
	    }
	  else if (rng->DimensionModel == GAIA_XY_M)
	    {
		gaiaGetPointXYM (rng->Coords, iv, &x, &y, &m);
	    }
	  else if (rng->DimensionModel == GAIA_XY_Z_M)
	    {
		gaiaGetPointXYZM (rng->Coords, iv, &x, &y, &z, &m);
	    }
	  else
	    {
		gaiaGetPoint (rng->Coords, iv, &x, &y);
	    }
	  if (m == nodata)
	      continue;
	  if (m < *min)
	      *min = m;
	  if (m > *max)
	      *max = m;
      }
}

GAIAGEO_DECLARE void
gaiaMRangePolygon (gaiaPolygonPtr polyg, double *min, double *max)
{
/* computes the M-range [min/max] for this polygon */
    gaiaRingPtr rng;
    int ib;
................................................................................
    if (r_max > *max)
	*max = r_max;
    for (ib = 0; ib < polyg->NumInteriors; ib++)
      {
	  rng = polyg->Interiors + ib;
	  gaiaMRangeRing (rng, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
      }
}

GAIAGEO_DECLARE void
gaiaMRangePolygonEx (gaiaPolygonPtr polyg, double nodata, double *min,
		     double *max)
{
/* computes the M-range [min/max] for this polygon (NODATA flavor) */
    gaiaRingPtr rng;
    int ib;
    double r_min;
    double r_max;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    rng = polyg->Exterior;
    gaiaMRangeRingEx (rng, nodata, &r_min, &r_max);
    if (r_min < *min)
	*min = r_min;
    if (r_max > *max)
	*max = r_max;
    for (ib = 0; ib < polyg->NumInteriors; ib++)
      {
	  rng = polyg->Interiors + ib;
	  gaiaMRangeRingEx (rng, nodata, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
      }
}

GAIAGEO_DECLARE void
................................................................................
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  polyg = polyg->Next;
      }
}

GAIAGEO_DECLARE void
gaiaMRangeGeometryEx (gaiaGeomCollPtr geom, double nodata, double *min,
		      double *max)
{
/* computes the M-range [min/max] for this geometry */
    gaiaPointPtr point = NULL;
    gaiaLinestringPtr line = NULL;
    gaiaPolygonPtr polyg = NULL;
    double m;
    double r_min;
    double r_max;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    point = geom->FirstPoint;
    while (point)
      {
	  m = 0.0;
	  if (point->DimensionModel == GAIA_XY_M
	      || point->DimensionModel == GAIA_XY_Z_M)
	      m = point->M;
	  if (m == nodata)
	      continue;
	  if (m < *min)
	      *min = m;
	  if (m > *max)
	      *max = m;
	  point = point->Next;
      }
    line = geom->FirstLinestring;
    while (line)
      {
	  gaiaMRangeLinestringEx (line, nodata, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  line = line->Next;
      }
    polyg = geom->FirstPolygon;
    while (polyg)
      {
	  gaiaMRangePolygonEx (polyg, nodata, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  polyg = polyg->Next;
      }
}

GAIAGEO_DECLARE void
gaiaZRangeLinestring (gaiaLinestringPtr line, double *min, double *max)
{
/* computes the Z-range [min/max] for this linestring */
    int iv;
    double x;
................................................................................
	    {
		gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m);
	    }
	  else
	    {
		gaiaGetPoint (line->Coords, iv, &x, &y);
	    }
	  if (z < *min)
	      *min = z;
	  if (z > *max)
	      *max = z;
      }
}

GAIAGEO_DECLARE void
gaiaZRangeLinestringEx (gaiaLinestringPtr line, double nodata, double *min,
			double *max)
{
/* computes the Z-range [min/max] for this linestring (NODATA flavor) */
    int iv;
    double x;
    double y;
    double z;
    double m;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    for (iv = 0; iv < line->Points; iv++)
      {
	  z = 0.0;
	  m = 0.0;
	  if (line->DimensionModel == GAIA_XY_Z)
	    {
		gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z);
	    }
	  else if (line->DimensionModel == GAIA_XY_M)
	    {
		gaiaGetPointXYM (line->Coords, iv, &x, &y, &m);
	    }
	  else if (line->DimensionModel == GAIA_XY_Z_M)
	    {
		gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m);
	    }
	  else
	    {
		gaiaGetPoint (line->Coords, iv, &x, &y);
	    }
	  if (z == nodata)
	      continue;
	  if (z < *min)
	      *min = z;
	  if (z > *max)
	      *max = z;
      }
}

................................................................................
	    }
	  if (z < *min)
	      *min = z;
	  if (z > *max)
	      *max = z;
      }
}

GAIAGEO_DECLARE void
gaiaZRangeRingEx (gaiaRingPtr rng, double nodata, double *min, double *max)
{
/* computes the Z-range [min/max] for this ring (NODATA flavor) */
    int iv;
    double x;
    double y;
    double z;
    double m;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    for (iv = 0; iv < rng->Points; iv++)
      {
	  z = 0.0;
	  m = 0.0;
	  if (rng->DimensionModel == GAIA_XY_Z)
	    {
		gaiaGetPointXYZ (rng->Coords, iv, &x, &y, &z);
	    }
	  else if (rng->DimensionModel == GAIA_XY_M)
	    {
		gaiaGetPointXYM (rng->Coords, iv, &x, &y, &m);
	    }
	  else if (rng->DimensionModel == GAIA_XY_Z_M)
	    {
		gaiaGetPointXYZM (rng->Coords, iv, &x, &y, &z, &m);
	    }
	  else
	    {
		gaiaGetPoint (rng->Coords, iv, &x, &y);
	    }
	  if (z == nodata)
	      continue;
	  if (z < *min)
	      *min = z;
	  if (z > *max)
	      *max = z;
      }
}

GAIAGEO_DECLARE void
gaiaZRangePolygon (gaiaPolygonPtr polyg, double *min, double *max)
{
/* computes the Z-range [min/max] for this polygon */
    gaiaRingPtr rng;
    int ib;
................................................................................
    if (r_max > *max)
	*max = r_max;
    for (ib = 0; ib < polyg->NumInteriors; ib++)
      {
	  rng = polyg->Interiors + ib;
	  gaiaZRangeRing (rng, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
      }
}

GAIAGEO_DECLARE void
gaiaZRangePolygonEx (gaiaPolygonPtr polyg, double nodata, double *min,
		     double *max)
{
/* computes the Z-range [min/max] for this polygon (NODATA flavor) */
    gaiaRingPtr rng;
    int ib;
    double r_min;
    double r_max;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    rng = polyg->Exterior;
    gaiaZRangeRingEx (rng, nodata, &r_min, &r_max);
    if (r_min < *min)
	*min = r_min;
    if (r_max > *max)
	*max = r_max;
    for (ib = 0; ib < polyg->NumInteriors; ib++)
      {
	  rng = polyg->Interiors + ib;
	  gaiaZRangeRingEx (rng, nodata, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
      }
}

GAIAGEO_DECLARE void
................................................................................
	  line = line->Next;
      }
    polyg = geom->FirstPolygon;
    while (polyg)
      {
	  gaiaZRangePolygon (polyg, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  polyg = polyg->Next;
      }
}

GAIAGEO_DECLARE void
gaiaZRangeGeometryEx (gaiaGeomCollPtr geom, double nodata, double *min,
		      double *max)
{
/* computes the Z-range [min/max] for this geometry (NODATA flavor) */
    gaiaPointPtr point = NULL;
    gaiaLinestringPtr line = NULL;
    gaiaPolygonPtr polyg = NULL;
    double z;
    double r_min;
    double r_max;
    *min = DBL_MAX;
    *max = -DBL_MAX;
    point = geom->FirstPoint;
    while (point)
      {
	  z = 0.0;
	  if (point->DimensionModel == GAIA_XY_Z
	      || point->DimensionModel == GAIA_XY_Z_M)
	      z = point->Z;
	  if (z == nodata)
	      continue;
	  if (z < *min)
	      *min = z;
	  if (z > *max)
	      *max = z;
	  point = point->Next;
      }
    line = geom->FirstLinestring;
    while (line)
      {
	  gaiaZRangeLinestringEx (line, nodata, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  line = line->Next;
      }
    polyg = geom->FirstPolygon;
    while (polyg)
      {
	  gaiaZRangePolygonEx (polyg, nodata, &r_min, &r_max);
	  if (r_min < *min)
	      *min = r_min;
	  if (r_max > *max)
	      *max = r_max;
	  polyg = polyg->Next;
      }
}

Changes to src/headers/spatialite/gg_core.h.

1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
....
2244
2245
2246
2247
2248
2249
2250



























2251
2252
2253
2254
2255
 \return the pointer to newly created Geometry object representing a Point
 laying on the input Geometry and positioned at the given M-Value
 NULL on failure.

 \sa gaiaIsValidTrajectory, gaiaFreeGeomColl

 \note you are responsible to destroy (before or after) any allocated Geometry,
 this including any Geometry returned by gaiaLineInterpolatePoint()\n
 not reentrant and thread unsafe.
 
 \note a Geometry is considered to be a valid Trajectory if it contains
 a simple LINESTRING supporting M-values growing from each vertex to the next.
 */
    GAIAGEO_DECLARE gaiaGeomCollPtr
	gaiaTrajectoryInterpolatePoint (gaiaGeomCollPtr geom, double m);
................................................................................
 You are responsible to destroy (before or after) any allocated Geometry,
 this including any Geometry returned by gaiaPolygonize()\n
 not reentrant and thread unsafe.
 */
    GAIAGEO_DECLARE gaiaGeomCollPtr gaiaMakePolygon (gaiaGeomCollPtr exterior,
						     gaiaGeomCollPtr interiors);




























#ifdef __cplusplus
}
#endif

#endif				/* _GG_CORE_H */







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
....
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
 \return the pointer to newly created Geometry object representing a Point
 laying on the input Geometry and positioned at the given M-Value
 NULL on failure.

 \sa gaiaIsValidTrajectory, gaiaFreeGeomColl

 \note you are responsible to destroy (before or after) any allocated Geometry,
 this including any Geometry returned by gaiaTrajectoryInterpolatePoint()\n
 not reentrant and thread unsafe.
 
 \note a Geometry is considered to be a valid Trajectory if it contains
 a simple LINESTRING supporting M-values growing from each vertex to the next.
 */
    GAIAGEO_DECLARE gaiaGeomCollPtr
	gaiaTrajectoryInterpolatePoint (gaiaGeomCollPtr geom, double m);
................................................................................
 You are responsible to destroy (before or after) any allocated Geometry,
 this including any Geometry returned by gaiaPolygonize()\n
 not reentrant and thread unsafe.
 */
    GAIAGEO_DECLARE gaiaGeomCollPtr gaiaMakePolygon (gaiaGeomCollPtr exterior,
						     gaiaGeomCollPtr interiors);

/**
 Computes the Curvosity Index for some Linestrings

 \param p_cache a memory pointer returned by spatialite_alloc_connection()
 \param line a generic Linestring.
 \param extra_points number of points to be interpolated at regular
 distance into the reference line.

 \return the calculated Curvosity Index (expected to be in the range between 0.0 and 1.0).
 */
    GAIAGEO_DECLARE double gaiaCurvosityIndex (const void *p_cache,
					       gaiaLinestringPtr line,
					       int extra_points);

/**
 Computes the Uphill and Downhill total Height for some 3D Linestrings

 \param line a generic Linestring.
 \param up on completion this variable will contain the total Uphill Height.\n
 Will always be ZERO for any 2D Linestring.
 \param down on completion this variable will contain the total Downhill Height.\n
 Will always be ZERO for any 2D Linestring.

 */
    GAIAGEO_DECLARE void gaiaUpDownHeight (gaiaLinestringPtr line, double *up,
					   double *down);

#ifdef __cplusplus
}
#endif

#endif				/* _GG_CORE_H */

Changes to src/headers/spatialite/gg_mbr.h.

362
363
364
365
366
367
368


369
370
371
372
373
374
















375
376
377
378
379
380


381
382
383
384
385
386















387
388
389
390
391
392


393
394
395
396
397
398
















399
400
401
402
403
404


405
406
407
408
409
410
















411
412
413
414
415
416


417
418
419
420
421
422
















423
424
425
426
427
428


429
430
431
432
433
434















435
436
437
438
439
440


441
442
443
444
445
446
















447
448
449
450
451
452


453
454
455
456
457
458
















459
460
461
462
463
464

/**
 Computes the Z-Range for a Linestring object

 \param line pointer to the Linestring object
 \param min on completion this variable will contain the min Z value found 
 \param max on completion this variable will contain the max Z value found 



 \note if the Linestring has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeLinestring (gaiaLinestringPtr line,
					       double *min, double *max);

















/**
 Computes the Z-Range for a Ring object

 \param rng pointer to the Ring object
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found



 \note if the Ring has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeRing (gaiaRingPtr rng, double *min,
					 double *max);
















/**
 Computes the Z-Range for a Polygon object

 \param polyg pointer to the Polygon object
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found



 \note if the Polygon has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangePolygon (gaiaPolygonPtr polyg, double *min,
					    double *max);

















/**
 Computes the Z-Range for a Geometry object

 \param geom pointer to the Geometry object
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found



 \note if the Geometry has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeGeometry (gaiaGeomCollPtr geom,
					     double *min, double *max);

















/**
 Computes the M-Range for a Linestring object

 \param line pointer to the Linestring object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found



 \note if the Linestring has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeLinestring (gaiaLinestringPtr line,
					       double *min, double *max);

















/**
 Computes the M-Range for a Ring object

 \param rng pointer to the Ring object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found



 \note if the Ring has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeRing (gaiaRingPtr rng, double *min,
					 double *max);
















/**
 Computes the M-Range for a Polygon object

 \param polyg pointer to the Polygon object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found



 \note if the Polygon has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangePolygon (gaiaPolygonPtr polyg, double *min,
					    double *max);

















/**
 Computes the Z-Range for a Geometry object

 \param geom pointer to the Geometry object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found



 \note if the Geometry has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeGeometry (gaiaGeomCollPtr geom,
					     double *min, double *max);


















#ifdef __cplusplus
}
#endif

#endif				/* _GG_MBR_H */







>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606

/**
 Computes the Z-Range for a Linestring object

 \param line pointer to the Linestring object
 \param min on completion this variable will contain the min Z value found 
 \param max on completion this variable will contain the max Z value found 
 
 \sa gaiaZRangeLinestringEx

 \note if the Linestring has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeLinestring (gaiaLinestringPtr line,
					       double *min, double *max);

/**
 Computes the Z-Range for a Linestring object (NODATA flavor)

 \param line pointer to the Linestring object
 \param nodata the NODATA value
 \param min on completion this variable will contain the min Z value found 
 \param max on completion this variable will contain the max Z value found
 
 \sa gaiaZRangeLinestring 

 \note if the Linestring has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeLinestringEx (gaiaLinestringPtr line,
						 double nodata, double *min,
						 double *max);

/**
 Computes the Z-Range for a Ring object

 \param rng pointer to the Ring object
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found
 
 \sa gaiaZRangeRingEx

 \note if the Ring has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeRing (gaiaRingPtr rng, double *min,
					 double *max);

/**
 Computes the Z-Range for a Ring object (NODATA flavor)

 \param rng pointer to the Ring object
 \param nodata the NODATA value
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found
 
 \sa gaiaZRangeRing

 \note if the Ring has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeRingEx (gaiaRingPtr rng, double nodata,
					   double *min, double *max);

/**
 Computes the Z-Range for a Polygon object

 \param polyg pointer to the Polygon object
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found
 
 \sa gaiaZRangePolygonEx

 \note if the Polygon has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangePolygon (gaiaPolygonPtr polyg, double *min,
					    double *max);

/**
 Computes the Z-Range for a Polygon object (NODATA flavor)

 \param polyg pointer to the Polygon object
 \param nodata the NODATA value
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found
 
 \sa gaiaZRangePolygon

 \note if the Polygon has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangePolygonEx (gaiaPolygonPtr polyg,
					      double nodata, double *min,
					      double *max);

/**
 Computes the Z-Range for a Geometry object

 \param geom pointer to the Geometry object
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found
 
 \sa gaiaZRangeGeometryEx

 \note if the Geometry has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeGeometry (gaiaGeomCollPtr geom,
					     double *min, double *max);

/**
 Computes the Z-Range for a Geometry object (NODATA flavor)

 \param geom pointer to the Geometry object
 \param nodata the NODATA value
 \param min on completion this variable will contain the min Z value found
 \param max on completion this variable will contain the max Z value found
 
 \sa gaiaZRangeGeometry

 \note if the Geometry has XY or XYM dims, the Z-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaZRangeGeometryEx (gaiaGeomCollPtr geom,
					       double nodata, double *min,
					       double *max);

/**
 Computes the M-Range for a Linestring object

 \param line pointer to the Linestring object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangeLinestringEx

 \note if the Linestring has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeLinestring (gaiaLinestringPtr line,
					       double *min, double *max);

/**
 Computes the M-Range for a Linestring object (NODATA flavor)

 \param line pointer to the Linestring object
 \param nodata the NODATA value
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangeLinestring

 \note if the Linestring has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeLinestringEx (gaiaLinestringPtr line,
						 double nodata, double *min,
						 double *max);

/**
 Computes the M-Range for a Ring object

 \param rng pointer to the Ring object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangeRingEx

 \note if the Ring has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeRing (gaiaRingPtr rng, double *min,
					 double *max);

/**
 Computes the M-Range for a Ring object (NODATA flavor)

 \param rng pointer to the Ring object
 \param nodata the NODATA value
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangeRing

 \note if the Ring has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeRingEx (gaiaRingPtr rng, double nodata,
					   double *min, double *max);

/**
 Computes the M-Range for a Polygon object

 \param polyg pointer to the Polygon object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangePolygonEx

 \note if the Polygon has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangePolygon (gaiaPolygonPtr polyg, double *min,
					    double *max);

/**
 Computes the M-Range for a Polygon object (NODATA flavor)

 \param polyg pointer to the Polygon object 
 \param nodata the NODATA value
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangePolygon

 \note if the Polygon has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangePolygonEx (gaiaPolygonPtr polyg,
					      double nodata, double *min,
					      double *max);

/**
 Computes the Z-Range for a Geometry object

 \param geom pointer to the Geometry object
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangeGeometryEx

 \note if the Geometry has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeGeometry (gaiaGeomCollPtr geom,
					     double *min, double *max);

/**
 Computes the Z-Range for a Geometry object (NODATA flavor)

 \param geom pointer to the Geometry object 
 \param nodata the NODATA value
 \param min on completion this variable will contain the min M value found
 \param max on completion this variable will contain the max M value found
 
 \sa gaiaMRangeGeometryEx

 \note if the Geometry has XY or XYZ dims, the M-Range is meaningless
 */
    GAIAGEO_DECLARE void gaiaMRangeGeometryEx (gaiaGeomCollPtr geom,
					       double nodata, double *min,
					       double *max);


#ifdef __cplusplus
}
#endif

#endif				/* _GG_MBR_H */

Changes to src/spatialite/spatialite.c.

4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
....
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
....
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
.....
17503
17504
17505
17506
17507
17508
17509


17510
17511
17512
17513
17514
17515
17516
17517


17518
17519
17520
17521
17522
17523
17524

















17525
17526
17527
17528
17529
17530
17531
.....
17555
17556
17557
17558
17559
17560
17561



17562
17563
17564
17565
17566
17567
17568
.....
17569
17570
17571
17572
17573
17574
17575


17576
17577
17578
17579
17580
17581
17582
17583


17584
17585
17586
17587
17588
17589
17590

















17591
17592
17593
17594
17595
17596
17597
.....
17621
17622
17623
17624
17625
17626
17627



17628
17629
17630
17631
17632
17633
17634
.....
17635
17636
17637
17638
17639
17640
17641


17642
17643
17644
17645
17646
17647
17648
17649


17650
17651
17652
17653
17654
17655
17656

















17657
17658
17659
17660
17661
17662
17663
.....
17687
17688
17689
17690
17691
17692
17693



17694
17695
17696
17697
17698
17699
17700
.....
17701
17702
17703
17704
17705
17706
17707


17708
17709
17710
17711
17712
17713
17714
17715


17716
17717
17718
17719
17720
17721
17722

















17723
17724
17725
17726
17727
17728
17729
.....
17753
17754
17755
17756
17757
17758
17759



17760
17761
17762
17763
17764
17765
17766
.....
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
.....
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
.....
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084































































































































































































































25085
25086
25087
25088
25089
25090
25091
.....
48800
48801
48802
48803
48804
48805
48806



48807
48808
48809



48810
48811
48812
48813
48814
48815
48816
48817
48818



48819
48820
48821



48822
48823
48824
48825
48826
48827
48828
.....
51058
51059
51060
51061
51062
51063
51064






























51065
51066
51067
51068
51069
51070
51071
    const char *db_prefix;
    const char *table;
    const char *column;
    const unsigned char *type;
    const unsigned char *txt_dims;
    int xtype;
    int srid = -1;
    int srid_exists = -1;
    int dimension = 2;
    int dims = -1;
    int auto_dims = -1;
    char sql[1024];
    char *sql2;
    int ret;
    int notNull = 0;
    sqlite3_stmt *stmt;
    char *p_table = NULL;
    char *quoted_prefix;
    char *quoted_table;
    char *quoted_column;
    const char *p_type = NULL;
    const char *p_dims = NULL;
    int n_type = 0;
    int n_dims = 0;
    char *sql_statement;
    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
	  spatialite_e
................................................................................
			sqlite3_errmsg (sqlite));
	  sqlite3_finalize (stmt);
	  goto error;
      }
    sqlite3_finalize (stmt);
    updateTemporaryGeometryTriggers (sqlite, db_prefix, table, column);
    sqlite3_result_int (context, 1);
    switch (xtype)
      {
      case GAIA_POINT:
	  p_type = "POINT";
	  break;
      case GAIA_LINESTRING:
	  p_type = "LINESTRING";
	  break;
      case GAIA_POLYGON:
	  p_type = "POLYGON";
	  break;
      case GAIA_MULTIPOINT:
	  p_type = "MULTIPOINT";
	  break;
      case GAIA_MULTILINESTRING:
	  p_type = "MULTILINESTRING";
	  break;
      case GAIA_MULTIPOLYGON:
	  p_type = "MULTIPOLYGON";
	  break;
      case GAIA_GEOMETRYCOLLECTION:
	  p_type = "GEOMETRYCOLLECTION";
	  break;
      case -1:
	  p_type = "GEOMETRY";
	  break;
      };
    switch (dims)
      {
      case GAIA_XY:
	  p_dims = "XY";
	  break;
      case GAIA_XY_Z:
	  p_dims = "XYZ";
	  break;
      case GAIA_XY_M:
	  p_dims = "XYM";
	  break;
      case GAIA_XY_Z_M:
	  p_dims = "XYZM";
	  break;
      };
    sqlite3_free (p_table);
    return;
  error:
    sqlite3_result_int (context, 0);
    sqlite3_free (p_table);
    return;
}
................................................................................
/ returns 1 on success
/ 0 on failure
*/
    const char *db_prefix;
    const char *table;
    const char *column;
    char *sql_statement;
    char sql[1024];
    char *prefix;
    char *errMsg = NULL;
    int ret;
    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
................................................................................
}

static void
fnct_MinZ (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MinZ(BLOB encoded GEMETRY)


/
/ returns the MinZ coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;


    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }

















    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {



		gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
}

static void
fnct_MaxZ (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MaxZ(BLOB encoded GEMETRY)


/
/ returns the MaxZ coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;


    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }

















    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {



		gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
}

static void
fnct_MinM (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MinM(BLOB encoded GEMETRY)


/
/ returns the MinM coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;


    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }

















    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {



		gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
}

static void
fnct_MaxM (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MaxM(BLOB encoded GEMETRY)


/
/ returns the MaxM coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;


    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }

















    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {



		gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
fnct_LinestringMinSegmentLength (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_LinestringMinSegmentLength(BLOB encoded LINESTRING)
/ ST_LinestringMinSegmentLength(BLOB encoded LINESTRING, BOOL ignore_repeated_vertices)
/
/ returns  the length of the shortest segment in the Linestring
/ or NULL if any error is encountered
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_MIN_SEGMENT_LENGTH);
}

................................................................................
static void
fnct_LinestringMaxSegmentLength (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_LinsetringMaxSegmentLength(BLOB encoded LINESTRING)
/
/ returns  the length of the longest segment in the Linstring
/ or NULL if any error is encountered
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_MAX_SEGMENT_LENGTH);
}

................................................................................
static void
fnct_LinestringAvgSegmentLength (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_LinestringMaxSegmentLength(BLOB encoded LINESTRING)
/
/ returns  the average segment length in the Linstring
/ or NULL if any error is encountered
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_AVG_SEGMENT_LENGTH);
}
































































































































































































































#ifdef ENABLE_RTTOPO		/* only if RTTOPO is enabled */

static void
fnct_3dLength (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
................................................................................
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMinX, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinY", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMinY, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinZ", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,



				fnct_MinZ, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinM", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,



				fnct_MinM, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxX", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMaxX, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxY", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMaxY, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxZ", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,



				fnct_MaxZ, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxM", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,



				fnct_MaxM, 0, 0, 0);
    sqlite3_create_function_v2 (db, "NumPoints", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_NumPoints, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_NumPoints", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_NumPoints, 0, 0, 0);
................................................................................
				fnct_LinestringMaxSegmentLength, 0, 0, 0);
    sqlite3_create_function_v2 (db, "LinestringAvgSegmentLength", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_LinestringAvgSegmentLength, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_LinestringAvgSegmentLength", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_LinestringAvgSegmentLength, 0, 0, 0);






























    sqlite3_create_function_v2 (db, "Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Circularity", 1,







<



<









<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<







 







>
>








>
>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>







 







>
>








>
>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>







 







>
>








>
>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>







 







>
>








>
>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>







 







|







 







|







 







|






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>



>
>
>









>
>
>



>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4983
4984
4985
4986
4987
4988
4989

4990
4991
4992

4993
4994
4995
4996
4997
4998
4999
5000
5001

5002
5003
5004
5005
5006
5007
5008
....
5545
5546
5547
5548
5549
5550
5551










































5552
5553
5554
5555
5556
5557
5558
....
8886
8887
8888
8889
8890
8891
8892

8893
8894
8895
8896
8897
8898
8899
.....
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
.....
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
.....
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
.....
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
.....
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
.....
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
.....
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
.....
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
.....
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
.....
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
.....
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
.....
49073
49074
49075
49076
49077
49078
49079
49080
49081
49082
49083
49084
49085
49086
49087
49088
49089
49090
49091
49092
49093
49094
49095
49096
49097
49098
49099
49100
49101
49102
49103
49104
49105
49106
49107
49108
49109
49110
49111
49112
49113
.....
51343
51344
51345
51346
51347
51348
51349
51350
51351
51352
51353
51354
51355
51356
51357
51358
51359
51360
51361
51362
51363
51364
51365
51366
51367
51368
51369
51370
51371
51372
51373
51374
51375
51376
51377
51378
51379
51380
51381
51382
51383
51384
51385
51386
    const char *db_prefix;
    const char *table;
    const char *column;
    const unsigned char *type;
    const unsigned char *txt_dims;
    int xtype;
    int srid = -1;

    int dimension = 2;
    int dims = -1;
    int auto_dims = -1;

    char *sql2;
    int ret;
    int notNull = 0;
    sqlite3_stmt *stmt;
    char *p_table = NULL;
    char *quoted_prefix;
    char *quoted_table;
    char *quoted_column;
    const char *p_type = NULL;

    int n_type = 0;
    int n_dims = 0;
    char *sql_statement;
    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
	  spatialite_e
................................................................................
			sqlite3_errmsg (sqlite));
	  sqlite3_finalize (stmt);
	  goto error;
      }
    sqlite3_finalize (stmt);
    updateTemporaryGeometryTriggers (sqlite, db_prefix, table, column);
    sqlite3_result_int (context, 1);










































    sqlite3_free (p_table);
    return;
  error:
    sqlite3_result_int (context, 0);
    sqlite3_free (p_table);
    return;
}
................................................................................
/ returns 1 on success
/ 0 on failure
*/
    const char *db_prefix;
    const char *table;
    const char *column;
    char *sql_statement;

    char *prefix;
    char *errMsg = NULL;
    int ret;
    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
................................................................................
}

static void
fnct_MinZ (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MinZ(BLOB encoded GEMETRY)
/    or
/ ST_MinZ(BLOB encoded GEOMETRY, DOUBLE nodata-value)
/
/ returns the MinZ coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;
    double nodata = DBL_MAX;
    int hasNodata = 0;
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaZRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
}

static void
fnct_MaxZ (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MaxZ(BLOB encoded GEMETRY)
/    or
/ ST_MaxZ(BLOB encoded GEOMETRY, DOUBLE nodata-value)
/
/ returns the MaxZ coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;
    double nodata = DBL_MAX;
    int hasNodata = 0;
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaZRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
}

static void
fnct_MinM (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MinM(BLOB encoded GEMETRY)
/    or
/ ST_MinM(BLOB encoded GEOMETRY, DOUBLE nodata-value)
/
/ returns the MinM coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;
    double nodata = DBL_MAX;
    int hasNodata = 0;
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaMRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
}

static void
fnct_MaxM (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ST_MaxM(BLOB encoded GEMETRY)
/    or
/ ST_MaxM(BLOB encoded GEOMETRY, DOUBLE nodata-value)
/
/ returns the MaxM coordinate for current geometry 
/ or NULL if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    double min;
    double max;
    double nodata = DBL_MAX;
    int hasNodata = 0;
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaMRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
................................................................................
fnct_LinestringMinSegmentLength (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_LinestringMinSegmentLength(BLOB encoded LINESTRING)
/ ST_LinestringMinSegmentLength(BLOB encoded LINESTRING, BOOL ignore_repeated_vertices)
/
/ returns the length of the shortest segment in the Linestring
/ or NULL if any error is encountered
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_MIN_SEGMENT_LENGTH);
}

................................................................................
static void
fnct_LinestringMaxSegmentLength (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_LinsetringMaxSegmentLength(BLOB encoded LINESTRING)
/
/ returns the length of the longest segment in the Linestring
/ or NULL if any error is encountered
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_MAX_SEGMENT_LENGTH);
}

................................................................................
static void
fnct_LinestringAvgSegmentLength (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_LinestringMaxSegmentLength(BLOB encoded LINESTRING)
/
/ returns the average segment length in the Linsetring
/ or NULL if any error is encountered
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_AVG_SEGMENT_LENGTH);
}

static void
fnct_CurvosityIndex (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_CurvosityIndex(BLOB encoded LINESTRING)
/    or
/ ST_CurvosityIndex(BLOB encoded LINESTRING, points INTEGER)
/
/ returns the CurvosityIndex of some Linestring
/ or NULL if any error is encountered
/
*/
    unsigned char *p_blob;
    int n_bytes;
    int extra_points = 0;
    double index;
    gaiaLinestringPtr ln;
    gaiaGeomCollPtr geo = NULL;
    int gpkg_amphibious = 0;
    int gpkg_mode = 0;
    struct splite_internal_cache *cache = sqlite3_user_data (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (cache != NULL)
      {
	  gpkg_amphibious = cache->gpkg_amphibious_mode;
	  gpkg_mode = cache->gpkg_mode;
      }
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (argc == 2)
      {
	  if (sqlite3_value_type (argv[1]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  extra_points = sqlite3_value_int (argv[1]);
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo =
	gaiaFromSpatiaLiteBlobWkbEx (p_blob, n_bytes, gpkg_mode,
				     gpkg_amphibious);
    if (!geo)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (!is_single_linestring (geo))
      {
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

    ln = geo->FirstLinestring;
    index = gaiaCurvosityIndex (cache, ln, extra_points);
	sqlite3_result_double (context, index);
}

static void
fnct_UphillHeight (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_UphillHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative Uphill Height of some 3D Linestring
/ or NULL if any error is encountered
/
*/
    unsigned char *p_blob;
    int n_bytes;
    double up;
    double down;
    gaiaLinestringPtr ln;
    gaiaGeomCollPtr geo = NULL;
    int gpkg_amphibious = 0;
    int gpkg_mode = 0;
    struct splite_internal_cache *cache = sqlite3_user_data (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (cache != NULL)
      {
	  gpkg_amphibious = cache->gpkg_amphibious_mode;
	  gpkg_mode = cache->gpkg_mode;
      }
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo =
	gaiaFromSpatiaLiteBlobWkbEx (p_blob, n_bytes, gpkg_mode,
				     gpkg_amphibious);
    if (!geo)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (!is_single_linestring (geo))
      {
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

    ln = geo->FirstLinestring;
    gaiaUpDownHeight (ln, &up, &down);
	sqlite3_result_double (context, up);
}

static void
fnct_DownhillHeight (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_DownhillHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative Downhill Height of some 3D Linestring
/ or NULL if any error is encountered
/
*/
    unsigned char *p_blob;
    int n_bytes;
    double up;
    double down;
    gaiaLinestringPtr ln;
    gaiaGeomCollPtr geo = NULL;
    int gpkg_amphibious = 0;
    int gpkg_mode = 0;
    struct splite_internal_cache *cache = sqlite3_user_data (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (cache != NULL)
      {
	  gpkg_amphibious = cache->gpkg_amphibious_mode;
	  gpkg_mode = cache->gpkg_mode;
      }
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo =
	gaiaFromSpatiaLiteBlobWkbEx (p_blob, n_bytes, gpkg_mode,
				     gpkg_amphibious);
    if (!geo)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (!is_single_linestring (geo))
      {
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

    ln = geo->FirstLinestring;
    gaiaUpDownHeight (ln, &up, &down);
	sqlite3_result_double (context, down);
}

static void
fnct_UpDownHeight (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_UpDownHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative UpDown Height of some 3D Linestring
/ or NULL if any error is encountered
/
*/
    unsigned char *p_blob;
    int n_bytes;
    double up;
    double down;
    gaiaLinestringPtr ln;
    gaiaGeomCollPtr geo = NULL;
    int gpkg_amphibious = 0;
    int gpkg_mode = 0;
    struct splite_internal_cache *cache = sqlite3_user_data (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (cache != NULL)
      {
	  gpkg_amphibious = cache->gpkg_amphibious_mode;
	  gpkg_mode = cache->gpkg_mode;
      }
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo =
	gaiaFromSpatiaLiteBlobWkbEx (p_blob, n_bytes, gpkg_mode,
				     gpkg_amphibious);
    if (!geo)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (!is_single_linestring (geo))
      {
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

    ln = geo->FirstLinestring;
    gaiaUpDownHeight (ln, &up, &down);
	sqlite3_result_double (context, up + down);
}

#ifdef ENABLE_RTTOPO		/* only if RTTOPO is enabled */

static void
fnct_3dLength (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
................................................................................
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMinX, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinY", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMinY, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinZ", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MinZ, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinZ", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MinZ, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinM", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MinM, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MinM", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MinM, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxX", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMaxX, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxY", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MbrMaxY, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxZ", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MaxZ, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxZ", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MaxZ, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxM", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MaxM, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_MaxM", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MaxM, 0, 0, 0);
    sqlite3_create_function_v2 (db, "NumPoints", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_NumPoints, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_NumPoints", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_NumPoints, 0, 0, 0);
................................................................................
				fnct_LinestringMaxSegmentLength, 0, 0, 0);
    sqlite3_create_function_v2 (db, "LinestringAvgSegmentLength", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_LinestringAvgSegmentLength, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_LinestringAvgSegmentLength", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_LinestringAvgSegmentLength, 0, 0, 0);
    sqlite3_create_function_v2 (db, "CurvosityIndex", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_CurvosityIndex", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "CurvosityIndex", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_CurvosityIndex", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "UphillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UphillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_UphillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UphillHeight, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "DownhillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_DownhillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_DownhillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_DownhillHeight, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "UpDownHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UpDownHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_UpDownHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UpDownHeight, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Circularity", 1,

Changes to test/sql_stmt_tests/Makefile.

913
914
915
916
917
918
919












920
921
922
923
924
925
926
...
990
991
992
993
994
995
996








997
998
999
1000
1001
1002
1003
....
2871
2872
2873
2874
2875
2876
2877
















2878
2879
2880
2881
2882
2883
2884
	compressgeometry69.testcase \
	compressgeometry6.testcase \
	compressgeometry7.testcase \
	compressgeometry8.testcase \
	compressgeometry9.testcase \
	createrastercoverages.testcase \
	createuuid1.testcase \












	datalic_register1.testcase \
	datalic_register2.testcase \
	datalic_register3.testcase \
	datalic_register4.testcase \
	datalic_register5.testcase \
	datalic_register6.testcase \
	datalic_register7.testcase \
................................................................................
	dissolve4.testcase \
	dissolve5.testcase \
	dissolve6.testcase \
	dissolve7.testcase \
	dissolve8.testcase \
	dissolve9.testcase \
	dm_m.testcase \








	DSC_1467.JPG \
	DSCN0042.JPG \
	dropgeo1.testcase \
	dropgeo2.testcase \
	dropgeo3.testcase \
	dropgeo4.testcase \
	dropgeo5.testcase \
................................................................................
	trajectorypoint6.testcase \
	trajectorypoint7.testcase \
	trajectorypoint8.testcase \
	trajectorypoint9.testcase \
	trajectorypoint10.testcase \
	trajectorypoint11.testcase \
	trajectorypoint12.testcase \
















	wms_defaultsetting1.testcase \
	wms_defaultsetting2.testcase \
	wms_defaultsetting3.testcase \
	wms_defaultsetting4.testcase \
	wms_defaultsetting5.testcase \
	wms_defaultsetting6.testcase \
	wms_defaultsetting7.testcase \







>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
....
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
....
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
	compressgeometry69.testcase \
	compressgeometry6.testcase \
	compressgeometry7.testcase \
	compressgeometry8.testcase \
	compressgeometry9.testcase \
	createrastercoverages.testcase \
	createuuid1.testcase \
	curvosity1.testcase \
	curvosity2.testcase \
	curvosity3.testcase \
	curvosity4.testcase \
	curvosity5.testcase \
	curvosity6.testcase \
	curvosity7.testcase \
	curvosity8.testcase \
	curvosity9.testcase \
	curvosity10.testcase \
	curvosity11.testcase \
	curvosity12.testcase \
	datalic_register1.testcase \
	datalic_register2.testcase \
	datalic_register3.testcase \
	datalic_register4.testcase \
	datalic_register5.testcase \
	datalic_register6.testcase \
	datalic_register7.testcase \
................................................................................
	dissolve4.testcase \
	dissolve5.testcase \
	dissolve6.testcase \
	dissolve7.testcase \
	dissolve8.testcase \
	dissolve9.testcase \
	dm_m.testcase \
	downhill1.testcase \
	downhill2.testcase \
	downhill3.testcase \
	downhill4.testcase \
	downhill5.testcase \
	downhill6.testcase \
	downhill7.testcase \
	downhill8.testcase \
	DSC_1467.JPG \
	DSCN0042.JPG \
	dropgeo1.testcase \
	dropgeo2.testcase \
	dropgeo3.testcase \
	dropgeo4.testcase \
	dropgeo5.testcase \
................................................................................
	trajectorypoint6.testcase \
	trajectorypoint7.testcase \
	trajectorypoint8.testcase \
	trajectorypoint9.testcase \
	trajectorypoint10.testcase \
	trajectorypoint11.testcase \
	trajectorypoint12.testcase \
	uphill1.testcase \
	uphill2.testcase \
	uphill3.testcase \
	uphill4.testcase \
	uphill5.testcase \
	uphill6.testcase \
	uphill7.testcase \
	uphill8.testcase \
	updown1.testcase \
	updown2.testcase \
	updown3.testcase \
	updown4.testcase \
	updown5.testcase \
	updown6.testcase \
	updown7.testcase \
	updown8.testcase \
	wms_defaultsetting1.testcase \
	wms_defaultsetting2.testcase \
	wms_defaultsetting3.testcase \
	wms_defaultsetting4.testcase \
	wms_defaultsetting5.testcase \
	wms_defaultsetting6.testcase \
	wms_defaultsetting7.testcase \

Changes to test/sql_stmt_tests/Makefile.am.

661
662
663
664
665
666
667












668
669
670
671
672
673
674
...
738
739
740
741
742
743
744








745
746
747
748
749
750
751
....
2619
2620
2621
2622
2623
2624
2625
















2626
2627
2628
2629
2630
2631
2632
	compressgeometry69.testcase \
	compressgeometry6.testcase \
	compressgeometry7.testcase \
	compressgeometry8.testcase \
	compressgeometry9.testcase \
	createrastercoverages.testcase \
	createuuid1.testcase \












	datalic_register1.testcase \
	datalic_register2.testcase \
	datalic_register3.testcase \
	datalic_register4.testcase \
	datalic_register5.testcase \
	datalic_register6.testcase \
	datalic_register7.testcase \
................................................................................
	dissolve4.testcase \
	dissolve5.testcase \
	dissolve6.testcase \
	dissolve7.testcase \
	dissolve8.testcase \
	dissolve9.testcase \
	dm_m.testcase \








	DSC_1467.JPG \
	DSCN0042.JPG \
	dropgeo1.testcase \
	dropgeo2.testcase \
	dropgeo3.testcase \
	dropgeo4.testcase \
	dropgeo5.testcase \
................................................................................
	trajectorypoint6.testcase \
	trajectorypoint7.testcase \
	trajectorypoint8.testcase \
	trajectorypoint9.testcase \
	trajectorypoint10.testcase \
	trajectorypoint11.testcase \
	trajectorypoint12.testcase \
















	wms_defaultsetting1.testcase \
	wms_defaultsetting2.testcase \
	wms_defaultsetting3.testcase \
	wms_defaultsetting4.testcase \
	wms_defaultsetting5.testcase \
	wms_defaultsetting6.testcase \
	wms_defaultsetting7.testcase \







>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
...
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
....
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
	compressgeometry69.testcase \
	compressgeometry6.testcase \
	compressgeometry7.testcase \
	compressgeometry8.testcase \
	compressgeometry9.testcase \
	createrastercoverages.testcase \
	createuuid1.testcase \
	curvosity1.testcase \
	curvosity2.testcase \
	curvosity3.testcase \
	curvosity4.testcase \
	curvosity5.testcase \
	curvosity6.testcase \
	curvosity7.testcase \
	curvosity8.testcase \
	curvosity9.testcase \
	curvosity10.testcase \
	curvosity11.testcase \
	curvosity12.testcase \
	datalic_register1.testcase \
	datalic_register2.testcase \
	datalic_register3.testcase \
	datalic_register4.testcase \
	datalic_register5.testcase \
	datalic_register6.testcase \
	datalic_register7.testcase \
................................................................................
	dissolve4.testcase \
	dissolve5.testcase \
	dissolve6.testcase \
	dissolve7.testcase \
	dissolve8.testcase \
	dissolve9.testcase \
	dm_m.testcase \
	downhill1.testcase \
	downhill2.testcase \
	downhill3.testcase \
	downhill4.testcase \
	downhill5.testcase \
	downhill6.testcase \
	downhill7.testcase \
	downhill8.testcase \
	DSC_1467.JPG \
	DSCN0042.JPG \
	dropgeo1.testcase \
	dropgeo2.testcase \
	dropgeo3.testcase \
	dropgeo4.testcase \
	dropgeo5.testcase \
................................................................................
	trajectorypoint6.testcase \
	trajectorypoint7.testcase \
	trajectorypoint8.testcase \
	trajectorypoint9.testcase \
	trajectorypoint10.testcase \
	trajectorypoint11.testcase \
	trajectorypoint12.testcase \
	uphill1.testcase \
	uphill2.testcase \
	uphill3.testcase \
	uphill4.testcase \
	uphill5.testcase \
	uphill6.testcase \
	uphill7.testcase \
	uphill8.testcase \
	updown1.testcase \
	updown2.testcase \
	updown3.testcase \
	updown4.testcase \
	updown5.testcase \
	updown6.testcase \
	updown7.testcase \
	updown8.testcase \
	wms_defaultsetting1.testcase \
	wms_defaultsetting2.testcase \
	wms_defaultsetting3.testcase \
	wms_defaultsetting4.testcase \
	wms_defaultsetting5.testcase \
	wms_defaultsetting6.testcase \
	wms_defaultsetting7.testcase \

Changes to test/sql_stmt_tests/Makefile.in.

913
914
915
916
917
918
919












920
921
922
923
924
925
926
...
990
991
992
993
994
995
996








997
998
999
1000
1001
1002
1003
....
2871
2872
2873
2874
2875
2876
2877
















2878
2879
2880
2881
2882
2883
2884
	compressgeometry69.testcase \
	compressgeometry6.testcase \
	compressgeometry7.testcase \
	compressgeometry8.testcase \
	compressgeometry9.testcase \
	createrastercoverages.testcase \
	createuuid1.testcase \












	datalic_register1.testcase \
	datalic_register2.testcase \
	datalic_register3.testcase \
	datalic_register4.testcase \
	datalic_register5.testcase \
	datalic_register6.testcase \
	datalic_register7.testcase \
................................................................................
	dissolve4.testcase \
	dissolve5.testcase \
	dissolve6.testcase \
	dissolve7.testcase \
	dissolve8.testcase \
	dissolve9.testcase \
	dm_m.testcase \








	DSC_1467.JPG \
	DSCN0042.JPG \
	dropgeo1.testcase \
	dropgeo2.testcase \
	dropgeo3.testcase \
	dropgeo4.testcase \
	dropgeo5.testcase \
................................................................................
	trajectorypoint6.testcase \
	trajectorypoint7.testcase \
	trajectorypoint8.testcase \
	trajectorypoint9.testcase \
	trajectorypoint10.testcase \
	trajectorypoint11.testcase \
	trajectorypoint12.testcase \
















	wms_defaultsetting1.testcase \
	wms_defaultsetting2.testcase \
	wms_defaultsetting3.testcase \
	wms_defaultsetting4.testcase \
	wms_defaultsetting5.testcase \
	wms_defaultsetting6.testcase \
	wms_defaultsetting7.testcase \







>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
....
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
....
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
	compressgeometry69.testcase \
	compressgeometry6.testcase \
	compressgeometry7.testcase \
	compressgeometry8.testcase \
	compressgeometry9.testcase \
	createrastercoverages.testcase \
	createuuid1.testcase \
	curvosity1.testcase \
	curvosity2.testcase \
	curvosity3.testcase \
	curvosity4.testcase \
	curvosity5.testcase \
	curvosity6.testcase \
	curvosity7.testcase \
	curvosity8.testcase \
	curvosity9.testcase \
	curvosity10.testcase \
	curvosity11.testcase \
	curvosity12.testcase \
	datalic_register1.testcase \
	datalic_register2.testcase \
	datalic_register3.testcase \
	datalic_register4.testcase \
	datalic_register5.testcase \
	datalic_register6.testcase \
	datalic_register7.testcase \
................................................................................
	dissolve4.testcase \
	dissolve5.testcase \
	dissolve6.testcase \
	dissolve7.testcase \
	dissolve8.testcase \
	dissolve9.testcase \
	dm_m.testcase \
	downhill1.testcase \
	downhill2.testcase \
	downhill3.testcase \
	downhill4.testcase \
	downhill5.testcase \
	downhill6.testcase \
	downhill7.testcase \
	downhill8.testcase \
	DSC_1467.JPG \
	DSCN0042.JPG \
	dropgeo1.testcase \
	dropgeo2.testcase \
	dropgeo3.testcase \
	dropgeo4.testcase \
	dropgeo5.testcase \
................................................................................
	trajectorypoint6.testcase \
	trajectorypoint7.testcase \
	trajectorypoint8.testcase \
	trajectorypoint9.testcase \
	trajectorypoint10.testcase \
	trajectorypoint11.testcase \
	trajectorypoint12.testcase \
	uphill1.testcase \
	uphill2.testcase \
	uphill3.testcase \
	uphill4.testcase \
	uphill5.testcase \
	uphill6.testcase \
	uphill7.testcase \
	uphill8.testcase \
	updown1.testcase \
	updown2.testcase \
	updown3.testcase \
	updown4.testcase \
	updown5.testcase \
	updown6.testcase \
	updown7.testcase \
	updown8.testcase \
	wms_defaultsetting1.testcase \
	wms_defaultsetting2.testcase \
	wms_defaultsetting3.testcase \
	wms_defaultsetting4.testcase \
	wms_defaultsetting5.testcase \
	wms_defaultsetting6.testcase \
	wms_defaultsetting7.testcase \

Added test/sql_stmt_tests/curvosity1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - invalid integer geom
:memory: #use in-memory database
SELECT ST_CurvosityIndex(1);
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(1)
(NULL)

Added test/sql_stmt_tests/curvosity10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - text extra-points
:memory: #use in-memory database
SELECT ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), 'extra');
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), 'extra')
(NULL)

Added test/sql_stmt_tests/curvosity11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - BLOB extra-points
:memory: #use in-memory database
SELECT ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), zeroblob(4));
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), zeroblob(4))
(NULL)

Added test/sql_stmt_tests/curvosity12.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - int extra-points
:memory: #use in-memory database
SELECT ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), 3);
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), 3)
1.0

Added test/sql_stmt_tests/curvosity2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - invalid double geom
:memory: #use in-memory database
SELECT ST_CurvosityIndex(1.5);
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(1.5)
(NULL)

Added test/sql_stmt_tests/curvosity3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - invalid text geom
:memory: #use in-memory database
SELECT ST_CurvosityIndex('geom');
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex('geom')
(NULL)

Added test/sql_stmt_tests/curvosity4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - invalid NULL geom
:memory: #use in-memory database
SELECT ST_CurvosityIndex(NULL);
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(NULL)
(NULL)

Added test/sql_stmt_tests/curvosity5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - invalid BLOB geom
:memory: #use in-memory database
SELECT ST_CurvosityIndex(zeroblob(10));
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(zeroblob(10))
(NULL)

Added test/sql_stmt_tests/curvosity6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - invalid Point geom
:memory: #use in-memory database
SELECT ST_CurvosityIndex(MakePoint(11, 42, 4326));
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(MakePoint(11, 42, 4326))
(NULL)

Added test/sql_stmt_tests/curvosity7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - 2D Linestring geom
:memory: #use in-memory database
SELECT ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326));
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326))
0.5

Added test/sql_stmt_tests/curvosity8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - NULL extra-points
:memory: #use in-memory database
SELECT ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), NULL);
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), NULL)
(NULL)

Added test/sql_stmt_tests/curvosity9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_CurvosityIndex - double extra-points
:memory: #use in-memory database
SELECT ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), 1.5);
1 # rows (not including the header row)
1 # columns
ST_CurvosityIndex(GeomFromText('LINESTRING(0 0, 0 10, 10 10, 10 20, 0 20)', 4326), 1.5)
(NULL)

Added test/sql_stmt_tests/downhill1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - invalid integer geom
:memory: #use in-memory database
SELECT ST_DownhillHeight(1);
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight(1)
(NULL)

Added test/sql_stmt_tests/downhill2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - invalid double geom
:memory: #use in-memory database
SELECT ST_DownhillHeight(1.5);
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight(1.5)
(NULL)

Added test/sql_stmt_tests/downhill3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - invalid text geom
:memory: #use in-memory database
SELECT ST_DownhillHeight('geom');
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight('geom')
(NULL)

Added test/sql_stmt_tests/downhill4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - invalid NULL geom
:memory: #use in-memory database
SELECT ST_DownhillHeight(NULL);
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight(NULL)
(NULL)

Added test/sql_stmt_tests/downhill5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - invalid BLOB geom
:memory: #use in-memory database
SELECT ST_DownhillHeight(zeroblob(10));
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight(zeroblob(10))
(NULL)

Added test/sql_stmt_tests/downhill6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - invalid Point geom
:memory: #use in-memory database
SELECT ST_DownhillHeight(MakePoint(11, 42, 4326));
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight(MakePoint(11, 42, 4326))
(NULL)

Added test/sql_stmt_tests/downhill7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - 2D Linestring geom
:memory: #use in-memory database
SELECT ST_DownhillHeight(GeomFromText('LINESTRING(10 10, 20 20, 30 30)', 4326));
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight(GeomFromText('LINESTRING(10 10, 20 20, 30 30)', 4326))
0.0

Added test/sql_stmt_tests/downhill8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_DownhillHeight - 3D Linestring geom
:memory: #use in-memory database
SELECT ST_DownhillHeight(GeomFromText('LINESTRING Z(10 10 0, 20 20 10, 30 30 5)', 4326));
1 # rows (not including the header row)
1 # columns
ST_DownhillHeight(GeomFromText('LINESTRING Z(10 10 0, 20 20 10, 30 30 5)', 4326))
5.0

Added test/sql_stmt_tests/updown1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - invalid integer geom
:memory: #use in-memory database
SELECT ST_UpDownHeight(1);
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight(1)
(NULL)

Added test/sql_stmt_tests/updown2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - invalid double geom
:memory: #use in-memory database
SELECT ST_UpDownHeight(1.5);
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight(1.5)
(NULL)

Added test/sql_stmt_tests/updown3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - invalid text geom
:memory: #use in-memory database
SELECT ST_UpDownHeight('geom');
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight('geom')
(NULL)

Added test/sql_stmt_tests/updown4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - invalid NULL geom
:memory: #use in-memory database
SELECT ST_UpDownHeight(NULL);
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight(NULL)
(NULL)

Added test/sql_stmt_tests/updown5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - invalid BLOB geom
:memory: #use in-memory database
SELECT ST_UpDownHeight(zeroblob(10));
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight(zeroblob(10))
(NULL)

Added test/sql_stmt_tests/updown6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - invalid Point geom
:memory: #use in-memory database
SELECT ST_UpDownHeight(MakePoint(11, 42, 4326));
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight(MakePoint(11, 42, 4326))
(NULL)

Added test/sql_stmt_tests/updown7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - 2D Linestring geom
:memory: #use in-memory database
SELECT ST_UpDownHeight(GeomFromText('LINESTRING(10 10, 20 20, 30 30)', 4326));
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight(GeomFromText('LINESTRING(10 10, 20 20, 30 30)', 4326))
0.0

Added test/sql_stmt_tests/updown8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UpDownHeight - 3D Linestring geom
:memory: #use in-memory database
SELECT ST_UpDownHeight(GeomFromText('LINESTRING Z(10 10 0, 20 20 10, 30 30 5)', 4326));
1 # rows (not including the header row)
1 # columns
ST_UpDownHeight(GeomFromText('LINESTRING Z(10 10 0, 20 20 10, 30 30 5)', 4326))
15.0

Added test/sql_stmt_tests/uphill1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - invalid integer geom
:memory: #use in-memory database
SELECT ST_UphillHeight(1);
1 # rows (not including the header row)
1 # columns
ST_UphillHeight(1)
(NULL)

Added test/sql_stmt_tests/uphill2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - invalid double geom
:memory: #use in-memory database
SELECT ST_UphillHeight(1.5);
1 # rows (not including the header row)
1 # columns
ST_UphillHeight(1.5)
(NULL)

Added test/sql_stmt_tests/uphill3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - invalid text geom
:memory: #use in-memory database
SELECT ST_UphillHeight('geom');
1 # rows (not including the header row)
1 # columns
ST_UphillHeight('geom')
(NULL)

Added test/sql_stmt_tests/uphill4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - invalid NULL geom
:memory: #use in-memory database
SELECT ST_UphillHeight(NULL);
1 # rows (not including the header row)
1 # columns
ST_UphillHeight(NULL)
(NULL)

Added test/sql_stmt_tests/uphill5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - invalid BLOB geom
:memory: #use in-memory database
SELECT ST_UphillHeight(zeroblob(10));
1 # rows (not including the header row)
1 # columns
ST_UphillHeight(zeroblob(10))
(NULL)

Added test/sql_stmt_tests/uphill6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - invalid Point geom
:memory: #use in-memory database
SELECT ST_UphillHeight(MakePoint(11, 42, 4326));
1 # rows (not including the header row)
1 # columns
ST_UphillHeight(MakePoint(11, 42, 4326))
(NULL)

Added test/sql_stmt_tests/uphill7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - 2D Linestring geom
:memory: #use in-memory database
SELECT ST_UphillHeight(GeomFromText('LINESTRING(10 10, 20 20, 30 30)', 4326));
1 # rows (not including the header row)
1 # columns
ST_UphillHeight(GeomFromText('LINESTRING(10 10, 20 20, 30 30)', 4326))
0.0

Added test/sql_stmt_tests/uphill8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ST_UphillHeight - 3D Linestring geom
:memory: #use in-memory database
SELECT ST_UphillHeight(GeomFromText('LINESTRING Z(10 10 0, 20 20 10, 30 30 5)', 4326));
1 # rows (not including the header row)
1 # columns
ST_UphillHeight(GeomFromText('LINESTRING Z(10 10 0, 20 20 10, 30 30 5)', 4326))
10.0