Check-in [10c77399be]
Not logged in

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

Overview
Comment:implementing XB_MLineFromGPX
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 10c77399beb2f25e4e0d281af73120034b6f740b
User & Date: sandro 2015-12-11 00:33:25
Context
2015-12-12
09:36
fixing the default datetime (M coord) for GPX tracks check-in: a080c1ba35 user: sandro tags: trunk
2015-12-11
00:33
implementing XB_MLineFromGPX check-in: 10c77399be user: sandro tags: trunk
2015-12-07
18:37
fixing an issue in KNN check-in: 907a56f20f user: sandro tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to spatialite-sql-latest.html.

3822
3823
3824
3825
3826
3827
3828






3829
3830
3831
3832
3833
3834
3835
....
3909
3910
3911
3912
3913
3914
3915







3916
3917
3918
3919
3920
3921
3922
					corresponding to a function invocation on NULL arguments.</td></tr>
			<tr><td><b>XB_IsSvg</b></td>
				<td>XB_IsSvg( xmlObject <i>XmlBLOB</i> ) : <i>Integer</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and &#8211;1 for UNKNOWN
					corresponding to a function invocation on NULL arguments.</td></tr>






			<tr><td><b>XB_GetDocumentSize</b></td>
				<td>XB_GetDocumentSize( xmlObject <i>XmlBLOB</i> ) : <i>Integer</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>Will return the size in bytes of the corresponding uncompressed XmlDocument.<hr>
				<b>NULL</b> will be returned for any invalid input (not a valid XmlBLOB object).</td></tr>
			<tr><td><b>XB_GetEncoding</b></td>
................................................................................
				<b>NULL</b> will be returned for any invalid input (not a valid XmlBLOB object), or when no Abstract is defined.<hr>Supported only on ISO Metadata and SLD/SE Styles.</td></tr>
			<tr><td><b>XB_GetGeometry</b></td>
				<td>XB_GetGeometry( xmlObject <i>XmlBLOB</i> ) : <i>Geometry</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>Will return the Geometry (Bounding Box) defined within the XmlBLOB (if any).<hr>
				<b>NULL</b> will be returned for any invalid input (not a valid XmlBLOB object), or when no Bounding Box is defined.<hr>Supported only on ISO Metadata XML Documents.</td></tr>







			<tr><td><b>XB_GetLastParseError</b></td>
				<td>XB_GetLastParseError( <i>void</i> ) : <i>String</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>Will return the most recent XML parsing error (if any).<hr>
				<b>NULL</b> will be returned if there is no pending parsing error.</td></tr>
			<tr><td><b>XB_GetLastValidateError</b></td>







>
>
>
>
>
>







 







>
>
>
>
>
>
>







3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
....
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
					corresponding to a function invocation on NULL arguments.</td></tr>
			<tr><td><b>XB_IsSvg</b></td>
				<td>XB_IsSvg( xmlObject <i>XmlBLOB</i> ) : <i>Integer</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and &#8211;1 for UNKNOWN
					corresponding to a function invocation on NULL arguments.</td></tr>
			<tr><td><b>XB_IsGpx</b></td>
				<td>XB_IsGpx( xmlObject <i>XmlBLOB</i> ) : <i>Integer</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and &#8211;1 for UNKNOWN
					corresponding to a function invocation on NULL arguments.</td></tr>
			<tr><td><b>XB_GetDocumentSize</b></td>
				<td>XB_GetDocumentSize( xmlObject <i>XmlBLOB</i> ) : <i>Integer</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>Will return the size in bytes of the corresponding uncompressed XmlDocument.<hr>
				<b>NULL</b> will be returned for any invalid input (not a valid XmlBLOB object).</td></tr>
			<tr><td><b>XB_GetEncoding</b></td>
................................................................................
				<b>NULL</b> will be returned for any invalid input (not a valid XmlBLOB object), or when no Abstract is defined.<hr>Supported only on ISO Metadata and SLD/SE Styles.</td></tr>
			<tr><td><b>XB_GetGeometry</b></td>
				<td>XB_GetGeometry( xmlObject <i>XmlBLOB</i> ) : <i>Geometry</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>Will return the Geometry (Bounding Box) defined within the XmlBLOB (if any).<hr>
				<b>NULL</b> will be returned for any invalid input (not a valid XmlBLOB object), or when no Bounding Box is defined.<hr>Supported only on ISO Metadata XML Documents.</td></tr>
			<tr><td><b>XB_MLineFromGPX</b></td>
				<td>XB_MLineFromGPX( xmlObject <i>XmlBLOB</i> ) : <i>Geometry</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>Will return a Geometry of the <b>MULTILINESTRING XYZM</b> type by parsing an XmlBLOB corresponding to a GPX document.<hr>
				<b>NULL</b> will be returned for any invalid input (not a valid XmlBLOB object), or when a valid XmlBLOB does not contains a GPX document, or when a valid GPX
				does not contains any <b>&lt;trk&gt;</b> tag.</td></tr>
			<tr><td><b>XB_GetLastParseError</b></td>
				<td>XB_GetLastParseError( <i>void</i> ) : <i>String</i></td>
				<td></td>
				<td align="center" bgcolor="#99d099">libxml2</td>
				<td>Will return the most recent XML parsing error (if any).<hr>
				<b>NULL</b> will be returned if there is no pending parsing error.</td></tr>
			<tr><td><b>XB_GetLastValidateError</b></td>

Changes to src/gaiageo/gg_xml.c.

434
435
436
437
438
439
440
441
442
443
444
445
446
447
448

449
450
451
452
453
454
455
...
483
484
485
486
487
488
489


490
491
492
493
494
495
496
....
1463
1464
1465
1466
1467
1468
1469

1470
1471
1472
1473
1474
1475
1476
....
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
....
1678
1679
1680
1681
1682
1683
1684


1685
1686
1687
1688
1689
1690
1691
....
1820
1821
1822
1823
1824
1825
1826

1827
1828
1829
1830
1831
1832
1833
....
1850
1851
1852
1853
1854
1855
1856


1857
1858
1859
1860
1861
1862
1863
....
2011
2012
2013
2014
2015
2016
2017


2018
2019
2020
2021
2022
2023
2024
....
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
....
4214
4215
4216
4217
4218
4219
4220





































































































































































































































































































































4221
4222
4223
4224
4225
4226
4227
	  node = node->next;
      }
}

static void
sniff_payload (xmlDocPtr xml_doc, int *is_iso_metadata,
	       int *is_sld_se_vector_style, int *is_sld_se_raster_style,
	       int *is_sld_style, int *is_svg)
{
/* sniffing the payload type */
    xmlNodePtr root = xmlDocGetRootElement (xml_doc);
    *is_iso_metadata = 0;
    *is_sld_se_vector_style = 0;
    *is_sld_se_raster_style = 0;
    *is_svg = 0;

    if (root->name != NULL)
      {
	  const char *name = (const char *) (root->name);
	  if (strcmp (name, "MD_Metadata") == 0)
	      *is_iso_metadata = 1;
	  if (strcmp (name, "FeatureTypeStyle") == 0
	      || strcmp (name, "PointSymbolizer") == 0
................................................................................
		      /* vector style */
		      *is_sld_se_vector_style = 1;
		  }
		*is_sld_style = 1;
	    }
	  if (strcmp (name, "svg") == 0)
	      *is_svg = 1;


      }
}

static void
find_iso_ids (xmlNodePtr node, const char *name, char **string, int *open_tag,
	      int *char_string, int *count)
{
................................................................................
    xmlSchemaParserCtxtPtr parser_ctxt;
    xmlSchemaValidCtxtPtr valid_ctxt;
    int is_iso_metadata = 0;
    int is_sld_se_vector_style = 0;
    int is_sld_se_raster_style = 0;
    int is_sld_style = 0;
    int is_svg = 0;

    int len;
    int zip_len;
    short uri_len = 0;
    short fileid_len = 0;
    short parentid_len = 0;
    short name_len = 0;
    short title_len = 0;
................................................................................
		return;
	    }
	  xmlSchemaFreeValidCtxt (valid_ctxt);
      }

/* testing for special cases: ISO Metadata, SLD/SE Styles and SVG */
    sniff_payload (xml_doc, &is_iso_metadata, &is_sld_se_vector_style,
		   &is_sld_se_raster_style, &is_sld_style, &is_svg);
    if (is_iso_metadata)
	retrieve_iso_identifiers (xml_doc, &fileIdentifier,
				  &parentIdentifier, &title, &abstract,
				  &geometry, &geometry_len);
    if (is_sld_style)
	retrieve_sld_identifiers (xml_doc, &name, &title, &abstract);
    else if (is_sld_se_vector_style || is_sld_se_raster_style)
................................................................................
	flags |= GAIA_XML_SLD_SE_VECTOR_STYLE;
    if (is_sld_se_raster_style)
	flags |= GAIA_XML_SLD_SE_RASTER_STYLE;
    if (is_sld_style)
	flags |= GAIA_XML_SLD_STYLE;
    if (is_svg)
	flags |= GAIA_XML_SVG;


    *(buf + 1) = flags;		/* XmlBLOB flags */
    *(buf + 2) = GAIA_XML_HEADER;	/* HEADER signature */
    gaiaExport32 (buf + 3, xml_len, 1, endian_arch);	/* the uncompressed XMLDocument size */
    gaiaExport32 (buf + 7, zip_len, 1, endian_arch);	/* the compressed XMLDocument size */
    gaiaExport16 (buf + 11, uri_len, 1, endian_arch);	/* the SchemaURI length in bytes */
    *(buf + 13) = GAIA_XML_SCHEMA;	/* SCHEMA signature */
    ptr = buf + 14;
................................................................................
    char *abstract;
    unsigned char *geometry;
    int is_iso_metadata = 0;
    int is_sld_se_vector_style = 0;
    int is_sld_se_raster_style = 0;
    int is_sld_style = 0;
    int is_svg = 0;

    unsigned char *xml;
    unsigned char *buf;
    unsigned char *ptr;
    unsigned char flags;
    int legacy_blob = 0;
    int endian_arch = gaiaEndianArch ();

................................................................................
	is_sld_se_vector_style = 1;
    if ((flag & GAIA_XML_SLD_SE_RASTER_STYLE) == GAIA_XML_SLD_SE_RASTER_STYLE)
	is_sld_se_raster_style = 1;
    if ((flag & GAIA_XML_SLD_STYLE) == GAIA_XML_SLD_STYLE)
	is_sld_style = 1;
    if ((flag & GAIA_XML_SVG) == GAIA_XML_SVG)
	is_svg = 1;


    in_xml_len = gaiaImport32 (blob + 3, little_endian, endian_arch);
    in_zip_len = gaiaImport32 (blob + 7, little_endian, endian_arch);
    uri_len = gaiaImport16 (blob + 11, little_endian, endian_arch);
    ptr = (unsigned char *) blob + 14;
    if (uri_len)
      {
	  schemaURI = (char *) ptr;
................................................................................
	flags |= GAIA_XML_SLD_SE_VECTOR_STYLE;
    if (is_sld_se_raster_style)
	flags |= GAIA_XML_SLD_SE_RASTER_STYLE;
    if (is_sld_style)
	flags |= GAIA_XML_SLD_STYLE;
    if (is_svg)
	flags |= GAIA_XML_SVG;


    *(buf + 1) = flags;		/* XmlBLOB flags */
    *(buf + 2) = GAIA_XML_HEADER;	/* HEADER signature */
    gaiaExport32 (buf + 3, out_xml_len, 1, endian_arch);	/* the uncompressed XMLDocument size */
    gaiaExport32 (buf + 7, out_zip_len, 1, endian_arch);	/* the compressed XMLDocument size */
    gaiaExport16 (buf + 11, uri_len, 1, endian_arch);	/* the SchemaURI length in bytes */
    *(buf + 13) = GAIA_XML_SCHEMA;	/* SCHEMA signature */
    ptr = buf + 14;
................................................................................
	sld_style = 1;
    return sld_style;
}

GAIAGEO_DECLARE int
gaiaIsSvgXmlBlob (const unsigned char *blob, int blob_size)
{
/* Checks if a valid XmlBLOB buffer does actually contains an SLD/SE Style or not */
    int svg = 0;
    unsigned char flag;

/* validity check */
    if (!gaiaIsValidXmlBlob (blob, blob_size))
	return -1;		/* cannot be an XmlBLOB */
    flag = *(blob + 1);
    if ((flag & GAIA_XML_SVG) == GAIA_XML_SVG)
	svg = 1;
    return svg;
}

















GAIAGEO_DECLARE int
gaiaXmlBlobGetDocumentSize (const unsigned char *blob, int blob_size)
{
/* Return the XMLDocument size (in bytes) from a valid XmlBLOB buffer */
    int little_endian = 0;
    unsigned char flag;
................................................................................
	  xmlSetGenericErrorFunc ((void *) stderr, NULL);
	  return encoding;
      }
    xmlFreeDoc (xml_doc);
    xmlSetGenericErrorFunc ((void *) stderr, NULL);
    return NULL;
}






































































































































































































































































































































GAIAGEO_DECLARE char *
gaia_libxml2_version (void)
{
/* return the current LIBXML2 version */
    int len;
    char *version;







|







>







 







>
>







 







>







 







|







 







>
>







 







>







 







>
>







 







>
>







 







|











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







 







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







434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
....
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
....
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
....
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
....
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
....
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
....
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
....
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
....
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
	  node = node->next;
      }
}

static void
sniff_payload (xmlDocPtr xml_doc, int *is_iso_metadata,
	       int *is_sld_se_vector_style, int *is_sld_se_raster_style,
	       int *is_sld_style, int *is_svg, int *is_gpx)
{
/* sniffing the payload type */
    xmlNodePtr root = xmlDocGetRootElement (xml_doc);
    *is_iso_metadata = 0;
    *is_sld_se_vector_style = 0;
    *is_sld_se_raster_style = 0;
    *is_svg = 0;
    *is_gpx = 0;
    if (root->name != NULL)
      {
	  const char *name = (const char *) (root->name);
	  if (strcmp (name, "MD_Metadata") == 0)
	      *is_iso_metadata = 1;
	  if (strcmp (name, "FeatureTypeStyle") == 0
	      || strcmp (name, "PointSymbolizer") == 0
................................................................................
		      /* vector style */
		      *is_sld_se_vector_style = 1;
		  }
		*is_sld_style = 1;
	    }
	  if (strcmp (name, "svg") == 0)
	      *is_svg = 1;
	  if (strcmp (name, "gpx") == 0)
	      *is_gpx = 1;
      }
}

static void
find_iso_ids (xmlNodePtr node, const char *name, char **string, int *open_tag,
	      int *char_string, int *count)
{
................................................................................
    xmlSchemaParserCtxtPtr parser_ctxt;
    xmlSchemaValidCtxtPtr valid_ctxt;
    int is_iso_metadata = 0;
    int is_sld_se_vector_style = 0;
    int is_sld_se_raster_style = 0;
    int is_sld_style = 0;
    int is_svg = 0;
    int is_gpx = 0;
    int len;
    int zip_len;
    short uri_len = 0;
    short fileid_len = 0;
    short parentid_len = 0;
    short name_len = 0;
    short title_len = 0;
................................................................................
		return;
	    }
	  xmlSchemaFreeValidCtxt (valid_ctxt);
      }

/* testing for special cases: ISO Metadata, SLD/SE Styles and SVG */
    sniff_payload (xml_doc, &is_iso_metadata, &is_sld_se_vector_style,
		   &is_sld_se_raster_style, &is_sld_style, &is_svg, &is_gpx);
    if (is_iso_metadata)
	retrieve_iso_identifiers (xml_doc, &fileIdentifier,
				  &parentIdentifier, &title, &abstract,
				  &geometry, &geometry_len);
    if (is_sld_style)
	retrieve_sld_identifiers (xml_doc, &name, &title, &abstract);
    else if (is_sld_se_vector_style || is_sld_se_raster_style)
................................................................................
	flags |= GAIA_XML_SLD_SE_VECTOR_STYLE;
    if (is_sld_se_raster_style)
	flags |= GAIA_XML_SLD_SE_RASTER_STYLE;
    if (is_sld_style)
	flags |= GAIA_XML_SLD_STYLE;
    if (is_svg)
	flags |= GAIA_XML_SVG;
    if (is_gpx)
	flags |= GAIA_XML_GPX;
    *(buf + 1) = flags;		/* XmlBLOB flags */
    *(buf + 2) = GAIA_XML_HEADER;	/* HEADER signature */
    gaiaExport32 (buf + 3, xml_len, 1, endian_arch);	/* the uncompressed XMLDocument size */
    gaiaExport32 (buf + 7, zip_len, 1, endian_arch);	/* the compressed XMLDocument size */
    gaiaExport16 (buf + 11, uri_len, 1, endian_arch);	/* the SchemaURI length in bytes */
    *(buf + 13) = GAIA_XML_SCHEMA;	/* SCHEMA signature */
    ptr = buf + 14;
................................................................................
    char *abstract;
    unsigned char *geometry;
    int is_iso_metadata = 0;
    int is_sld_se_vector_style = 0;
    int is_sld_se_raster_style = 0;
    int is_sld_style = 0;
    int is_svg = 0;
    int is_gpx = 0;
    unsigned char *xml;
    unsigned char *buf;
    unsigned char *ptr;
    unsigned char flags;
    int legacy_blob = 0;
    int endian_arch = gaiaEndianArch ();

................................................................................
	is_sld_se_vector_style = 1;
    if ((flag & GAIA_XML_SLD_SE_RASTER_STYLE) == GAIA_XML_SLD_SE_RASTER_STYLE)
	is_sld_se_raster_style = 1;
    if ((flag & GAIA_XML_SLD_STYLE) == GAIA_XML_SLD_STYLE)
	is_sld_style = 1;
    if ((flag & GAIA_XML_SVG) == GAIA_XML_SVG)
	is_svg = 1;
    if ((flag & GAIA_XML_GPX) == GAIA_XML_GPX)
	is_gpx = 1;
    in_xml_len = gaiaImport32 (blob + 3, little_endian, endian_arch);
    in_zip_len = gaiaImport32 (blob + 7, little_endian, endian_arch);
    uri_len = gaiaImport16 (blob + 11, little_endian, endian_arch);
    ptr = (unsigned char *) blob + 14;
    if (uri_len)
      {
	  schemaURI = (char *) ptr;
................................................................................
	flags |= GAIA_XML_SLD_SE_VECTOR_STYLE;
    if (is_sld_se_raster_style)
	flags |= GAIA_XML_SLD_SE_RASTER_STYLE;
    if (is_sld_style)
	flags |= GAIA_XML_SLD_STYLE;
    if (is_svg)
	flags |= GAIA_XML_SVG;
    if (is_gpx)
	flags |= GAIA_XML_GPX;
    *(buf + 1) = flags;		/* XmlBLOB flags */
    *(buf + 2) = GAIA_XML_HEADER;	/* HEADER signature */
    gaiaExport32 (buf + 3, out_xml_len, 1, endian_arch);	/* the uncompressed XMLDocument size */
    gaiaExport32 (buf + 7, out_zip_len, 1, endian_arch);	/* the compressed XMLDocument size */
    gaiaExport16 (buf + 11, uri_len, 1, endian_arch);	/* the SchemaURI length in bytes */
    *(buf + 13) = GAIA_XML_SCHEMA;	/* SCHEMA signature */
    ptr = buf + 14;
................................................................................
	sld_style = 1;
    return sld_style;
}

GAIAGEO_DECLARE int
gaiaIsSvgXmlBlob (const unsigned char *blob, int blob_size)
{
/* Checks if a valid XmlBLOB buffer does actually contains an SVG image or not */
    int svg = 0;
    unsigned char flag;

/* validity check */
    if (!gaiaIsValidXmlBlob (blob, blob_size))
	return -1;		/* cannot be an XmlBLOB */
    flag = *(blob + 1);
    if ((flag & GAIA_XML_SVG) == GAIA_XML_SVG)
	svg = 1;
    return svg;
}

GAIAGEO_DECLARE int
gaiaIsGpxXmlBlob (const unsigned char *blob, int blob_size)
{
/* Checks if a valid XmlBLOB buffer does actually contains a GPX document or not */
    int gpx = 0;
    unsigned char flag;

/* validity check */
    if (!gaiaIsValidXmlBlob (blob, blob_size))
	return -1;		/* cannot be an XmlBLOB */
    flag = *(blob + 1);
    if ((flag & GAIA_XML_GPX) == GAIA_XML_GPX)
	gpx = 1;
    return gpx;
}

GAIAGEO_DECLARE int
gaiaXmlBlobGetDocumentSize (const unsigned char *blob, int blob_size)
{
/* Return the XMLDocument size (in bytes) from a valid XmlBLOB buffer */
    int little_endian = 0;
    unsigned char flag;
................................................................................
	  xmlSetGenericErrorFunc ((void *) stderr, NULL);
	  return encoding;
      }
    xmlFreeDoc (xml_doc);
    xmlSetGenericErrorFunc ((void *) stderr, NULL);
    return NULL;
}

static void
parse_gpx_trkpt_values (xmlNodePtr node, double *x, double *y)
{
/* fetching values from a GPX <trkpt> tag */
    struct _xmlAttr *attr;

    *x = 0.0;
    *y = 0.0;

    attr = node->properties;
    while (attr != NULL)
      {
	  /* attributes */
	  if (attr->type == XML_ATTRIBUTE_NODE)
	    {
		const char *name = (const char *) (attr->name);
		xmlNode *text = attr->children;
		if (strcmp (name, "lat") == 0 && text != NULL)
		    *y = atof ((const char *) (text->content));
		if (strcmp (name, "lon") == 0 && text != NULL)
		    *x = atof ((const char *) (text->content));
	    }
	  attr = attr->next;
      }
}

static double
gpx_time2m (sqlite3_stmt * stmt, const char *timestamp)
{
/* transforming a timestamp into an M-value */
    double m = 0.0;
    int ret;

    sqlite3_reset (stmt);
    sqlite3_clear_bindings (stmt);
    sqlite3_bind_text (stmt, 1, timestamp, strlen (timestamp), SQLITE_STATIC);
    while (1)
      {
	  /* scrolling the result set rows */
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE)
	      break;		/* end of result set */
	  if (ret == SQLITE_ROW)
	    {
		if (sqlite3_column_type (stmt, 0) == SQLITE_FLOAT)
		    m = sqlite3_column_double (stmt, 0);
	    }
      }
    return m;
}

static void
parse_gpx_trkpt_children (xmlNodePtr node, sqlite3_stmt * stmt, double *z,
			  double *m)
{
/* parsing the children of a GPX <trkpt> tag */
    xmlNode *text;
    *z = 0.0;
    *m = 2384143.0;		/* Battle of Waterloo */

    while (node)
      {
	  if (node->type == XML_ELEMENT_NODE)
	    {
		const char *name = (const char *) (node->name);
		if (strcmp (name, "ele") == 0)
		  {
		      text = node->children;
		      if (text != NULL)
			  *z = atof ((const char *) (text->content));
		  }
		if (strcmp (name, "time") == 0)
		  {
		      text = node->children;
		      if (text != NULL)
			  *m = gpx_time2m (stmt,
					   (const char *) (text->content));
		  }
	    }
	  node = node->next;
      }
}

static void
parse_gpx_trkpt_tag (xmlNodePtr node, sqlite3_stmt * stmt,
		     gaiaDynamicLinePtr dyn)
{
/* parsing a GPX <trkpt> tag */

    while (node)
      {
	  if (node->type == XML_ELEMENT_NODE)
	    {
		const char *name = (const char *) (node->name);
		if (strcmp (name, "trkpt") == 0)
		  {
		      double x;
		      double y;
		      double z;
		      double m;
		      parse_gpx_trkpt_values (node, &x, &y);
		      parse_gpx_trkpt_children (node->children, stmt, &z, &m);
		      gaiaAppendPointZMToDynamicLine (dyn, x, y, z, m);
		  }
	    }
	  node = node->next;
      }
}

static void
gpx_copy_line (gaiaDynamicLinePtr dyn, gaiaGeomCollPtr geom)
{
/* copying a Linestring from a DynamicLine */
    gaiaPointPtr pt;
    int pts = 0;
    gaiaLinestringPtr ln;
    int iv;

    pt = dyn->First;
    while (pt != NULL)
      {
	  /* counting how many points */
	  pts++;
	  pt = pt->Next;
      }
    if (pts < 2)
	return;

    ln = gaiaAddLinestringToGeomColl (geom, pts);
    iv = 0;
    pt = dyn->First;
    while (pt != NULL)
      {
	  /* copying points */
	  gaiaSetPointXYZM (ln->Coords, iv, pt->X, pt->Y, pt->Z, pt->M);
	  iv++;
	  pt = pt->Next;
      }
}

static void
parse_gpx_trkseg_tag (xmlNodePtr node, sqlite3_stmt * stmt,
		      gaiaGeomCollPtr geom)
{
/* parsing a GPX <trkseg> tag */

    while (node)
      {
	  if (node->type == XML_ELEMENT_NODE)
	    {
		const char *name = (const char *) (node->name);
		if (strcmp (name, "trkseg") == 0)
		  {
		      gaiaDynamicLinePtr dyn = gaiaAllocDynamicLine ();
		      parse_gpx_trkpt_tag (node->children, stmt, dyn);
		      gpx_copy_line (dyn, geom);
		      gaiaFreeDynamicLine (dyn);
		  }
	    }
	  node = node->next;
      }
}

static void
parse_gpx_trk_tag (xmlNodePtr node, sqlite3_stmt * stmt, gaiaGeomCollPtr geom)
{
/* parsing a GPX <trk> tag */

    while (node)
      {
	  if (node->type == XML_ELEMENT_NODE)
	    {
		const char *name = (const char *) (node->name);
		if (strcmp (name, "trk") == 0)
		    parse_gpx_trkseg_tag (node->children, stmt, geom);
	    }
	  node = node->next;
      }
}

static void
parse_gpx_tag (xmlNodePtr node, sqlite3_stmt * stmt, gaiaGeomCollPtr geom)
{
/* parsing a GPX document */

    while (node)
      {
	  if (node->type == XML_ELEMENT_NODE)
	    {
		const char *name = (const char *) (node->name);
		if (strcmp (name, "gpx") == 0)
		    parse_gpx_trk_tag (node->children, stmt, geom);
	    }
	  node = node->next;
      }
}

static void
parse_gpx (xmlDocPtr xml_doc, sqlite3_stmt * stmt, gaiaGeomCollPtr geom)
{
/* attempting to parse a GPX document */
    xmlNodePtr root = xmlDocGetRootElement (xml_doc);
    parse_gpx_tag (root, stmt, geom);
}

GAIAGEO_DECLARE gaiaGeomCollPtr
gaiaXmlBlobMLineFromGPX (const unsigned char *blob, int blob_size,
			 sqlite3 * sqlite)
{
/* Return a MultiLinestring Geometry from a valid XmlBLOB buffer of the GPX type */
    int ret;
    const char *sql;
    sqlite3_stmt *stmt = NULL;
    int compressed = 0;
    int little_endian = 0;
    unsigned char flag;
    const unsigned char *ptr;
    int xml_len;
    int zip_len;
    short uri_len;
    short fileid_len;
    short parentid_len;
    short name_len;
    short title_len;
    short abstract_len;
    short geometry_len;
    unsigned char *xml;
    xmlDocPtr xml_doc;
    int legacy_blob = 0;
    int endian_arch = gaiaEndianArch ();
    xmlGenericErrorFunc silentError = (xmlGenericErrorFunc) spliteSilentError;
    gaiaGeomCollPtr geom = NULL;

/* validity check */
    if (!gaiaIsValidXmlBlob (blob, blob_size))
	return NULL;		/* cannot be an XmlBLOB */
    if (!gaiaIsGpxXmlBlob (blob, blob_size))
	return NULL;		/* not a GPX document */
    if (*(blob + 2) == GAIA_XML_LEGACY_HEADER)
	legacy_blob = 1;
    flag = *(blob + 1);
    if ((flag & GAIA_XML_LITTLE_ENDIAN) == GAIA_XML_LITTLE_ENDIAN)
	little_endian = 1;
    if ((flag & GAIA_XML_COMPRESSED) == GAIA_XML_COMPRESSED)
	compressed = 1;
    xml_len = gaiaImport32 (blob + 3, little_endian, endian_arch);
    zip_len = gaiaImport32 (blob + 7, little_endian, endian_arch);
    ptr = blob + 11;
    uri_len = gaiaImport16 (ptr, little_endian, endian_arch);
    ptr += 3 + uri_len;
    fileid_len = gaiaImport16 (ptr, little_endian, endian_arch);
    ptr += 3 + fileid_len;
    parentid_len = gaiaImport16 (ptr, little_endian, endian_arch);
    ptr += 3 + parentid_len;
    if (!legacy_blob)
      {
	  name_len = gaiaImport16 (ptr, little_endian, endian_arch);
	  ptr += 3 + name_len;
      }
    title_len = gaiaImport16 (ptr, little_endian, endian_arch);
    ptr += 3 + title_len;
    abstract_len = gaiaImport16 (ptr, little_endian, endian_arch);
    ptr += 3 + abstract_len;
    geometry_len = gaiaImport16 (ptr, little_endian, endian_arch);
    ptr += 3 + geometry_len;
    ptr++;
    if (compressed)
      {
	  /* unzipping the XML payload */
	  uLong refLen = xml_len;
	  const Bytef *in = ptr;
	  xml = malloc (xml_len + 1);
	  if (uncompress (xml, &refLen, in, zip_len) != Z_OK)
	    {
		/* uncompress error */
		spatialite_e ("XmlBLOB DEFLATE uncompress error\n");
		free (xml);
		return NULL;
	    }
	  *(xml + xml_len) = '\0';
      }
    else
      {
	  /* just copying the uncompressed XML payload */
	  xml = malloc (xml_len + 1);
	  memcpy (xml, ptr, xml_len);
	  *(xml + xml_len) = '\0';
      }
/* attempting to parse the GPX document */
    xmlSetGenericErrorFunc (NULL, silentError);
    xml_doc =
	xmlReadMemory ((const char *) xml, xml_len, "noname.xml", NULL, 0);
    if (xml_doc == NULL)
      {
	  /* parsing error; not a well-formed XML */
	  xmlSetGenericErrorFunc ((void *) stderr, NULL);
	  return NULL;
      }
    free (xml);

/* creating a prepared SQL statement transforming timestamps into M-values */
    sql = "SELECT julianday(?)";
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	goto end;

    geom = gaiaAllocGeomCollXYZM ();
    geom->Srid = 4326;
    geom->DeclaredType = GAIA_MULTILINESTRING;
    parse_gpx (xml_doc, stmt, geom);
    sqlite3_finalize (stmt);

    if (geom->FirstLinestring == NULL)
      {
	  /* empty geometry: returning NULL */
	  gaiaFreeGeomColl (geom);
	  geom = NULL;
      }

  end:
    xmlFreeDoc (xml_doc);
    xmlSetGenericErrorFunc ((void *) stderr, NULL);
    return geom;
}

GAIAGEO_DECLARE char *
gaia_libxml2_version (void)
{
/* return the current LIBXML2 version */
    int len;
    char *version;

Changes to src/headers/spatialite.h.

719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
...
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
...
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
 Remove duplicated rows from a table

 \param sqlite handle to current DB connection
 \param table name of the table to be cleaned

 \sa check_duplicated_rows, remove_duplicated_rows_ex

 \note when two (or more) duplicated rows exist, only the first occurence
 will be preserved, then deleting any further occurrence.
 */
    SPATIALITE_DECLARE void remove_duplicated_rows (sqlite3 * sqlite,
						    char *table);

/**
 Remove duplicated rows from a table
................................................................................
 \param sqlite handle to current DB connection
 \param table name of the table to be cleaned
 \param removed on successful completion will contain the total
 count of removed duplicate rows

 \sa check_duplicated_rows, remove_duplicated_rows_ex2

 \note when two (or more) duplicated rows exist, only the first occurence
 will be preserved, then deleting any further occurrence.
 */
    SPATIALITE_DECLARE void remove_duplicated_rows_ex (sqlite3 * sqlite,
						       char *table,
						       int *removed);

/**
................................................................................
 \param removed on successful completion will contain the total
 count of removed duplicate rows
 \param transaction boolena; if set to TRUE will internally handle
 a SQL Transaction

 \sa check_duplicated_rows, remove_duplicated_rows

 \note when two (or more) duplicated rows exist, only the first occurence
 will be preserved, then deleting any further occurrence.
 */
    SPATIALITE_DECLARE void remove_duplicated_rows_ex2 (sqlite3 * sqlite,
							char *table,
							int *removed,
							int transaction);








|







 







|







 







|







719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
...
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
...
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
 Remove duplicated rows from a table

 \param sqlite handle to current DB connection
 \param table name of the table to be cleaned

 \sa check_duplicated_rows, remove_duplicated_rows_ex

 \note when two (or more) duplicated rows exist, only the first occurrence
 will be preserved, then deleting any further occurrence.
 */
    SPATIALITE_DECLARE void remove_duplicated_rows (sqlite3 * sqlite,
						    char *table);

/**
 Remove duplicated rows from a table
................................................................................
 \param sqlite handle to current DB connection
 \param table name of the table to be cleaned
 \param removed on successful completion will contain the total
 count of removed duplicate rows

 \sa check_duplicated_rows, remove_duplicated_rows_ex2

 \note when two (or more) duplicated rows exist, only the first occurrence
 will be preserved, then deleting any further occurrence.
 */
    SPATIALITE_DECLARE void remove_duplicated_rows_ex (sqlite3 * sqlite,
						       char *table,
						       int *removed);

/**
................................................................................
 \param removed on successful completion will contain the total
 count of removed duplicate rows
 \param transaction boolena; if set to TRUE will internally handle
 a SQL Transaction

 \sa check_duplicated_rows, remove_duplicated_rows

 \note when two (or more) duplicated rows exist, only the first occurrence
 will be preserved, then deleting any further occurrence.
 */
    SPATIALITE_DECLARE void remove_duplicated_rows_ex2 (sqlite3 * sqlite,
							char *table,
							int *removed,
							int transaction);

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

102
103
104
105
106
107
108


109
110
111
112
113
114
115
...
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
...
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
...
312
313
314
315
316
317
318
319
320
321
322















323
324
325
326
327
328
329
...
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627



















628
629
630
631
632
633
634
#define GAIA_XML_SLD_SE_RASTER_STYLE	0x10
/** XmlBLOB FLAG - SLDSE VECTOR STYLE bitmask */
#define GAIA_XML_SLD_SE_VECTOR_STYLE	0x40
/** XmlBLOB FLAG - SLD STYLE bitmask */
#define GAIA_XML_SLD_STYLE		0x48
/** XmlBLOB FLAG - SVG bitmask */
#define GAIA_XML_SVG			0x20




/* function prototypes */

#ifndef DOXYGEN_SHOULD_IGNORE_THIS
#ifdef ENABLE_LIBXML2		/* LIBXML2 enabled: supporting XML documents */
#endif
................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE

 \sa gaiaIsCompressedXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsIsoMetadataXmlBlob, gaiaIsSldSeVectorStyleXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsValidXmlBlob (const unsigned char *blob,
					    int size);

/**
 Checks if a valid XmlBLOB buffer is compressed or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsIsoMetadataXmlBlob, gaiaIsSldSeVectorStyleXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsCompressedXmlBlob (const unsigned char *blob,
						 int size);

/**
 Checks if a valid XmlBLOB buffer does contain an ISO Metadata or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsSldSeVectorStyleXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsIsoMetadataXmlBlob (const unsigned char *blob,
						  int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SLD/SE Style or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB of the 
 Vector type; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSvgXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSldSeVectorStyleXmlBlob (const unsigned char
						       *blob, int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SLD/SE Style or not

................................................................................

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB of the
 Raster type; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeVectorStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSldSeRasterStyleXmlBlob (const unsigned char
						       *blob, int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SLD Style or not

................................................................................

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB of the
 SLD type; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeVectorStyleXmlBlob, gaiaIsSldSeRasterXmlBlob,
 gaiaIsSvgXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSldStyleXmlBlob (const unsigned char
					       *blob, int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SVG Symbol or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeVectorStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSldSeRasterStyleXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSvgXmlBlob (const unsigned char *blob, int size);
















/**
 Return another XmlBLOB buffer compressed / uncompressed

 \param blob pointer to the input XmlBLOB buffer.
 \param in_size input XmlBLOB's size (in bytes).
 \param compressed if TRUE the returned XmlBLOB will be zip-compressed.
 \param result on completion will containt a pointer to the output XmlBLOB:
................................................................................
 \note the returned Abstract corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE char *gaiaXmlBlobGetAbstract (const unsigned char
						  *blob, int size);

/**
 Return the Geometry Buffer from a valid XmlBLOB buffer

 \param blob pointer to the XmlBLOB buffer.
 \param size XmlBLOB's size (in bytes).
 \param blob_geom on completion this variable will contain
 a pointer to the returned Geometry Buffer (NULL if no Geometry
 was defined within the XmlBLOB)
 \param blob_size on completion this variable will contain
 the size (in bytes) of the returned Geometry Buffer

 \sa gaiaIsIsoMetadataXmlBlob

 \note the returned Geometry Buffer corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE void gaiaXmlBlobGetGeometry (const unsigned char
						 *blob, int size,
						 unsigned char **blob_geom,
						 int *blob_size);




















/**
 Return the Charset Encoding from a valid XmlBLOB buffer

 \param blob pointer to the XmlBLOB buffer.
 \param size XmlBLOB's size (in bytes).

 \return the Charset Encoding for any valid XmlBLOB explicitly defining an Encoding; 







>
>







 







|







 







|







 







|







 







|







 







|







 







|







 







|



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







 







|




|


|



|







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







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
...
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
...
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
...
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
#define GAIA_XML_SLD_SE_RASTER_STYLE	0x10
/** XmlBLOB FLAG - SLDSE VECTOR STYLE bitmask */
#define GAIA_XML_SLD_SE_VECTOR_STYLE	0x40
/** XmlBLOB FLAG - SLD STYLE bitmask */
#define GAIA_XML_SLD_STYLE		0x48
/** XmlBLOB FLAG - SVG bitmask */
#define GAIA_XML_SVG			0x20
/** XmlBLOB FLAG - GPX bitmask */
#define GAIA_XML_GPX			0x08


/* function prototypes */

#ifndef DOXYGEN_SHOULD_IGNORE_THIS
#ifdef ENABLE_LIBXML2		/* LIBXML2 enabled: supporting XML documents */
#endif
................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE

 \sa gaiaIsCompressedXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsIsoMetadataXmlBlob, gaiaIsSldSeVectorStyleXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob, gaiaIsGpxXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsValidXmlBlob (const unsigned char *blob,
					    int size);

/**
 Checks if a valid XmlBLOB buffer is compressed or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsIsoMetadataXmlBlob, gaiaIsSldSeVectorStyleXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob, gaiaIsGpxXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsCompressedXmlBlob (const unsigned char *blob,
						 int size);

/**
 Checks if a valid XmlBLOB buffer does contain an ISO Metadata or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsSldSeVectorStyleXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob, gaiaIsGpxXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsIsoMetadataXmlBlob (const unsigned char *blob,
						  int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SLD/SE Style or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB of the 
 Vector type; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSvgXmlBlob, gaiaIsGpxXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSldSeVectorStyleXmlBlob (const unsigned char
						       *blob, int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SLD/SE Style or not

................................................................................

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB of the
 Raster type; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeVectorStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSvgXmlBlob, gaiaIsGpxXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSldSeRasterStyleXmlBlob (const unsigned char
						       *blob, int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SLD Style or not

................................................................................

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB of the
 SLD type; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeVectorStyleXmlBlob, gaiaIsSldSeRasterXmlBlob,
 gaiaIsSvgXmlBlob, gaiaIsGpxXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSldStyleXmlBlob (const unsigned char
					       *blob, int size);

/**
 Checks if a valid XmlBLOB buffer does contain an SVG Symbol or not

................................................................................
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeVectorStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsGpxXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsSvgXmlBlob (const unsigned char *blob, int size);

/**
 Checks if a valid XmlBLOB buffer does contain a GPX document or not

 \param blob pointer to the XmlBLOB buffer.
 \param size XmlBLOB's size (in bytes).

 \return TRUE or FALSE if the BLOB actually is a valid XmlBLOB; -1 in any other case.

 \sa gaiaIsValidXmlBlob, gaiaIsSchemaValidatedXmlBlob, 
 gaiaIsCompressedXmlBlob, gaiaIsIsoMetadataXmlBlob, 
 gaiaIsSldSeVectorStyleXmlBlob, gaiaIsSldStyleXmlBlob,
 gaiaIsSldSeRasterStyleXmlBlob, gaiaIsSvgXmlBlob
 */
    GAIAGEO_DECLARE int gaiaIsGpxXmlBlob (const unsigned char *blob, int size);

/**
 Return another XmlBLOB buffer compressed / uncompressed

 \param blob pointer to the input XmlBLOB buffer.
 \param in_size input XmlBLOB's size (in bytes).
 \param compressed if TRUE the returned XmlBLOB will be zip-compressed.
 \param result on completion will containt a pointer to the output XmlBLOB:
................................................................................
 \note the returned Abstract corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE char *gaiaXmlBlobGetAbstract (const unsigned char
						  *blob, int size);

/**
 Return the Geometry buffer from a valid XmlBLOB buffer

 \param blob pointer to the XmlBLOB buffer.
 \param size XmlBLOB's size (in bytes).
 \param blob_geom on completion this variable will contain
 a pointer to the returned Geometry buffer (NULL if no Geometry
 was defined within the XmlBLOB)
 \param blob_size on completion this variable will contain
 the size (in bytes) of the returned Geometry buffer

 \sa gaiaIsIsoMetadataXmlBlob

 \note the returned Geometry buffer corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE void gaiaXmlBlobGetGeometry (const unsigned char
						 *blob, int size,
						 unsigned char **blob_geom,
						 int *blob_size);

/**
 Return a MultiLinestring Geometry from a valid GPX XmlBLOB buffer

 \param blob pointer to the XmlBLOB buffer.
 \param size XmlBLOB's size (in bytes).
 \param db_handle handle to the current SQLite connection
 
 \return a Geometry of the MultiLinestring type, or NULL

 \sa gaiaIsIsoMetadataXmlBlob

 \note the returned Geometry corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE gaiaGeomCollPtr gaiaXmlBlobMLineFromGPX (const unsigned char
							     *blob, int size,
							     sqlite3 *
							     db_handle);

/**
 Return the Charset Encoding from a valid XmlBLOB buffer

 \param blob pointer to the XmlBLOB buffer.
 \param size XmlBLOB's size (in bytes).

 \return the Charset Encoding for any valid XmlBLOB explicitly defining an Encoding; 

Changes to src/shapefiles/shapefiles.c.

681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
	  if (strcasecmp (dummy, geo_column) == 0)
	      dup = 1;
	  if (dup)
	    {
		xdummy = sqlite3_mprintf ("COL_%d", seed++);
		spatialite_e
		    ("Warning: duplicated fieldName \"%s\" in shapefile \"%s\": "
		     "renaming the second occurence in table \"%s\" as \"%s\".\n",
		     dummy, shp_path, table, xdummy);
		dummy = xdummy;
	    }
	  len = strlen (dummy);
	  *(col_name + cnt) = malloc (len + 1);
	  strcpy (*(col_name + cnt), dummy);
	  if (xdummy)







|







681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
	  if (strcasecmp (dummy, geo_column) == 0)
	      dup = 1;
	  if (dup)
	    {
		xdummy = sqlite3_mprintf ("COL_%d", seed++);
		spatialite_e
		    ("Warning: duplicated fieldName \"%s\" in shapefile \"%s\": "
		     "renaming the second occurrence in table \"%s\" as \"%s\".\n",
		     dummy, shp_path, table, xdummy);
		dummy = xdummy;
	    }
	  len = strlen (dummy);
	  *(col_name + cnt) = malloc (len + 1);
	  strcpy (*(col_name + cnt), dummy);
	  if (xdummy)

Changes to src/spatialite/spatialite.c.

460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
.....
32173
32174
32175
32176
32177
32178
32179

























32180
32181
32182
32183
32184
32185
32186
.....
32641
32642
32643
32644
32645
32646
32647









































32648
32649
32650
32651
32652
32653
32654
.....
38261
38262
38263
38264
38265
38266
38267



38268
38269
38270
38271
38272
38273
38274
.....
38297
38298
38299
38300
38301
38302
38303



38304
38305
38306
38307
38308
38309
38310
*/
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    sqlite3_result_int (context, 0);
}

static void
fnct_has_geos_reentrant (sqlite3_context * context, int argc,
			sqlite3_value ** argv)
{
/* SQL function:
/ HasGeosReentrant()
/
/ return 1 if built including GEOS-REENTRANT; otherwise 0
*/
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
................................................................................
#else
    sqlite3_result_int (context, 0);
#endif
}

static void
fnct_has_geos_only_reentrant (sqlite3_context * context, int argc,
			sqlite3_value ** argv)
{
/* SQL function:
/ HasGeosOnlyReentrant()
/
/ return 1 if built including GEOS-ONLY_REENTRANT; otherwise 0
*/
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
#ifdef GEOS_REENTRANT		/* GEOS-REENTRANT is supported */
#ifdef GEOS_ONLY_REENTRANT		/* GEOS-ONLY-REENTRANT is supported */
    sqlite3_result_int (context, 1);
#else
    sqlite3_result_int (context, 0);
#endif
#else
    sqlite3_result_int (context, 0);
#endif
................................................................................
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    ret = gaiaIsSvgXmlBlob (p_blob, n_bytes);
    sqlite3_result_int (context, ret);
}


























static void
fnct_XB_GetDocumentSize (sqlite3_context * context, int argc,
			 sqlite3_value ** argv)
{
/* SQL function:
/ XB_GetDocumentSize(XmlBLOB)
................................................................................
    n_bytes = sqlite3_value_bytes (argv[0]);
    gaiaXmlBlobGetGeometry (p_blob, n_bytes, &blob, &blob_len);
    if (blob == NULL)
	sqlite3_result_null (context);
    else
	sqlite3_result_blob (context, blob, blob_len, free);
}










































static void
fnct_XB_GetEncoding (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ XB_GetEncoding(XmlBLOB)
/
................................................................................
				fnct_XB_IsSldSeRasterStyle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_IsSldStyle", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_IsSldStyle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_IsSvg", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_IsSvg, 0, 0, 0);



    sqlite3_create_function_v2 (db, "XB_GetSchemaURI", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetSchemaURI, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetInternalSchemaURI", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_XB_GetInternalSchemaURI, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetFileId", 1,
................................................................................
				fnct_XB_GetTitle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetAbstract", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetAbstract, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetGeometry", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetGeometry, 0, 0, 0);



    sqlite3_create_function_v2 (db, "XB_GetDocumentSize", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetDocumentSize, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetEncoding", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetEncoding, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetLastParseError", 0, SQLITE_UTF8,







|







 







|








|







 







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







 







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







 







>
>
>







 







>
>
>







460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
.....
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
.....
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
.....
38327
38328
38329
38330
38331
38332
38333
38334
38335
38336
38337
38338
38339
38340
38341
38342
38343
.....
38366
38367
38368
38369
38370
38371
38372
38373
38374
38375
38376
38377
38378
38379
38380
38381
38382
*/
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    sqlite3_result_int (context, 0);
}

static void
fnct_has_geos_reentrant (sqlite3_context * context, int argc,
			 sqlite3_value ** argv)
{
/* SQL function:
/ HasGeosReentrant()
/
/ return 1 if built including GEOS-REENTRANT; otherwise 0
*/
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
................................................................................
#else
    sqlite3_result_int (context, 0);
#endif
}

static void
fnct_has_geos_only_reentrant (sqlite3_context * context, int argc,
			      sqlite3_value ** argv)
{
/* SQL function:
/ HasGeosOnlyReentrant()
/
/ return 1 if built including GEOS-ONLY_REENTRANT; otherwise 0
*/
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
#ifdef GEOS_REENTRANT		/* GEOS-REENTRANT is supported */
#ifdef GEOS_ONLY_REENTRANT	/* GEOS-ONLY-REENTRANT is supported */
    sqlite3_result_int (context, 1);
#else
    sqlite3_result_int (context, 0);
#endif
#else
    sqlite3_result_int (context, 0);
#endif
................................................................................
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    ret = gaiaIsSvgXmlBlob (p_blob, n_bytes);
    sqlite3_result_int (context, ret);
}

static void
fnct_XB_IsGpx (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ XB_IsGpx(XmlBLOB)
/
/ returns TRUE if the current BLOB is a GPX document XmlBLOB,
/ FALSE if it's a valid XmlBLOB but not a GPX document
/ or -1 if any error is encountered
*/
    unsigned char *p_blob;
    int n_bytes;
    int ret;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    ret = gaiaIsGpxXmlBlob (p_blob, n_bytes);
    sqlite3_result_int (context, ret);
}

static void
fnct_XB_GetDocumentSize (sqlite3_context * context, int argc,
			 sqlite3_value ** argv)
{
/* SQL function:
/ XB_GetDocumentSize(XmlBLOB)
................................................................................
    n_bytes = sqlite3_value_bytes (argv[0]);
    gaiaXmlBlobGetGeometry (p_blob, n_bytes, &blob, &blob_len);
    if (blob == NULL)
	sqlite3_result_null (context);
    else
	sqlite3_result_blob (context, blob, blob_len, free);
}

static void
fnct_XB_MLineFromGPX (sqlite3_context * context, int argc,
		      sqlite3_value ** argv)
{
/* SQL function:
/ XB_MLineFromGPX(XmlBLOB)
/
/ if the BLOB is a valid XmlBLOB of the GPX type then
/ a MultiLinestring will be returned
/ return NULL on any other case
*/
    const unsigned char *p_blob;
    int n_bytes;
    int blob_len;
    unsigned char *blob = NULL;
    gaiaGeomCollPtr geom;
    int gpkg_mode = 0;
    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    struct splite_internal_cache *cache = sqlite3_user_data (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (cache != NULL)
	gpkg_mode = cache->gpkg_mode;
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    p_blob = sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geom = gaiaXmlBlobMLineFromGPX (p_blob, n_bytes, sqlite);
    if (geom != NULL)
      {
	  /* builds the BLOB geometry to be returned */
	  gaiaToSpatiaLiteBlobWkbEx (geom, &blob, &blob_len, gpkg_mode);
	  sqlite3_result_blob (context, blob, blob_len, free);
	  gaiaFreeGeomColl (geom);
      }
    else
	sqlite3_result_null (context);
}

static void
fnct_XB_GetEncoding (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ XB_GetEncoding(XmlBLOB)
/
................................................................................
				fnct_XB_IsSldSeRasterStyle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_IsSldStyle", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_IsSldStyle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_IsSvg", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_IsSvg, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_IsGpx", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_IsGpx, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetSchemaURI", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetSchemaURI, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetInternalSchemaURI", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_XB_GetInternalSchemaURI, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetFileId", 1,
................................................................................
				fnct_XB_GetTitle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetAbstract", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetAbstract, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetGeometry", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetGeometry, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_MLineFromGPX", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_XB_MLineFromGPX, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetDocumentSize", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetDocumentSize, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetEncoding", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_GetEncoding, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_GetLastParseError", 0, SQLITE_UTF8,

Changes to src/srsinit/epsg_update/Makefile.in.

248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = README.txt README-obsolete.txt auto_epsg.c \
	epsg_from_gdal.c auto_epsg_ext.c

all: all-am

.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
	@for dep in $?; do \
	  case '$(am__configure_deps)' in \







|







248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = README.txt README-obsolete.txt auto_epsg.c \
	epsg_from_gdal.c auto_epsg_ext.c check_srid_spatialite.sh

all: all-am

.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
	@for dep in $?; do \
	  case '$(am__configure_deps)' in \

Added test/000323485.gpx.























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?xml version='1.0' encoding='utf-8'?>
<gpx xmlns="http://www.topografix.com/GPX/1/0" version="1.0" creator="OSM gpx_dump.py">
  <trk>
    <name>Track 0</name>
    <number>0</number>
    <trkseg>
      <trkpt lat="37.7709000" lon="-25.2021000" />
      <trkpt lat="37.7710000" lon="-25.2002500" />
      <trkpt lat="37.7696900" lon="-25.1987500" />
      <trkpt lat="37.7699700" lon="-25.1971200" />
      <trkpt lat="37.7710900" lon="-25.1959200" />
      <trkpt lat="37.7724100" lon="-25.1965000" />
      <trkpt lat="37.7732400" lon="-25.1979200" />
      <trkpt lat="37.7742300" lon="-25.1977000" />
      <trkpt lat="37.7753400" lon="-25.1970600" />
      <trkpt lat="37.7767900" lon="-25.1965200" />
      <trkpt lat="37.7764900" lon="-25.1947400" />
      <trkpt lat="37.7780300" lon="-25.1951500" />
      <trkpt lat="37.7788000" lon="-25.1962200" />
      <trkpt lat="37.7796000" lon="-25.1974000" />
      <trkpt lat="37.7803200" lon="-25.1982400" />
      <trkpt lat="37.7815300" lon="-25.1986400" />
      <trkpt lat="37.7816400" lon="-25.2000000" />
      <trkpt lat="37.7833400" lon="-25.2002500" />
      <trkpt lat="37.7845300" lon="-25.2007000" />
      <trkpt lat="37.7860900" lon="-25.2016900" />
      <trkpt lat="37.7867600" lon="-25.2007300" />
      <trkpt lat="37.7858800" lon="-25.1993300" />
      <trkpt lat="37.7859400" lon="-25.1976400" />
      <trkpt lat="37.7854200" lon="-25.1959000" />
      <trkpt lat="37.7856300" lon="-25.1953800" />
      <trkpt lat="37.7863600" lon="-25.1947600" />
      <trkpt lat="37.7868000" lon="-25.1937500" />
      <trkpt lat="37.7874600" lon="-25.1929800" />
      <trkpt lat="37.7877000" lon="-25.1914100" />
      <trkpt lat="37.7887000" lon="-25.1899300" />
      <trkpt lat="37.7897800" lon="-25.1885600" />
      <trkpt lat="37.7913100" lon="-25.1864100" />
      <trkpt lat="37.7936600" lon="-25.1853600" />
      <trkpt lat="37.7961200" lon="-25.1847800" />
    </trkseg>
  </trk>
</gpx>

Added test/Gpx-sample.gpx.











































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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
<?xml version="1.0"?>
<gpx version="1.0" creator="maemo-mapper" xmlns="http://www.topografix.com/GPX/1/0">
  <trk>
    <trkseg>
      <trkpt lat="55.753572" lon="37.808250">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:30Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753622" lon="37.808255">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:31Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753593" lon="37.808158">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:32Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753597" lon="37.808158">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:33Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753587" lon="37.808177">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:34Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753565" lon="37.808157">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:35Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753552" lon="37.808140">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:36Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753513" lon="37.808103">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:37Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753493" lon="37.808077">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:38Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753460" lon="37.808065">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:39Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753457" lon="37.808053">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:40Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753390" lon="37.808072">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:41Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.61</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753365" lon="37.808068">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:42Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753332" lon="37.808057">
        <ele>135.00</ele>
        <time>2009-05-19T04:00:43Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753290" lon="37.808067">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:44Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753275" lon="37.808043">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:45Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753243" lon="37.808033">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:46Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753228" lon="37.808028">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:47Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753200" lon="37.808005">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:48Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753193" lon="37.807987">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:49Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753193" lon="37.807950">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:50Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753185" lon="37.807892">
        <ele>133.00</ele>
        <time>2009-05-19T04:00:51Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753175" lon="37.807818">
        <ele>133.00</ele>
        <time>2009-05-19T04:00:52Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753180" lon="37.807740">
        <ele>133.00</ele>
        <time>2009-05-19T04:00:53Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753183" lon="37.807653">
        <ele>133.00</ele>
        <time>2009-05-19T04:00:54Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753185" lon="37.807547">
        <ele>133.00</ele>
        <time>2009-05-19T04:00:55Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753192" lon="37.807437">
        <ele>133.00</ele>
        <time>2009-05-19T04:00:56Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753203" lon="37.807312">
        <ele>132.00</ele>
        <time>2009-05-19T04:00:57Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753208" lon="37.807168">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:58Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753220" lon="37.807020">
        <ele>134.00</ele>
        <time>2009-05-19T04:00:59Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753238" lon="37.806860">
        <ele>134.00</ele>
        <time>2009-05-19T04:01:00Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.753267" lon="37.806703">
        <ele>134.00</ele>
        <time>2009-05-19T04:01:01Z</time>
        <fix>2d</fix>
        <sat>3</sat>
        <hdop>2.60</hdop>
        <vdop>1.00</vdop>
        <pdop>2.79</pdop>
      </trkpt>
      <trkpt lat="55.758175" lon="37.677798">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:14Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758175" lon="37.677798">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:15Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758175" lon="37.677800">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:16Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677800">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:17Z</time>
        <fix>3d</fix>
        <sat>7</sat>
        <hdop>1.17</hdop>
        <vdop>0.94</vdop>
        <pdop>1.50</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677800">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:18Z</time>
        <fix>3d</fix>
        <sat>7</sat>
        <hdop>1.17</hdop>
        <vdop>0.94</vdop>
        <pdop>1.50</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677802">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:19Z</time>
        <fix>3d</fix>
        <sat>7</sat>
        <hdop>1.17</hdop>
        <vdop>0.94</vdop>
        <pdop>1.50</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677802">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:20Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677800">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:21Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677802">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:22Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677802">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:23Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677803">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:24Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758178" lon="37.677803">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:25Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677803">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:26Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
      <trkpt lat="55.758177" lon="37.677802">
        <ele>152.00</ele>
        <time>2009-05-19T04:46:27Z</time>
        <fix>3d</fix>
        <sat>8</sat>
        <hdop>1.09</hdop>
        <vdop>0.92</vdop>
        <pdop>1.43</pdop>
      </trkpt>
    </trkseg>
  </trk>
</gpx>

Changes to test/Makefile.am.

189
190
191
192
193
194
195
196

197
198
199
200
201
202
203
204
205
206
	getcapabilities-1.1.0.wfs \
	describefeaturetype.wfs	\
	22.dxf f06.dxf l02.dxf p05.dxf \
	archaic.dxf linked.dxf hatch.dxf \
	symbol.dxf gpkg_test.sqlite gpkg_test.gpkg \
	gpkg_test_broken.gpkg gpkg_test_extrasrid.gpkg \
	elba-pg.shp elba-pg.shx elba-pg.dbf \
	elba-ln.shp elba-ln.shx elba-ln.dbf


SUBDIRS = sql_stmt_geosadvanced_tests sql_stmt_geos_tests \
	sql_stmt_libxml2_tests sql_stmt_lwgeom_tests \
	sql_stmt_lwgeom_20_tests sql_stmt_lwgeom_22_tests \
	sql_stmt_mathsql_tests sql_stmt_proj_tests \
	sql_stmt_security_tests sql_stmt_tests \
	sql_stmt_xmlsec_tests sql_stmt_geopackage_tests \
	sql_stmt_freexl_tests sql_stmt_cache_tests \
	sql_stmt_nocache_tests sql_stmt_voronoj1_tests \
	sql_stmt_voronoj2_tests







|
>










189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
	getcapabilities-1.1.0.wfs \
	describefeaturetype.wfs	\
	22.dxf f06.dxf l02.dxf p05.dxf \
	archaic.dxf linked.dxf hatch.dxf \
	symbol.dxf gpkg_test.sqlite gpkg_test.gpkg \
	gpkg_test_broken.gpkg gpkg_test_extrasrid.gpkg \
	elba-pg.shp elba-pg.shx elba-pg.dbf \
	elba-ln.shp elba-ln.shx elba-ln.dbf \
	Gpx-sample.gpx 000323485.gpx

SUBDIRS = sql_stmt_geosadvanced_tests sql_stmt_geos_tests \
	sql_stmt_libxml2_tests sql_stmt_lwgeom_tests \
	sql_stmt_lwgeom_20_tests sql_stmt_lwgeom_22_tests \
	sql_stmt_mathsql_tests sql_stmt_proj_tests \
	sql_stmt_security_tests sql_stmt_tests \
	sql_stmt_xmlsec_tests sql_stmt_geopackage_tests \
	sql_stmt_freexl_tests sql_stmt_cache_tests \
	sql_stmt_nocache_tests sql_stmt_voronoj1_tests \
	sql_stmt_voronoj2_tests

Changes to test/check_libxml2.c.

635
636
637
638
639
640
641




































































































































642
643
644
645
646
647
648
...
720
721
722
723
724
725
726











727
728
729
730
731
732
733
		return 0;
	    }
      }
    free (xml);

    return 1;
}





































































































































#endif

int
main (int argc, char *argv[])
{
    int ret;
................................................................................
	  return -11;
      }
    if (!check_bad_schema (cache))
      {
	  fprintf (stderr, "unable to test invalid Schema\n");
	  return -12;
      }












#endif

    ret = sqlite3_close (handle);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "sqlite3_close() error: %s\n",







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







 







>
>
>
>
>
>
>
>
>
>
>







635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
...
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
		return 0;
	    }
      }
    free (xml);

    return 1;
}

static int
check_mline_gpx (sqlite3 * handle, void *cache, const char *path)
{
/* parsing an XML Sample */
    FILE *fl;
    int sz = 0;
    int rd;
    unsigned char *xml = NULL;
    int uncompressed_sz;
    unsigned char *p_result = NULL;
    gaiaGeomCollPtr geom;
    gaiaLinestringPtr ln;
    double x;
    double y;
    double z;
    double m;

/* loading the XMLDocument */
    fl = fopen (path, "rb");
    if (!fl)
      {
	  fprintf (stderr, "cannot open \"%s\"\n", path);
	  return 0;
      }
    if (fseek (fl, 0, SEEK_END) == 0)
	sz = ftell (fl);
    xml = malloc (sz);
    rewind (fl);
    rd = fread (xml, 1, sz, fl);
    if (rd != sz)
      {
	  fprintf (stderr, "read error \"%s\"\n", path);
	  return 0;
      }
    fclose (fl);

/* parsing the GPX document (no validation / not compressed) */
    gaiaXmlToBlob (cache, xml, rd, 0, NULL, &p_result, &uncompressed_sz, NULL,
		   NULL);
    if (p_result == NULL)
      {
	  fprintf (stderr, "unable to parse(gpx)\"%s\"\n", path);
	  return 0;
      }

    geom = gaiaXmlBlobMLineFromGPX (p_result, uncompressed_sz, handle);
    if (geom == NULL)
      {
	  fprintf (stderr, "XB_MLineFromGPX: unexpected failure \"%s\"\n",
		   path);
	  return 0;
      }

    if (geom->Srid != 4326)
      {
	  fprintf (stderr, "XB_MLineFromGPX: invalid SRID (%d) \"%s\"\n",
		   geom->Srid, path);
	  return 0;
      }
    ln = geom->FirstLinestring;
    if (ln == NULL)
      {
	  fprintf (stderr, "XB_MLineFromGPX: not a Linestring \"%s\"\n", path);
	  return 0;
      }
    if (ln->Points < 5)
      {
	  fprintf (stderr, "XB_MLineFromGPX: too few points \"%s\"\n", path);
	  return 0;
      }
    gaiaGetPointXYZM (ln->Coords, 4, &x, &y, &z, &m);
    if (strcmp (path, "Gpx-sample.gpx") == 0)
      {
	  if (x != 37.808177)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected X=%f \"%s\"\n", x,
			 path);
		return 0;
	    }
	  if (y != 55.753587)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected Y=%f \"%s\"\n", y,
			 path);
		return 0;
	    }
	  if (z != 135.0)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected Z=%f \"%s\"\n", z,
			 path);
		return 0;
	    }
	  if (m < 2454970.667060 || m > 2454970.667061)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected M=%f \"%s\"\n", m,
			 path);
		return 0;
	    }
      }
    else
      {
	  if (x != -25.1959200)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected X=%f \"%s\"\n", x,
			 path);
		return 0;
	    }
	  if (y != 37.7710900)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected Y=%f \"%s\"\n", y,
			 path);
		return 0;
	    }
	  if (z != 0.0)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected Z=%f \"%s\"\n", z,
			 path);
		return 0;
	    }
	  if (m != 2384143.0)
	    {
		fprintf (stderr, "XB_MLineFromGPX: unexpected M=%f \"%s\"\n", m,
			 path);
		return 0;
	    }
      }

    gaiaFreeGeomColl (geom);
    free (p_result);
    free (xml);
    return 1;
}

#endif

int
main (int argc, char *argv[])
{
    int ret;
................................................................................
	  return -11;
      }
    if (!check_bad_schema (cache))
      {
	  fprintf (stderr, "unable to test invalid Schema\n");
	  return -12;
      }

    if (!check_mline_gpx (handle, cache, "000323485.gpx"))
      {
	  fprintf (stderr, "unable to test \"000323485.gpx\"\n");
	  return -13;
      }
    if (!check_mline_gpx (handle, cache, "Gpx-sample.gpx"))
      {
	  fprintf (stderr, "unable to test \"Gpx-sample.gpx\"\n");
	  return -14;
      }

#endif

    ret = sqlite3_close (handle);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "sqlite3_close() error: %s\n",

Changes to test/sql_stmt_libxml2_tests/Makefile.am.

65
66
67
68
69
70
71







72
73
74
75
76
77
78
...
553
554
555
556
557
558
559






560
561
562
563
564
565
566
	issldsestyle1.testcase \
	issldsestyle2.testcase \
	issldsestyle3.testcase \
	issldsestyle4.testcase \
	issldsestyle5.testcase \
	issldsestyle6.testcase \
	issldsestyle7.testcase \







	issvg1.testcase \
	issvg2.testcase \
	issvg3.testcase \
	issvg4.testcase \
	issvg5.testcase \
	issvg6.testcase \
	issvg7.testcase \
................................................................................
	xmlblobgetname8.testcase \
	xmlblobgettitle1.testcase \
	xmlblobgettitle2.testcase \
	xmlblobgettitle3.testcase \
	xmlblobgettitle4.testcase \
	xmlblobgettitle5.testcase \
	xmlblobgettitle6.testcase \






	xmlcompress1.testcase \
	xmlcompress2.testcase \
	xmlcompress3.testcase \
	xmlcompress4.testcase \
	xmlcompress5.testcase \
	xmlcompress6.testcase \
	xmlcompress7.testcase \







>
>
>
>
>
>
>







 







>
>
>
>
>
>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
	issldsestyle1.testcase \
	issldsestyle2.testcase \
	issldsestyle3.testcase \
	issldsestyle4.testcase \
	issldsestyle5.testcase \
	issldsestyle6.testcase \
	issldsestyle7.testcase \
	isgpx1.testcase \
	isgpx2.testcase \
	isgpx3.testcase \
	isgpx4.testcase \
	isgpx5.testcase \
	isgpx6.testcase \
	isgpx7.testcase \
	issvg1.testcase \
	issvg2.testcase \
	issvg3.testcase \
	issvg4.testcase \
	issvg5.testcase \
	issvg6.testcase \
	issvg7.testcase \
................................................................................
	xmlblobgetname8.testcase \
	xmlblobgettitle1.testcase \
	xmlblobgettitle2.testcase \
	xmlblobgettitle3.testcase \
	xmlblobgettitle4.testcase \
	xmlblobgettitle5.testcase \
	xmlblobgettitle6.testcase \
	xmlblobmlinegpx1.testcase \
	xmlblobmlinegpx2.testcase \
	xmlblobmlinegpx3.testcase \
	xmlblobmlinegpx4.testcase \
	xmlblobmlinegpx5.testcase \
	xmlblobmlinegpx6.testcase \
	xmlcompress1.testcase \
	xmlcompress2.testcase \
	xmlcompress3.testcase \
	xmlcompress4.testcase \
	xmlcompress5.testcase \
	xmlcompress6.testcase \
	xmlcompress7.testcase \

Changes to test/sql_stmt_libxml2_tests/Makefile.in.

317
318
319
320
321
322
323







324
325
326
327
328
329
330
...
805
806
807
808
809
810
811






812
813
814
815
816
817
818
	issldsestyle1.testcase \
	issldsestyle2.testcase \
	issldsestyle3.testcase \
	issldsestyle4.testcase \
	issldsestyle5.testcase \
	issldsestyle6.testcase \
	issldsestyle7.testcase \







	issvg1.testcase \
	issvg2.testcase \
	issvg3.testcase \
	issvg4.testcase \
	issvg5.testcase \
	issvg6.testcase \
	issvg7.testcase \
................................................................................
	xmlblobgetname8.testcase \
	xmlblobgettitle1.testcase \
	xmlblobgettitle2.testcase \
	xmlblobgettitle3.testcase \
	xmlblobgettitle4.testcase \
	xmlblobgettitle5.testcase \
	xmlblobgettitle6.testcase \






	xmlcompress1.testcase \
	xmlcompress2.testcase \
	xmlcompress3.testcase \
	xmlcompress4.testcase \
	xmlcompress5.testcase \
	xmlcompress6.testcase \
	xmlcompress7.testcase \







>
>
>
>
>
>
>







 







>
>
>
>
>
>







317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
...
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
	issldsestyle1.testcase \
	issldsestyle2.testcase \
	issldsestyle3.testcase \
	issldsestyle4.testcase \
	issldsestyle5.testcase \
	issldsestyle6.testcase \
	issldsestyle7.testcase \
	isgpx1.testcase \
	isgpx2.testcase \
	isgpx3.testcase \
	isgpx4.testcase \
	isgpx5.testcase \
	isgpx6.testcase \
	isgpx7.testcase \
	issvg1.testcase \
	issvg2.testcase \
	issvg3.testcase \
	issvg4.testcase \
	issvg5.testcase \
	issvg6.testcase \
	issvg7.testcase \
................................................................................
	xmlblobgetname8.testcase \
	xmlblobgettitle1.testcase \
	xmlblobgettitle2.testcase \
	xmlblobgettitle3.testcase \
	xmlblobgettitle4.testcase \
	xmlblobgettitle5.testcase \
	xmlblobgettitle6.testcase \
	xmlblobmlinegpx1.testcase \
	xmlblobmlinegpx2.testcase \
	xmlblobmlinegpx3.testcase \
	xmlblobmlinegpx4.testcase \
	xmlblobmlinegpx5.testcase \
	xmlblobmlinegpx6.testcase \
	xmlcompress1.testcase \
	xmlcompress2.testcase \
	xmlcompress3.testcase \
	xmlcompress4.testcase \
	xmlcompress5.testcase \
	xmlcompress6.testcase \
	xmlcompress7.testcase \

Added test/sql_stmt_libxml2_tests/isgpx1.testcase.

















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

Added test/sql_stmt_libxml2_tests/isgpx2.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_IsGpx - INTEGER XmlBLOB
:memory: #use in-memory database
SELECT XB_IsGpx(1);
1 # rows (not including the header row)
1 # columns
XB_IsGpx(1)
-1

Added test/sql_stmt_libxml2_tests/isgpx3.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_IsGpx - DOUBLE XmlBLOB
:memory: #use in-memory database
SELECT XB_IsGpx(1.1);
1 # rows (not including the header row)
1 # columns
XB_IsGpx(1.1)
-1

Added test/sql_stmt_libxml2_tests/isgpx4.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_IsGpx - TEXT XmlBLOB
:memory: #use in-memory database
SELECT XB_IsGpx('alpha');
1 # rows (not including the header row)
1 # columns
XB_IsGpx('alpha')
-1

Added test/sql_stmt_libxml2_tests/isgpx5.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_IsGpx - invalid XmlBLOB
:memory: #use in-memory database
SELECT XB_IsGpx(zeroblob(100));
1 # rows (not including the header row)
1 # columns
XB_IsGpx(zeroblob(100))
-1

Added test/sql_stmt_libxml2_tests/isgpx6.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_IsGpx - valid XmlBLOB (TRUE)
:memory: #use in-memory database
SELECT XB_IsGpx(x'000BAC070000000F0000000000BA0000CA0000DA0000DE0000DB0000DC0000DDCB789CB3492FA850D0B7030009210219BC37382DE2DD');
1 # rows (not including the header row)
1 # columns
XB_IsGpx(x'000BAC070000000F0000000000BA0000CA0000DA0000DE0000DB0000DC0000DDCB789CB3492FA850D0B7030009210219BC37382DE2DD')
1

Added test/sql_stmt_libxml2_tests/isgpx7.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_IsGpx - valid XmlBLOB (FALSE)
:memory: #use in-memory database
SELECT XB_IsGpx(x'0001AB12000000120000000000BA0000CA0000DA0000DB0000DC0000DDCB3C613E3C623E746578743C2F623E3C2F613EBC49A10C93DD');
1 # rows (not including the header row)
1 # columns
XB_IsGpx(x'0001AB12000000120000000000BA0000CA0000DA0000DB0000DC0000DDCB3C613E3C623E746578743C2F623E3C2F613EBC49A10C93DD')
0

Changes to test/sql_stmt_libxml2_tests/xmlblobgetgeometry4.testcase.

1
2
3
4
5
6
7
8
XB_GetGeometry - BLOB XmlDocument
:memory: #use in-memory database
SELECT XB_GetGeometry(zeroblob(100));
1 # rows (not including the header row)
1 # columns
XB_GetGeometry(zeroblob(100))
(NULL)

|

|


|


1
2
3
4
5
6
7
8
XB_GetGeometry - TEXT XmlDocument
:memory: #use in-memory database
SELECT XB_GetGeometry('alpha');
1 # rows (not including the header row)
1 # columns
XB_GetGeometry('alpha')
(NULL)

Changes to test/sql_stmt_libxml2_tests/xmlblobgetgeometry5.testcase.

1
2
3
4
5
6
7
8
XB_GetGeometry - invalid XmlBLOB
:memory: #use in-memory database
SELECT XB_GetGeometry(zeroblob(100));
1 # rows (not including the header row)
1 # columns
XB_GetGeometry(zeroblob(100))
(NULL)

|







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

Added test/sql_stmt_libxml2_tests/xmlblobmlinegpx1.testcase.

















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

Added test/sql_stmt_libxml2_tests/xmlblobmlinegpx2.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_MLineFromGPX - INTEGER XmlDocument
:memory: #use in-memory database
SELECT XB_MLineFromGPX(1);
1 # rows (not including the header row)
1 # columns
XB_MLineFromGPX(1)
(NULL)

Added test/sql_stmt_libxml2_tests/xmlblobmlinegpx3.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_MLineFromGPX - DOUBLE XmlDocument
:memory: #use in-memory database
SELECT XB_MLineFromGPX(1.1);
1 # rows (not including the header row)
1 # columns
XB_MLineFromGPX(1.1)
(NULL)

Added test/sql_stmt_libxml2_tests/xmlblobmlinegpx4.testcase.

















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

Added test/sql_stmt_libxml2_tests/xmlblobmlinegpx5.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_MLineFromGPX - valid XmlBLOB not a GPX
:memory: #use in-memory database
SELECT XB_MLineFromGPX(x'0001AB12000000120000000000BA0000CA0000DA0000DB0000DC0000DDCB3C613E3C623E746578743C2F623E3C2F613EBC49A10C93DD');
1 # rows (not including the header row)
1 # columns
XB_MLineFromGPX(x'0001AB12000000120000000000BA0000CA0000DA0000DB0000DC0000DDCB3C613E3C623E746578743C2F623E3C2F613EBC49A10C93DD')
(NULL)

Added test/sql_stmt_libxml2_tests/xmlblobmlinegpx6.testcase.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
XB_MLineFromGPX - TEXT XmlDocument
:memory: #use in-memory database
SELECT XB_MLineFromGPX('alpha');
1 # rows (not including the header row)
1 # columns
XB_MLineFromGPX('alpha')
(NULL)