Check-in [56d41a1593]
Not logged in

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

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

Changes to config.h.in.

4
5
6
7
8
9
10



11
12
13
14
15
16
17
..
83
84
85
86
87
88
89



90
91
92
93
94
95
96
#undef ENABLE_GCP

/* Should be defined in order to enable GeoPackage support. */
#undef ENABLE_GEOPACKAGE

/* Should be defined in order to enable LIBXML2 support. */
#undef ENABLE_LIBXML2




/* Should be defined in order to enable RTTOPO support. */
#undef ENABLE_RTTOPO

/* Should be defined in order to enable GEOS_370 support. */
#undef GEOS_370

................................................................................
#undef HAVE_MEMMOVE

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET




/* Define to 1 if you have the <proj_api.h> header file. */
#undef HAVE_PROJ_API_H

/* Define to 1 if you have the <proj.h> header file. */
#undef HAVE_PROJ_H








>
>
>







 







>
>
>







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#undef ENABLE_GCP

/* Should be defined in order to enable GeoPackage support. */
#undef ENABLE_GEOPACKAGE

/* Should be defined in order to enable LIBXML2 support. */
#undef ENABLE_LIBXML2

/* Should be defined in order to enable MiniZIP support. */
#undef ENABLE_MINIZIP

/* Should be defined in order to enable RTTOPO support. */
#undef ENABLE_RTTOPO

/* Should be defined in order to enable GEOS_370 support. */
#undef GEOS_370

................................................................................
#undef HAVE_MEMMOVE

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET

/* Define to 1 if you have the <minizip/unzip.h> header file. */
#undef HAVE_MINIZIP_UNZIP_H

/* Define to 1 if you have the <proj_api.h> header file. */
#undef HAVE_PROJ_API_H

/* Define to 1 if you have the <proj.h> header file. */
#undef HAVE_PROJ_H

Changes to configure.

803
804
805
806
807
808
809

810
811
812
813
814
815
816
....
1473
1474
1475
1476
1477
1478
1479

1480
1481
1482
1483
1484
1485
1486
....
3176
3177
3178
3179
3180
3181
3182

3183
3184
3185
3186
3187
3188
3189
.....
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
.....
18815
18816
18817
18818
18819
18820
18821























































































18822
18823
18824
18825
18826
18827
18828
.....
20139
20140
20141
20142
20143
20144
20145


20146
20147
20148
20149
20150
20151
20152
enable_gcp
enable_geosadvanced
enable_geosreentrant
with_geosonlyreentrant
enable_geos370
enable_rttopo
enable_libxml2

enable_geopackage
enable_gcov
enable_examples
enable_module_only
'
      ac_precious_vars='build_alias
host_alias
................................................................................
  --enable-gcp            enables Control Points (from Grass GIS) [default=no]
  --enable-geosadvanced   enables GEOS advanced features [default=yes]
  --enable-geosreentrant  enables GEOS reentrant (fully thread safe)
                          [default=yes]
  --enable-geos370        enables GEOS 3.7.0 features [default=yes]
  --enable-rttopo         enables RTTOPO support [default=no]
  --enable-libxml2        enables libxml2 inclusion [default=yes]

  --enable-geopackage     enables GeoPackage support [default=yes]
  --enable-gcov           turn on code coverage analysis tools
  --enable-examples       enables building examples [default=yes]
  --enable-module-only    builds only mod_spatialite alone [default=no]

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
................................................................................

# disabling debug support

$as_echo "#define NDEBUG 1" >>confdefs.h


# config depending options








................................................................................
  LIBS="-lz $LIBS"

else
  as_fn_error $? "'libz' is required but it doesn't seem to be installed on this system." "$LINENO" 5
fi


ac_config_files="$ac_config_files Makefile src/Makefile src/headers/Makefile src/gaiaaux/Makefile src/gaiaexif/Makefile src/gaiageo/Makefile src/gaiageo/flex/Makefile src/gaiageo/lemon/Makefile src/gaiageo/lemon/lemon_src/Makefile src/geopackage/Makefile src/spatialite/Makefile src/shapefiles/Makefile src/dxf/Makefile src/md5/Makefile src/control_points/Makefile src/cutter/Makefile src/topology/Makefile src/srsinit/Makefile src/srsinit/epsg_update/Makefile src/stored_procedures/Makefile src/connection_cache/Makefile src/connection_cache/generator/Makefile src/virtualtext/Makefile src/wfs/Makefile test/Makefile test/sql_stmt_tests/Makefile test/sql_stmt_geos_tests/Makefile test/sql_stmt_geos_380/Makefile test/sql_stmt_geos_non380/Makefile test/sql_stmt_geosadvanced_tests/Makefile test/sql_stmt_geopackage_tests/Makefile test/sql_stmt_gpkg_epsg492_tests/Makefile test/sql_stmt_gpkg_epsg493_tests/Makefile test/sql_stmt_gpkg_epsg600_tests/Makefile test/sql_stmt_proj_tests/Makefile test/sql_stmt_proj492_tests/Makefile test/sql_stmt_proj493_tests/Makefile test/sql_stmt_proj600_tests/Makefile test/sql_stmt_proj600security_tests/Makefile test/sql_stmt_mathsql_tests/Makefile test/sql_stmt_rtgeom_tests/Makefile test/sql_stmt_rttopo_tests/Makefile test/sql_stmt_libxml2_tests/Makefile test/sql_stmt_security_tests/Makefile test/sql_stmt_xmlsec_tests/Makefile test/sql_stmt_freexl_tests/Makefile test/sql_stmt_cache_tests/Makefile test/sql_stmt_gpkgcache_tests/Makefile test/sql_stmt_nocache_tests/Makefile test/sql_stmt_gpkgnocache_tests/Makefile test/sql_stmt_voronoj1_tests/Makefile test/sql_stmt_voronoj2_tests/Makefile test/sql_stmt_sequence_tests/Makefile test/sql_stmt_routing_tests/Makefile test/sql_stmt_logfile_tests/Makefile test/sql_stmt_iconv_tests/Makefile test/sql_stmt_proc_tests/Makefile test/sql_stmt_point_geom/Makefile test/sql_stmt_tiny_point/Makefile test/sql_stmt_postgres_tests/Makefile test/sql_stmt_geos370_tests/Makefile test/sql_stmt_renamenew_tests/Makefile test/sql_stmt_renameold_tests/Makefile test/sql_stmt_bufoptsnew_tests/Makefile test/sql_stmt_bufoptsold_tests/Makefile examples/Makefile Doxyfile spatialite.pc"


# exporting the TARGET_CPU string
splite_cpu=`$CC -dumpmachine`
cat >>confdefs.h <<_ACEOF
#define TARGET_CPU "$splite_cpu"
_ACEOF
................................................................................

fi


  $as_echo "#define ENABLE_LIBXML2 1" >>confdefs.h

fi
























































































#-----------------------------------------------------------------------
#   --enable-geopackage
#
# Check whether --enable-geopackage was given.
if test "${enable_geopackage+set}" = set; then :
  enableval=$enable_geopackage;
................................................................................
    "test/sql_stmt_tiny_point/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_tiny_point/Makefile" ;;
    "test/sql_stmt_postgres_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_postgres_tests/Makefile" ;;
    "test/sql_stmt_geos370_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_geos370_tests/Makefile" ;;
    "test/sql_stmt_renamenew_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_renamenew_tests/Makefile" ;;
    "test/sql_stmt_renameold_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_renameold_tests/Makefile" ;;
    "test/sql_stmt_bufoptsnew_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_bufoptsnew_tests/Makefile" ;;
    "test/sql_stmt_bufoptsold_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_bufoptsold_tests/Makefile" ;;


    "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
    "Doxyfile") CONFIG_FILES="$CONFIG_FILES Doxyfile" ;;
    "spatialite.pc") CONFIG_FILES="$CONFIG_FILES spatialite.pc" ;;

  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
  esac
done







>







 







>







 







>







 







|







 







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







 







>
>







803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
....
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
....
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
.....
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
.....
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
.....
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
enable_gcp
enable_geosadvanced
enable_geosreentrant
with_geosonlyreentrant
enable_geos370
enable_rttopo
enable_libxml2
enable_minizip
enable_geopackage
enable_gcov
enable_examples
enable_module_only
'
      ac_precious_vars='build_alias
host_alias
................................................................................
  --enable-gcp            enables Control Points (from Grass GIS) [default=no]
  --enable-geosadvanced   enables GEOS advanced features [default=yes]
  --enable-geosreentrant  enables GEOS reentrant (fully thread safe)
                          [default=yes]
  --enable-geos370        enables GEOS 3.7.0 features [default=yes]
  --enable-rttopo         enables RTTOPO support [default=no]
  --enable-libxml2        enables libxml2 inclusion [default=yes]
  --enable-minizip        enables MiniZIP inclusion [default=yes]
  --enable-geopackage     enables GeoPackage support [default=yes]
  --enable-gcov           turn on code coverage analysis tools
  --enable-examples       enables building examples [default=yes]
  --enable-module-only    builds only mod_spatialite alone [default=no]

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
................................................................................

# disabling debug support

$as_echo "#define NDEBUG 1" >>confdefs.h


# config depending options








................................................................................
  LIBS="-lz $LIBS"

else
  as_fn_error $? "'libz' is required but it doesn't seem to be installed on this system." "$LINENO" 5
fi


ac_config_files="$ac_config_files Makefile src/Makefile src/headers/Makefile src/gaiaaux/Makefile src/gaiaexif/Makefile src/gaiageo/Makefile src/gaiageo/flex/Makefile src/gaiageo/lemon/Makefile src/gaiageo/lemon/lemon_src/Makefile src/geopackage/Makefile src/spatialite/Makefile src/shapefiles/Makefile src/dxf/Makefile src/md5/Makefile src/control_points/Makefile src/cutter/Makefile src/topology/Makefile src/srsinit/Makefile src/srsinit/epsg_update/Makefile src/stored_procedures/Makefile src/connection_cache/Makefile src/connection_cache/generator/Makefile src/virtualtext/Makefile src/wfs/Makefile test/Makefile test/sql_stmt_tests/Makefile test/sql_stmt_geos_tests/Makefile test/sql_stmt_geos_380/Makefile test/sql_stmt_geos_non380/Makefile test/sql_stmt_geosadvanced_tests/Makefile test/sql_stmt_geopackage_tests/Makefile test/sql_stmt_gpkg_epsg492_tests/Makefile test/sql_stmt_gpkg_epsg493_tests/Makefile test/sql_stmt_gpkg_epsg600_tests/Makefile test/sql_stmt_proj_tests/Makefile test/sql_stmt_proj492_tests/Makefile test/sql_stmt_proj493_tests/Makefile test/sql_stmt_proj600_tests/Makefile test/sql_stmt_proj600security_tests/Makefile test/sql_stmt_mathsql_tests/Makefile test/sql_stmt_rtgeom_tests/Makefile test/sql_stmt_rttopo_tests/Makefile test/sql_stmt_libxml2_tests/Makefile test/sql_stmt_security_tests/Makefile test/sql_stmt_xmlsec_tests/Makefile test/sql_stmt_freexl_tests/Makefile test/sql_stmt_cache_tests/Makefile test/sql_stmt_gpkgcache_tests/Makefile test/sql_stmt_nocache_tests/Makefile test/sql_stmt_gpkgnocache_tests/Makefile test/sql_stmt_voronoj1_tests/Makefile test/sql_stmt_voronoj2_tests/Makefile test/sql_stmt_sequence_tests/Makefile test/sql_stmt_routing_tests/Makefile test/sql_stmt_logfile_tests/Makefile test/sql_stmt_iconv_tests/Makefile test/sql_stmt_proc_tests/Makefile test/sql_stmt_point_geom/Makefile test/sql_stmt_tiny_point/Makefile test/sql_stmt_postgres_tests/Makefile test/sql_stmt_geos370_tests/Makefile test/sql_stmt_renamenew_tests/Makefile test/sql_stmt_renameold_tests/Makefile test/sql_stmt_bufoptsnew_tests/Makefile test/sql_stmt_bufoptsold_tests/Makefile test/sql_stmt_minizip/Makefile test/sql_stmt_zip_proj6/Makefile examples/Makefile Doxyfile spatialite.pc"


# exporting the TARGET_CPU string
splite_cpu=`$CC -dumpmachine`
cat >>confdefs.h <<_ACEOF
#define TARGET_CPU "$splite_cpu"
_ACEOF
................................................................................

fi


  $as_echo "#define ENABLE_LIBXML2 1" >>confdefs.h

fi

#-----------------------------------------------------------------------
#   --enable-minizip
#
# Check whether --enable-minizip was given.
if test "${enable_minizip+set}" = set; then :
  enableval=$enable_minizip;
else
  enable_minizip=yes
fi

if test x"$enable_minizip" != "xno"; then
  for ac_header in minizip/unzip.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "minizip/unzip.h" "ac_cv_header_minizip_unzip_h" "$ac_includes_default"
if test "x$ac_cv_header_minizip_unzip_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_MINIZIP_UNZIP_H 1
_ACEOF

else
  as_fn_error $? "cannot find minizip/unzip.h, bailing out" "$LINENO" 5
fi

done

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing unzLocateFile" >&5
$as_echo_n "checking for library containing unzLocateFile... " >&6; }
if ${ac_cv_search_unzLocateFile+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char unzLocateFile ();
int
main ()
{
return unzLocateFile ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' minizip; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_unzLocateFile=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_unzLocateFile+:} false; then :
  break
fi
done
if ${ac_cv_search_unzLocateFile+:} false; then :

else
  ac_cv_search_unzLocateFile=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_unzLocateFile" >&5
$as_echo "$ac_cv_search_unzLocateFile" >&6; }
ac_res=$ac_cv_search_unzLocateFile
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"

else
  as_fn_error $? "'libminizip' is required but it doesn't seem to be installed on this system." "$LINENO" 5
fi

  $as_echo "#define ENABLE_MINIZIP 1" >>confdefs.h

fi

#-----------------------------------------------------------------------
#   --enable-geopackage
#
# Check whether --enable-geopackage was given.
if test "${enable_geopackage+set}" = set; then :
  enableval=$enable_geopackage;
................................................................................
    "test/sql_stmt_tiny_point/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_tiny_point/Makefile" ;;
    "test/sql_stmt_postgres_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_postgres_tests/Makefile" ;;
    "test/sql_stmt_geos370_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_geos370_tests/Makefile" ;;
    "test/sql_stmt_renamenew_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_renamenew_tests/Makefile" ;;
    "test/sql_stmt_renameold_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_renameold_tests/Makefile" ;;
    "test/sql_stmt_bufoptsnew_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_bufoptsnew_tests/Makefile" ;;
    "test/sql_stmt_bufoptsold_tests/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_bufoptsold_tests/Makefile" ;;
    "test/sql_stmt_minizip/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_minizip/Makefile" ;;
    "test/sql_stmt_zip_proj6/Makefile") CONFIG_FILES="$CONFIG_FILES test/sql_stmt_zip_proj6/Makefile" ;;
    "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
    "Doxyfile") CONFIG_FILES="$CONFIG_FILES Doxyfile" ;;
    "spatialite.pc") CONFIG_FILES="$CONFIG_FILES spatialite.pc" ;;

  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
  esac
done

Changes to configure.ac.

55
56
57
58
59
60
61


62
63
64
65
66
67
68
...
175
176
177
178
179
180
181


182
183
184
185
186
187
188
...
412
413
414
415
416
417
418












419
420
421
422
423
424
425
            [Should be defined in order to disable GEOCALLBACKS support.])
AH_TEMPLATE([OMIT_KNN],
            [Should be defined in order to disable KNN support.])
AH_TEMPLATE([OMIT_FREEXL],
            [Should be defined in order to disable FREEXL support.])
AH_TEMPLATE([ENABLE_LIBXML2],
            [Should be defined in order to enable LIBXML2 support.])


AH_TEMPLATE([ENABLE_GEOPACKAGE],
            [Should be defined in order to enable GeoPackage support.])
AH_TEMPLATE([TARGET_CPU],
            [Should contain a text-string describing the intended target CPU])
AH_TEMPLATE([HAVE_DECL_SQLITE_INDEX_CONSTRAINT_LIKE],
            [depending on SQLite library version.])

................................................................................
		test/sql_stmt_tiny_point/Makefile \
		test/sql_stmt_postgres_tests/Makefile \
		test/sql_stmt_geos370_tests/Makefile \
		test/sql_stmt_renamenew_tests/Makefile \
		test/sql_stmt_renameold_tests/Makefile \
		test/sql_stmt_bufoptsnew_tests/Makefile \
		test/sql_stmt_bufoptsold_tests/Makefile \


		examples/Makefile \
		Doxyfile \
		spatialite.pc])

# exporting the TARGET_CPU string
splite_cpu=`$CC -dumpmachine`
AC_DEFINE_UNQUOTED([TARGET_CPU], ["$splite_cpu"])
................................................................................
  [], [enable_libxml2=yes])
if test x"$enable_libxml2" != "xno"; then
  PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], , AC_MSG_ERROR(['libxml2' is required but it doesn't seem to be installed on this system.]))
  AC_SUBST(LIBXML2_CFLAGS)
  AC_SUBST(LIBXML2_LIBS)
  AC_DEFINE(ENABLE_LIBXML2)
fi













#-----------------------------------------------------------------------
#   --enable-geopackage
#
AC_ARG_ENABLE(geopackage, [AS_HELP_STRING(
  [--enable-geopackage], [enables GeoPackage support [default=yes]])],
  [], [enable_geopackage=yes])







>
>







 







>
>







 







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







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
            [Should be defined in order to disable GEOCALLBACKS support.])
AH_TEMPLATE([OMIT_KNN],
            [Should be defined in order to disable KNN support.])
AH_TEMPLATE([OMIT_FREEXL],
            [Should be defined in order to disable FREEXL support.])
AH_TEMPLATE([ENABLE_LIBXML2],
            [Should be defined in order to enable LIBXML2 support.])
AH_TEMPLATE([ENABLE_MINIZIP],
            [Should be defined in order to enable MiniZIP support.])
AH_TEMPLATE([ENABLE_GEOPACKAGE],
            [Should be defined in order to enable GeoPackage support.])
AH_TEMPLATE([TARGET_CPU],
            [Should contain a text-string describing the intended target CPU])
AH_TEMPLATE([HAVE_DECL_SQLITE_INDEX_CONSTRAINT_LIKE],
            [depending on SQLite library version.])

................................................................................
		test/sql_stmt_tiny_point/Makefile \
		test/sql_stmt_postgres_tests/Makefile \
		test/sql_stmt_geos370_tests/Makefile \
		test/sql_stmt_renamenew_tests/Makefile \
		test/sql_stmt_renameold_tests/Makefile \
		test/sql_stmt_bufoptsnew_tests/Makefile \
		test/sql_stmt_bufoptsold_tests/Makefile \
		test/sql_stmt_minizip/Makefile \
		test/sql_stmt_zip_proj6/Makefile \
		examples/Makefile \
		Doxyfile \
		spatialite.pc])

# exporting the TARGET_CPU string
splite_cpu=`$CC -dumpmachine`
AC_DEFINE_UNQUOTED([TARGET_CPU], ["$splite_cpu"])
................................................................................
  [], [enable_libxml2=yes])
if test x"$enable_libxml2" != "xno"; then
  PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], , AC_MSG_ERROR(['libxml2' is required but it doesn't seem to be installed on this system.]))
  AC_SUBST(LIBXML2_CFLAGS)
  AC_SUBST(LIBXML2_LIBS)
  AC_DEFINE(ENABLE_LIBXML2)
fi

#-----------------------------------------------------------------------
#   --enable-minizip
#
AC_ARG_ENABLE(minizip, [AS_HELP_STRING(
  [--enable-minizip], [enables MiniZIP inclusion [default=yes]])],
  [], [enable_minizip=yes])
if test x"$enable_minizip" != "xno"; then
  AC_CHECK_HEADERS(minizip/unzip.h,, [AC_MSG_ERROR([cannot find minizip/unzip.h, bailing out])])
  AC_SEARCH_LIBS(unzLocateFile, minizip,,AC_MSG_ERROR(['libminizip' is required but it doesn't seem to be installed on this system.]))
  AC_DEFINE(ENABLE_MINIZIP)
fi

#-----------------------------------------------------------------------
#   --enable-geopackage
#
AC_ARG_ENABLE(geopackage, [AS_HELP_STRING(
  [--enable-geopackage], [enables GeoPackage support [default=yes]])],
  [], [enable_geopackage=yes])

Changes to spatialite-sql-latest.html.

133
134
135
136
137
138
139



140
141
142
143
144
145
146
...
266
267
268
269
270
271
272



273
274
275
276
277
278
279
....
5057
5058
5059
5060
5061
5062
5063












5064
5065
5066
5067
5068
5069
5070
....
6344
6345
6346
6347
6348
6349
6350

























6351
6352
6353
6354
6355
6356
6357
....
6395
6396
6397
6398
6399
6400
6401























6402
6403
6404
6405
6406
6407
6408
				<td colspan="3">TRUE if the underlying library was built enabling <b>GEOSTRUNK</b></td></tr>
			<tr><td><b>HasGeosReentrant</b></td>
				<td>HasGeosReentrant( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>GEOSREENTRANT</b></td></tr>
			<tr><td><b>HasGeosOnlyReentrant</b></td>
				<td>HasGeosOnlyReentrant( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>GEOSONLYREENTRANT</b></td></tr>



			<tr><td><b>HasRtTopo</b></td>
				<td>HasRtTopo( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>RTTOPO</b></td></tr>
			<tr><td><b>HasLibXML2</b></td>
				<td>HasLibXML2( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>LibXML2</b></td></tr>
			<tr><td><b>HasEpsg</b></td>
................................................................................
				<td>FileNameFromPath( TEXT ) : <i>Text</i></td>
				<td colspan="3">returns the File Name (excluding an eventual File Extension) from a relative or absolute Pathname.<br>Will return <b>NULL</b> for invalid input of for any path
				 lacking a File Name.</td></tr>
			<tr><td><b>FileExtFromPath</b></td>
				<td>FileExtFromPath( TEXT ) : <i>Text</i></td>
				<td colspan="3">returns the File Extension from a relative or absolute Pathname.<br>Will return <b>NULL</b> for invalid input of for any path
				 lacking a File Name or when no Extension is present.</td></tr>



			<tr><td><b>MakeStringList</b></td>
				<td>MakeStringList( value ) : <i>Text</i><hr>
				    MakeStringList( value , delimiter <i>text</i>) : <i>Text</i></td>
				<td colspan="3">returns a comma-delimited list of integer or text values.<br>
				the optional argument <b>delimiter</b> can be used so to specify an alternative delimiter different from comma.<br>
				<b><u>aggregate function</u></b><hr>
				Will return <b>NULL</b> for invalid arguments.</td></tr>
................................................................................
				<td colspan="3">Will return the SRID value [if any] corresponding to the CRS defined by the <b>.PRJ</b> member of the Shapefile.<br>
				<u><i>Note</i></u>: exactley as required by <b><i>ImportSHP()</i></b> <b>filename</b> must define an absolute or relative path leading to the Shapefile
				(omitting any <i>.shp</i>, <i>.shx</i>, <i>.dbf</i> or <i>.prj</i> suffix).<hr>
				<b>-1</b> will be returned if no CRS supported by PROJ.6 matches the .PRJ member of the Shapefile.<br>
				<b>NULL</b> will be returned on invalid path or if no .PRJ member supports the Shapefile.<br>
				<u>Note</u>: this SQL function will be available only when SpatiaLite is built on <b>PROJ.6</b> (or any later version).<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>












			<tr><td colspan="5" align="center" bgcolor="#f0e0c0">
				<h3><a name="topology">SQL functions supporting Topology-Geometry</a></h3></td></tr>
			<tr><th bgcolor="#d0d0d0">Function</th>
				<th bgcolor="#d0d0d0">Syntax</th>
				<th bgcolor="#d0d0d0">ISO 13249-3<br>defined</th>
				<th bgcolor="#d0d0d0">required<br>module</th>
				<th bgcolor="#d0d0d0" colspan="3">Summary</th></tr>
................................................................................
					if you better whish a silent output.
				</ul></li>
				</ul>
				<hr>
				Will return the total number of imported rows.<br> <b>NULL</b> will be returned on invalid arguments.<hr>
                <u>Please note well</u>: this SQL function opens the door to many potential security issues, and thus is always <i>disabled by default</i>.<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>

























			<tr><td><b>ExportSHP</b></td>
				<td>ExportSHP( table <i>Text</i> , geom_column <i>Text</i> , filename <i>Text</i> , charset <i>Text</i> ) : <i>Integer</i><hr>
				ExportSHP( table <i>Text</i> , geom_column <i>Text</i> , filename <i>Text</i> , charset <i>Text</i> , [ geom_type <i>Text</i>
				[ , colname_case <i>Text</i> ] ] ) : <i>Integer</i></td>
				<td colspan="3">Will export an internal Table as an external Shapefile:
				<ul>
					<li><b>table</b> name of the table to be exported.</li>
................................................................................
					</ul></li>
				</ul></li>
				</ul>
				<hr>
				Will return the total number of imported rows.<br> <b>NULL</b> will be returned on invalid arguments.<hr>
                <u>Please note well</u>: this SQL function opens the door to many potential security issues, and thus is always <i>disabled by default</i>.<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>























			<tr><td><b>ExportDBF</b></td>
				<td>ExportDBF( table <i>Text</i> , filename <i>Text</i> , charset <i>Text</i> [ , colname_case <i>Text</i> ] ) : <i>Integer</i></td>
				<td colspan="3">Will export an internal Table as an external DBF file:
				<ul>
					<li><b>table</b> name of the table to be exported.</li>
					<li><b>filename</b> absolute or relative path leading to the DBF (including the <i>.dbf</i> suffix).</li>
					<li><b>charset</b> the character encoding adopted by the DBF, as e.g. <i>UTF-8</i> or <i>CP1252</i></li>







>
>
>







 







>
>
>







 







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







 







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







 







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







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
....
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
....
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
....
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
				<td colspan="3">TRUE if the underlying library was built enabling <b>GEOSTRUNK</b></td></tr>
			<tr><td><b>HasGeosReentrant</b></td>
				<td>HasGeosReentrant( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>GEOSREENTRANT</b></td></tr>
			<tr><td><b>HasGeosOnlyReentrant</b></td>
				<td>HasGeosOnlyReentrant( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>GEOSONLYREENTRANT</b></td></tr>
			<tr><td><b>HasMiniZip</b></td>
				<td>HasMiniZip( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>MINIZIP</b></td></tr>
			<tr><td><b>HasRtTopo</b></td>
				<td>HasRtTopo( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>RTTOPO</b></td></tr>
			<tr><td><b>HasLibXML2</b></td>
				<td>HasLibXML2( void ) : <i>Boolean</i></td>
				<td colspan="3">TRUE if the underlying library was built enabling <b>LibXML2</b></td></tr>
			<tr><td><b>HasEpsg</b></td>
................................................................................
				<td>FileNameFromPath( TEXT ) : <i>Text</i></td>
				<td colspan="3">returns the File Name (excluding an eventual File Extension) from a relative or absolute Pathname.<br>Will return <b>NULL</b> for invalid input of for any path
				 lacking a File Name.</td></tr>
			<tr><td><b>FileExtFromPath</b></td>
				<td>FileExtFromPath( TEXT ) : <i>Text</i></td>
				<td colspan="3">returns the File Extension from a relative or absolute Pathname.<br>Will return <b>NULL</b> for invalid input of for any path
				 lacking a File Name or when no Extension is present.</td></tr>
			<tr><td><b>RemoveExtraSpaces</b></td>
				<td>RemoveExtraSpaces( TEXT ) : <i>Text</i></td>
				<td colspan="3">returns a text string containing no repeated whitespaces (<b>SPACE</b> or <b>TAB</b> characters).<br>Will return <b>NULL</b> for invalid input.</td></tr>
			<tr><td><b>MakeStringList</b></td>
				<td>MakeStringList( value ) : <i>Text</i><hr>
				    MakeStringList( value , delimiter <i>text</i>) : <i>Text</i></td>
				<td colspan="3">returns a comma-delimited list of integer or text values.<br>
				the optional argument <b>delimiter</b> can be used so to specify an alternative delimiter different from comma.<br>
				<b><u>aggregate function</u></b><hr>
				Will return <b>NULL</b> for invalid arguments.</td></tr>
................................................................................
				<td colspan="3">Will return the SRID value [if any] corresponding to the CRS defined by the <b>.PRJ</b> member of the Shapefile.<br>
				<u><i>Note</i></u>: exactley as required by <b><i>ImportSHP()</i></b> <b>filename</b> must define an absolute or relative path leading to the Shapefile
				(omitting any <i>.shp</i>, <i>.shx</i>, <i>.dbf</i> or <i>.prj</i> suffix).<hr>
				<b>-1</b> will be returned if no CRS supported by PROJ.6 matches the .PRJ member of the Shapefile.<br>
				<b>NULL</b> will be returned on invalid path or if no .PRJ member supports the Shapefile.<br>
				<u>Note</u>: this SQL function will be available only when SpatiaLite is built on <b>PROJ.6</b> (or any later version).<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>
			<tr><td><b>PROJ_GuessSridFromZipSHP</b></td>
				<td>PROJ_GuessSridFromZipSHP( zip_path <i>String</i> , filename <i>String</i> ) : <i>Integer</i></td>
				<td colspan="3">Will return the SRID value [if any] corresponding to the CRS defined by the <b>.PRJ</b> member of a zipped Shapefile.<br>
				This function is almost the same as <b>PROJ_GuessSridFromSHP()</b>, except in that the Shapefile is expected to be stored within some Zipfile.<br>
				The following arguments are required:
				<ul>
					<li><b>zip_path</b>: expected to be the full or relative pathname of some Zipfile.</li>
					<li><b>filename</b> base name of the Shapefile within the Zipfile (omitting any <i>.shp</i>, <i>.shx</i> or <i>.dbf</i> suffix).</li>
				</ul>
				<hr>
				<u>Note</u>: this SQL function will be available only when SpatiaLite is built on <b>PROJ.6</b> (or any later version).<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>
			<tr><td colspan="5" align="center" bgcolor="#f0e0c0">
				<h3><a name="topology">SQL functions supporting Topology-Geometry</a></h3></td></tr>
			<tr><th bgcolor="#d0d0d0">Function</th>
				<th bgcolor="#d0d0d0">Syntax</th>
				<th bgcolor="#d0d0d0">ISO 13249-3<br>defined</th>
				<th bgcolor="#d0d0d0">required<br>module</th>
				<th bgcolor="#d0d0d0" colspan="3">Summary</th></tr>
................................................................................
					if you better whish a silent output.
				</ul></li>
				</ul>
				<hr>
				Will return the total number of imported rows.<br> <b>NULL</b> will be returned on invalid arguments.<hr>
                <u>Please note well</u>: this SQL function opens the door to many potential security issues, and thus is always <i>disabled by default</i>.<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>
			<tr><td><b>ImportZipSHP</b></td>
				<td>ImportZipSHP( zip_path <i>Text</i> , basename <i>Text</i> , table <i>Text</i> , charset <i>Text</i> ) : <i>Integer</i><hr>
				ImportZipSHP( zip_path <i>Text</i> , basename <i>Text</i> , table <i>Text</i> , charset <i>Text</i> [ , srid <i>Integer</i>  [ ,
				    geom_column <i>Text</i> [ , pk_column <i>Text</i> [ , geometry_type <i>Text</i> [ , coerce2D <i>Integer</i> 
				    [ , compressed <i>Integer</i> [ , spatial_index <i>Integer</i> [ , text_dates <i>Integer</i> 
				    [ , colname_case <i>Text</i> [ , update_statistics <i>Integer</i> [ , verbose <i>Integer</i> ] ] ] ] ] ] ] ] ] ] ] )
				    : <i>Integer</i></td>
				<td colspan="3">Will import an external Shapfile from a Zipfile into an internal Table.
				This function is almost the same as <b>ImportSHP()</b>, except in that the Shapefile is expected to be stored within some Zipfile.<br>
				The only two arguments having a different meaning are:
				<ul>
					<li><b>zip_path</b>: expected to be the full or relative pathname of some Zipfile.</li>
					<li><b>basename</b> base name of the Shapefile within the Zipfile (omitting any <i>.shp</i>, <i>.shx</i> or <i>.dbf</i> suffix).</li>
				</ul>
				<hr>
                <u>Please note well</u>: this SQL function opens the door to many potential security issues, and thus is always <i>disabled by default</i>.<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>
			<tr><td><b>Zipfile_NumSHP</b></td>
				<td>Zipfile_NumSHP( zip_path <i>Text</i> ) : <i>Integer</i></td>
				<td colspan="3">return the number of Shapefiles contained within the Zipfile identified by <b>zip_path</b><br>
				<b>NULL</b> on invalid argument or if the Zipfile does not exist or is corrupted.</td></tr>
			<tr><td><b>Zipfile_ShpN</b></td>
				<td>Zipfile_ShpN( zip_path <i>Text</i> , idx <i>Integer</i> ) : <i>Text</i></td>
				<td colspan="3">return the basename of the nth (1-based) Shapefile contained within the Zipfile identified by <b>zip_path</b><br>
				<b>NULL</b> on invalid arguments or if the Zipfile does not exist or is corrupted.</td></tr>
			<tr><td><b>ExportSHP</b></td>
				<td>ExportSHP( table <i>Text</i> , geom_column <i>Text</i> , filename <i>Text</i> , charset <i>Text</i> ) : <i>Integer</i><hr>
				ExportSHP( table <i>Text</i> , geom_column <i>Text</i> , filename <i>Text</i> , charset <i>Text</i> , [ geom_type <i>Text</i>
				[ , colname_case <i>Text</i> ] ] ) : <i>Integer</i></td>
				<td colspan="3">Will export an internal Table as an external Shapefile:
				<ul>
					<li><b>table</b> name of the table to be exported.</li>
................................................................................
					</ul></li>
				</ul></li>
				</ul>
				<hr>
				Will return the total number of imported rows.<br> <b>NULL</b> will be returned on invalid arguments.<hr>
                <u>Please note well</u>: this SQL function opens the door to many potential security issues, and thus is always <i>disabled by default</i>.<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>
			<tr><td><b>ImportZipDBF</b></td>
				<td>ImportZipDBF( zip_path <i>Text</i> , filename <i>Text</i> , table <i>Text</i> , charset <i>Text</i> ) : <i>Integer</i><hr>
				ImportZipDBF( zip_path <i>Text</i> , filename <i>Text</i> , table <i>Text</i> , charset <i>Text</i> [ , pk_column <i>Text</i>  
				    [ , text_dates <i>Integer</i> [ , colname_case <i>Text</i> ] ] ] ) : <i>Integer</i></td>
				<td colspan="3">Will import an external DBF file from a Zipfile into an internal Table.
				This function is almost the same as <b>ImportDBF()</b>, except in that the DBF file is expected to be stored within some Zipfile.<br>
				The only two arguments having a different meaning are:
				<ul>
					<li><b>zip_path</b>: expected to be the full or relative pathname of some Zipfile.</li>
					<li><b>filename</b> name of the Shapefile within the Zipfile (including the <i>.dbf</i> suffix).</li>
				</ul>
				<hr>
				Will return the total number of imported rows.<br> <b>NULL</b> will be returned on invalid arguments.<hr>
                <u>Please note well</u>: this SQL function opens the door to many potential security issues, and thus is always <i>disabled by default</i>.<br>
                Explicitly setting the environment variable <b>SPATIALITE_SECURITY=relaxed</b> is absolutely required in order to enable this function.</td></tr>
			<tr><td><b>Zipfile_NumDBF</b></td>
				<td>Zipfile_NumDBF( zip_path <i>Text</i> ) : <i>Integer</i></td>
				<td colspan="3">return the number of DBF files contained within the Zipfile identified by <b>zip_path</b><br>
				<b>NULL</b> on invalid argument or if the Zipfile does not exist or is corrupted.</td></tr>
			<tr><td><b>Zipfile_DbfN</b></td>
				<td>Zipfile_DbfN( zip_path <i>Text</i> , idx <i>Integer</i> ) : <i>Text</i></td>
				<td colspan="3">return the filename of the nth (1-based)  DBF file contained within the Zipfile identified by <b>zip_path</b><br>
				<b>NULL</b> on invalid arguments or if the Zipfile does not exist or is corrupted.</td></tr>
			<tr><td><b>ExportDBF</b></td>
				<td>ExportDBF( table <i>Text</i> , filename <i>Text</i> , charset <i>Text</i> [ , colname_case <i>Text</i> ] ) : <i>Integer</i></td>
				<td colspan="3">Will export an internal Table as an external DBF file:
				<ul>
					<li><b>table</b> name of the table to be exported.</li>
					<li><b>filename</b> absolute or relative path leading to the DBF (including the <i>.dbf</i> suffix).</li>
					<li><b>charset</b> the character encoding adopted by the DBF, as e.g. <i>UTF-8</i> or <i>CP1252</i></li>

Changes to src/gaiaaux/gg_sqlaux.c.

1470
1471
1472
1473
1474
1475
1476



































    len = strlen (path + pos + 1);
    if (len == 0)
	return NULL;
    name = malloc (len + 1);
    strcpy (name, path + pos + 1);
    return name;
}










































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
    len = strlen (path + pos + 1);
    if (len == 0)
	return NULL;
    name = malloc (len + 1);
    strcpy (name, path + pos + 1);
    return name;
}

GAIAAUX_DECLARE char *
gaiaRemoveExtraSpaces (const char *string)
{
/* removing all repeated whitespaces from a string */
	int len;
	char *clean;
	char *p;
	int i;
	int space = 0;
	
	if (string == NULL)
		return NULL;
		
	len = strlen(string);
	clean = malloc (len + 1);
	p = clean;
	for (i = 0; i < len; i++)
	{
		int sp = 0;
		if (string[i] == ' ' || string[i] == '\t')
			sp = 1;
		else
			sp = 0;
		if (space && sp)
		continue;
		*p++ = string[i];
		if (sp)
		space = 1;
		else
		space = 0;
	}
	*p = '\0';
	return clean;
}

Changes to src/gaiageo/gg_shape.c.

170
171
172
173
174
175
176











































177
178
179
180
181
182
183
...
372
373
374
375
376
377
378



379
380
381
382
383
384
385
...
473
474
475
476
477
478
479


480
481
482
483
484
485
486
487
488



489
490
491
492
493
494
495
496
497



498
499
500
501
502
503
504
505
506

507



508
509
510
511
512
513
514



515
516
517
518
519
520
521
522
...
528
529
530
531
532
533
534



535
536
537
538
539
540
541
542
...
578
579
580
581
582
583
584



585
586
587
588
589
590



591
592
593
594
595
596
597
598
....
1712
1713
1714
1715
1716
1717
1718



1719
1720
1721



1722
1723
1724
1725
1726
1727
1728
1729



1730
1731
1732



1733
1734
1735
1736
1737
1738
1739
1740



1741
1742
1743



1744
1745
1746
1747
1748
1749
1750
1751
....
1759
1760
1761
1762
1763
1764
1765



1766
1767
1768
1769
1770
1771
1772
1773
....
1791
1792
1793
1794
1795
1796
1797



1798
1799
1800
1801
1802
1803
1804
1805
....
1834
1835
1836
1837
1838
1839
1840



1841
1842
1843
1844
1845
1846
1847
1848
....
1869
1870
1871
1872
1873
1874
1875



1876
1877
1878



1879
1880
1881
1882
1883
1884
1885
1886
1887
....
1972
1973
1974
1975
1976
1977
1978



1979
1980
1981



1982
1983
1984
1985
1986
1987
1988
1989
1990
....
2069
2070
2071
2072
2073
2074
2075



2076
2077
2078



2079
2080
2081
2082
2083
2084
2085
2086
2087
....
2164
2165
2166
2167
2168
2169
2170



2171
2172
2173



2174
2175
2176
2177
2178
2179
2180
2181
2182
....
2243
2244
2245
2246
2247
2248
2249



2250
2251
2252



2253
2254
2255
2256
2257
2258
2259
2260
2261
....
2340
2341
2342
2343
2344
2345
2346



2347
2348
2349



2350
2351
2352
2353
2354
2355
2356
2357
2358
....
2434
2435
2436
2437
2438
2439
2440



2441
2442
2443



2444
2445
2446
2447
2448
2449
2450
2451
2452
....
2471
2472
2473
2474
2475
2476
2477



2478
2479
2480



2481
2482
2483
2484
2485
2486
2487
2488
2489
....
2526
2527
2528
2529
2530
2531
2532



2533
2534
2535



2536
2537
2538
2539
2540
2541
2542
2543
2544
....
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
....
4564
4565
4566
4567
4568
4569
4570



4571
4572
4573
4574



4575
4576
4577
4578
4579
4580
4581
4582
4583
....
4595
4596
4597
4598
4599
4600
4601



4602
4603
4604
4605



4606
4607
4608
4609
4610
4611
4612
4613
4614
....
4661
4662
4663
4664
4665
4666
4667



4668
4669
4670
4671



4672
4673
4674
4675
4676
4677
4678
4679
4680
....
4720
4721
4722
4723
4724
4725
4726

4727
4728
4729
4730
4731
4732
4733
....
4800
4801
4802
4803
4804
4805
4806


4807
4808
4809
4810
4811
4812
4813
4814

4815



4816
4817
4818
4819
4820
4821
4822
4823
....
4859
4860
4861
4862
4863
4864
4865



4866
4867
4868
4869
4870
4871



4872
4873
4874
4875
4876
4877
4878
4879
....
5304
5305
5306
5307
5308
5309
5310



5311
5312
5313



5314
5315
5316
5317
5318
5319
5320
5321
5322
    if (field->Value)
	gaiaFreeValue (field->Value);
    field->Value = malloc (sizeof (gaiaValue));
    field->Value->Type = GAIA_TEXT_VALUE;
    field->Value->TxtValue = malloc (len + 1);
    strcpy (field->Value->TxtValue, str);
}












































GAIAGEO_DECLARE gaiaDbfFieldPtr
gaiaAllocDbfField (char *name, unsigned char type,
		   int offset, unsigned char length, unsigned char decimals)
{
/* allocates and initializes a DBF Field definition */
    gaiaDbfFieldPtr p = malloc (sizeof (gaiaDbfField));
................................................................................
    shp->Path = NULL;
    shp->Shape = -1;
    shp->EffectiveType = GAIA_UNKNOWN;
    shp->EffectiveDims = GAIA_XY;
    shp->flShp = NULL;
    shp->flShx = NULL;
    shp->flDbf = NULL;



    shp->Dbf = NULL;
    shp->BufShp = NULL;
    shp->ShpBfsz = 0;
    shp->BufDbf = NULL;
    shp->DbfHdsz = 0;
    shp->DbfReclen = 0;
    shp->DbfSize = 0;
................................................................................
      }
    if (shp->flShp != NULL || shp->flShx != NULL || shp->flDbf != NULL)
      {
	  sprintf (errMsg,
		   "attempting to reopen an already opened Shapefile\n");
	  goto unsupported_conversion;
      }


    sprintf (xpath, "%s.shx", path);
    fl_shx = fopen (xpath, "rb");
    if (!fl_shx)
      {
	  sys_err = strerror (errno);
	  sprintf (errMsg, "unable to open '%s' for reading: %s", xpath,
		   sys_err);
	  goto no_file;
      }



    sprintf (xpath, "%s.shp", path);
    fl_shp = fopen (xpath, "rb");
    if (!fl_shp)
      {
	  sys_err = strerror (errno);
	  sprintf (errMsg, "unable to open '%s' for reading: %s", xpath,
		   sys_err);
	  goto no_file;
      }



    sprintf (xpath, "%s.dbf", path);
    fl_dbf = fopen (xpath, "rb");
    if (!fl_dbf)
      {
	  sys_err = strerror (errno);
	  sprintf (errMsg, "unable to open '%s' for reading: %s", xpath,
		   sys_err);
	  goto no_file;
      }

/* reading SHX file header */



    rd = fread (buf_shx, sizeof (unsigned char), 100, fl_shx);
    if (rd != 100)
	goto error;
    if (gaiaImport32 (buf_shx + 0, GAIA_BIG_ENDIAN, endian_arch) != 9994)	/* checks the SHX magic number */
	goto error;
/* reading SHP file header */
    buf_shp = malloc (sizeof (unsigned char) * buf_size);



    rd = fread (buf_shp, sizeof (unsigned char), 100, fl_shp);
    if (rd != 100)
	goto error;
    if (gaiaImport32 (buf_shp + 0, GAIA_BIG_ENDIAN, endian_arch) != 9994)	/* checks the SHP magic number */
	goto error;
    shape = gaiaImport32 (buf_shp + 32, GAIA_LITTLE_ENDIAN, endian_arch);
    if (shape == GAIA_SHP_POINT || shape == GAIA_SHP_POINTZ
	|| shape == GAIA_SHP_POINTM || shape == GAIA_SHP_POLYLINE
................................................................................
    else
	goto unsupported;
    shp->MinX = gaiaImport64 (buf_shp + 36, GAIA_LITTLE_ENDIAN, endian_arch);
    shp->MinY = gaiaImport64 (buf_shp + 44, GAIA_LITTLE_ENDIAN, endian_arch);
    shp->MaxX = gaiaImport64 (buf_shp + 52, GAIA_LITTLE_ENDIAN, endian_arch);
    shp->MaxY = gaiaImport64 (buf_shp + 60, GAIA_LITTLE_ENDIAN, endian_arch);
/* reading DBF file header */



    rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
    if (rd != 32)
	goto error;
    switch (*bf)
      {
	  /* checks the DBF magic number */
      case 0x03:
      case 0x83:
................................................................................
    for (ind = 32; ind < dbf_size; ind += 32)
      {
	  /* fetches DBF fields definitions */
	  if ((dbf_size - ind) < 32)
	    {
		/* some odd DBF could contain some unexpected extra-padding */
		int extra = dbf_size - ind;



		rd = fread (bf, sizeof (unsigned char), extra, fl_dbf);
		if (rd != extra)
		    goto error;
		/* ignoring the extra-padding */
		break;
	    }



	  rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
	  if (rd != 32)
	      goto error;
	  if (*(bf + 11) == 'M')
	    {
		/* skipping any MEMO field */
		memcpy (field_name, bf, 11);
		field_name[11] = '\0';
................................................................................
    gaiaDbfFieldPtr pFld;
    struct shp_ring_collection ringsColl;
/* initializing the RING collection */
    ringsColl.First = NULL;
    ringsColl.Last = NULL;
/* positioning and reading the SHX file */
    offset = 100 + ((gaia_off_t) current_row * (gaia_off_t) 8);	/* 100 bytes for the header + current row displacement; each SHX row = 8 bytes */



    skpos = gaia_fseek (shp->flShx, offset, SEEK_SET);
    if (skpos != 0)
	goto eof;



    rd = fread (buf, sizeof (unsigned char), 8, shp->flShx);
    if (rd != 8)
	goto eof;
    off_shp = gaiaImport32 (buf, GAIA_BIG_ENDIAN, shp->endian_arch);
/* positioning and reading the DBF file */
    offset =
	shp->DbfHdsz +
	((gaia_off_t) current_row * (gaia_off_t) (shp->DbfReclen));



    skpos = gaia_fseek (shp->flDbf, offset, SEEK_SET);
    if (skpos != 0)
	goto error;



    rd = fread (shp->BufDbf, sizeof (unsigned char), shp->DbfReclen,
		shp->flDbf);
    if (rd != shp->DbfReclen)
	goto error;
    if (*(shp->BufDbf) == '*')
	goto dbf_deleted;
/* positioning and reading corresponding SHP entity - geometry */
    offset = (gaia_off_t) off_shp *2;



    skpos = gaia_fseek (shp->flShp, offset, SEEK_SET);
    if (skpos != 0)
	goto error;



    rd = fread (buf, sizeof (unsigned char), 12, shp->flShp);
    if (rd != 12)
	goto error;
    sz = gaiaImport32 (buf + 4, GAIA_BIG_ENDIAN, shp->endian_arch);
    shape = gaiaImport32 (buf + 8, GAIA_LITTLE_ENDIAN, shp->endian_arch);
    if (shape == GAIA_SHP_NULL)
      {
	  /* handling a NULL shape */
................................................................................
	  free (shp->BufShp);
	  shp->ShpBfsz = sz * 2;
	  shp->BufShp = malloc (sizeof (unsigned char) * shp->ShpBfsz);
      }
    if (shape == GAIA_SHP_POINT)
      {
	  /* shape point */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 16, shp->flShp);
	  if (rd != 16)
	      goto error;
	  x = gaiaImport64 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  y = gaiaImport64 (shp->BufShp + 8, GAIA_LITTLE_ENDIAN,
			    shp->endian_arch);
	  if (shp->EffectiveDims == GAIA_XY_Z)
	    {
................................................................................
	    }
	  geom->DeclaredType = GAIA_POINT;
	  geom->Srid = srid;
      }
    if (shape == GAIA_SHP_POINTZ)
      {
	  /* shape point Z */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	    {
		/* required by some buggish SHP (e.g. the GDAL/OGR ones) */
		if (rd != 24)
		    goto error;
	    }
	  x = gaiaImport64 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
................................................................................
	    }
	  geom->DeclaredType = GAIA_POINT;
	  geom->Srid = srid;
      }
    if (shape == GAIA_SHP_POINTM)
      {
	  /* shape point M */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 24, shp->flShp);
	  if (rd != 24)
	      goto error;
	  x = gaiaImport64 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  y = gaiaImport64 (shp->BufShp + 8, GAIA_LITTLE_ENDIAN,
			    shp->endian_arch);
	  m = gaiaImport64 (shp->BufShp + 16, GAIA_LITTLE_ENDIAN,
			    shp->endian_arch);
................................................................................
	  geom->DeclaredType = GAIA_POINT;
	  geom->Srid = srid;
      }
    if (shape == GAIA_SHP_POLYLINE)
      {
	  /* shape polyline */
	  int extra_check = 0;



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	    {
		if (rd == (sz * 2) - 44)
		  {
		      /* sandro 2018-02-17
		       * it could be some defective SHP badly computing the
		       * expected record length.
................................................................................
		  }
		gaiaInsertLinestringInGeomColl (geom, line);
	    }
      }
    if (shape == GAIA_SHP_POLYLINEZ)
      {
	  /* shape polyline Z */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 38 + (2 * n) + (n1 * 16);	/* size [in 16 bits words !!!] ZM */
................................................................................
		  }
		gaiaInsertLinestringInGeomColl (geom, line);
	    }
      }
    if (shape == GAIA_SHP_POLYLINEM)
      {
	  /* shape polyline M */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 30 + (2 * n) + (n1 * 12);	/* size [in 16 bits words !!!] M */
................................................................................
		  }
		gaiaInsertLinestringInGeomColl (geom, line);
	    }
      }
    if (shape == GAIA_SHP_POLYGON)
      {
	  /* shape polygon */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  base = 8 + (n * 4);
	  start = 0;
................................................................................
	      geom->DeclaredType = GAIA_MULTIPOLYGON;
	  geom->Srid = srid;
	  shp_build_area (&ringsColl, geom);
      }
    if (shape == GAIA_SHP_POLYGONZ)
      {
	  /* shape polygon Z */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 38 + (2 * n) + (n1 * 16);	/* size [in 16 bits words !!!] ZM */
................................................................................
	      geom->DeclaredType = GAIA_MULTIPOLYGON;
	  geom->Srid = srid;
	  shp_build_area (&ringsColl, geom);
      }
    if (shape == GAIA_SHP_POLYGONM)
      {
	  /* shape polygon M */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 30 + (2 * n) + (n1 * 12);	/* size [in 16 bits words !!!] M */
................................................................................
	      geom->DeclaredType = GAIA_MULTIPOLYGON;
	  geom->Srid = srid;
	  shp_build_area (&ringsColl, geom);
      }
    if (shape == GAIA_SHP_MULTIPOINT)
      {
	  /* shape multipoint */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  if (shp->EffectiveDims == GAIA_XY_Z)
	      geom = gaiaAllocGeomCollXYZ ();
	  else if (shp->EffectiveDims == GAIA_XY_M)
	      geom = gaiaAllocGeomCollXYM ();
................................................................................
		else
		    gaiaAddPointToGeomColl (geom, x, y);
	    }
      }
    if (shape == GAIA_SHP_MULTIPOINTZ)
      {
	  /* shape multipoint Z */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  hasM = 0;
	  max_size = 36 + (n * 16);	/* size [in 16 bits words !!!] ZM */
	  min_size = 28 + (n * 12);	/* size [in 16 bits words !!!] Z-only */
	  if (sz < min_size)
................................................................................
		else
		    gaiaAddPointToGeomColl (geom, x, y);
	    }
      }
    if (shape == GAIA_SHP_MULTIPOINTM)
      {
	  /* shape multipoint M */



	  rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;



	  rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
		      shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  hasM = 0;
	  max_size = 28 + (n * 12);	/* size [in 16 bits words !!!] M */
	  min_size = 20 + (n * 8);	/* size [in 16 bits words !!!] no-M */
	  if (sz < min_size)
................................................................................
    int current_row = 0;

    gaiaRingPtr ring = NULL;
    while (1)
      {
	  /* positioning and reading the SHX file */
	  offset = 100 + ((gaia_off_t) current_row * (gaia_off_t) 8);	/* 100 bytes for the header + current row displacement; each SHX row = 8 bytes */



	  skpos = gaia_fseek (shp->flShx, offset, SEEK_SET);
	  if (skpos != 0)
	      goto exit;



	  rd = fread (buf, sizeof (unsigned char), 8, shp->flShx);
	  if (rd != 8)
	      goto exit;
	  off_shp = gaiaImport32 (buf, GAIA_BIG_ENDIAN, shp->endian_arch);
	  /* positioning and reading corresponding SHP entity - geometry */
	  offset = (gaia_off_t) off_shp *2;



	  skpos = gaia_fseek (shp->flShp, offset, SEEK_SET);
	  if (skpos != 0)
	      goto exit;



	  rd = fread (buf, sizeof (unsigned char), 12, shp->flShp);
	  if (rd != 12)
	      goto exit;
	  sz = gaiaImport32 (buf + 4, GAIA_BIG_ENDIAN, shp->endian_arch);
	  shape = gaiaImport32 (buf + 8, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  if ((sz * 2) > shp->ShpBfsz)
	    {
		/* current buffer is too small; we need to allocate a bigger buffer */
................................................................................
		shp->ShpBfsz = sz * 2;
		shp->BufShp = malloc (sizeof (unsigned char) * shp->ShpBfsz);
	    }
	  if (shape == GAIA_SHP_POLYLINE || shape == GAIA_SHP_POLYLINEZ
	      || shape == GAIA_SHP_POLYLINEM)
	    {
		/* shape polyline */



		rd = fread (shp->BufShp, sizeof (unsigned char), 32,
			    shp->flShp);
		if (rd != 32)
		    goto exit;



		rd = fread (shp->BufShp, sizeof (unsigned char),
			    (sz * 2) - 36, shp->flShp);
		if (rd != (sz * 2) - 36)
		    goto exit;
		n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN,
				  shp->endian_arch);
		n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
				   shp->endian_arch);
		if (n > 1)
................................................................................
		/* shape polygon */
		struct shp_ring_item *pExt;
		struct shp_ring_collection ringsColl;
		/* initializing the RING collection */
		ringsColl.First = NULL;
		ringsColl.Last = NULL;




		rd = fread (shp->BufShp, sizeof (unsigned char), 32,
			    shp->flShp);
		if (rd != 32)
		    goto exit;



		rd = fread (shp->BufShp, sizeof (unsigned char),
			    (sz * 2) - 36, shp->flShp);
		if (rd != (sz * 2) - 36)
		    goto exit;
		n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN,
				  shp->endian_arch);
		n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
				   shp->endian_arch);
		base = 8 + (n * 4);
................................................................................
		      if (sz == ZM_size)
			  hasM = 1;
		  }
	    }
	  if (shape == GAIA_SHP_MULTIPOINTZ)
	    {
		/* shape multipoint Z */



		rd = fread (shp->BufShp, sizeof (unsigned char), 32,
			    shp->flShp);
		if (rd != 32)
		    goto exit;



		rd = fread (shp->BufShp, sizeof (unsigned char),
			    (sz * 2) - 36, shp->flShp);
		if (rd != (sz * 2) - 36)
		    goto exit;
		n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN,
				  shp->endian_arch);
		ZM_size = 38 + (n * 16);	/* size [in 16 bits words !!!] ZM */
		if (sz == ZM_size)
		    hasM = 1;
................................................................................
gaiaAllocDbf ()
{
/* allocates and initializes the DBF object */
    gaiaDbfPtr dbf = malloc (sizeof (gaiaDbf));
    dbf->endian_arch = 1;
    dbf->Path = NULL;
    dbf->flDbf = NULL;

    dbf->Dbf = NULL;
    dbf->BufDbf = NULL;
    dbf->DbfHdsz = 0;
    dbf->DbfReclen = 0;
    dbf->DbfSize = 0;
    dbf->DbfRecno = 0;
    dbf->Valid = 0;
................................................................................
	  goto unsupported_conversion;
      }
    if (dbf->flDbf != NULL)
      {
	  sprintf (errMsg, "attempting to reopen an already opened DBF\n");
	  goto unsupported_conversion;
      }


    fl_dbf = fopen (path, "rb");
    if (!fl_dbf)
      {
	  sys_err = strerror (errno);
	  sprintf (errMsg, "unable to open '%s' for reading: %s", path,
		   sys_err);
	  goto no_file;
      }

/* reading DBF file header */



    rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
    if (rd != 32)
	goto error;
    switch (*bf)
      {
	  /* checks the DBF magic number */
      case 0x03:
      case 0x83:
................................................................................
    for (ind = 32; ind < dbf_size; ind += 32)
      {
	  /* fetches DBF fields definitions */
	  if ((dbf_size - ind) < 32)
	    {
		/* some odd DBF could contain some unexpected extra-padding */
		int extra = dbf_size - ind;



		rd = fread (bf, sizeof (unsigned char), extra, fl_dbf);
		if (rd != extra)
		    goto error;
		/* ignoring the extra-padding */
		break;
	    }



	  rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
	  if (rd != 32)
	      goto error;
	  if (*(bf + 11) == 'M')
	    {
		/* skipping any MEMO field */
		memcpy (field_name, bf, 11);
		field_name[11] = '\0';
................................................................................
    int len;
    char errMsg[1024];
    gaiaDbfFieldPtr pFld;
/* positioning and reading the DBF file */
    offset =
	dbf->DbfHdsz +
	((gaia_off_t) current_row * (gaia_off_t) (dbf->DbfReclen));



    skpos = gaia_fseek (dbf->flDbf, offset, SEEK_SET);
    if (skpos != 0)
	goto eof;



    rd = fread (dbf->BufDbf, sizeof (unsigned char), dbf->DbfReclen,
		dbf->flDbf);
    if (rd != dbf->DbfReclen)
	goto eof;
/* setting up the current DBF ENTITY */
    gaiaResetDbfEntity (dbf->Dbf);
    dbf->Dbf->RowId = current_row;
    if (*(dbf->BufDbf) == '*')
      {







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







 







>
>
>







 







>
>
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|
|
|
|
|
|
>

>
>
>
|






>
>
>
|







 







>
>
>
|







 







>
>
>
|





>
>
>
|







 







>
>
>
|


>
>
>
|







>
>
>
|


>
>
>
|
|






>
>
>
|


>
>
>
|







 







>
>
>
|







 







>
>
>
|







 







>
>
>
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|
|







 







>
>
>
|


>
>
>
|





>
>
>
|


>
>
>
|







 







>
>
>
|
|


>
>
>
|
|







 







>
>
>
|
|


>
>
>
|
|







 







>
>
>
|
|


>
>
>
|
|







 







>







 







>
>
|
|
|
|
|
|
|
|
>

>
>
>
|







 







>
>
>
|





>
>
>
|







 







>
>
>
|


>
>
>
|
|







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
...
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
...
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
...
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
....
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
....
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
....
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
....
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
....
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
....
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
....
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
....
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
....
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
....
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
....
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
....
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
....
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
....
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
....
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
....
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
....
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
....
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
....
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
....
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
....
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
    if (field->Value)
	gaiaFreeValue (field->Value);
    field->Value = malloc (sizeof (gaiaValue));
    field->Value->Type = GAIA_TEXT_VALUE;
    field->Value->TxtValue = malloc (len + 1);
    strcpy (field->Value->TxtValue, str);
}

GAIAGEO_DECLARE int
gaiaMemFseek (gaiaMemFilePtr mem, long offset)
{
/* repositioning a Memory File */
    if (mem == NULL)
	return -1;
    if (mem->buf == NULL)
	return -1;
    if (offset < 0)
	return -1;
    if (offset >= mem->size)
	return -1;
    mem->offset = offset;
    return 0;
}

GAIAGEO_DECLARE size_t
gaiaMemRead (void *ptr, size_t bytes, gaiaMemFilePtr mem)
{
/* reading from Memory File */
    size_t rd = 0;
    size_t i;
    unsigned char *in;
    unsigned char *out;

    if (mem == NULL)
	return 0;
    if (mem->buf == NULL)
	return 0;

    for (i = 0; i < bytes; i++)
      {
	  if (mem->offset >= mem->size)
	      break;
	  in = (unsigned char *) (mem->buf) + mem->offset;
	  out = (unsigned char *) ptr + i;
	  *out = *in;
	  mem->offset += 1;
	  rd++;
      }
    return rd;
}

GAIAGEO_DECLARE gaiaDbfFieldPtr
gaiaAllocDbfField (char *name, unsigned char type,
		   int offset, unsigned char length, unsigned char decimals)
{
/* allocates and initializes a DBF Field definition */
    gaiaDbfFieldPtr p = malloc (sizeof (gaiaDbfField));
................................................................................
    shp->Path = NULL;
    shp->Shape = -1;
    shp->EffectiveType = GAIA_UNKNOWN;
    shp->EffectiveDims = GAIA_XY;
    shp->flShp = NULL;
    shp->flShx = NULL;
    shp->flDbf = NULL;
    shp->memShp = NULL;
    shp->memShx = NULL;
    shp->memDbf = NULL;
    shp->Dbf = NULL;
    shp->BufShp = NULL;
    shp->ShpBfsz = 0;
    shp->BufDbf = NULL;
    shp->DbfHdsz = 0;
    shp->DbfReclen = 0;
    shp->DbfSize = 0;
................................................................................
      }
    if (shp->flShp != NULL || shp->flShx != NULL || shp->flDbf != NULL)
      {
	  sprintf (errMsg,
		   "attempting to reopen an already opened Shapefile\n");
	  goto unsupported_conversion;
      }
    if (shp->memShx == NULL)
      {
	  sprintf (xpath, "%s.shx", path);
	  fl_shx = fopen (xpath, "rb");
	  if (!fl_shx)
	    {
		sys_err = strerror (errno);
		sprintf (errMsg, "unable to open '%s' for reading: %s", xpath,
			 sys_err);
		goto no_file;
	    }
      }
    if (shp->memShp == NULL)
      {
	  sprintf (xpath, "%s.shp", path);
	  fl_shp = fopen (xpath, "rb");
	  if (!fl_shp)
	    {
		sys_err = strerror (errno);
		sprintf (errMsg, "unable to open '%s' for reading: %s", xpath,
			 sys_err);
		goto no_file;
	    }
      }
    if (shp->memDbf == NULL)
      {
	  sprintf (xpath, "%s.dbf", path);
	  fl_dbf = fopen (xpath, "rb");
	  if (!fl_dbf)
	    {
		sys_err = strerror (errno);
		sprintf (errMsg, "unable to open '%s' for reading: %s", xpath,
			 sys_err);
		goto no_file;
	    }
      }
/* reading SHX file header */
    if (shp->memShx != NULL)
	rd = gaiaMemRead (buf_shx, 100, shp->memShx);
    else
	rd = fread (buf_shx, sizeof (unsigned char), 100, fl_shx);
    if (rd != 100)
	goto error;
    if (gaiaImport32 (buf_shx + 0, GAIA_BIG_ENDIAN, endian_arch) != 9994)	/* checks the SHX magic number */
	goto error;
/* reading SHP file header */
    buf_shp = malloc (sizeof (unsigned char) * buf_size);
    if (shp->memShp != NULL)
	rd = gaiaMemRead (buf_shp, 100, shp->memShp);
    else
	rd = fread (buf_shp, sizeof (unsigned char), 100, fl_shp);
    if (rd != 100)
	goto error;
    if (gaiaImport32 (buf_shp + 0, GAIA_BIG_ENDIAN, endian_arch) != 9994)	/* checks the SHP magic number */
	goto error;
    shape = gaiaImport32 (buf_shp + 32, GAIA_LITTLE_ENDIAN, endian_arch);
    if (shape == GAIA_SHP_POINT || shape == GAIA_SHP_POINTZ
	|| shape == GAIA_SHP_POINTM || shape == GAIA_SHP_POLYLINE
................................................................................
    else
	goto unsupported;
    shp->MinX = gaiaImport64 (buf_shp + 36, GAIA_LITTLE_ENDIAN, endian_arch);
    shp->MinY = gaiaImport64 (buf_shp + 44, GAIA_LITTLE_ENDIAN, endian_arch);
    shp->MaxX = gaiaImport64 (buf_shp + 52, GAIA_LITTLE_ENDIAN, endian_arch);
    shp->MaxY = gaiaImport64 (buf_shp + 60, GAIA_LITTLE_ENDIAN, endian_arch);
/* reading DBF file header */
    if (shp->memDbf != NULL)
	rd = gaiaMemRead (bf, 32, shp->memDbf);
    else
	rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
    if (rd != 32)
	goto error;
    switch (*bf)
      {
	  /* checks the DBF magic number */
      case 0x03:
      case 0x83:
................................................................................
    for (ind = 32; ind < dbf_size; ind += 32)
      {
	  /* fetches DBF fields definitions */
	  if ((dbf_size - ind) < 32)
	    {
		/* some odd DBF could contain some unexpected extra-padding */
		int extra = dbf_size - ind;
		if (shp->memDbf != NULL)
		    rd = gaiaMemRead (bf, extra, shp->memDbf);
		else
		    rd = fread (bf, sizeof (unsigned char), extra, fl_dbf);
		if (rd != extra)
		    goto error;
		/* ignoring the extra-padding */
		break;
	    }
	  if (shp->memDbf != NULL)
	      rd = gaiaMemRead (bf, 32, shp->memDbf);
	  else
	      rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
	  if (rd != 32)
	      goto error;
	  if (*(bf + 11) == 'M')
	    {
		/* skipping any MEMO field */
		memcpy (field_name, bf, 11);
		field_name[11] = '\0';
................................................................................
    gaiaDbfFieldPtr pFld;
    struct shp_ring_collection ringsColl;
/* initializing the RING collection */
    ringsColl.First = NULL;
    ringsColl.Last = NULL;
/* positioning and reading the SHX file */
    offset = 100 + ((gaia_off_t) current_row * (gaia_off_t) 8);	/* 100 bytes for the header + current row displacement; each SHX row = 8 bytes */
    if (shp->memShx != NULL)
	skpos = gaiaMemFseek (shp->memShx, offset);
    else
	skpos = gaia_fseek (shp->flShx, offset, SEEK_SET);
    if (skpos != 0)
	goto eof;
    if (shp->memDbf != NULL)
	rd = gaiaMemRead (buf, 8, shp->memShx);
    else
	rd = fread (buf, sizeof (unsigned char), 8, shp->flShx);
    if (rd != 8)
	goto eof;
    off_shp = gaiaImport32 (buf, GAIA_BIG_ENDIAN, shp->endian_arch);
/* positioning and reading the DBF file */
    offset =
	shp->DbfHdsz +
	((gaia_off_t) current_row * (gaia_off_t) (shp->DbfReclen));
    if (shp->memDbf != NULL)
	skpos = gaiaMemFseek (shp->memDbf, offset);
    else
	skpos = gaia_fseek (shp->flDbf, offset, SEEK_SET);
    if (skpos != 0)
	goto error;
    if (shp->memDbf != NULL)
	rd = gaiaMemRead (shp->BufDbf, shp->DbfReclen, shp->memDbf);
    else
	rd = fread (shp->BufDbf, sizeof (unsigned char), shp->DbfReclen,
		    shp->flDbf);
    if (rd != shp->DbfReclen)
	goto error;
    if (*(shp->BufDbf) == '*')
	goto dbf_deleted;
/* positioning and reading corresponding SHP entity - geometry */
    offset = (gaia_off_t) off_shp *2;
    if (shp->memShp != NULL)
	skpos = gaiaMemFseek (shp->memShp, offset);
    else
	skpos = gaia_fseek (shp->flShp, offset, SEEK_SET);
    if (skpos != 0)
	goto error;
    if (shp->memShp != NULL)
	rd = gaiaMemRead (buf, 12, shp->memShp);
    else
	rd = fread (buf, sizeof (unsigned char), 12, shp->flShp);
    if (rd != 12)
	goto error;
    sz = gaiaImport32 (buf + 4, GAIA_BIG_ENDIAN, shp->endian_arch);
    shape = gaiaImport32 (buf + 8, GAIA_LITTLE_ENDIAN, shp->endian_arch);
    if (shape == GAIA_SHP_NULL)
      {
	  /* handling a NULL shape */
................................................................................
	  free (shp->BufShp);
	  shp->ShpBfsz = sz * 2;
	  shp->BufShp = malloc (sizeof (unsigned char) * shp->ShpBfsz);
      }
    if (shape == GAIA_SHP_POINT)
      {
	  /* shape point */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 16, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 16, shp->flShp);
	  if (rd != 16)
	      goto error;
	  x = gaiaImport64 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  y = gaiaImport64 (shp->BufShp + 8, GAIA_LITTLE_ENDIAN,
			    shp->endian_arch);
	  if (shp->EffectiveDims == GAIA_XY_Z)
	    {
................................................................................
	    }
	  geom->DeclaredType = GAIA_POINT;
	  geom->Srid = srid;
      }
    if (shape == GAIA_SHP_POINTZ)
      {
	  /* shape point Z */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	    {
		/* required by some buggish SHP (e.g. the GDAL/OGR ones) */
		if (rd != 24)
		    goto error;
	    }
	  x = gaiaImport64 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
................................................................................
	    }
	  geom->DeclaredType = GAIA_POINT;
	  geom->Srid = srid;
      }
    if (shape == GAIA_SHP_POINTM)
      {
	  /* shape point M */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 24, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 24, shp->flShp);
	  if (rd != 24)
	      goto error;
	  x = gaiaImport64 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  y = gaiaImport64 (shp->BufShp + 8, GAIA_LITTLE_ENDIAN,
			    shp->endian_arch);
	  m = gaiaImport64 (shp->BufShp + 16, GAIA_LITTLE_ENDIAN,
			    shp->endian_arch);
................................................................................
	  geom->DeclaredType = GAIA_POINT;
	  geom->Srid = srid;
      }
    if (shape == GAIA_SHP_POLYLINE)
      {
	  /* shape polyline */
	  int extra_check = 0;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	    {
		if (rd == (sz * 2) - 44)
		  {
		      /* sandro 2018-02-17
		       * it could be some defective SHP badly computing the
		       * expected record length.
................................................................................
		  }
		gaiaInsertLinestringInGeomColl (geom, line);
	    }
      }
    if (shape == GAIA_SHP_POLYLINEZ)
      {
	  /* shape polyline Z */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 38 + (2 * n) + (n1 * 16);	/* size [in 16 bits words !!!] ZM */
................................................................................
		  }
		gaiaInsertLinestringInGeomColl (geom, line);
	    }
      }
    if (shape == GAIA_SHP_POLYLINEM)
      {
	  /* shape polyline M */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 30 + (2 * n) + (n1 * 12);	/* size [in 16 bits words !!!] M */
................................................................................
		  }
		gaiaInsertLinestringInGeomColl (geom, line);
	    }
      }
    if (shape == GAIA_SHP_POLYGON)
      {
	  /* shape polygon */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  base = 8 + (n * 4);
	  start = 0;
................................................................................
	      geom->DeclaredType = GAIA_MULTIPOLYGON;
	  geom->Srid = srid;
	  shp_build_area (&ringsColl, geom);
      }
    if (shape == GAIA_SHP_POLYGONZ)
      {
	  /* shape polygon Z */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 38 + (2 * n) + (n1 * 16);	/* size [in 16 bits words !!!] ZM */
................................................................................
	      geom->DeclaredType = GAIA_MULTIPOLYGON;
	  geom->Srid = srid;
	  shp_build_area (&ringsColl, geom);
      }
    if (shape == GAIA_SHP_POLYGONM)
      {
	  /* shape polygon M */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
			     shp->endian_arch);
	  hasM = 0;
	  max_size = 30 + (2 * n) + (n1 * 12);	/* size [in 16 bits words !!!] M */
................................................................................
	      geom->DeclaredType = GAIA_MULTIPOLYGON;
	  geom->Srid = srid;
	  shp_build_area (&ringsColl, geom);
      }
    if (shape == GAIA_SHP_MULTIPOINT)
      {
	  /* shape multipoint */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  if (shp->EffectiveDims == GAIA_XY_Z)
	      geom = gaiaAllocGeomCollXYZ ();
	  else if (shp->EffectiveDims == GAIA_XY_M)
	      geom = gaiaAllocGeomCollXYM ();
................................................................................
		else
		    gaiaAddPointToGeomColl (geom, x, y);
	    }
      }
    if (shape == GAIA_SHP_MULTIPOINTZ)
      {
	  /* shape multipoint Z */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  hasM = 0;
	  max_size = 36 + (n * 16);	/* size [in 16 bits words !!!] ZM */
	  min_size = 28 + (n * 12);	/* size [in 16 bits words !!!] Z-only */
	  if (sz < min_size)
................................................................................
		else
		    gaiaAddPointToGeomColl (geom, x, y);
	    }
      }
    if (shape == GAIA_SHP_MULTIPOINTM)
      {
	  /* shape multipoint M */
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), 32, shp->flShp);
	  if (rd != 32)
	      goto error;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
	  else
	      rd = fread (shp->BufShp, sizeof (unsigned char), (sz * 2) - 36,
			  shp->flShp);
	  if (rd != (sz * 2) - 36)
	      goto error;
	  n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  hasM = 0;
	  max_size = 28 + (n * 12);	/* size [in 16 bits words !!!] M */
	  min_size = 20 + (n * 8);	/* size [in 16 bits words !!!] no-M */
	  if (sz < min_size)
................................................................................
    int current_row = 0;

    gaiaRingPtr ring = NULL;
    while (1)
      {
	  /* positioning and reading the SHX file */
	  offset = 100 + ((gaia_off_t) current_row * (gaia_off_t) 8);	/* 100 bytes for the header + current row displacement; each SHX row = 8 bytes */
	  if (shp->memShx != NULL)
	      skpos = gaiaMemFseek (shp->memShx, offset);
	  else
	      skpos = gaia_fseek (shp->flShx, offset, SEEK_SET);
	  if (skpos != 0)
	      goto exit;
	  if (shp->memShx != NULL)
	      rd = gaiaMemRead (buf, 8, shp->memShx);
	  else
	      rd = fread (buf, sizeof (unsigned char), 8, shp->flShx);
	  if (rd != 8)
	      goto exit;
	  off_shp = gaiaImport32 (buf, GAIA_BIG_ENDIAN, shp->endian_arch);
	  /* positioning and reading corresponding SHP entity - geometry */
	  offset = (gaia_off_t) off_shp *2;
	  if (shp->memShp != NULL)
	      skpos = gaiaMemFseek (shp->memShp, offset);
	  else
	      skpos = gaia_fseek (shp->flShp, offset, SEEK_SET);
	  if (skpos != 0)
	      goto exit;
	  if (shp->memShp != NULL)
	      rd = gaiaMemRead (buf, 12, shp->memShp);
	  else
	      rd = fread (buf, sizeof (unsigned char), 12, shp->flShp);
	  if (rd != 12)
	      goto exit;
	  sz = gaiaImport32 (buf + 4, GAIA_BIG_ENDIAN, shp->endian_arch);
	  shape = gaiaImport32 (buf + 8, GAIA_LITTLE_ENDIAN, shp->endian_arch);
	  if ((sz * 2) > shp->ShpBfsz)
	    {
		/* current buffer is too small; we need to allocate a bigger buffer */
................................................................................
		shp->ShpBfsz = sz * 2;
		shp->BufShp = malloc (sizeof (unsigned char) * shp->ShpBfsz);
	    }
	  if (shape == GAIA_SHP_POLYLINE || shape == GAIA_SHP_POLYLINEZ
	      || shape == GAIA_SHP_POLYLINEM)
	    {
		/* shape polyline */
		if (shp->memShp != NULL)
		    rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
		else
		    rd = fread (shp->BufShp, sizeof (unsigned char), 32,
				shp->flShp);
		if (rd != 32)
		    goto exit;
		if (shp->memShp != NULL)
		    rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
		else
		    rd = fread (shp->BufShp, sizeof (unsigned char),
				(sz * 2) - 36, shp->flShp);
		if (rd != (sz * 2) - 36)
		    goto exit;
		n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN,
				  shp->endian_arch);
		n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
				   shp->endian_arch);
		if (n > 1)
................................................................................
		/* shape polygon */
		struct shp_ring_item *pExt;
		struct shp_ring_collection ringsColl;
		/* initializing the RING collection */
		ringsColl.First = NULL;
		ringsColl.Last = NULL;

		if (shp->memShp != NULL)
		    rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
		else
		    rd = fread (shp->BufShp, sizeof (unsigned char), 32,
				shp->flShp);
		if (rd != 32)
		    goto exit;
		if (shp->memShp != NULL)
		    rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
		else
		    rd = fread (shp->BufShp, sizeof (unsigned char),
				(sz * 2) - 36, shp->flShp);
		if (rd != (sz * 2) - 36)
		    goto exit;
		n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN,
				  shp->endian_arch);
		n1 = gaiaImport32 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN,
				   shp->endian_arch);
		base = 8 + (n * 4);
................................................................................
		      if (sz == ZM_size)
			  hasM = 1;
		  }
	    }
	  if (shape == GAIA_SHP_MULTIPOINTZ)
	    {
		/* shape multipoint Z */
		if (shp->memShp != NULL)
		    rd = gaiaMemRead (shp->BufShp, 32, shp->memShp);
		else
		    rd = fread (shp->BufShp, sizeof (unsigned char), 32,
				shp->flShp);
		if (rd != 32)
		    goto exit;
		if (shp->memShp != NULL)
		    rd = gaiaMemRead (shp->BufShp, (sz * 2) - 36, shp->memShp);
		else
		    rd = fread (shp->BufShp, sizeof (unsigned char),
				(sz * 2) - 36, shp->flShp);
		if (rd != (sz * 2) - 36)
		    goto exit;
		n = gaiaImport32 (shp->BufShp, GAIA_LITTLE_ENDIAN,
				  shp->endian_arch);
		ZM_size = 38 + (n * 16);	/* size [in 16 bits words !!!] ZM */
		if (sz == ZM_size)
		    hasM = 1;
................................................................................
gaiaAllocDbf ()
{
/* allocates and initializes the DBF object */
    gaiaDbfPtr dbf = malloc (sizeof (gaiaDbf));
    dbf->endian_arch = 1;
    dbf->Path = NULL;
    dbf->flDbf = NULL;
    dbf->memDbf = NULL;
    dbf->Dbf = NULL;
    dbf->BufDbf = NULL;
    dbf->DbfHdsz = 0;
    dbf->DbfReclen = 0;
    dbf->DbfSize = 0;
    dbf->DbfRecno = 0;
    dbf->Valid = 0;
................................................................................
	  goto unsupported_conversion;
      }
    if (dbf->flDbf != NULL)
      {
	  sprintf (errMsg, "attempting to reopen an already opened DBF\n");
	  goto unsupported_conversion;
      }
    if (dbf->memDbf == NULL)
      {
	  fl_dbf = fopen (path, "rb");
	  if (!fl_dbf)
	    {
		sys_err = strerror (errno);
		sprintf (errMsg, "unable to open '%s' for reading: %s", path,
			 sys_err);
		goto no_file;
	    }
      }
/* reading DBF file header */
    if (dbf->memDbf != NULL)
	rd = gaiaMemRead (bf, 32, dbf->memDbf);
    else
	rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
    if (rd != 32)
	goto error;
    switch (*bf)
      {
	  /* checks the DBF magic number */
      case 0x03:
      case 0x83:
................................................................................
    for (ind = 32; ind < dbf_size; ind += 32)
      {
	  /* fetches DBF fields definitions */
	  if ((dbf_size - ind) < 32)
	    {
		/* some odd DBF could contain some unexpected extra-padding */
		int extra = dbf_size - ind;
		if (dbf->memDbf != NULL)
		    rd = gaiaMemRead (bf, extra, dbf->memDbf);
		else
		    rd = fread (bf, sizeof (unsigned char), extra, fl_dbf);
		if (rd != extra)
		    goto error;
		/* ignoring the extra-padding */
		break;
	    }
	  if (dbf->memDbf != NULL)
	      rd = gaiaMemRead (bf, 32, dbf->memDbf);
	  else
	      rd = fread (bf, sizeof (unsigned char), 32, fl_dbf);
	  if (rd != 32)
	      goto error;
	  if (*(bf + 11) == 'M')
	    {
		/* skipping any MEMO field */
		memcpy (field_name, bf, 11);
		field_name[11] = '\0';
................................................................................
    int len;
    char errMsg[1024];
    gaiaDbfFieldPtr pFld;
/* positioning and reading the DBF file */
    offset =
	dbf->DbfHdsz +
	((gaia_off_t) current_row * (gaia_off_t) (dbf->DbfReclen));
    if (dbf->memDbf != NULL)
	skpos = gaiaMemFseek (dbf->memDbf, offset);
    else
	skpos = gaia_fseek (dbf->flDbf, offset, SEEK_SET);
    if (skpos != 0)
	goto eof;
    if (dbf->memDbf != NULL)
	rd = gaiaMemRead (dbf->BufDbf, dbf->DbfReclen, dbf->memDbf);
    else
	rd = fread (dbf->BufDbf, sizeof (unsigned char), dbf->DbfReclen,
		    dbf->flDbf);
    if (rd != dbf->DbfReclen)
	goto eof;
/* setting up the current DBF ENTITY */
    gaiaResetDbfEntity (dbf->Dbf);
    dbf->Dbf->RowId = current_row;
    if (*(dbf->BufDbf) == '*')
      {

Changes to src/headers/spatialite.h.

472
473
474
475
476
477
478
479




















































480
481
482
483
484
485
486
487
488
489
490


491

492

493
494
495
496
497
498
499
500
...
576
577
578
579
580
581
582
583
584
585
586
587

588
589

































590
591
592
593
594
595
596
 \param rows on completion will contain the total number of imported rows
 \param colname_case one between GAIA_DBF_COLNAME_LOWERCASE, 
	GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
 \param err_msg on completion will contain an error message (if any)

 \return 0 on failure, any other value on success

 \sa load_shapefile, load_shapefile_ex, load_shapefile_ex2





















































 \note the Shapefile format doesn't supports any distinction between
  LINESTRINGs and MULTILINESTRINGs, or between POLYGONs and MULTIPOLYGONs;
  as does not allows to clearly distinguish if the M-measure is required.
 \n So a first preliminary scan of the Shapefile is required in order to
  correctly identify the actual payload (gtype = "AUTO", default case).
 \n By explicitly specifying some expected geometry type this first scan
  will be skipped at all thus introducing a noticeable performance gain.
 \n Anyway, declaring a mismatching geometry type will surely cause a failure.
 */
    SPATIALITE_DECLARE int load_shapefile_ex3 (sqlite3 * sqlite, char *shp_path,


					       char *table, char *charset,

					       int srid, char *geo_column,

					       char *gtype, char *pk_column,
					       int coerce2d, int compressed,
					       int verbose, int spatial_index,
					       int text_date, int *rows,
					       int colname_case, char *err_msg);

/**
 Loads an external DBF file into a newly created table
................................................................................
 \param verbose if TRUE a short report is shown on stderr
 \param text_dates is TRUE all DBF dates will be considered as TEXT
 \param rows on completion will contain the total number of imported rows
 \param colname_case one between GAIA_DBF_COLNAME_LOWERCASE, 
	GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
 \param err_msg on completion will contain an error message (if any)

 \sa load_dbf, load_dbf_ex, load_dbf_ex2

 \return 0 on failure, any other value on success
 */
    SPATIALITE_DECLARE int load_dbf_ex3 (sqlite3 * sqlite, char *dbf_path,

					 char *table, char *pk_column,
					 char *charset, int verbose,

































					 int text_date, int *rows,
					 int colname_case, char *err_msg);

/**
 Dumps a full table into an external DBF file

 \param sqlite handle to current DB connection







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










|
>
>
|
>
|
>
|







 







|



|
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
...
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
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
 \param rows on completion will contain the total number of imported rows
 \param colname_case one between GAIA_DBF_COLNAME_LOWERCASE, 
	GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
 \param err_msg on completion will contain an error message (if any)

 \return 0 on failure, any other value on success

 \sa load_shapefile, load_shapefile_ex, load_shapefile_ex2, load_zip_shapefile

 \note the Shapefile format doesn't supports any distinction between
  LINESTRINGs and MULTILINESTRINGs, or between POLYGONs and MULTIPOLYGONs;
  as does not allows to clearly distinguish if the M-measure is required.
 \n So a first preliminary scan of the Shapefile is required in order to
  correctly identify the actual payload (gtype = "AUTO", default case).
 \n By explicitly specifying some expected geometry type this first scan
  will be skipped at all thus introducing a noticeable performance gain.
 \n Anyway, declaring a mismatching geometry type will surely cause a failure.
 */
    SPATIALITE_DECLARE int load_shapefile_ex3 (sqlite3 * sqlite,
					       const char *shp_path,
					       const char *table,
					       const char *charset, int srid,
					       const char *geo_column,
					       const char *gtype,
					       const char *pk_column,
					       int coerce2d, int compressed,
					       int verbose, int spatial_index,
					       int text_date, int *rows,
					       int colname_case, char *err_msg);

/**
 Loads an external Shapefile (from Zipfile) into a newly created table

 \param sqlite handle to current DB connection
 \param zip_path pathname of the Zipfile 
 \param shp_path pseudo-pathname of the Shapefile to be imported (no suffix) 
 \param table the name of the table to be created
 \param charset a valid GNU ICONV charset to be used for DBF text strings
 \param srid the SRID to be set for Geometries
 \param geo_column the name of the geometry column
 \param gtype expected to be one of: "LINESTRING", "LINESTRINGZ", 
  "LINESTRINGM", "LINESTRINGZM", "MULTILINESTRING", "MULTILINESTRINGZ",
  "MULTILINESTRINGM", "MULTILINESTRINGZM", "POLYGON", "POLYGONZ", "POLYGONM", 
  "POLYGONZM", "MULTIPOLYGON", "MULTIPOLYGONZ", "MULTIPOLYGONM", 
  "MULTIPOLYGONZM" or "AUTO".
 \param pk_column name of the Primary Key column; if NULL or mismatching
 then "PK_UID" will be assumed by default.
 \param coerce2d if TRUE any Geometry will be casted to 2D [XY]
 \param compressed if TRUE compressed Geometries will be created
 \param verbose if TRUE a short report is shown on stderr
 \param spatial_index if TRUE an R*Tree Spatial Index will be created
 \param text_dates is TRUE all DBF dates will be considered as TEXT
 \param rows on completion will contain the total number of imported rows
 \param colname_case one between GAIA_DBF_COLNAME_LOWERCASE, 
	GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
 \param err_msg on completion will contain an error message (if any)

 \return 0 on failure, any other value on success

 \sa load_shapefile_ex3

 \note the Shapefile format doesn't supports any distinction between
  LINESTRINGs and MULTILINESTRINGs, or between POLYGONs and MULTIPOLYGONs;
  as does not allows to clearly distinguish if the M-measure is required.
 \n So a first preliminary scan of the Shapefile is required in order to
  correctly identify the actual payload (gtype = "AUTO", default case).
 \n By explicitly specifying some expected geometry type this first scan
  will be skipped at all thus introducing a noticeable performance gain.
 \n Anyway, declaring a mismatching geometry type will surely cause a failure.
 */
    SPATIALITE_DECLARE int load_zip_shapefile (sqlite3 * sqlite,
					       const char *zip_path,
					       const char *shp_path,
					       const char *table,
					       const char *charset, int srid,
					       const char *geo_column,
					       const char *gtype,
					       const char *pk_column,
					       int coerce2d, int compressed,
					       int verbose, int spatial_index,
					       int text_date, int *rows,
					       int colname_case, char *err_msg);

/**
 Loads an external DBF file into a newly created table
................................................................................
 \param verbose if TRUE a short report is shown on stderr
 \param text_dates is TRUE all DBF dates will be considered as TEXT
 \param rows on completion will contain the total number of imported rows
 \param colname_case one between GAIA_DBF_COLNAME_LOWERCASE, 
	GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
 \param err_msg on completion will contain an error message (if any)

 \sa load_dbf, load_dbf_ex, load_dbf_ex2, load_zip_dbf

 \return 0 on failure, any other value on success
 */
    SPATIALITE_DECLARE int load_dbf_ex3 (sqlite3 * sqlite, const char *dbf_path,
					 const char *table,
					 const char *pk_column,
					 const char *charset, int verbose,
					 int text_date, int *rows,
					 int colname_case, char *err_msg);

/**
 Loads an external DBF file (from Zipfile) into a newly created table

 \param sqlite handle to current DB connection
 \param zip_path pathname of the Zipfile 
 \param shp_path pseudo-pathname of the Shapefile to be imported (no suffix) 

 \param sqlite handle to current DB connection
 \param zip_path pathname of the Zipfile 
 \param filenamepseudo-pathname of the DBF file to be imported (including the '.dbf' suffix) 
 \param table the name of the table to be created
 \param pk_column name of the Primary Key column; if NULL or mismatching
 then "PK_UID" will be assumed by default.
 \param charset a valid GNU ICONV charset to be used for DBF text strings
 \param verbose if TRUE a short report is shown on stderr
 \param text_dates is TRUE all DBF dates will be considered as TEXT
 \param rows on completion will contain the total number of imported rows
 \param colname_case one between GAIA_DBF_COLNAME_LOWERCASE, 
	GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
 \param err_msg on completion will contain an error message (if any)

 \sa load_dbf_ex3

 \return 0 on failure, any other value on success
 */
    SPATIALITE_DECLARE int load_zip_dbf (sqlite3 * sqlite, const char *zip_file,
					 const char *dbf_path,
					 const char *table,
					 const char *pk_column,
					 const char *charset, int verbose,
					 int text_date, int *rows,
					 int colname_case, char *err_msg);

/**
 Dumps a full table into an external DBF file

 \param sqlite handle to current DB connection

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

515
516
517
518
519
520
521














522
523
524
525
526

 \note this function will return a dynamically allocated buffer created 
 by malloc(). 
 You are required to explicitly free() any string returned by this function.
 */
    GAIAAUX_DECLARE char *gaiaFileExtFromPath (const char *path);















#ifdef __cplusplus
}
#endif

#endif				/* _GAIAAUX_H */







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





515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540

 \note this function will return a dynamically allocated buffer created 
 by malloc(). 
 You are required to explicitly free() any string returned by this function.
 */
    GAIAAUX_DECLARE char *gaiaFileExtFromPath (const char *path);

/**
 Return a text string containing no repeated whitespaces

 \param string the input string to be cleaned

 \return the corresponding string containing no repeated whitespaces,
 or NULL on failure

 \note this function will return a dynamically allocated buffer created 
 by malloc(). 
 You are required to explicitly free() any string returned by this function.
 */
    GAIAAUX_DECLARE char *gaiaRemoveExtraSpaces (const char *string);

#ifdef __cplusplus
}
#endif

#endif				/* _GAIAAUX_H */

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

1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702






















1703
1704
1705
1706
1707
1708
1709
....
1817
1818
1819
1820
1821
1822
1823
























































































1824
1825
1826
1827
1828
1829
1830
 Open a DBF File in read mode

 \param dbf pointer to the DBF File object.
 \param path pathname to the corresponding file-system file.
 \param charFrom GNU ICONV name identifying the input charset encoding.
 \param charTo GNU ICONV name identifying the output charset encoding.

 \sa gaiaAllocDbf, gaiaFreeDbf, gaiaOpenDbfWrite,
 gaiaReadDbfEntity, gaiaWriteDbfEntity, gaiaFlushDbfHeader

 \note on failure the object member \e Valid will be set to 0; and the
 object member \e LastError will contain the appropriate error message.
 */
    GAIAGEO_DECLARE void gaiaOpenDbfRead (gaiaDbfPtr dbf,
					  const char *path,
					  const char *charFrom,
					  const char *charTo);























/** 
 Open a DBF File in write mode,- extended

 \param dbf pointer to the DBF File object.
 \param path pathname to the corresponding file-system file.
 \param charFrom GNU ICONV name identifying the input charset encoding.
 \param charTo GNU ICONV name identifying the output charset encoding.
................................................................................

 \note forgetting to call gaiaFlushDbfHeader for any DBF File opened in
 \e write mode immediately before destroying the object, will surely 
 cause severe file corruption.
 */
    GAIAGEO_DECLARE void gaiaFlushDbfHeader (gaiaDbfPtr dbf);



























































































#ifndef OMIT_ICONV		/* ICONV enabled: supporting text reader */

/** 
 Creates a Text Reader object








|










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







 







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







1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
....
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
 Open a DBF File in read mode

 \param dbf pointer to the DBF File object.
 \param path pathname to the corresponding file-system file.
 \param charFrom GNU ICONV name identifying the input charset encoding.
 \param charTo GNU ICONV name identifying the output charset encoding.

 \sa gaiaAllocDbf, gaiaFreeDbf, gaiaOpenDbfWrite, gaiaOpenZipDbf,
 gaiaReadDbfEntity, gaiaWriteDbfEntity, gaiaFlushDbfHeader

 \note on failure the object member \e Valid will be set to 0; and the
 object member \e LastError will contain the appropriate error message.
 */
    GAIAGEO_DECLARE void gaiaOpenDbfRead (gaiaDbfPtr dbf,
					  const char *path,
					  const char *charFrom,
					  const char *charTo);

/**
 Open a DBF File contained within a Zipfile (just for checking its fields)

 \param zip_path path of the Zipfile.
 \param filename filename of the DB file within the Zipfile.
 \param charFrom GNU ICONV name identifying the input charset encoding.
 \param charTo GNU ICONV name identifying the output charset encoding.
 
 \return dbf pointer to the DBF File object. NULL on error.

 \sa gaiaAllocDbf, gaiaFreeDbf, gaiaOpenDbfWrite,
 gaiaReadDbfEntity, gaiaWriteDbfEntity, gaiaFlushDbfHeader
 
 \note you are responsible to destroy (before or after) any allocated DBF File.
 \n you should phisically open the DBF File in \e read or \e write mode
 before performing any actual I/O operation.
 */
    GAIAGEO_DECLARE gaiaDbfPtr gaiaOpenZipDbf (const char *zip_path,
					       const char *filename,
					       const char *charFrom,
					       const char *charTo);

/** 
 Open a DBF File in write mode,- extended

 \param dbf pointer to the DBF File object.
 \param path pathname to the corresponding file-system file.
 \param charFrom GNU ICONV name identifying the input charset encoding.
 \param charTo GNU ICONV name identifying the output charset encoding.
................................................................................

 \note forgetting to call gaiaFlushDbfHeader for any DBF File opened in
 \e write mode immediately before destroying the object, will surely 
 cause severe file corruption.
 */
    GAIAGEO_DECLARE void gaiaFlushDbfHeader (gaiaDbfPtr dbf);

/**
 Reads from a Memory File
 
 \param ptr pointer to the output buffer.
 \param bytes numeber of bytes to read.
 \param mem pointer to the Memory File object.

 \return the number of bytes read.

 \sa gaiaMemFseek
 */
    GAIAGEO_DECLARE size_t gaiaMemRead (void *ptr, size_t bytes,
					gaiaMemFilePtr mem);

/**
 Repositioning a Memory File
 
 \param mem pointer to the Memry File object.
 \param offset file offset relative to the start of file

 \return 0 on success; -1 on failure.

 \sa gaiaFseek
 */
    GAIAGEO_DECLARE int gaiaMemFseek (gaiaMemFilePtr mem, long offset);

/**
 Attempting to get a WKT from the .PRJ member of a given zipped Shapefile
 
 \param zip_path absolute or relativ pathname leading to the Zipfile.
 \param basename name of the Shapefile (excluding any .shp, .shx or .dbf suffix)

 \return the returned WKT expression from the .prj member of the zipped Shapefile
  or NULL on failure
  
 \note the WKT expression corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE char *gaiaReadWktFromZipShp (const char *zip_path,
						 const char *basename);

/**
 Will return the number of Shapefiles from within a given Zipfile
 
 \param zip_path absolute or relativ pathname leading to the Zipfile.
 \param count on success will contain the number of Shapefiles

 \return 0 on failure; any other value on success.
 */
    GAIAGEO_DECLARE int gaiaZipfileNumSHP (const char *zip_path, int *count);

/**
 Will return the basename of the Nth Shapefile from within a given Zipfile
 
 \param zip_path absolute or relativ pathname leading to the Zipfile.
 \param idx index (1-based) of the Shapefile

 \return the basename of the Nth Shapefile
  or NULL on failure
  
 \note the returned basename corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE char *gaiaZipfileShpN (const char *zip_path, int idx);

/**
 Will return the number of DBF files from within a given Zipfile
 
 \param zip_path absolute or relativ pathname leading to the Zipfile.
 \param count on success will contain the number of DBF files

 \return 0 on failure; any other value on success.
 */
    GAIAGEO_DECLARE int gaiaZipfileNumDBF (const char *zip_path, int *count);

/**
 Will return the filename of the Nth DBF file from within a given Zipfile
 
 \param zip_path absolute or relativ pathname leading to the Zipfile.
 \param idx index (1-based) of the DBF file

 \return the filename of the Nth DBF file
  or NULL on failure
  
 \note the returned filename corresponds to dynamically allocated memory:
 so you are responsible to free() it before or after.
 */
    GAIAGEO_DECLARE char *gaiaZipfileDbfN (const char *zip_path, int idx);


#ifndef OMIT_ICONV		/* ICONV enabled: supporting text reader */

/** 
 Creates a Text Reader object

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

52
53
54
55
56
57
58

59
60
61
62
63
64
65
...
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
...
413
414
415
416
417
418
419






420
421
422
423
424
425
426

#ifndef _GG_STRUCTS_H
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define _GG_STRUCTS_H
#endif

#include <sys/types.h>


#ifdef __cplusplus
extern "C"
{
#endif

/* supporting files bigger than 2 GB */
................................................................................
/**
 Typedef for a list of DBF fields
 
 \sa gaiaDbfList
 */
    typedef gaiaDbfList *gaiaDbfListPtr;



















/**
 Container for DBF file handling
 */
    typedef struct gaiaDbfStruct
    {
/* DBF TYPE */
/** DBF endian arch */
................................................................................
	int endian_arch;
/** validity flag: 1 = ready to be processed */
	int Valid;		/* 1 = ready to process */
/** DBF file pathname */
	char *Path;		/* the DBF path */
/** FILE handle */
	FILE *flDbf;		/* the DBF file handle */


/** list of DBF fields */
	gaiaDbfListPtr Dbf;	/* the DBF attributes list */
/** I/O buffer */
	unsigned char *BufDbf;	/* the DBF I/O buffer */
/** header size (in bytes) */
	int DbfHdsz;		/* the DBF header length */
/** record length (in bytes) */
................................................................................
	char *Path;		/* the shapefile abstract path [no suffixes] */
/** FILE handle to SHX file */
	FILE *flShx;		/* the SHX file handle */
/** FILE handle to SHP file */
	FILE *flShp;		/* the SHP file handle */
/** FILE handle to DBF file */
	FILE *flDbf;		/* the DBF file handle */






/** the SHP shape code */
	int Shape;		/* the SHAPE code for the whole shapefile */
/** list of DBF fields */
	gaiaDbfListPtr Dbf;	/* the DBF attributes list */
/** DBF I/O buffer */
	unsigned char *BufDbf;	/* the DBF I/O buffer */
/** DBF header size (in bytes) */







>







 







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







 







>
>







 







>
>
>
>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
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
...
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453

#ifndef _GG_STRUCTS_H
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define _GG_STRUCTS_H
#endif

#include <sys/types.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif

/* supporting files bigger than 2 GB */
................................................................................
/**
 Typedef for a list of DBF fields
 
 \sa gaiaDbfList
 */
    typedef gaiaDbfList *gaiaDbfListPtr;

/**
 A Memory based File
 */
    typedef struct gaiaMemFileStruct
    {
/* Memory File Type */
	char *path;
	void *buf;
	uint32_t size;
	uint32_t offset;
    } gaiaMemFile;
/** 
 Typedef for Memory File structure

 \sa gaiaMemFile
 */
    typedef gaiaMemFile *gaiaMemFilePtr;

/**
 Container for DBF file handling
 */
    typedef struct gaiaDbfStruct
    {
/* DBF TYPE */
/** DBF endian arch */
................................................................................
	int endian_arch;
/** validity flag: 1 = ready to be processed */
	int Valid;		/* 1 = ready to process */
/** DBF file pathname */
	char *Path;		/* the DBF path */
/** FILE handle */
	FILE *flDbf;		/* the DBF file handle */
/** Memory based DBF file */
	gaiaMemFilePtr memDbf;	/* the DBF memory file */
/** list of DBF fields */
	gaiaDbfListPtr Dbf;	/* the DBF attributes list */
/** I/O buffer */
	unsigned char *BufDbf;	/* the DBF I/O buffer */
/** header size (in bytes) */
	int DbfHdsz;		/* the DBF header length */
/** record length (in bytes) */
................................................................................
	char *Path;		/* the shapefile abstract path [no suffixes] */
/** FILE handle to SHX file */
	FILE *flShx;		/* the SHX file handle */
/** FILE handle to SHP file */
	FILE *flShp;		/* the SHP file handle */
/** FILE handle to DBF file */
	FILE *flDbf;		/* the DBF file handle */
/** Memory based SHX file */
	gaiaMemFilePtr memShx;	/* the SHX memory file */
/** Memory based SHP file */
	gaiaMemFilePtr memShp;	/* the SHP memory file */
/** Memory based DBF file */
	gaiaMemFilePtr memDbf;	/* the DBF memory file */
/** the SHP shape code */
	int Shape;		/* the SHAPE code for the whole shapefile */
/** list of DBF fields */
	gaiaDbfListPtr Dbf;	/* the DBF attributes list */
/** DBF I/O buffer */
	unsigned char *BufDbf;	/* the DBF I/O buffer */
/** DBF header size (in bytes) */

Changes to src/shapefiles/shapefiles.c.

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
...
136
137
138
139
140
141
142

































































































































































































































143
144
145
146
147
148
149
...
568
569
570
571
572
573
574
575
576

577
578
579

580
581
582
583
584
585
586
587
...
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
...
739
740
741
742
743
744
745







746
747
748
749
750
751
752
....
1532
1533
1534
1535
1536
1537
1538





















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1539
1540
1541
1542
1543
1544
1545
....
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
....
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
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
....
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
....
7771
7772
7773
7774
7775
7776
7777














































































































































































































































#endif

#ifndef OMIT_PROJ		/* including PROJ */
#ifdef PROJ_NEW			/* supporting PROJ.6 */
#include <proj.h>
#endif
#endif



#if defined(_WIN32) && !defined(__MINGW32__)
#define strcasecmp	_stricmp
#define strncasecmp	_strnicmp
#endif

/* 64 bit integer: portable format for printf() */
#if defined(_WIN32) && !defined(__MINGW32__)
#define FRMT64 "%I64d"
#else
#define FRMT64 "%lld"
#endif






struct auxdbf_fld
{
/* auxiliary DBF field struct */
    char already_used;
    gaiaDbfFieldPtr dbf_field;
    struct auxdbf_fld *next;
................................................................................
struct aux_elemgeom_options
{
/* Elementary Geometries Options */
    struct aux_elemgeom_ignore *first;
    struct aux_elemgeom_ignore *last;
    int cast2multi;
};


































































































































































































































static struct resultset_comparator *
create_resultset_comparator (int columns)
{
/* creating an empty resultset comparator object */
    int i;
    struct resultset_comparator *p =
................................................................................
{
    return load_shapefile_ex3 (sqlite, shp_path, table, charset, srid, g_column,
			       gtype, pk_column, coerce2d, compressed, verbose,
			       spatial_index, text_dates, rows,
			       GAIA_DBF_COLNAME_LOWERCASE, err_msg);
}

SPATIALITE_DECLARE int
load_shapefile_ex3 (sqlite3 * sqlite, char *shp_path, char *table,

		    char *charset, int srid, char *g_column, char *gtype,
		    char *pk_column, int coerce2d, int compressed,
		    int verbose, int spatial_index, int text_dates, int *rows,

		    int colname_case, char *err_msg)
{
    sqlite3_stmt *stmt = NULL;
    int ret;
    char *errMsg = NULL;
    char *sql;
    char *dummy;
    int already_exists = 0;
................................................................................
    int current_row = 0;
    int deleted = 0;
    char **col_name = NULL;
    unsigned char *blob;
    int blob_size;
    char *geom_type = NULL;
    char *txt_dims;
    char *geo_column = g_column;
    char *xgtype = gtype;
    char *qtable = NULL;
    char *qpk_name = NULL;
    const char *pk_name = NULL;
    char *casename;
    int pk_autoincr = 1;
    char *xname;
    int pk_type = SQLITE_INTEGER;
................................................................................
		spatialite_e ("load shapefile error: <%s>\n",
			      sqlite3_errmsg (sqlite));
		break;
	    }
      }
    sqlite3_finalize (stmt);
    shp = gaiaAllocShapefile ();







    gaiaOpenShpRead (shp, shp_path, charset, "UTF-8");
    if (!(shp->Valid))
      {
	  if (!err_msg)
	    {
		spatialite_e
		    ("load shapefile error: cannot open shapefile '%s'\n",
................................................................................
	  if (err_msg)
	      sprintf (err_msg, "Inserted %d rows into '%s' from SHAPEFILE",
		       current_row - deleted, table);
	  return 1;
      }
}






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































#endif /* end ICONV (SHP) */

#ifndef OMIT_PROJ		/* including PROJ */
#ifdef PROJ_NEW			/* only if new PROJ.6 is supported */
static int
output_prj_file_proj_new (int srid, const char *path, void *proj_ctx)
{
................................................................................
    if (db_prefix != NULL)
	free (db_prefix);
    if (table_name != NULL)
	free (table_name);
    return 0;
}

static int
do_check_dbf_unique_pk_values (sqlite3 * sqlite, gaiaDbfPtr dbf, int text_dates,
			       const char *pk_name, int pk_type)
{
/* checking for duplicate PK values */
    char *sql;
    sqlite3_stmt *stmt = NULL;
    gaiaDbfFieldPtr dbf_field;
    int ret;
    int deleted;
    int duplicates = 0;
    int current_row = 0;

    sql = "CREATE TABLE TEMP.check_unique_pk (pkey ANYVALUE)";
    ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
    if (ret != SQLITE_OK)
	return 0;

    sql = "INSERT INTO TEMP.check_unique_pk (pkey) VALUES (?)";
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	goto error;

    sqlite3_exec (sqlite, "BEGIN", NULL, NULL, NULL);

    while (1)
      {
	  /* reading rows from shapefile */
	  int ok_insert = 0;
	  ret = gaiaReadDbfEntity_ex (dbf, current_row, &deleted, text_dates);
	  if (!ret)
	      break;
	  current_row++;
	  if (deleted)
	    {
		/* skipping DBF deleted row */
		continue;
	    }
	  /* binding query params */
	  sqlite3_reset (stmt);
	  sqlite3_clear_bindings (stmt);
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		/* Primary Key value */
		if (strcasecmp (pk_name, dbf_field->Name) == 0)
		  {
		      if (pk_type == SQLITE_TEXT)
			{
			    ok_insert = 1;
			    sqlite3_bind_text (stmt, 1,
					       dbf_field->Value->TxtValue,
					       strlen (dbf_field->
						       Value->TxtValue),
					       SQLITE_STATIC);
			}
		      else if (pk_type == SQLITE_FLOAT)
			{
			    ok_insert = 1;
			    sqlite3_bind_double (stmt, 1,
						 dbf_field->Value->DblValue);
			}
		      else
			{
			    ok_insert = 1;
			    sqlite3_bind_int64 (stmt, 1,
						dbf_field->Value->IntValue);
			}
		  }
		dbf_field = dbf_field->Next;
	    }
	  if (ok_insert)
	    {
		ret = sqlite3_step (stmt);
		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
		    ;
		else
		    goto error;
	    }
      }
    sqlite3_finalize (stmt);
    stmt = NULL;
    sqlite3_exec (sqlite, "COMMIT", NULL, NULL, NULL);

    sql = "SELECT Count(*) FROM TEMP.check_unique_pk GROUP BY pkey";
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	goto error;

    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_int (stmt, 0) > 1)
		    duplicates = 1;
	    }
      }
    sqlite3_finalize (stmt);

    sqlite3_exec (sqlite, "DROP TABLE TEMP.check_unique_pk", NULL, NULL, NULL);
    if (duplicates)
	return 0;
    else
	return 1;

  error:
    if (stmt != NULL)
	sqlite3_finalize (stmt);
    sqlite3_exec (sqlite, "COMMIT", NULL, NULL, NULL);
    sqlite3_exec (sqlite, "DROP TABLE TEMP.check_unique_pk", NULL, NULL, NULL);
    return 0;
}

SPATIALITE_DECLARE int
load_dbf (sqlite3 * sqlite, char *dbf_path, char *table, char *charset,
	  int verbose, int *rows, char *err_msg)
{
    return load_dbf_ex (sqlite, dbf_path, table, NULL, charset, verbose, rows,
			err_msg);
}
................................................................................
	      char *err_msg)
{
    return load_dbf_ex3 (sqlite, dbf_path, table, pk_column, charset, verbose,
			 text_dates, rows, GAIA_DBF_COLNAME_LOWERCASE, err_msg);
}

SPATIALITE_DECLARE int
load_dbf_ex3 (sqlite3 * sqlite, char *dbf_path, char *table, char *pk_column,
	      char *charset, int verbose, int text_dates, int *rows,
	      int colname_case, char *err_msg)
{
    sqlite3_stmt *stmt;
    int ret;
    char *errMsg = NULL;
    char *sql;
    char *dummy;
    char *xname;
    int already_exists = 0;
    int sqlError = 0;
    gaiaDbfPtr dbf = NULL;
    gaiaDbfFieldPtr dbf_field;
    int cnt;
    int col_cnt;
    int seed;
    int len;
    int dup;
    int idup;
    int current_row = 0;
    char **col_name = NULL;
    int deleted;
    char *qtable = NULL;
    char *qpk_name = NULL;
    const char *pk_name = NULL;
    char *casename;
    int pk_autoincr = 1;
    gaiaOutBuffer sql_statement;
    int pk_type = SQLITE_INTEGER;
    int pk_set;
    const char *alt_pk[10] =
	{ "PK_ALT0", "PK_ALT1", "PK_ALT2", "PK_ALT3", "PK_ALT4", "PK_ALT5",
	"PK_ALT6", "PK_ALT7", "PK_ALT8", "PK_ALT9"
    };
    qtable = gaiaDoubleQuotedSql (table);
    if (rows)
	*rows = -1;
/* checking if TABLE already exists */
    sql = sqlite3_mprintf ("SELECT name FROM sqlite_master WHERE "
			   "type = 'table' AND Lower(name) = Lower(%Q)", table);
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    sqlite3_free (sql);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", sqlite3_errmsg (sqlite));
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n",
		       sqlite3_errmsg (sqlite));
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
    while (1)
      {
	  /* scrolling the result set */
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE)
	      break;		/* end of result set */
	  if (ret == SQLITE_ROW)
	      already_exists = 1;
	  else
	    {
		spatialite_e ("load DBF error: <%s>\n",
			      sqlite3_errmsg (sqlite));
		break;
	    }
      }
    sqlite3_finalize (stmt);
    if (already_exists)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: table '%s' already exists\n",
			    table);
	  else
	      sprintf (err_msg, "load DBF error: table '%s' already exists\n",
		       table);
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
    dbf = gaiaAllocDbf ();
    gaiaOpenDbfRead (dbf, dbf_path, charset, "UTF-8");
    if (!(dbf->Valid))
      {
	  if (!err_msg)
	    {
		spatialite_e ("load DBF error: cannot open '%s'\n", dbf_path);
		if (dbf->LastError)
		    spatialite_e ("\tcause: %s\n", dbf->LastError);
	    }
	  else
	    {
		char extra[512];
		*extra = '\0';
		if (dbf->LastError)
		    sprintf (extra, "\n\tcause: %s", dbf->LastError);
		sprintf (err_msg, "load DBF error: cannot open '%s'%s",
			 dbf_path, extra);
	    }
	  gaiaFreeDbf (dbf);
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
/* checking for duplicate / illegal column names and antialising them */
    col_cnt = 0;
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* counting DBF fields */
	  col_cnt++;
	  dbf_field = dbf_field->Next;
      }
    col_name = malloc (sizeof (char *) * col_cnt);
    cnt = 0;
    seed = 0;
    if (pk_column != NULL)
      {
	  /* validating the Primary Key column */
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		if (strcasecmp (pk_column, dbf_field->Name) == 0)
		  {
		      /* ok, using this field as Primary Key */
		      pk_name = pk_column;
		      pk_autoincr = 0;
		      switch (dbf_field->Type)
			{
			case 'C':
			    pk_type = SQLITE_TEXT;
			    break;
			case 'N':
			    if (dbf_field->Decimals)
				pk_type = SQLITE_FLOAT;
			    else
			      {
				  if (dbf_field->Length <= 18)
				      pk_type = SQLITE_INTEGER;
				  else
				      pk_type = SQLITE_FLOAT;
			      }
			    break;
			case 'D':
			    if (text_dates)
				pk_type = SQLITE_TEXT;
			    else
				pk_type = SQLITE_FLOAT;
			    break;
			case 'F':
			    pk_type = SQLITE_FLOAT;
			    break;
			case 'L':
			    pk_type = SQLITE_INTEGER;
			    break;
			};
		  }
		dbf_field = dbf_field->Next;
	    }
      }
    if (pk_name == NULL)
      {
	  if (pk_column != NULL)
	      pk_name = pk_column;
	  else
	      pk_name = "PK_UID";
      }
    if (!do_check_dbf_unique_pk_values
	(sqlite, dbf, text_dates, pk_name, pk_type))
      {
	  const char *old_pk = pk_name;
	  int antialias;
	  for (antialias = 0; antialias < 10; antialias++)
	    {
		/* searching an alternative Primary Key column name */
		int found = 0;
		pk_name = alt_pk[antialias];
		dbf_field = dbf->Dbf->First;
		while (dbf_field)
		  {
		      if (strcasecmp (pk_name, dbf_field->Name) == 0)
			  found = 1;
		      dbf_field = dbf_field->Next;
		  }
		if (!found)
		  {
		      pk_autoincr = 1;
		      goto ok_pk;
		  }
	    }
	  pk_name = old_pk;
      }
  ok_pk:
    casename = convert_dbf_colname_case (pk_name, colname_case);
    qpk_name = gaiaDoubleQuotedSql (casename);
    free (casename);
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* preparing column names */
	  char *xdummy = NULL;
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dummy = dbf_field->Name;
		len = strlen (dummy);
		*(col_name + cnt) = malloc (len + 1);
		strcpy (*(col_name + cnt), dummy);
		cnt++;
		dbf_field = dbf_field->Next;
		continue;
	    }
	  dummy = dbf_field->Name;
	  dup = 0;
	  for (idup = 0; idup < cnt; idup++)
	    {
		if (strcasecmp (dummy, *(col_name + idup)) == 0)
		    dup = 1;
	    }
	  if (dup)
	    {
		xdummy = sqlite3_mprintf ("COL_%d", seed++);
		dummy = xdummy;
	    }
	  len = strlen (dummy);
	  *(col_name + cnt) = malloc (len + 1);
	  strcpy (*(col_name + cnt), dummy);
	  if (xdummy)
	      free (xdummy);
	  cnt++;
	  dbf_field = dbf_field->Next;
      }
    if (verbose)
	spatialite_e ("========\nLoading DBF at '%s' into SQLite table '%s'\n",
		      dbf_path, table);
/* starting a transaction */
    if (verbose)
	spatialite_e ("\nBEGIN;\n");
    ret = sqlite3_exec (sqlite, "BEGIN", NULL, 0, &errMsg);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", errMsg);
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n", errMsg);
	  sqlite3_free (errMsg);
	  sqlError = 1;
	  goto clean_up;
      }
/* creating the Table */
    gaiaOutBufferInitialize (&sql_statement);
    if (pk_type == SQLITE_TEXT)
      {
	  sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				 "TEXT PRIMARY KEY NOT NULL", qtable, qpk_name);
      }
    else if (pk_type == SQLITE_FLOAT)
      {
	  sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				 "DOUBLE PRIMARY KEY NOT NULL", qtable,
				 qpk_name);
      }
    else
      {
	  if (pk_autoincr)
	      sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				     "INTEGER PRIMARY KEY AUTOINCREMENT",
				     qtable, qpk_name);
	  else
	      sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				     "INTEGER NOT NULL PRIMARY KEY", qtable,
				     qpk_name);
      }
    gaiaAppendToOutBuffer (&sql_statement, sql);
    sqlite3_free (sql);
    cnt = 0;
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dbf_field = dbf_field->Next;
		cnt++;
		continue;
	    }
	  casename = convert_dbf_colname_case (*(col_name + cnt), colname_case);
	  xname = gaiaDoubleQuotedSql (casename);
	  free (casename);
	  sql = sqlite3_mprintf (",\n\"%s\"", xname);
	  free (xname);
	  gaiaAppendToOutBuffer (&sql_statement, sql);
	  sqlite3_free (sql);
	  cnt++;
	  switch (dbf_field->Type)
	    {
	    case 'C':
		gaiaAppendToOutBuffer (&sql_statement, " TEXT");
		break;
	    case 'N':
		if (dbf_field->Decimals)
		    gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		else
		  {
		      if (dbf_field->Length <= 18)
			  gaiaAppendToOutBuffer (&sql_statement, " INTEGER");
		      else
			  gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		  }
		break;
	    case 'D':
		if (text_dates)
		    gaiaAppendToOutBuffer (&sql_statement, " TEXT");
		else
		    gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		break;
	    case 'F':
		gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		break;
	    case 'L':
		gaiaAppendToOutBuffer (&sql_statement, " INTEGER");
		break;
	    };
	  dbf_field = dbf_field->Next;
      }
    gaiaAppendToOutBuffer (&sql_statement, ")");
    if (sql_statement.Error == 0 && sql_statement.Buffer != NULL)
      {
	  if (verbose)
	      spatialite_e ("%s;\n", sql_statement.Buffer);
	  ret = sqlite3_exec (sqlite, sql_statement.Buffer, NULL, 0, &errMsg);
      }
    else
	ret = SQLITE_ERROR;
    gaiaOutBufferReset (&sql_statement);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", errMsg);
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n", errMsg);
	  sqlite3_free (errMsg);
	  sqlError = 1;
	  goto clean_up;
      }
    /* preparing the INSERT INTO parametrerized statement */
    sql = sqlite3_mprintf ("INSERT INTO \"%s\" (\"%s\"", qtable, qpk_name);
    gaiaAppendToOutBuffer (&sql_statement, sql);
    sqlite3_free (sql);
    cnt = 0;
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* columns corresponding to some DBF attribute */
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dbf_field = dbf_field->Next;
		cnt++;
		continue;
	    }
	  xname = gaiaDoubleQuotedSql (*(col_name + cnt++));
	  sql = sqlite3_mprintf (",\"%s\"", xname);
	  free (xname);
	  gaiaAppendToOutBuffer (&sql_statement, sql);
	  sqlite3_free (sql);
	  dbf_field = dbf_field->Next;
      }
    gaiaAppendToOutBuffer (&sql_statement, ")\nVALUES (?");
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* column values */
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dbf_field = dbf_field->Next;
		continue;
	    }
	  gaiaAppendToOutBuffer (&sql_statement, ", ?");
	  dbf_field = dbf_field->Next;
      }
    gaiaAppendToOutBuffer (&sql_statement, ")");
    if (sql_statement.Error == 0 && sql_statement.Buffer != NULL)
	ret =
	    sqlite3_prepare_v2 (sqlite, sql_statement.Buffer,
				strlen (sql_statement.Buffer), &stmt, NULL);
    else
	ret = SQLITE_ERROR;
    gaiaOutBufferReset (&sql_statement);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", sqlite3_errmsg (sqlite));
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n",
		       sqlite3_errmsg (sqlite));
	  sqlError = 1;
	  goto clean_up;
      }
    current_row = 0;
    while (1)
      {
	  /* inserting rows from DBF */
	  ret = gaiaReadDbfEntity_ex (dbf, current_row, &deleted, text_dates);
	  if (!ret)
	    {
		if (!(dbf->LastError))	/* normal DBF EOF */
		    break;
		if (!err_msg)
		    spatialite_e ("%s\n", dbf->LastError);
		else
		    sprintf (err_msg, "%s\n", dbf->LastError);
		sqlError = 1;
		goto clean_up;
	    }
	  current_row++;
	  if (deleted)
	    {
		/* skipping DBF deleted row */
		continue;
	    }
	  /* binding query params */
	  sqlite3_reset (stmt);
	  sqlite3_clear_bindings (stmt);
	  pk_set = 0;
	  cnt = 0;
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		/* Primary Key value */
		if (strcasecmp (pk_name, dbf_field->Name) == 0)
		  {
		      if (pk_type == SQLITE_TEXT)
			  sqlite3_bind_text (stmt, 1,
					     dbf_field->Value->TxtValue,
					     strlen (dbf_field->
						     Value->TxtValue),
					     SQLITE_STATIC);
		      else if (pk_type == SQLITE_FLOAT)
			  sqlite3_bind_double (stmt, 1,
					       dbf_field->Value->DblValue);
		      else
			  sqlite3_bind_int64 (stmt, 1,
					      dbf_field->Value->IntValue);
		      pk_set = 1;
		  }
		dbf_field = dbf_field->Next;
	    }
	  if (!pk_set)
	      sqlite3_bind_int (stmt, 1, current_row);
	  cnt = 0;
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		/* column values */
		if (strcasecmp (pk_name, dbf_field->Name) == 0)
		  {
		      /* skipping the Primary Key field */
		      dbf_field = dbf_field->Next;
		      continue;
		  }
		if (!(dbf_field->Value))
		    sqlite3_bind_null (stmt, cnt + 2);
		else
		  {
		      switch (dbf_field->Value->Type)
			{
			case GAIA_INT_VALUE:
			    sqlite3_bind_int64 (stmt, cnt + 2,
						dbf_field->Value->IntValue);
			    break;
			case GAIA_DOUBLE_VALUE:
			    sqlite3_bind_double (stmt, cnt + 2,
						 dbf_field->Value->DblValue);
			    break;
			case GAIA_TEXT_VALUE:
			    sqlite3_bind_text (stmt, cnt + 2,
					       dbf_field->Value->TxtValue,
					       strlen (dbf_field->
						       Value->TxtValue),
					       SQLITE_STATIC);
			    break;
			default:
			    sqlite3_bind_null (stmt, cnt + 2);
			    break;
			}
		  }
		cnt++;
		dbf_field = dbf_field->Next;
	    }
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
	      ;
	  else
	    {
		if (!err_msg)
		    spatialite_e ("load DBF error: <%s>\n",
				  sqlite3_errmsg (sqlite));
		else
		    sprintf (err_msg, "load DBF error: <%s>\n",
			     sqlite3_errmsg (sqlite));
		sqlite3_finalize (stmt);
		sqlError = 1;
		goto clean_up;
	    }
      }
    sqlite3_finalize (stmt);
  clean_up:
    if (qtable)
	free (qtable);
    qtable = NULL;
    if (qpk_name)
	free (qpk_name);
    qpk_name = NULL;
    gaiaFreeDbf (dbf);
    if (col_name)
      {
	  /* releasing memory allocation for column names */
	  for (cnt = 0; cnt < col_cnt; cnt++)
	      free (*(col_name + cnt));
	  free (col_name);
      }
    if (sqlError)
      {
	  /* some error occurred - ROLLBACK */
	  if (verbose)
	      spatialite_e ("ROLLBACK;\n");
	  ret = sqlite3_exec (sqlite, "ROLLBACK", NULL, 0, &errMsg);
	  if (ret != SQLITE_OK)
	    {
		spatialite_e ("load DBF error: <%s>\n", errMsg);
		sqlite3_free (errMsg);
	    };
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
    else
      {
	  /* ok - confirming pending transaction - COMMIT */
	  if (verbose)
	      spatialite_e ("COMMIT;\n");
	  ret = sqlite3_exec (sqlite, "COMMIT", NULL, 0, &errMsg);
	  if (ret != SQLITE_OK)
	    {
		spatialite_e ("load DBF error: <%s>\n", errMsg);
		sqlite3_free (errMsg);
		return 0;
	    }
	  if (rows)
	      *rows = current_row;
	  if (verbose)
	      spatialite_e ("\nInserted %d rows into '%s' from DBF\n========\n",
			    current_row, table);
	  if (err_msg)
	      sprintf (err_msg, "Inserted %d rows into '%s' from DBF",
		       current_row, table);
	  return 1;
      }
}

SPATIALITE_DECLARE int
dump_dbf (sqlite3 * sqlite, char *table, char *dbf_path, char *charset,
	  char *err_msg)
{
    int rows;
................................................................................
    xgeom_col = gaiaDoubleQuotedSql (geom_col);
    sql =
	sqlite3_mprintf
	("SELECT AsGeoJSON(\"%s\", %d, %d) FROM \"%s\" WHERE \"%s\" IS NOT NULL",
	 xgeom_col, precision, option, xtable, xgeom_col);
    free (xtable);
    free (xgeom_col);
fprintf(stderr, "%s\n", sql);
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    sqlite3_free (sql);
    if (ret != SQLITE_OK)
	goto sql_error;

    while (1)
      {
................................................................................
	return;

    if (strncasecmp (option, "::cast2multi::", 14) == 0)
	options->cast2multi = 1;
    if (strncasecmp (option, "::ignore::", 10) == 0)
	ignore_column (options, option + 10);
}





















































































































































































































































>
>












>
>
>
>
>







 







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







 







|
|
>
|
|
|
>
|







 







|
|







 







>
>
>
>
>
>
>







 







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







 







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







 







|
|
|

|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
...
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
...
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
...
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
...
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
....
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
....
5037
5038
5039
5040
5041
5042
5043





















































































































5044
5045
5046
5047
5048
5049
5050
....
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075




















































































































































































































































































































































































































































































































































































5076
5077
5078
5079
5080
5081
5082
....
7562
7563
7564
7565
7566
7567
7568

7569
7570
7571
7572
7573
7574
7575
....
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
#endif

#ifndef OMIT_PROJ		/* including PROJ */
#ifdef PROJ_NEW			/* supporting PROJ.6 */
#include <proj.h>
#endif
#endif

#include <minizip/unzip.h>

#if defined(_WIN32) && !defined(__MINGW32__)
#define strcasecmp	_stricmp
#define strncasecmp	_strnicmp
#endif

/* 64 bit integer: portable format for printf() */
#if defined(_WIN32) && !defined(__MINGW32__)
#define FRMT64 "%I64d"
#else
#define FRMT64 "%lld"
#endif

#define GAIA_ZIPFILE_SHP	1
#define GAIA_ZIPFILE_SHX	2
#define GAIA_ZIPFILE_DBF	3
#define GAIA_ZIPFILE_PRJ	4

struct auxdbf_fld
{
/* auxiliary DBF field struct */
    char already_used;
    gaiaDbfFieldPtr dbf_field;
    struct auxdbf_fld *next;
................................................................................
struct aux_elemgeom_options
{
/* Elementary Geometries Options */
    struct aux_elemgeom_ignore *first;
    struct aux_elemgeom_ignore *last;
    int cast2multi;
};

struct zip_mem_shapefile
{
/* a struct wrapping a Memory Shapefile from Zipfile */
    gaiaMemFile shp;
    gaiaMemFile shx;
    gaiaMemFile dbf;
    gaiaMemFile prj;
};

struct zip_mem_shp_item
{
/* a Shapefile within a Zipfile */
    char *basename;
    int shp;
    int shx;
    int dbf;
    int prj;
    struct zip_mem_shp_item *next;
};

struct zip_mem_shp_list
{
/* a list of Shapefiles within a Zipfile */
    struct zip_mem_shp_item *first;
    struct zip_mem_shp_item *last;
};

static struct zip_mem_shp_item *
alloc_zip_mem_shp_item (const char *basename, int wich, int dbf_only)
{
/* creating a Shapefile within a Zipfile */
    struct zip_mem_shp_item *item = malloc (sizeof (struct zip_mem_shp_item));
    if (basename == NULL)
	item->basename = NULL;
    else
      {
	  int len = strlen (basename);
	  item->basename = malloc (len + 1);
	  strcpy (item->basename, basename);
	  if (!dbf_only)
	    {
		if (*(item->basename + len - 4) == '.')
		    *(item->basename + len - 4) = '\0';
	    }
      }
    item->shp = 0;
    item->shx = 0;
    item->dbf = 0;
    item->prj = 0;
    switch (wich)
      {
      case GAIA_ZIPFILE_SHP:
	  item->shp = 1;
	  break;
      case GAIA_ZIPFILE_SHX:
	  item->shx = 1;
	  break;
      case GAIA_ZIPFILE_DBF:
	  item->dbf = 1;
	  break;
      case GAIA_ZIPFILE_PRJ:
	  item->prj = 1;
	  break;
      };
    item->next = NULL;
    return item;
}

static void
add_item_into_zip_mem_shp_list (struct zip_mem_shp_list *list,
				const char *filename, int wich, int dbf_only)
{
/* populating the list of Zipfile Shapefiles */
    struct zip_mem_shp_item *item;

    if (list == NULL)
	return;

    item = list->first;
    while (item != NULL)
      {
	  /* verifying an already existing basename */
	  char *name = NULL;
	  switch (wich)
	    {
	    case GAIA_ZIPFILE_SHP:
		name = sqlite3_mprintf ("%s.shp", item->basename);
		break;
	    case GAIA_ZIPFILE_SHX:
		name = sqlite3_mprintf ("%s.shx", item->basename);
		break;
	    case GAIA_ZIPFILE_DBF:
		name = sqlite3_mprintf ("%s.dbf", item->basename);
		break;
	    case GAIA_ZIPFILE_PRJ:
		name = sqlite3_mprintf ("%s.prj", item->basename);
		break;
	    };
	  if (name != NULL)
	    {
		if (strcasecmp (name, filename) == 0)
		  {
		      /* found a mathcing basename */
		      sqlite3_free (name);
		      switch (wich)
			{
			case GAIA_ZIPFILE_SHP:
			    item->shp = 1;
			    break;
			case GAIA_ZIPFILE_SHX:
			    item->shx = 1;
			    break;
			case GAIA_ZIPFILE_DBF:
			    item->dbf = 1;
			    break;
			case GAIA_ZIPFILE_PRJ:
			    item->prj = 1;
			    break;
			};
		      return;
		  }
		sqlite3_free (name);
	    }
	  item = item->next;
      }

/* inserting a new basename into the list */
    item = alloc_zip_mem_shp_item (filename, wich, dbf_only);
    if (list->first == NULL)
	list->first = item;
    if (list->last != NULL)
	list->last->next = item;
    list->last = item;
}

static struct zip_mem_shapefile *
alloc_zip_mem_shapefile ()
{
/* allocating a Memory Zip Shapefile */
    struct zip_mem_shapefile *mem_shp =
	malloc (sizeof (struct zip_mem_shapefile));
    mem_shp->shp.path = NULL;
    mem_shp->shp.buf = NULL;
    mem_shp->shp.size = 0;
    mem_shp->shp.offset = 0;
    mem_shp->shx.path = NULL;
    mem_shp->shx.buf = NULL;
    mem_shp->shx.size = 0;
    mem_shp->shx.offset = 0;
    mem_shp->dbf.path = NULL;
    mem_shp->dbf.buf = NULL;
    mem_shp->dbf.size = 0;
    mem_shp->dbf.offset = 0;
    mem_shp->prj.path = NULL;
    mem_shp->prj.buf = NULL;
    mem_shp->prj.size = 0;
    mem_shp->prj.offset = 0;
    return mem_shp;
}

static void
destroy_zip_mem_file (gaiaMemFilePtr mem)
{
/* memory cleanup: destroying a Memoroy Zip File */
    if (mem == NULL)
	return;
    if (mem->path != NULL)
	free (mem->path);
    if (mem->buf != NULL)
	free (mem->buf);
}

static void
destroy_zip_mem_shapefile (struct zip_mem_shapefile *mem_shp)
{
/* memory cleanup: destroying a Memory Zip Shapefile */
    if (mem_shp == NULL)
	return;
    destroy_zip_mem_file (&(mem_shp->shp));
    destroy_zip_mem_file (&(mem_shp->shx));
    destroy_zip_mem_file (&(mem_shp->dbf));
    destroy_zip_mem_file (&(mem_shp->prj));
    free (mem_shp);
}

static void
destroy_zip_mem_shp_item (struct zip_mem_shp_item *item)
{
/* destroying a Shapefile item */
    if (item == NULL)
	return;
    if (item->basename != NULL)
	free (item->basename);
    free (item);
}

static struct zip_mem_shp_list *
alloc_zip_mem_shp_list ()
{
/* creating a list of Shapefiles within a Shapefile */
    struct zip_mem_shp_list *list = malloc (sizeof (struct zip_mem_shp_list));
    list->first = NULL;
    list->last = NULL;
    return list;
}

static void
destroy_zip_mem_shp_list (struct zip_mem_shp_list *list)
{
/* memory cleanup: destroying a list of Shapefiles within a Shapefile */
    struct zip_mem_shp_item *item;
    struct zip_mem_shp_item *item_n;

    if (list == NULL)
	return;
    item = list->first;
    while (item != NULL)
      {
	  item_n = item->next;
	  destroy_zip_mem_shp_item (item);
	  item = item_n;
      }
    free (list);
}

static struct resultset_comparator *
create_resultset_comparator (int columns)
{
/* creating an empty resultset comparator object */
    int i;
    struct resultset_comparator *p =
................................................................................
{
    return load_shapefile_ex3 (sqlite, shp_path, table, charset, srid, g_column,
			       gtype, pk_column, coerce2d, compressed, verbose,
			       spatial_index, text_dates, rows,
			       GAIA_DBF_COLNAME_LOWERCASE, err_msg);
}

static int
load_shapefile_common (struct zip_mem_shapefile *mem_shape, sqlite3 * sqlite,
		       const char *shp_path, const char *table,
		       const char *charset, int srid, const char *g_column,
		       const char *gtype, const char *pk_column, int coerce2d,
		       int compressed, int verbose, int spatial_index,
		       int text_dates, int *rows, int colname_case,
		       char *err_msg)
{
    sqlite3_stmt *stmt = NULL;
    int ret;
    char *errMsg = NULL;
    char *sql;
    char *dummy;
    int already_exists = 0;
................................................................................
    int current_row = 0;
    int deleted = 0;
    char **col_name = NULL;
    unsigned char *blob;
    int blob_size;
    char *geom_type = NULL;
    char *txt_dims;
    const char *geo_column = g_column;
    const char *xgtype = gtype;
    char *qtable = NULL;
    char *qpk_name = NULL;
    const char *pk_name = NULL;
    char *casename;
    int pk_autoincr = 1;
    char *xname;
    int pk_type = SQLITE_INTEGER;
................................................................................
		spatialite_e ("load shapefile error: <%s>\n",
			      sqlite3_errmsg (sqlite));
		break;
	    }
      }
    sqlite3_finalize (stmt);
    shp = gaiaAllocShapefile ();
    if (mem_shape != NULL)
      {
	  /* initializing Memory based files */
	  shp->memShx = &(mem_shape->shx);
	  shp->memShp = &(mem_shape->shp);
	  shp->memDbf = &(mem_shape->dbf);
      }
    gaiaOpenShpRead (shp, shp_path, charset, "UTF-8");
    if (!(shp->Valid))
      {
	  if (!err_msg)
	    {
		spatialite_e
		    ("load shapefile error: cannot open shapefile '%s'\n",
................................................................................
	  if (err_msg)
	      sprintf (err_msg, "Inserted %d rows into '%s' from SHAPEFILE",
		       current_row - deleted, table);
	  return 1;
      }
}

SPATIALITE_DECLARE int
load_shapefile_ex3 (sqlite3 * sqlite, const char *shp_path, const char *table,
		    const char *charset, int srid, const char *g_column,
		    const char *gtype, const char *pk_column, int coerce2d,
		    int compressed, int verbose, int spatial_index,
		    int text_dates, int *rows, int colname_case, char *err_msg)
{
    return load_shapefile_common (NULL, sqlite, shp_path, table, charset, srid,
				  g_column, gtype, pk_column, coerce2d,
				  compressed, verbose, spatial_index,
				  text_dates, rows, colname_case, err_msg);
}

#ifdef ENABLE_MINIZIP		/* MINIZIP is enabled */

static int
do_sniff_zipfile_dir (unzFile uf, struct zip_mem_shp_list *list, int dbf_only)
{
/* sniffing a Zipfile directory */
    int retval = 1;
    unz_global_info64 gi;
    int ret;
    unsigned int i;

    ret = unzGetGlobalInfo64 (uf, &gi);
    if (ret != UNZ_OK)
      {
	  spatialite_e ("Error %d within zipfile in unzGetGlobalInfo\n", ret);
	  return 0;
      }

    for (i = 0; i < gi.number_entry; i++)
      {
	  unsigned int len;
	  char suffix[6];
	  char filename[256];
	  unz_file_info64 file_info;

	  ret =
	      unzGetCurrentFileInfo64 (uf, &file_info, filename, 256, NULL, 0,
				       NULL, 0);
	  if (ret != UNZ_OK)
	    {
		spatialite_e
		    ("Error %d with zipfile in unzGetCurrentFileInfo\n", ret);
		retval = 0;
		goto stop;
	    }

	  suffix[0] = '\0';
	  len = strlen (filename);
	  if (len >= 5)
	    {
		suffix[0] = *(filename + len - 4);
		suffix[1] = *(filename + len - 3);
		suffix[2] = *(filename + len - 2);
		suffix[3] = *(filename + len - 1);
		suffix[4] = '\0';
	    }
	  if (strcasecmp (suffix, ".shp") == 0)
	      add_item_into_zip_mem_shp_list (list, filename, GAIA_ZIPFILE_SHP,
					      0);
	  if (strcasecmp (suffix, ".shx") == 0)
	      add_item_into_zip_mem_shp_list (list, filename, GAIA_ZIPFILE_SHX,
					      0);
	  if (strcasecmp (suffix, ".dbf") == 0)
	      add_item_into_zip_mem_shp_list (list, filename, GAIA_ZIPFILE_DBF,
					      dbf_only);
	  if (strcasecmp (suffix, ".prj") == 0)
	      add_item_into_zip_mem_shp_list (list, filename, GAIA_ZIPFILE_PRJ,
					      0);

	  if (i + 1 == gi.number_entry)
	      break;
	  ret = unzGoToNextFile (uf);
	  if (ret != UNZ_OK)
	    {
		spatialite_e ("Error %d with zipfile in unzGoToNextFile\n",
			      ret);
		retval = 0;
		goto stop;
	    }
      }
  stop:
    return retval;
}

static struct zip_mem_shapefile *
do_list_zipfile_dir (unzFile uf, const char *shp_path, int dbf_mode)
{
/* parsing a Zipfile directory */
    unz_global_info64 gi;
    int ret;
    unsigned int i;
    int len;
    int shp = 0;
    int dbf = 0;
    int shx = 0;
    int prj = 0;
    struct zip_mem_shapefile *mem_shp = NULL;

    ret = unzGetGlobalInfo64 (uf, &gi);
    if (ret != UNZ_OK)
      {
	  spatialite_e ("Error %d within zipfile in unzGetGlobalInfo\n", ret);
	  return 0;
      }

    mem_shp = alloc_zip_mem_shapefile ();
    for (i = 0; i < gi.number_entry; i++)
      {
	  char *path;
	  char filename[256];
	  unz_file_info64 file_info;

	  ret =
	      unzGetCurrentFileInfo64 (uf, &file_info, filename, 256, NULL, 0,
				       NULL, 0);
	  if (ret != UNZ_OK)
	    {
		spatialite_e
		    ("Error %d with zipfile in unzGetCurrentFileInfo\n", ret);
		goto error;
	    }
	  if (dbf_mode)
	    {
		/* searching for just a bare DBF */
		if (!dbf)
		  {
		      if (strcasecmp (shp_path, filename) == 0)
			{
			    dbf = 1;
			    len = strlen (filename);
			    mem_shp->dbf.path = malloc (len + 1);
			    strcpy (mem_shp->dbf.path, filename);
			}
		  }
	    }
	  else
	    {
		/* searching for a Shapefile */
		if (!shp)
		  {
		      path = sqlite3_mprintf ("%s.shp", shp_path);
		      if (strcasecmp (path, filename) == 0)
			{
			    shp = 1;
			    len = strlen (filename);
			    mem_shp->shp.path = malloc (len + 1);
			    strcpy (mem_shp->shp.path, filename);
			}
		      sqlite3_free (path);
		  }
		if (!shx)
		  {
		      path = sqlite3_mprintf ("%s.shx", shp_path);
		      if (strcasecmp (path, filename) == 0)
			{
			    shx = 1;
			    len = strlen (filename);
			    mem_shp->shx.path = malloc (len + 1);
			    strcpy (mem_shp->shx.path, filename);
			}
		      sqlite3_free (path);
		  }
		if (!dbf)
		  {
		      path = sqlite3_mprintf ("%s.dbf", shp_path);
		      if (strcasecmp (path, filename) == 0)
			{
			    dbf = 1;
			    len = strlen (filename);
			    mem_shp->dbf.path = malloc (len + 1);
			    strcpy (mem_shp->dbf.path, filename);
			}
		      sqlite3_free (path);
		  }
		if (!prj)
		  {
		      path = sqlite3_mprintf ("%s.prj", shp_path);
		      if (strcasecmp (path, filename) == 0)
			{
			    prj = 1;
			    len = strlen (filename);
			    mem_shp->prj.path = malloc (len + 1);
			    strcpy (mem_shp->prj.path, filename);
			}
		      sqlite3_free (path);
		  }
	    }

	  if (i + 1 == gi.number_entry)
	      break;
	  ret = unzGoToNextFile (uf);
	  if (ret != UNZ_OK)
	    {
		spatialite_e ("Error %d with zipfile in unzGoToNextFile\n",
			      ret);
		goto error;
	    }
      }
    if (dbf_mode && dbf)
	return mem_shp;
    if (shp && shx && dbf)
	return mem_shp;

  error:
    destroy_zip_mem_shapefile (mem_shp);
    return NULL;
}

static int
do_read_zipfile_file (unzFile uf, struct zip_mem_shapefile *mem_shape, int wich)
{
//
// impo
    int is_open = 0;
    int retval = 1;
    uint32_t size_buf;
    void *buf = NULL;
    char filename[256];
    gaiaMemFilePtr mem_file;
    unz_file_info64 file_info;
    int err;

    switch (wich)
      {
      case GAIA_ZIPFILE_SHP:
	  mem_file = &(mem_shape->shp);
	  break;
      case GAIA_ZIPFILE_SHX:
	  mem_file = &(mem_shape->shx);
	  break;
      case GAIA_ZIPFILE_DBF:
	  mem_file = &(mem_shape->dbf);
	  break;
      case GAIA_ZIPFILE_PRJ:
	  mem_file = &(mem_shape->prj);
	  break;
      default:
	  mem_file = NULL;
      };
    if (mem_file == NULL)
	return 0;
    if (mem_file->path == NULL)
	return 0;

    err = unzLocateFile (uf, mem_file->path, 0);
    if (err != UNZ_OK)
      {
	  spatialite_e ("File %s not found within zipfile\n", mem_file->path);
	  retval = 0;
	  goto skip;
      }
    err =
	unzGetCurrentFileInfo64 (uf, &file_info, filename, 256, NULL, 0, NULL,
				 0);
    if (err != UNZ_OK)
      {
	  spatialite_e ("Error %d with zipfile in unzGetCurrentFileInfo\n",
			err);
	  retval = 0;
	  goto skip;
      }
    size_buf = file_info.uncompressed_size;
    buf = malloc (size_buf);
    err = unzOpenCurrentFile (uf);
    if (err != UNZ_OK)
      {
	  spatialite_e ("Error %d with zipfile in unzGetCurrentFileInfo\n",
			err);
	  retval = 0;
	  goto skip;
      }
    is_open = 1;
    err = unzReadCurrentFile (uf, buf, size_buf);
    if (err < 0)
      {
	  spatialite_e ("Error %d with zipfile in unzReadCurrentFile\n", err);
	  retval = 0;
	  goto skip;
      }
    mem_file->buf = buf;
    mem_file->size = size_buf;

  skip:
    if (buf != NULL && !retval)
	free (buf);
    if (is_open)
	unzCloseCurrentFile (uf);
    return retval;
}

SPATIALITE_DECLARE int
load_zip_shapefile (sqlite3 * sqlite, const char *zip_path,
		    const char *shp_path, const char *table,
		    const char *charset, int srid, const char *g_column,
		    const char *gtype, const char *pk_column, int coerce2d,
		    int compressed, int verbose, int spatial_index,
		    int text_dates, int *rows, int colname_case, char *err_msg)
{
/* loading a Shapefile from within a Zipfile */
    unzFile uf = NULL;
    int retval = 0;
    struct zip_mem_shapefile *mem_shape = NULL;

    if (zip_path == NULL)
      {
	  spatialite_e ("load zip shapefile error: <%s>\n",
			"NULL zipfile path");
	  return 0;
      }
/* opening the Zipfile expected to contain the Shapefile */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  return 0;
      }
/* parsing the Zipfile directory */
    mem_shape = do_list_zipfile_dir (uf, shp_path, 0);
    if (mem_shape == NULL)
      {
	  spatialite_e ("No SHP %s with Zipfile\n", shp_path);
	  goto stop;
      }
/* unzipping the SHP member */
    if (!do_read_zipfile_file (uf, mem_shape, GAIA_ZIPFILE_SHP))
	goto stop;
/* unzipping the SHX member */
    if (!do_read_zipfile_file (uf, mem_shape, GAIA_ZIPFILE_SHX))
	goto stop;
/* unzipping the DBF member */
    if (!do_read_zipfile_file (uf, mem_shape, GAIA_ZIPFILE_DBF))
	goto stop;
/* unzipping the PRJ member */
    if (!do_read_zipfile_file (uf, mem_shape, GAIA_ZIPFILE_PRJ))
	goto stop;

/* doing the hard work */
    if (load_shapefile_common
	(mem_shape, sqlite, shp_path, table, charset, srid, g_column, gtype,
	 pk_column, coerce2d, compressed, verbose, spatial_index, text_dates,
	 rows, colname_case, err_msg))
	retval = 1;

  stop:
    unzClose (uf);
    if (mem_shape != NULL)
	destroy_zip_mem_shapefile (mem_shape);
    return retval;
}

static int
do_check_dbf_unique_pk_values (sqlite3 * sqlite, gaiaDbfPtr dbf, int text_dates,
			       const char *pk_name, int pk_type)
{
/* checking for duplicate PK values */
    char *sql;
    sqlite3_stmt *stmt = NULL;
    gaiaDbfFieldPtr dbf_field;
    int ret;
    int deleted;
    int duplicates = 0;
    int current_row = 0;

    sql = "CREATE TABLE TEMP.check_unique_pk (pkey ANYVALUE)";
    ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
    if (ret != SQLITE_OK)
	return 0;

    sql = "INSERT INTO TEMP.check_unique_pk (pkey) VALUES (?)";
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	goto error;

    sqlite3_exec (sqlite, "BEGIN", NULL, NULL, NULL);

    while (1)
      {
	  /* reading rows from shapefile */
	  int ok_insert = 0;
	  ret = gaiaReadDbfEntity_ex (dbf, current_row, &deleted, text_dates);
	  if (!ret)
	      break;
	  current_row++;
	  if (deleted)
	    {
		/* skipping DBF deleted row */
		continue;
	    }
	  /* binding query params */
	  sqlite3_reset (stmt);
	  sqlite3_clear_bindings (stmt);
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		/* Primary Key value */
		if (strcasecmp (pk_name, dbf_field->Name) == 0)
		  {
		      if (pk_type == SQLITE_TEXT)
			{
			    ok_insert = 1;
			    sqlite3_bind_text (stmt, 1,
					       dbf_field->Value->TxtValue,
					       strlen (dbf_field->
						       Value->TxtValue),
					       SQLITE_STATIC);
			}
		      else if (pk_type == SQLITE_FLOAT)
			{
			    ok_insert = 1;
			    sqlite3_bind_double (stmt, 1,
						 dbf_field->Value->DblValue);
			}
		      else
			{
			    ok_insert = 1;
			    sqlite3_bind_int64 (stmt, 1,
						dbf_field->Value->IntValue);
			}
		  }
		dbf_field = dbf_field->Next;
	    }
	  if (ok_insert)
	    {
		ret = sqlite3_step (stmt);
		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
		    ;
		else
		    goto error;
	    }
      }
    sqlite3_finalize (stmt);
    stmt = NULL;
    sqlite3_exec (sqlite, "COMMIT", NULL, NULL, NULL);

    sql = "SELECT Count(*) FROM TEMP.check_unique_pk GROUP BY pkey";
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	goto error;

    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_int (stmt, 0) > 1)
		    duplicates = 1;
	    }
      }
    sqlite3_finalize (stmt);

    sqlite3_exec (sqlite, "DROP TABLE TEMP.check_unique_pk", NULL, NULL, NULL);
    if (duplicates)
	return 0;
    else
	return 1;

  error:
    if (stmt != NULL)
	sqlite3_finalize (stmt);
    sqlite3_exec (sqlite, "COMMIT", NULL, NULL, NULL);
    sqlite3_exec (sqlite, "DROP TABLE TEMP.check_unique_pk", NULL, NULL, NULL);
    return 0;
}

SPATIALITE_DECLARE int
load_dbf_common (struct zip_mem_shapefile *mem_shape, sqlite3 * sqlite,
		 const char *dbf_path, const char *table, const char *pk_column,
		 const char *charset, int verbose, int text_dates, int *rows,
		 int colname_case, char *err_msg)
{
    sqlite3_stmt *stmt;
    int ret;
    char *errMsg = NULL;
    char *sql;
    char *dummy;
    char *xname;
    int already_exists = 0;
    int sqlError = 0;
    gaiaDbfPtr dbf = NULL;
    gaiaDbfFieldPtr dbf_field;
    int cnt;
    int col_cnt;
    int seed;
    int len;
    int dup;
    int idup;
    int current_row = 0;
    char **col_name = NULL;
    int deleted;
    char *qtable = NULL;
    char *qpk_name = NULL;
    const char *pk_name = NULL;
    char *casename;
    int pk_autoincr = 1;
    gaiaOutBuffer sql_statement;
    int pk_type = SQLITE_INTEGER;
    int pk_set;
    const char *alt_pk[10] =
	{ "PK_ALT0", "PK_ALT1", "PK_ALT2", "PK_ALT3", "PK_ALT4", "PK_ALT5",
	"PK_ALT6", "PK_ALT7", "PK_ALT8", "PK_ALT9"
    };
    qtable = gaiaDoubleQuotedSql (table);
    if (rows)
	*rows = -1;
/* checking if TABLE already exists */
    sql = sqlite3_mprintf ("SELECT name FROM sqlite_master WHERE "
			   "type = 'table' AND Lower(name) = Lower(%Q)", table);
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    sqlite3_free (sql);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", sqlite3_errmsg (sqlite));
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n",
		       sqlite3_errmsg (sqlite));
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
    while (1)
      {
	  /* scrolling the result set */
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE)
	      break;		/* end of result set */
	  if (ret == SQLITE_ROW)
	      already_exists = 1;
	  else
	    {
		spatialite_e ("load DBF error: <%s>\n",
			      sqlite3_errmsg (sqlite));
		break;
	    }
      }
    sqlite3_finalize (stmt);
    if (already_exists)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: table '%s' already exists\n",
			    table);
	  else
	      sprintf (err_msg, "load DBF error: table '%s' already exists\n",
		       table);
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
    dbf = gaiaAllocDbf ();
    if (mem_shape != NULL)
      {
	  /* initializing Memory based files */
	  dbf->memDbf = &(mem_shape->dbf);
      }
    gaiaOpenDbfRead (dbf, dbf_path, charset, "UTF-8");
    if (!(dbf->Valid))
      {
	  if (!err_msg)
	    {
		spatialite_e ("load DBF error: cannot open '%s'\n", dbf_path);
		if (dbf->LastError)
		    spatialite_e ("\tcause: %s\n", dbf->LastError);
	    }
	  else
	    {
		char extra[512];
		*extra = '\0';
		if (dbf->LastError)
		    sprintf (extra, "\n\tcause: %s", dbf->LastError);
		sprintf (err_msg, "load DBF error: cannot open '%s'%s",
			 dbf_path, extra);
	    }
	  gaiaFreeDbf (dbf);
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
/* checking for duplicate / illegal column names and antialising them */
    col_cnt = 0;
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* counting DBF fields */
	  col_cnt++;
	  dbf_field = dbf_field->Next;
      }
    col_name = malloc (sizeof (char *) * col_cnt);
    cnt = 0;
    seed = 0;
    if (pk_column != NULL)
      {
	  /* validating the Primary Key column */
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		if (strcasecmp (pk_column, dbf_field->Name) == 0)
		  {
		      /* ok, using this field as Primary Key */
		      pk_name = pk_column;
		      pk_autoincr = 0;
		      switch (dbf_field->Type)
			{
			case 'C':
			    pk_type = SQLITE_TEXT;
			    break;
			case 'N':
			    if (dbf_field->Decimals)
				pk_type = SQLITE_FLOAT;
			    else
			      {
				  if (dbf_field->Length <= 18)
				      pk_type = SQLITE_INTEGER;
				  else
				      pk_type = SQLITE_FLOAT;
			      }
			    break;
			case 'D':
			    if (text_dates)
				pk_type = SQLITE_TEXT;
			    else
				pk_type = SQLITE_FLOAT;
			    break;
			case 'F':
			    pk_type = SQLITE_FLOAT;
			    break;
			case 'L':
			    pk_type = SQLITE_INTEGER;
			    break;
			};
		  }
		dbf_field = dbf_field->Next;
	    }
      }
    if (pk_name == NULL)
      {
	  if (pk_column != NULL)
	      pk_name = pk_column;
	  else
	      pk_name = "PK_UID";
      }
    if (!do_check_dbf_unique_pk_values
	(sqlite, dbf, text_dates, pk_name, pk_type))
      {
	  const char *old_pk = pk_name;
	  int antialias;
	  for (antialias = 0; antialias < 10; antialias++)
	    {
		/* searching an alternative Primary Key column name */
		int found = 0;
		pk_name = alt_pk[antialias];
		dbf_field = dbf->Dbf->First;
		while (dbf_field)
		  {
		      if (strcasecmp (pk_name, dbf_field->Name) == 0)
			  found = 1;
		      dbf_field = dbf_field->Next;
		  }
		if (!found)
		  {
		      pk_autoincr = 1;
		      goto ok_pk;
		  }
	    }
	  pk_name = old_pk;
      }
  ok_pk:
    casename = convert_dbf_colname_case (pk_name, colname_case);
    qpk_name = gaiaDoubleQuotedSql (casename);
    free (casename);
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* preparing column names */
	  char *xdummy = NULL;
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dummy = dbf_field->Name;
		len = strlen (dummy);
		*(col_name + cnt) = malloc (len + 1);
		strcpy (*(col_name + cnt), dummy);
		cnt++;
		dbf_field = dbf_field->Next;
		continue;
	    }
	  dummy = dbf_field->Name;
	  dup = 0;
	  for (idup = 0; idup < cnt; idup++)
	    {
		if (strcasecmp (dummy, *(col_name + idup)) == 0)
		    dup = 1;
	    }
	  if (dup)
	    {
		xdummy = sqlite3_mprintf ("COL_%d", seed++);
		dummy = xdummy;
	    }
	  len = strlen (dummy);
	  *(col_name + cnt) = malloc (len + 1);
	  strcpy (*(col_name + cnt), dummy);
	  if (xdummy)
	      free (xdummy);
	  cnt++;
	  dbf_field = dbf_field->Next;
      }
    if (verbose)
	spatialite_e ("========\nLoading DBF at '%s' into SQLite table '%s'\n",
		      dbf_path, table);
/* starting a transaction */
    if (verbose)
	spatialite_e ("\nBEGIN;\n");
    ret = sqlite3_exec (sqlite, "BEGIN", NULL, 0, &errMsg);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", errMsg);
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n", errMsg);
	  sqlite3_free (errMsg);
	  sqlError = 1;
	  goto clean_up;
      }
/* creating the Table */
    gaiaOutBufferInitialize (&sql_statement);
    if (pk_type == SQLITE_TEXT)
      {
	  sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				 "TEXT PRIMARY KEY NOT NULL", qtable, qpk_name);
      }
    else if (pk_type == SQLITE_FLOAT)
      {
	  sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				 "DOUBLE PRIMARY KEY NOT NULL", qtable,
				 qpk_name);
      }
    else
      {
	  if (pk_autoincr)
	      sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				     "INTEGER PRIMARY KEY AUTOINCREMENT",
				     qtable, qpk_name);
	  else
	      sql = sqlite3_mprintf ("CREATE TABLE \"%s\" (\n\"%s\" "
				     "INTEGER NOT NULL PRIMARY KEY", qtable,
				     qpk_name);
      }
    gaiaAppendToOutBuffer (&sql_statement, sql);
    sqlite3_free (sql);
    cnt = 0;
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dbf_field = dbf_field->Next;
		cnt++;
		continue;
	    }
	  casename = convert_dbf_colname_case (*(col_name + cnt), colname_case);
	  xname = gaiaDoubleQuotedSql (casename);
	  free (casename);
	  sql = sqlite3_mprintf (",\n\"%s\"", xname);
	  free (xname);
	  gaiaAppendToOutBuffer (&sql_statement, sql);
	  sqlite3_free (sql);
	  cnt++;
	  switch (dbf_field->Type)
	    {
	    case 'C':
		gaiaAppendToOutBuffer (&sql_statement, " TEXT");
		break;
	    case 'N':
		if (dbf_field->Decimals)
		    gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		else
		  {
		      if (dbf_field->Length <= 18)
			  gaiaAppendToOutBuffer (&sql_statement, " INTEGER");
		      else
			  gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		  }
		break;
	    case 'D':
		if (text_dates)
		    gaiaAppendToOutBuffer (&sql_statement, " TEXT");
		else
		    gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		break;
	    case 'F':
		gaiaAppendToOutBuffer (&sql_statement, " DOUBLE");
		break;
	    case 'L':
		gaiaAppendToOutBuffer (&sql_statement, " INTEGER");
		break;
	    };
	  dbf_field = dbf_field->Next;
      }
    gaiaAppendToOutBuffer (&sql_statement, ")");
    if (sql_statement.Error == 0 && sql_statement.Buffer != NULL)
      {
	  if (verbose)
	      spatialite_e ("%s;\n", sql_statement.Buffer);
	  ret = sqlite3_exec (sqlite, sql_statement.Buffer, NULL, 0, &errMsg);
      }
    else
	ret = SQLITE_ERROR;
    gaiaOutBufferReset (&sql_statement);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", errMsg);
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n", errMsg);
	  sqlite3_free (errMsg);
	  sqlError = 1;
	  goto clean_up;
      }
    /* preparing the INSERT INTO parametrerized statement */
    sql = sqlite3_mprintf ("INSERT INTO \"%s\" (\"%s\"", qtable, qpk_name);
    gaiaAppendToOutBuffer (&sql_statement, sql);
    sqlite3_free (sql);
    cnt = 0;
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* columns corresponding to some DBF attribute */
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dbf_field = dbf_field->Next;
		cnt++;
		continue;
	    }
	  xname = gaiaDoubleQuotedSql (*(col_name + cnt++));
	  sql = sqlite3_mprintf (",\"%s\"", xname);
	  free (xname);
	  gaiaAppendToOutBuffer (&sql_statement, sql);
	  sqlite3_free (sql);
	  dbf_field = dbf_field->Next;
      }
    gaiaAppendToOutBuffer (&sql_statement, ")\nVALUES (?");
    dbf_field = dbf->Dbf->First;
    while (dbf_field)
      {
	  /* column values */
	  if (strcasecmp (pk_name, dbf_field->Name) == 0)
	    {
		/* skipping the Primary Key field */
		dbf_field = dbf_field->Next;
		continue;
	    }
	  gaiaAppendToOutBuffer (&sql_statement, ", ?");
	  dbf_field = dbf_field->Next;
      }
    gaiaAppendToOutBuffer (&sql_statement, ")");
    if (sql_statement.Error == 0 && sql_statement.Buffer != NULL)
	ret =
	    sqlite3_prepare_v2 (sqlite, sql_statement.Buffer,
				strlen (sql_statement.Buffer), &stmt, NULL);
    else
	ret = SQLITE_ERROR;
    gaiaOutBufferReset (&sql_statement);
    if (ret != SQLITE_OK)
      {
	  if (!err_msg)
	      spatialite_e ("load DBF error: <%s>\n", sqlite3_errmsg (sqlite));
	  else
	      sprintf (err_msg, "load DBF error: <%s>\n",
		       sqlite3_errmsg (sqlite));
	  sqlError = 1;
	  goto clean_up;
      }
    current_row = 0;
    while (1)
      {
	  /* inserting rows from DBF */
	  ret = gaiaReadDbfEntity_ex (dbf, current_row, &deleted, text_dates);
	  if (!ret)
	    {
		if (!(dbf->LastError))	/* normal DBF EOF */
		    break;
		if (!err_msg)
		    spatialite_e ("%s\n", dbf->LastError);
		else
		    sprintf (err_msg, "%s\n", dbf->LastError);
		sqlError = 1;
		goto clean_up;
	    }
	  current_row++;
	  if (deleted)
	    {
		/* skipping DBF deleted row */
		continue;
	    }
	  /* binding query params */
	  sqlite3_reset (stmt);
	  sqlite3_clear_bindings (stmt);
	  pk_set = 0;
	  cnt = 0;
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		/* Primary Key value */
		if (strcasecmp (pk_name, dbf_field->Name) == 0)
		  {
		      if (pk_type == SQLITE_TEXT)
			  sqlite3_bind_text (stmt, 1,
					     dbf_field->Value->TxtValue,
					     strlen (dbf_field->
						     Value->TxtValue),
					     SQLITE_STATIC);
		      else if (pk_type == SQLITE_FLOAT)
			  sqlite3_bind_double (stmt, 1,
					       dbf_field->Value->DblValue);
		      else
			  sqlite3_bind_int64 (stmt, 1,
					      dbf_field->Value->IntValue);
		      pk_set = 1;
		  }
		dbf_field = dbf_field->Next;
	    }
	  if (!pk_set)
	      sqlite3_bind_int (stmt, 1, current_row);
	  cnt = 0;
	  dbf_field = dbf->Dbf->First;
	  while (dbf_field)
	    {
		/* column values */
		if (strcasecmp (pk_name, dbf_field->Name) == 0)
		  {
		      /* skipping the Primary Key field */
		      dbf_field = dbf_field->Next;
		      continue;
		  }
		if (!(dbf_field->Value))
		    sqlite3_bind_null (stmt, cnt + 2);
		else
		  {
		      switch (dbf_field->Value->Type)
			{
			case GAIA_INT_VALUE:
			    sqlite3_bind_int64 (stmt, cnt + 2,
						dbf_field->Value->IntValue);
			    break;
			case GAIA_DOUBLE_VALUE:
			    sqlite3_bind_double (stmt, cnt + 2,
						 dbf_field->Value->DblValue);
			    break;
			case GAIA_TEXT_VALUE:
			    sqlite3_bind_text (stmt, cnt + 2,
					       dbf_field->Value->TxtValue,
					       strlen (dbf_field->
						       Value->TxtValue),
					       SQLITE_STATIC);
			    break;
			default:
			    sqlite3_bind_null (stmt, cnt + 2);
			    break;
			}
		  }
		cnt++;
		dbf_field = dbf_field->Next;
	    }
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
	      ;
	  else
	    {
		if (!err_msg)
		    spatialite_e ("load DBF error: <%s>\n",
				  sqlite3_errmsg (sqlite));
		else
		    sprintf (err_msg, "load DBF error: <%s>\n",
			     sqlite3_errmsg (sqlite));
		sqlite3_finalize (stmt);
		sqlError = 1;
		goto clean_up;
	    }
      }
    sqlite3_finalize (stmt);
  clean_up:
    if (qtable)
	free (qtable);
    qtable = NULL;
    if (qpk_name)
	free (qpk_name);
    qpk_name = NULL;
    gaiaFreeDbf (dbf);
    if (col_name)
      {
	  /* releasing memory allocation for column names */
	  for (cnt = 0; cnt < col_cnt; cnt++)
	      free (*(col_name + cnt));
	  free (col_name);
      }
    if (sqlError)
      {
	  /* some error occurred - ROLLBACK */
	  if (verbose)
	      spatialite_e ("ROLLBACK;\n");
	  ret = sqlite3_exec (sqlite, "ROLLBACK", NULL, 0, &errMsg);
	  if (ret != SQLITE_OK)
	    {
		spatialite_e ("load DBF error: <%s>\n", errMsg);
		sqlite3_free (errMsg);
	    };
	  if (qtable)
	      free (qtable);
	  if (qpk_name)
	      free (qpk_name);
	  return 0;
      }
    else
      {
	  /* ok - confirming pending transaction - COMMIT */
	  if (verbose)
	      spatialite_e ("COMMIT;\n");
	  ret = sqlite3_exec (sqlite, "COMMIT", NULL, 0, &errMsg);
	  if (ret != SQLITE_OK)
	    {
		spatialite_e ("load DBF error: <%s>\n", errMsg);
		sqlite3_free (errMsg);
		return 0;
	    }
	  if (rows)
	      *rows = current_row;
	  if (verbose)
	      spatialite_e ("\nInserted %d rows into '%s' from DBF\n========\n",
			    current_row, table);
	  if (err_msg)
	      sprintf (err_msg, "Inserted %d rows into '%s' from DBF",
		       current_row, table);
	  return 1;
      }
}

GAIAGEO_DECLARE gaiaDbfPtr 
gaiaOpenZipDbf (const char *zip_path, const char *filename, const char *charFrom, const char *charTo)
{
/* creating a DBF object (just for checking its fields) */
    unzFile uf = NULL;
    struct zip_mem_shapefile *mem_shape = NULL;
  gaiaDbfPtr dbf = NULL;

    if (zip_path == NULL)
      {
	  spatialite_e ("open zip dbf error: <%s>\n",
			"NULL zipfile path");
	  return 0;
      }
/* opening the Zipfile expected to contain the Shapefile */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  return 0;
      }
/* parsing the Zipfile directory */
    mem_shape = do_list_zipfile_dir (uf, filename, 1);
    if (mem_shape == NULL)
      {
	  spatialite_e ("No DBF %s with Zipfile\n", filename);
	  goto stop;
      }
/* unzipping the DBF member */
    if (!do_read_zipfile_file (uf, mem_shape, GAIA_ZIPFILE_DBF))
	goto stop; 
/* attempting to create and initialize the DBF object */
	dbf = gaiaAllocDbf();
	  dbf->memDbf = &(mem_shape->dbf);
  gaiaOpenDbfRead(dbf, filename, charFrom, charTo);

  stop:
    unzClose (uf);
	destroy_zip_mem_shapefile (mem_shape);
    return dbf;
}

SPATIALITE_DECLARE int
load_zip_dbf (sqlite3 * sqlite, const char *zip_path, const char *dbf_path,
	      const char *table, const char *pk_column, const char *charset,
	      int verbose, int text_dates, int *rows,
	      int colname_case, char *err_msg)
{
/* loading a DBF file from within a Zipfile */
    unzFile uf = NULL;
    int retval = 0;
    struct zip_mem_shapefile *mem_shape = NULL;

    if (zip_path == NULL)
      {
	  spatialite_e ("load zip shapefile error: <%s>\n",
			"NULL zipfile path");
	  return 0;
      }
/* opening the Zipfile expected to contain the Shapefile */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  return 0;
      }
/* parsing the Zipfile directory */
    mem_shape = do_list_zipfile_dir (uf, dbf_path, 1);
    if (mem_shape == NULL)
      {
	  spatialite_e ("No DBF %s with Zipfile\n", dbf_path);
	  goto stop;
      }
/* unzipping the DBF member */
    if (!do_read_zipfile_file (uf, mem_shape, GAIA_ZIPFILE_DBF))
	goto stop;

/* doing the hard work */
    if (load_dbf_common
	(mem_shape, sqlite, dbf_path, table, pk_column, charset, verbose,
	 text_dates, rows, colname_case, err_msg))
	retval = 1;

  stop:
    unzClose (uf);
    if (mem_shape != NULL)
	destroy_zip_mem_shapefile (mem_shape);
    return retval;
}

#endif /* end MINIZIP */

#endif /* end ICONV (SHP) */

#ifndef OMIT_PROJ		/* including PROJ */
#ifdef PROJ_NEW			/* only if new PROJ.6 is supported */
static int
output_prj_file_proj_new (int srid, const char *path, void *proj_ctx)
{
................................................................................
    if (db_prefix != NULL)
	free (db_prefix);
    if (table_name != NULL)
	free (table_name);
    return 0;
}






















































































































SPATIALITE_DECLARE int
load_dbf (sqlite3 * sqlite, char *dbf_path, char *table, char *charset,
	  int verbose, int *rows, char *err_msg)
{
    return load_dbf_ex (sqlite, dbf_path, table, NULL, charset, verbose, rows,
			err_msg);
}
................................................................................
	      char *err_msg)
{
    return load_dbf_ex3 (sqlite, dbf_path, table, pk_column, charset, verbose,
			 text_dates, rows, GAIA_DBF_COLNAME_LOWERCASE, err_msg);
}

SPATIALITE_DECLARE int
load_dbf_ex3 (sqlite3 * sqlite, const char *dbf_path, const char *table,
	      const char *pk_column, const char *charset, int verbose,
	      int text_dates, int *rows, int colname_case, char *err_msg)
{
    return load_dbf_common (NULL, sqlite, dbf_path, table, pk_column, charset,
			    verbose, text_dates, rows, colname_case, err_msg);




















































































































































































































































































































































































































































































































































































}

SPATIALITE_DECLARE int
dump_dbf (sqlite3 * sqlite, char *table, char *dbf_path, char *charset,
	  char *err_msg)
{
    int rows;
................................................................................
    xgeom_col = gaiaDoubleQuotedSql (geom_col);
    sql =
	sqlite3_mprintf
	("SELECT AsGeoJSON(\"%s\", %d, %d) FROM \"%s\" WHERE \"%s\" IS NOT NULL",
	 xgeom_col, precision, option, xtable, xgeom_col);
    free (xtable);
    free (xgeom_col);

    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    sqlite3_free (sql);
    if (ret != SQLITE_OK)
	goto sql_error;

    while (1)
      {
................................................................................
	return;

    if (strncasecmp (option, "::cast2multi::", 14) == 0)
	options->cast2multi = 1;
    if (strncasecmp (option, "::ignore::", 10) == 0)
	ignore_column (options, option + 10);
}

#ifdef ENABLE_MINIZIP		/* MINIZIP is enabled */

GAIAGEO_DECLARE char *
gaiaReadWktFromZipShp (const char *zip_path, const char *basename)
{
/* attempting to read the .PRJ member of some zipped Shapefile */
    char *wkt = NULL;
    unzFile uf = NULL;
    struct zip_mem_shapefile *mem_shape = NULL;

    if (zip_path == NULL)
      {
	  spatialite_e ("read_wkt_from_zipshp error: <%s>\n",
			"NULL zipfile path");
	  return NULL;
      }
/* opening the Zipfile expected to contain the Shapefile */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  return NULL;
      }
/* parsing the Zipfile directory */
    mem_shape = do_list_zipfile_dir (uf, basename, 0);
    if (mem_shape == NULL)
      {
	  spatialite_e ("No SHP %s with Zipfile\n", basename);
	  goto stop;
      }
/* unzipping the PRJ member (if any) */
    do_read_zipfile_file (uf, mem_shape, GAIA_ZIPFILE_PRJ);
    if (mem_shape->prj.buf != NULL)
      {
	  wkt = malloc (mem_shape->prj.size + 1);
	  memcpy (wkt, mem_shape->prj.buf, mem_shape->prj.size);
	  *(wkt + mem_shape->prj.size) = '\0';
      }

  stop:
    unzClose (uf);
    if (mem_shape != NULL)
	destroy_zip_mem_shapefile (mem_shape);
    return wkt;
}

GAIAGEO_DECLARE int
gaiaZipfileNumSHP (const char *zip_path, int *count)
{
/* attempting to count how many Shapefiles are within a given Zipfile */
    int ret;
    int retval = 1;
    struct zip_mem_shp_item *item;
    struct zip_mem_shp_list *list = alloc_zip_mem_shp_list ();
    unzFile uf = NULL;

    *count = 0;
    if (zip_path == NULL)
      {
	  spatialite_e ("zipfile NumSHP error: <%s>\n", "NULL zipfile path");
	  retval = 0;
	  goto stop;
      }
/* opening the Zipfile expected to contain the Shapefile */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  retval = 0;
	  goto stop;
      }
/* sniffing the Zipfile */
    ret = do_sniff_zipfile_dir (uf, list, 0);
    if (!ret)
      {
	  retval = 0;
	  goto stop;
      }
    item = list->first;
    while (item != NULL)
      {
	  /* counting how many Shapefiles are there */
	  if (item->shp && item->shx && item->dbf)
	      *count += 1;
	  item = item->next;
      }
  stop:
    unzClose (uf);
    destroy_zip_mem_shp_list (list);
    return retval;
}

GAIAGEO_DECLARE char *
gaiaZipfileShpN (const char *zip_path, int idx)
{
/* attempting to return the Nth Shapefile's basename fromt within a given Zipfile */
    int ret;
    int count = 0;
    char *basename = NULL;
    struct zip_mem_shp_item *item;
    struct zip_mem_shp_list *list = alloc_zip_mem_shp_list ();
    unzFile uf = NULL;

    count = 0;
    if (zip_path == NULL)
      {
	  spatialite_e ("zipfile NumSHP error: <%s>\n", "NULL zipfile path");
	  goto stop;
      }
/* opening the Zipfile expected to contain the Shapefile */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  goto stop;
      }
/* sniffing the Zipfile */
    ret = do_sniff_zipfile_dir (uf, list, 0);
    if (!ret)
	goto stop;
    item = list->first;
    while (item != NULL)
      {
	  /* counting how many Shapefiles are there */
	  if (item->shp && item->shx && item->dbf)
	      count++;
	  if (count == idx)
	    {
		int len = strlen (item->basename);
		basename = malloc (len + 1);
		strcpy (basename, item->basename);
		break;
	    }
	  item = item->next;
      }
  stop:
    unzClose (uf);
    destroy_zip_mem_shp_list (list);
    return basename;
}

GAIAGEO_DECLARE int
gaiaZipfileNumDBF (const char *zip_path, int *count)
{
/* attempting to count how many DBF files are within a given Zipfile */
    int ret;
    int retval = 1;
    struct zip_mem_shp_item *item;
    struct zip_mem_shp_list *list = alloc_zip_mem_shp_list ();
    unzFile uf = NULL;

    *count = 0;
    if (zip_path == NULL)
      {
	  spatialite_e ("zipfile NumDBF error: <%s>\n", "NULL zipfile path");
	  retval = 0;
	  goto stop;
      }
/* opening the Zipfile expected to contain the DBF file */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  retval = 0;
	  goto stop;
      }
/* sniffing the Zipfile */
    ret = do_sniff_zipfile_dir (uf, list, 1);
    if (!ret)
      {
	  retval = 0;
	  goto stop;
      }
    item = list->first;
    while (item != NULL)
      {
	  /* counting how many DBF files are there */
	  if (item->dbf)
	      *count += 1;
	  item = item->next;
      }
  stop:
    unzClose (uf);
    destroy_zip_mem_shp_list (list);
    return retval;
}

GAIAGEO_DECLARE char *
gaiaZipfileDbfN (const char *zip_path, int idx)
{
/* attempting to return the Nth DBF filename fromt within a given Zipfile */
    int ret;
    int count = 0;
    char *filename = NULL;
    struct zip_mem_shp_item *item;
    struct zip_mem_shp_list *list = alloc_zip_mem_shp_list ();
    unzFile uf = NULL;

    count = 0;
    if (zip_path == NULL)
      {
	  spatialite_e ("zipfile NumDBF error: <%s>\n", "NULL zipfile path");
	  goto stop;
      }
/* opening the Zipfile expected to contain the DBF file */
    uf = unzOpen64 (zip_path);
    if (uf == NULL)
      {
	  spatialite_e ("Unable to Open %s\n", zip_path);
	  goto stop;
      }
/* sniffing the Zipfile */
    ret = do_sniff_zipfile_dir (uf, list, 1);
    if (!ret)
	goto stop;
    item = list->first;
    while (item != NULL)
      {
	  /* counting how many DBF files are there */
	  if (item->dbf)
	      count++;
	  if (count == idx)
	    {
		int len = strlen (item->basename);
		filename = malloc (len + 1);
		strcpy (filename, item->basename);
		break;
	    }
	  item = item->next;
      }
  stop:
    unzClose (uf);
    destroy_zip_mem_shp_list (list);
    return filename;
}

#endif /* end MINIZIP */

Changes to src/spatialite/spatialite.c.

627
628
629
630
631
632
633
















634
635
636
637
638
639
640
.....
11031
11032
11033
11034
11035
11036
11037








































































































































11038
11039
11040
11041
11042
11043
11044
.....
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
.....
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
.....
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
.....
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
.....
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
.....
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
.....
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
.....
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
.....
24121
24122
24123
24124
24125
24126
24127















































24128


24129
24130
24131
24132
24133
24134
24135
.....
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
.....
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
.....
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
.....
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
.....
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
.....
34069
34070
34071
34072
34073
34074
34075






























34076
34077
34078
34079
34080
34081
34082
.....
39075
39076
39077
39078
39079
39080
39081










































































































































































































































































































































39082
39083
39084
39085
39086
39087
39088
.....
39929
39930
39931
39932
39933
39934
39935

39936
39937
39938
39939
39940
39941
39942
.....
39959
39960
39961
39962
39963
39964
39965



39966
39967
39968
39969



39970
39971
39972
39973
39974
39975
39976
.....
47917
47918
47919
47920
47921
47922
47923



47924
47925
47926
47927
47928
47929
47930
.....
48879
48880
48881
48882
48883
48884
48885




48886
48887
48888
48889
48890
48891
48892
.....
48896
48897
48898
48899
48900
48901
48902















48903
48904
48905
48906
48907
48908
48909
.....
50627
50628
50629
50630
50631
50632
50633






















































50634
50635
50636
50637





50638



50639
50640
50641
50642
50643
50644
50645
.....
51348
51349
51350
51351
51352
51353
51354
51355
51356
51357
51358
51359
51360
51361
51362
51363
51364
51365
51366
51367
51368
51369
51370
51371
51372
51373
51374
51375
51376
51377
51378
51379
51380
51381
51382
51383
51384
51385
51386
.....
52346
52347
52348
52349
52350
52351
52352



52353
52354
52355
52356
52357
52358
52359
#else
    sqlite3_result_int (context, 0);
#endif
#else
    sqlite3_result_int (context, 0);
#endif
}

















static void
fnct_rttopo_version (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ rttopo_version()
/
................................................................................
	  if (ret != SQLITE_OK)
	      sqlite3_free (errMsg);
      }
    sqlite3_result_int (context, 0);
    return;
}









































































































































static gaiaPointPtr
simplePoint (gaiaGeomCollPtr geo)
{
/* helper function
/ if this GEOMETRY contains only one POINT, and no other elementary geometry
/ the POINT address will be returned
/ otherwise NULL will be returned
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaZRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaZRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaMRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
      if (argc == 2)
      {
		  if (sqlite3_value_type(argv[1]) == SQLITE_FLOAT)
		  {
			  nodata = sqlite3_value_double(argv[1]);
			  hasNodata = 1;
		  }
		  else if (sqlite3_value_type(argv[1]) == SQLITE_INTEGER)
		  {
			  int intval = sqlite3_value_int(argv[1]);
			  nodata = intval;
			  hasNodata = 1;
		  }
		  else
		  sqlite3_result_null(context);
		  return;
	  }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
			if (hasNodata)
		gaiaMRangeGeometryEx(geo, nodata, &min, &max);
		else
		gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
      }
    if (!gaiaGuessSridFromWKT (sqlite, data, wkt, &srid))
	sqlite3_result_int (context, -1);
    else
	sqlite3_result_int (context, srid);
    free (wkt);
}















































#endif



#endif /* end including PROJ.4 */

#ifndef OMIT_GEOS		/* including GEOS */

static void
fnct_GEOS_GetLastWarningMsg (sqlite3_context * context, int argc,
................................................................................
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_AVG_SEGMENT_LENGTH);
}

static void
fnct_CurvosityIndex (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_CurvosityIndex(BLOB encoded LINESTRING)
/    or
/ ST_CurvosityIndex(BLOB encoded LINESTRING, points INTEGER)
/
/ returns the CurvosityIndex of some Linestring
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

static void
fnct_UphillHeight (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_UphillHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative Uphill Height of some 3D Linestring
/ or NULL if any error is encountered
/
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

static void
fnct_DownhillHeight (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_DownhillHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative Downhill Height of some 3D Linestring
/ or NULL if any error is encountered
/
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

static void
fnct_UpDownHeight (sqlite3_context * context, int argc,
				 sqlite3_value ** argv)
{
/* SQL function:
/ ST_UpDownHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative UpDown Height of some 3D Linestring
/ or NULL if any error is encountered
/
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

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

static void
fnct_3dLength (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
................................................................................
/* breaking the Path */
    ext = gaiaFileExtFromPath (path);
    if (ext == NULL)
	sqlite3_result_null (context);
    else
	sqlite3_result_text (context, ext, strlen (ext), free);
}































static void
fnct_make_string_list_step (sqlite3_context * context, int argc,
			    sqlite3_value ** argv)
{
/* SQL function:
/ MakeStringList(X)
................................................................................
      {
	  if (update_statistics)
	      update_layer_statistics (db_handle, table, NULL);
	  sqlite3_result_int (context, rows);
      }
}











































































































































































































































































































































static void
fnct_ExportSHP (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ExportSHP(TEXT table, TEXT geom_column, TEXT filename, TEXT charset)
/ ExportSHP(TEXT table, TEXT geom_column, TEXT filename, TEXT charset,
/           TEXT geom_type)
................................................................................
/* checking all Triggers */
    sql = "SELECT Lower(sql) FROM sqlite_master WHERE "
	"type IN ('trigger', 'view') AND (sql LIKE '%BlobFromFile%' "
	"OR sql LIKE '%BlobToFile%' OR sql LIKE '%XB_LoadXML%' "
	"OR sql LIKE '%XB_StoreXML%' OR sql LIKE '%ImportDXF%' "
	"OR sql LIKE '%ExportDXF%' OR sql LIKE '%ImportDBF%' "
	"OR sql LIKE '%ExportDBF%' OR sql LIKE '%ImportSHP%' "

	"OR sql LIKE '%ExportSHP%' OR sql LIKE '%ExportKML%' "
	"OR sql LIKE '%ExportGeoJSON%' OR (sql LIKE '%eval%' AND sql LIKE '%(%') "
	"OR sql LIKE '%ExportGeoJSON2%' OR sql LIKE '%ImportGeoJSON%' "
	"OR sql LIKE '%ImportWFS%' OR sql LIKE '%ImportXLS%')";
    ret = sqlite3_get_table (sqlite, sql, &results, &rows, &columns, NULL);
    if (ret != SQLITE_OK)
	goto unknown;
................................................................................
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "importdxf"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "exportdxf"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "importdbf"))
		    dangerous = 1;



		if (do_check_impexp (results[(i * columns) + 0], "exportdbf"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "importshp"))
		    dangerous = 1;



		if (do_check_impexp (results[(i * columns) + 0], "exportshp"))
		    dangerous = 1;
		if (do_check_impexp
		    (results[(i * columns) + 0], "importgeojson"))
		    dangerous = 1;
		if (do_check_impexp
		    (results[(i * columns) + 0], "exportgeojson2"))
................................................................................
				fnct_has_geos_trunk, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasGeosReentrant", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_geos_reentrant, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasGeosOnlyReentrant", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_geos_only_reentrant, 0, 0, 0);



    sqlite3_create_function_v2 (db, "HasRtTopo", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_rttopo, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasMathSql", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_math_sql, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasGeoCallbacks", 0,
................................................................................
    sqlite3_create_function_v2 (db, "MD5Checksum", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MD5Checksum, 0, 0, 0);
    sqlite3_create_function_v2 (db, "MD5TotalChecksum", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, 0,
				fnct_MD5TotalChecksum_step,
				fnct_MD5TotalChecksum_final, 0);





#if OMIT_ICONV == 0		/* ICONV is absolutely required */

    sqlite3_create_function_v2 (db, "EncodeURL", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_EncodeURL, 0, 0, 0);
    sqlite3_create_function_v2 (db, "EncodeURL", 2,
................................................................................
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_DecodeURL, 0, 0, 0);
    sqlite3_create_function_v2 (db, "DecodeURL", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_DecodeURL, 0, 0, 0);

#endif /* ICONV enabled/disabled */
















    sqlite3_create_function_v2 (db, "DirNameFromPath", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_DirNameFromPath, 0, 0, 0);
    sqlite3_create_function_v2 (db, "FullFileNameFromPath", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_FullFileNameFromPath, 0, 0, 0);
................................................................................
				      fnct_ImportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportSHP", 13,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportSHP", 14,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportSHP, 0, 0, 0);






















































#ifdef PROJ_NEW			/* supporting new PROJ.6 */
	  sqlite3_create_function_v2 (db, "PROJ_GuessSridFromSHP", 1,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				      fnct_PROJ_GuessSridFromSHP, 0, 0, 0);





#endif



	  sqlite3_create_function_v2 (db, "ExportSHP", 4,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				      fnct_ExportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ExportSHP", 5,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				      fnct_ExportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ExportSHP", 6,
................................................................................
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_LinestringAvgSegmentLength, 0, 0, 0);
    sqlite3_create_function_v2 (db, "CurvosityIndex", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_CurvosityIndex", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "CurvosityIndex", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_CurvosityIndex", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "UphillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UphillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_UphillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UphillHeight, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "DownhillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_DownhillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_DownhillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_DownhillHeight, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "UpDownHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UpDownHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_UpDownHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UpDownHeight, 0, 0, 0);	
    sqlite3_create_function_v2 (db, "Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Circularity", 1,
................................................................................
				fnct_XB_IsSldStyle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_IsMapConfig", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_IsMapConfig, 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,







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







 







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







 







|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







 







|
|

|







 







|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







 







|
|

|







 







|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







 







|
|

|







 







|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







 







|
|

|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>







 







|
<







 







|



|
<







 







|



|
<







 







|



|
<







 







|







 







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







 







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







 







>







 







>
>
>




>
>
>







 







>
>
>







 







>
>
>
>







 







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







 







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




>
>
>
>
>
|
>
>
>







 







|











|





|





|







 







>
>
>







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
.....
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
.....
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
.....
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
.....
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
.....
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
.....
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
.....
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
.....
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
.....
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
.....
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
.....
25331
25332
25333
25334
25335
25336
25337
25338

25339
25340
25341
25342
25343
25344
25345
.....
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401

25402
25403
25404
25405
25406
25407
25408
.....
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453

25454
25455
25456
25457
25458
25459
25460
.....
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505

25506
25507
25508
25509
25510
25511
25512
.....
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
.....
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
.....
39302
39303
39304
39305
39306
39307
39308
39309
39310
39311
39312
39313
39314
39315
39316
39317
39318
39319
39320
39321
39322
39323
39324
39325
39326
39327
39328
39329
39330
39331
39332
39333
39334
39335
39336
39337
39338
39339
39340
39341
39342
39343
39344
39345
39346
39347
39348
39349
39350
39351
39352
39353
39354
39355
39356
39357
39358
39359
39360
39361
39362
39363
39364
39365
39366
39367
39368
39369
39370
39371
39372
39373
39374
39375
39376
39377
39378
39379
39380
39381
39382
39383
39384
39385
39386
39387
39388
39389
39390
39391
39392
39393
39394
39395
39396
39397
39398
39399
39400
39401
39402
39403
39404
39405
39406
39407
39408
39409
39410
39411
39412
39413
39414
39415
39416
39417
39418
39419
39420
39421
39422
39423
39424
39425
39426
39427
39428
39429
39430
39431
39432
39433
39434
39435
39436
39437
39438
39439
39440
39441
39442
39443
39444
39445
39446
39447
39448
39449
39450
39451
39452
39453
39454
39455
39456
39457
39458
39459
39460
39461
39462
39463
39464
39465
39466
39467
39468
39469
39470
39471
39472
39473
39474
39475
39476
39477
39478
39479
39480
39481
39482
39483
39484
39485
39486
39487
39488
39489
39490
39491
39492
39493
39494
39495
39496
39497
39498
39499
39500
39501
39502
39503
39504
39505
39506
39507
39508
39509
39510
39511
39512
39513
39514
39515
39516
39517
39518
39519
39520
39521
39522
39523
39524
39525
39526
39527
39528
39529
39530
39531
39532
39533
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
39545
39546
39547
39548
39549
39550
39551
39552
39553
39554
39555
39556
39557
39558
39559
39560
39561
39562
39563
39564
39565
39566
39567
39568
39569
39570
39571
39572
39573
39574
39575
39576
39577
39578
39579
39580
39581
39582
39583
39584
39585
39586
39587
39588
39589
39590
39591
39592
39593
39594
39595
39596
39597
39598
39599
39600
39601
39602
39603
39604
39605
39606
39607
39608
39609
39610
39611
39612
39613
39614
39615
39616
39617
39618
39619
39620
39621
39622
39623
39624
39625
39626
39627
39628
39629
39630
39631
39632
39633
39634
39635
39636
39637
39638
39639
39640
39641
39642
39643
39644
39645
.....
40486
40487
40488
40489
40490
40491
40492
40493
40494
40495
40496
40497
40498
40499
40500
.....
40517
40518
40519
40520
40521
40522
40523
40524
40525
40526
40527
40528
40529
40530
40531
40532
40533
40534
40535
40536
40537
40538
40539
40540
.....
48481
48482
48483
48484
48485
48486
48487
48488
48489
48490
48491
48492
48493
48494
48495
48496
48497
.....
49446
49447
49448
49449
49450
49451
49452
49453
49454
49455
49456
49457
49458
49459
49460
49461
49462
49463
.....
49467
49468
49469
49470
49471
49472
49473
49474
49475
49476
49477
49478
49479
49480
49481
49482
49483
49484
49485
49486
49487
49488
49489
49490
49491
49492
49493
49494
49495
.....
51213
51214
51215
51216
51217
51218
51219
51220
51221
51222
51223
51224
51225
51226
51227
51228
51229
51230
51231
51232
51233
51234
51235
51236
51237
51238
51239
51240
51241
51242
51243
51244
51245
51246
51247
51248
51249
51250
51251
51252
51253
51254
51255
51256
51257
51258
51259
51260
51261
51262
51263
51264
51265
51266
51267
51268
51269
51270
51271
51272
51273
51274
51275
51276
51277
51278
51279
51280
51281
51282
51283
51284
51285
51286
51287
51288
51289
51290
51291
51292
51293
.....
51996
51997
51998
51999
52000
52001
52002
52003
52004
52005
52006
52007
52008
52009
52010
52011
52012
52013
52014
52015
52016
52017
52018
52019
52020
52021
52022
52023
52024
52025
52026
52027
52028
52029
52030
52031
52032
52033
52034
.....
52994
52995
52996
52997
52998
52999
53000
53001
53002
53003
53004
53005
53006
53007
53008
53009
53010
#else
    sqlite3_result_int (context, 0);
#endif
#else
    sqlite3_result_int (context, 0);
#endif
}

static void
fnct_has_minizip (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ HasMiniZip()
/
/ return 1 if built including MINIZIP; otherwise 0
*/
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
#ifdef ENABLE_MINIZIP		/* MINIZIP is supported */
    sqlite3_result_int (context, 1);
#else
    sqlite3_result_int (context, 0);
#endif
}

static void
fnct_rttopo_version (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ rttopo_version()
/
................................................................................
	  if (ret != SQLITE_OK)
	      sqlite3_free (errMsg);
      }
    sqlite3_result_int (context, 0);
    return;
}

#ifdef ENABLE_MINIZIP		/* only id MINIZIP is enabled */

static void
fnct_Zipfile_NumSHP (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ Zipfile_NumSHP(zip_path TEXT)
/
/ return the total number of Shapefiles contained within a given Zipfile
/ 0 if not Shapefile exists
/ or NULL on error or invalid arguments
*/
    const char *zip_path;
    int count;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	zip_path = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
/* searching for Shapefiles */
    if (!gaiaZipfileNumSHP (zip_path, &count))
      {
	  sqlite3_result_null (context);
	  return;
      }
    sqlite3_result_int (context, count);
}

static void
fnct_Zipfile_ShpN (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ Zipfile_ShpN(zip_path TEXT, idx INTEGER)
/
/ return the name of the Nth Shapefile from within a Zipfile
/ or NULL on error or invalid arguments
*/
    const char *zip_path;
    int idx;
    char *basename;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	zip_path = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (sqlite3_value_type (argv[1]) == SQLITE_INTEGER)
	idx = sqlite3_value_int (argv[1]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
/* searching the Nth Shapefile */
    basename = gaiaZipfileShpN (zip_path, idx);
    if (basename == NULL)
      {
	  sqlite3_result_null (context);
	  return;
      }
    sqlite3_result_text (context, basename, strlen (basename), free);
}

static void
fnct_Zipfile_NumDBF (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ Zipfile_NumDBF(zip_path TEXT)
/
/ return the total number of DBF files contained within a given Zipfile
/ 0 if not DBF file exists
/ or NULL on error or invalid arguments
*/
    const char *zip_path;
    int count;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	zip_path = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
/* searching for DBF files */
    if (!gaiaZipfileNumDBF (zip_path, &count))
      {
	  sqlite3_result_null (context);
	  return;
      }
    sqlite3_result_int (context, count);
}

static void
fnct_Zipfile_DbfN (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ Zipfile_DbfN(zip_path TEXT, idx INTEGER)
/
/ return the name of the Nth DBF file from within a Zipfile
/ or NULL on error or invalid arguments
*/
    const char *zip_path;
    int idx;
    char *filename;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	zip_path = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (sqlite3_value_type (argv[1]) == SQLITE_INTEGER)
	idx = sqlite3_value_int (argv[1]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
/* searching the Nth DBF file */
    filename = gaiaZipfileDbfN (zip_path, idx);
    if (filename == NULL)
      {
	  sqlite3_result_null (context);
	  return;
      }
    sqlite3_result_text (context, filename, strlen (filename), free);
}

#endif /* end MINIZIP */

static gaiaPointPtr
simplePoint (gaiaGeomCollPtr geo)
{
/* helper function
/ if this GEOMETRY contains only one POINT, and no other elementary geometry
/ the POINT address will be returned
/ otherwise NULL will be returned
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (argc == 2)
      {
	  if (sqlite3_value_type (argv[1]) == SQLITE_FLOAT)
	    {
		nodata = sqlite3_value_double (argv[1]);
		hasNodata = 1;
	    }
	  else if (sqlite3_value_type (argv[1]) == SQLITE_INTEGER)
	    {
		int intval = sqlite3_value_int (argv[1]);
		nodata = intval;
		hasNodata = 1;
	    }
	  else
	      sqlite3_result_null (context);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
		if (hasNodata)
		    gaiaZRangeGeometryEx (geo, nodata, &min, &max);
		else
		    gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (argc == 2)
      {
	  if (sqlite3_value_type (argv[1]) == SQLITE_FLOAT)
	    {
		nodata = sqlite3_value_double (argv[1]);
		hasNodata = 1;
	    }
	  else if (sqlite3_value_type (argv[1]) == SQLITE_INTEGER)
	    {
		int intval = sqlite3_value_int (argv[1]);
		nodata = intval;
		hasNodata = 1;
	    }
	  else
	      sqlite3_result_null (context);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_Z
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
		if (hasNodata)
		    gaiaZRangeGeometryEx (geo, nodata, &min, &max);
		else
		    gaiaZRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (argc == 2)
      {
	  if (sqlite3_value_type (argv[1]) == SQLITE_FLOAT)
	    {
		nodata = sqlite3_value_double (argv[1]);
		hasNodata = 1;
	    }
	  else if (sqlite3_value_type (argv[1]) == SQLITE_INTEGER)
	    {
		int intval = sqlite3_value_int (argv[1]);
		nodata = intval;
		hasNodata = 1;
	    }
	  else
	      sqlite3_result_null (context);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
		if (hasNodata)
		    gaiaMRangeGeometryEx (geo, nodata, &min, &max);
		else
		    gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, min);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
    gaiaGeomCollPtr geo = NULL;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_BLOB)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (argc == 2)
      {
	  if (sqlite3_value_type (argv[1]) == SQLITE_FLOAT)
	    {
		nodata = sqlite3_value_double (argv[1]);
		hasNodata = 1;
	    }
	  else if (sqlite3_value_type (argv[1]) == SQLITE_INTEGER)
	    {
		int intval = sqlite3_value_int (argv[1]);
		nodata = intval;
		hasNodata = 1;
	    }
	  else
	      sqlite3_result_null (context);
	  return;
      }
    p_blob = (unsigned char *) sqlite3_value_blob (argv[0]);
    n_bytes = sqlite3_value_bytes (argv[0]);
    geo = gaiaFromSpatiaLiteBlobWkb (p_blob, n_bytes);
    if (!geo)
      {
#ifdef ENABLE_GEOPACKAGE	/* GEOPACKAGE enabled: supporting GPKG geometries */
	  if (gaiaIsValidGPB (p_blob, n_bytes))
................................................................................
	      sqlite3_result_null (context);
      }
    else
      {
	  if (geo->DimensionModel == GAIA_XY_M
	      || geo->DimensionModel == GAIA_XY_Z_M)
	    {
		if (hasNodata)
		    gaiaMRangeGeometryEx (geo, nodata, &min, &max);
		else
		    gaiaMRangeGeometry (geo, &min, &max);
		sqlite3_result_double (context, max);
	    }
	  else
	      sqlite3_result_null (context);
	  gaiaFreeGeomColl (geo);
      }
}
................................................................................
      }
    if (!gaiaGuessSridFromWKT (sqlite, data, wkt, &srid))
	sqlite3_result_int (context, -1);
    else
	sqlite3_result_int (context, srid);
    free (wkt);
}

#ifdef ENABLE_MINIZIP		/* only id MINIZIP is enabled */
static void
fnct_PROJ_GuessSridFromZipSHP (sqlite3_context * context, int argc,
			       sqlite3_value ** argv)
{
/* SQL function:
/ PROJ_GuessSridFromZipSHP(zip_path TEXT, filename TEXT)
/
/ return the SRID corresponding to a given Shapefile
/ -1 if not matching SRID exists
/ or NULL on error or invalid arguments
*/
    const char *zip_path;
    const char *basepath;
    char *wkt = NULL;
    int srid;
    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    void *data = sqlite3_user_data (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	zip_path = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (sqlite3_value_type (argv[1]) == SQLITE_TEXT)
	basepath = (const char *) sqlite3_value_text (argv[1]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
/* loocking for an eventual .PRJ file */
    wkt = gaiaReadWktFromZipShp (zip_path, basepath);
    if (wkt == NULL)
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (!gaiaGuessSridFromWKT (sqlite, data, wkt, &srid))
	sqlite3_result_int (context, -1);
    else
	sqlite3_result_int (context, srid);
    free (wkt);
}
#endif /* end MINIZIP */

#endif /* end PROJ_NEW */

#endif /* end including PROJ.4 */

#ifndef OMIT_GEOS		/* including GEOS */

static void
fnct_GEOS_GetLastWarningMsg (sqlite3_context * context, int argc,
................................................................................
/
*/
    linestring_segment_length_common (context, argc, argv,
				      LINESTRING_AVG_SEGMENT_LENGTH);
}

static void
fnct_CurvosityIndex (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ ST_CurvosityIndex(BLOB encoded LINESTRING)
/    or
/ ST_CurvosityIndex(BLOB encoded LINESTRING, points INTEGER)
/
/ returns the CurvosityIndex of some Linestring
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

static void
fnct_UphillHeight (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ ST_UphillHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative Uphill Height of some 3D Linestring
/ or NULL if any error is encountered
/
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

static void
fnct_DownhillHeight (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ ST_DownhillHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative Downhill Height of some 3D Linestring
/ or NULL if any error is encountered
/
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

static void
fnct_UpDownHeight (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ ST_UpDownHeight(BLOB encoded LINESTRING)
/
/ returns the cumulative UpDown Height of some 3D Linestring
/ or NULL if any error is encountered
/
................................................................................
	  gaiaFreeGeomColl (geo);
	  sqlite3_result_null (context);
	  return;
      }

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

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

static void
fnct_3dLength (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
................................................................................
/* breaking the Path */
    ext = gaiaFileExtFromPath (path);
    if (ext == NULL)
	sqlite3_result_null (context);
    else
	sqlite3_result_text (context, ext, strlen (ext), free);
}

static void
fnct_RemoveExtraSpaces (sqlite3_context * context, int argc,
			sqlite3_value ** argv)
{
/* SQL function:
/ RemoveExtraSpaces(TEXT string)
/
/ returns a TEXT value containing no repeated whitespaces
/      or
/ NULL on invalid arguments
*/
    const char *dirty;
    char *clean;
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */

    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	dirty = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
/* removing whitespaces from the string */
    clean = gaiaRemoveExtraSpaces (dirty);
    if (clean == NULL)
	sqlite3_result_null (context);
    else
	sqlite3_result_text (context, clean, strlen (clean), free);
}

static void
fnct_make_string_list_step (sqlite3_context * context, int argc,
			    sqlite3_value ** argv)
{
/* SQL function:
/ MakeStringList(X)
................................................................................
      {
	  if (update_statistics)
	      update_layer_statistics (db_handle, table, NULL);
	  sqlite3_result_int (context, rows);
      }
}

#ifdef ENABLE_MINIZIP		/* only if MINIZIP is enabled */

static void
fnct_ImportZipDBF (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ImportZipDBF(TEXT zip_path, TEXT filename, TEXT table, TEXT charset)
/ ImportZipDBF(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              TEXT pk_column)
/ ImportZipDBF(TEXT zip_path, TEXT filename, TEXT table, TEXT charset,
/              TEXT pk_column, INTEGER text_dates)
/ ImportZipDBF(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              TEXT pk_column, INTEGER text_dates, INTEGER colname_case)
/
/ returns:
/ the number of inserted rows
/ NULL on invalid arguments
*/
    int ret;
    char *zip_path;
    char *table;
    char *path;
    char *charset;
    char *pk_column = NULL;
    int text_dates = 0;
    int colname_case = GAIA_DBF_COLNAME_LOWERCASE;
    int rows = 0;
    sqlite3 *db_handle = sqlite3_context_db_handle (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    zip_path = (char *) sqlite3_value_text (argv[0]);
    if (sqlite3_value_type (argv[1]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    path = (char *) sqlite3_value_text (argv[1]);
    if (sqlite3_value_type (argv[2]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    table = (char *) sqlite3_value_text (argv[2]);
    if (sqlite3_value_type (argv[3]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    charset = (char *) sqlite3_value_text (argv[3]);
    if (argc > 4)
      {
	  if (sqlite3_value_type (argv[4]) != SQLITE_TEXT)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      pk_column = (char *) sqlite3_value_text (argv[4]);
      }
    if (argc > 5)
      {
	  if (sqlite3_value_type (argv[5]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      text_dates = sqlite3_value_int (argv[5]);
      }
    if (argc > 6)
      {
	  if (sqlite3_value_type (argv[6]) != SQLITE_TEXT)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	    {
		const char *val = (char *) sqlite3_value_text (argv[6]);
		if (strcasecmp (val, "UPPER") == 0
		    || strcasecmp (val, "UPPERCASE") == 0)
		    colname_case = GAIA_DBF_COLNAME_UPPERCASE;
		else if (strcasecmp (val, "SAME") == 0
			 || strcasecmp (val, "SAMECASE") == 0)
		    colname_case = GAIA_DBF_COLNAME_CASE_IGNORE;
		else
		    colname_case = GAIA_DBF_COLNAME_LOWERCASE;
	    }
      }

    ret =
	load_zip_dbf (db_handle, zip_path, path, table, pk_column, charset, 1,
		      text_dates, &rows, colname_case, NULL);

    if (rows < 0 || !ret)
	sqlite3_result_null (context);
    else
	sqlite3_result_int (context, rows);
}

static void
fnct_ImportZipSHP (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type,
/              INT coerce2d) 
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type,
/              INT coerce2d, INT compressed) 
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type,
/              INT coerce2d, INT compressed, INT spatial_index) 
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type,
/              INT coerce2d, INT compressed, INT spatial_index,
/              INT text_dates)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type,
/              INT coerce2d, INT compressed, INT spatial_index,
/              INT text_dates, TEXT colname_case)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type,
/              INT coerce2d, INT compressed, INT spatial_index,
/              INT text_dates, TEXT colname_case, INT update_statistics)
/ ImportZipSHP(TEXT zip_path, TEXT filename, TEXT table, TEXT charset, 
/              INT srid, TEXT geom_column, TEXT pk_column, TEXT geom_type,
/              INT coerce2d, INT compressed, INT spatial_index,
/              INT text_dates, TEXT colname_case, INT update_statistics,
/              INT verbose)
/
/ returns:
/ the number of imported rows
/ NULL on invalid arguments
*/
    int ret;
    char *zip_path;
    char *table;
    char *path;
    char *charset;
    int srid = -1;
    int coerce2d = 0;
    int compressed = 0;
    int spatial_index = 0;
    int text_dates = 0;
    int update_statistics = 1;
    int verbose = 1;
    char *pk_column = NULL;
    char *geo_column = NULL;
    char *geom_type = NULL;
    int colname_case = GAIA_DBF_COLNAME_LOWERCASE;
    int rows = 0;
    sqlite3 *db_handle = sqlite3_context_db_handle (context);
    GAIA_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    zip_path = (char *) sqlite3_value_text (argv[0]);
    if (sqlite3_value_type (argv[1]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    path = (char *) sqlite3_value_text (argv[1]);
    if (sqlite3_value_type (argv[2]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    table = (char *) sqlite3_value_text (argv[2]);
    if (sqlite3_value_type (argv[3]) != SQLITE_TEXT)
      {
	  sqlite3_result_null (context);
	  return;
      }
    charset = (char *) sqlite3_value_text (argv[3]);
    if (argc > 4)
      {
	  if (sqlite3_value_type (argv[4]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      srid = sqlite3_value_int (argv[4]);
      }
    if (argc > 5)
      {
	  if (sqlite3_value_type (argv[5]) != SQLITE_TEXT)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      geo_column = (char *) sqlite3_value_text (argv[5]);
      }
    if (argc > 6)
      {
	  if (sqlite3_value_type (argv[6]) != SQLITE_TEXT)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      pk_column = (char *) sqlite3_value_text (argv[6]);
      }
    if (argc > 7)
      {
	  if (sqlite3_value_type (argv[7]) != SQLITE_TEXT)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      geom_type = (char *) sqlite3_value_text (argv[7]);
      }
    if (argc > 8)
      {
	  if (sqlite3_value_type (argv[8]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      coerce2d = sqlite3_value_int (argv[8]);
      }
    if (argc > 9)
      {
	  if (sqlite3_value_type (argv[9]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      compressed = sqlite3_value_int (argv[9]);
      }
    if (argc > 10)
      {
	  if (sqlite3_value_type (argv[10]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      spatial_index = sqlite3_value_int (argv[10]);
      }
    if (argc > 11)
      {
	  if (sqlite3_value_type (argv[11]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      text_dates = sqlite3_value_int (argv[11]);
      }
    if (argc > 12)
      {
	  if (sqlite3_value_type (argv[12]) != SQLITE_TEXT)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	    {
		const char *val = (char *) sqlite3_value_text (argv[12]);
		if (strcasecmp (val, "UPPER") == 0
		    || strcasecmp (val, "UPPERCASE") == 0)
		    colname_case = GAIA_DBF_COLNAME_UPPERCASE;
		else if (strcasecmp (val, "SAME") == 0
			 || strcasecmp (val, "SAMECASE") == 0)
		    colname_case = GAIA_DBF_COLNAME_CASE_IGNORE;
		else
		    colname_case = GAIA_DBF_COLNAME_LOWERCASE;
	    }
      }
    if (argc > 13)
      {
	  if (sqlite3_value_type (argv[13]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      update_statistics = sqlite3_value_int (argv[13]);
      }
    if (argc > 14)
      {
	  if (sqlite3_value_type (argv[14]) != SQLITE_INTEGER)
	    {
		sqlite3_result_null (context);
		return;
	    }
	  else
	      verbose = sqlite3_value_int (argv[14]);
      }

    ret =
	load_zip_shapefile (db_handle, zip_path, path, table, charset, srid,
			    geo_column, geom_type, pk_column, coerce2d,
			    compressed, verbose, spatial_index, text_dates,
			    &rows, colname_case, NULL);

    if (rows < 0 || !ret)
	sqlite3_result_null (context);
    else
      {
	  if (update_statistics)
	      update_layer_statistics (db_handle, table, NULL);
	  sqlite3_result_int (context, rows);
      }
}

#endif /* end enabling ImportZipSHP */

static void
fnct_ExportSHP (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ ExportSHP(TEXT table, TEXT geom_column, TEXT filename, TEXT charset)
/ ExportSHP(TEXT table, TEXT geom_column, TEXT filename, TEXT charset,
/           TEXT geom_type)
................................................................................
/* checking all Triggers */
    sql = "SELECT Lower(sql) FROM sqlite_master WHERE "
	"type IN ('trigger', 'view') AND (sql LIKE '%BlobFromFile%' "
	"OR sql LIKE '%BlobToFile%' OR sql LIKE '%XB_LoadXML%' "
	"OR sql LIKE '%XB_StoreXML%' OR sql LIKE '%ImportDXF%' "
	"OR sql LIKE '%ExportDXF%' OR sql LIKE '%ImportDBF%' "
	"OR sql LIKE '%ExportDBF%' OR sql LIKE '%ImportSHP%' "
	"OR sql LIKE '%ImportZipDBF%' OR sql LIKE '%ImportZipSHP%' "
	"OR sql LIKE '%ExportSHP%' OR sql LIKE '%ExportKML%' "
	"OR sql LIKE '%ExportGeoJSON%' OR (sql LIKE '%eval%' AND sql LIKE '%(%') "
	"OR sql LIKE '%ExportGeoJSON2%' OR sql LIKE '%ImportGeoJSON%' "
	"OR sql LIKE '%ImportWFS%' OR sql LIKE '%ImportXLS%')";
    ret = sqlite3_get_table (sqlite, sql, &results, &rows, &columns, NULL);
    if (ret != SQLITE_OK)
	goto unknown;
................................................................................
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "importdxf"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "exportdxf"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "importdbf"))
		    dangerous = 1;
		if (do_check_impexp
		    (results[(i * columns) + 0], "importzipdbf"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "exportdbf"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "importshp"))
		    dangerous = 1;
		if (do_check_impexp
		    (results[(i * columns) + 0], "importzipshp"))
		    dangerous = 1;
		if (do_check_impexp (results[(i * columns) + 0], "exportshp"))
		    dangerous = 1;
		if (do_check_impexp
		    (results[(i * columns) + 0], "importgeojson"))
		    dangerous = 1;
		if (do_check_impexp
		    (results[(i * columns) + 0], "exportgeojson2"))
................................................................................
				fnct_has_geos_trunk, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasGeosReentrant", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_geos_reentrant, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasGeosOnlyReentrant", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_geos_only_reentrant, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasMinZip", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_minizip, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasRtTopo", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_rttopo, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasMathSql", 0,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_has_math_sql, 0, 0, 0);
    sqlite3_create_function_v2 (db, "HasGeoCallbacks", 0,
................................................................................
    sqlite3_create_function_v2 (db, "MD5Checksum", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_MD5Checksum, 0, 0, 0);
    sqlite3_create_function_v2 (db, "MD5TotalChecksum", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, 0,
				fnct_MD5TotalChecksum_step,
				fnct_MD5TotalChecksum_final, 0);

    sqlite3_create_function_v2 (db, "RemoveExtraSpaces", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_RemoveExtraSpaces, 0, 0, 0);

#if OMIT_ICONV == 0		/* ICONV is absolutely required */

    sqlite3_create_function_v2 (db, "EncodeURL", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_EncodeURL, 0, 0, 0);
    sqlite3_create_function_v2 (db, "EncodeURL", 2,
................................................................................
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_DecodeURL, 0, 0, 0);
    sqlite3_create_function_v2 (db, "DecodeURL", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_DecodeURL, 0, 0, 0);

#endif /* ICONV enabled/disabled */

#ifdef ENABLE_MINIZIP		/* only if MINIZIP is enabled */
    sqlite3_create_function_v2 (db, "Zipfile_NumSHP", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Zipfile_NumSHP, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Zipfile_ShpN", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Zipfile_ShpN, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Zipfile_NumDBF", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Zipfile_NumDBF, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Zipfile_DbfN", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Zipfile_DbfN, 0, 0, 0);
#endif /* end MINIZIP */

    sqlite3_create_function_v2 (db, "DirNameFromPath", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_DirNameFromPath, 0, 0, 0);
    sqlite3_create_function_v2 (db, "FullFileNameFromPath", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_FullFileNameFromPath, 0, 0, 0);
................................................................................
				      fnct_ImportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportSHP", 13,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportSHP", 14,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportSHP, 0, 0, 0);

#ifdef ENABLE_MINIZIP		/* only if MINIZIP is enabled */

	  sqlite3_create_function_v2 (db, "ImportZipDBF", 4,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipDBF, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipDBF", 5,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipDBF, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipDBF", 6,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipDBF, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipDBF", 7,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipDBF, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 4,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 5,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 6,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 7,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 8,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 9,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 10,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 11,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 12,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 13,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 14,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ImportZipSHP", 15,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				      fnct_ImportZipSHP, 0, 0, 0);

#endif /* end enabling ImportZipSHP */

#ifdef PROJ_NEW			/* supporting new PROJ.6 */
	  sqlite3_create_function_v2 (db, "PROJ_GuessSridFromSHP", 1,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				      fnct_PROJ_GuessSridFromSHP, 0, 0, 0);

#ifdef ENABLE_MINIZIP		/* only if MINIZIP is enabled */
	  sqlite3_create_function_v2 (db, "PROJ_GuessSridFromZipSHP", 2,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				      fnct_PROJ_GuessSridFromZipSHP, 0, 0, 0);
#endif /* end MINIZIP */

#endif /* end PROJ_NEW */

	  sqlite3_create_function_v2 (db, "ExportSHP", 4,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				      fnct_ExportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ExportSHP", 5,
				      SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				      fnct_ExportSHP, 0, 0, 0);
	  sqlite3_create_function_v2 (db, "ExportSHP", 6,
................................................................................
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_LinestringAvgSegmentLength, 0, 0, 0);
    sqlite3_create_function_v2 (db, "CurvosityIndex", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_CurvosityIndex", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "CurvosityIndex", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_CurvosityIndex", 2,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_CurvosityIndex, 0, 0, 0);
    sqlite3_create_function_v2 (db, "UphillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UphillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_UphillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UphillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "DownhillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_DownhillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_DownhillHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_DownhillHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "UpDownHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UpDownHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_UpDownHeight", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_UpDownHeight, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "ST_Area", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,
				fnct_Area, 0, 0, 0);
    sqlite3_create_function_v2 (db, "Circularity", 1,
................................................................................
				fnct_XB_IsSldStyle, 0, 0, 0);
    sqlite3_create_function_v2 (db, "XB_IsMapConfig", 1,
				SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
				fnct_XB_IsMapConfig, 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_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,

Changes to test/Makefile.am.

72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
...
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
		check_network_log \
		check_virtualknn \
		check_sequence \
		check_stored_proc \
		check_wms \
		check_drop_rename \
		routing_test \
		geojson_test

		
if ENABLE_GEOPACKAGE
check_PROGRAMS += \
		check_createBaseTables \
		check_gpkgCreateTilesTable \
		check_gpkgCreateTilesTableMissingSRID \
		check_gpkgCreateTilesZoomLevel \
................................................................................
	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 \
	sqlproc_sample.txt sqlproc_logfile.txt \
	sqlproc_error.txt orbetello.sqlite \
	test.geojson mapconfig.xml mapconfig2.xml

SUBDIRS = sql_stmt_geosadvanced_tests sql_stmt_geos_tests \
	sql_stmt_geos_380 sql_stmt_geos_non380 \
	sql_stmt_libxml2_tests sql_stmt_rtgeom_tests \
	sql_stmt_mathsql_tests sql_stmt_proj_tests \
	sql_stmt_proj492_tests sql_stmt_proj493_tests \
	sql_stmt_proj600security_tests \

	sql_stmt_proj600_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 \
	sql_stmt_gpkg_epsg492_tests sql_stmt_gpkg_epsg493_tests \
	sql_stmt_gpkg_epsg600_tests \







|
>







 







|











>







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
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
		check_network_log \
		check_virtualknn \
		check_sequence \
		check_stored_proc \
		check_wms \
		check_drop_rename \
		routing_test \
		geojson_test \
		check_zipshp
		
if ENABLE_GEOPACKAGE
check_PROGRAMS += \
		check_createBaseTables \
		check_gpkgCreateTilesTable \
		check_gpkgCreateTilesTableMissingSRID \
		check_gpkgCreateTilesZoomLevel \
................................................................................
	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 elba.zip \
	Gpx-sample.gpx 000323485.gpx \
	sqlproc_sample.txt sqlproc_logfile.txt \
	sqlproc_error.txt orbetello.sqlite \
	test.geojson mapconfig.xml mapconfig2.xml

SUBDIRS = sql_stmt_geosadvanced_tests sql_stmt_geos_tests \
	sql_stmt_geos_380 sql_stmt_geos_non380 \
	sql_stmt_libxml2_tests sql_stmt_rtgeom_tests \
	sql_stmt_mathsql_tests sql_stmt_proj_tests \
	sql_stmt_proj492_tests sql_stmt_proj493_tests \
	sql_stmt_proj600security_tests \
	sql_stmt_zip_proj6 sql_stmt_minizip \
	sql_stmt_proj600_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 \
	sql_stmt_gpkg_epsg492_tests sql_stmt_gpkg_epsg493_tests \
	sql_stmt_gpkg_epsg600_tests \

Changes to test/Makefile.in.

121
122
123
124
125
126
127
128

129
130
131
132
133
134
135
...
530
531
532
533
534
535
536



537
538
539
540
541
542
543
...
647
648
649
650
651
652
653

654
655
656
657
658
659
660
661
662
663
664
...
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
...
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
....
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274

1275
1276
1277
1278
1279
1280
1281
....
1718
1719
1720
1721
1722
1723
1724




1725
1726
1727
1728
1729
1730
1731
....
1855
1856
1857
1858
1859
1860
1861

1862
1863
1864
1865
1866
1867
1868
....
2676
2677
2678
2679
2680
2681
2682







2683
2684
2685
2686
2687
2688
2689
....
3097
3098
3099
3100
3101
3102
3103

3104
3105
3106
3107
3108
3109
3110
....
3248
3249
3250
3251
3252
3253
3254

3255
3256
3257
3258
3259
3260
3261
	check_cutter$(EXEEXT) check_topology2d$(EXEEXT) \
	check_topology3d$(EXEEXT) check_toponoface2d$(EXEEXT) \
	check_topoplus$(EXEEXT) check_toposnap$(EXEEXT) \
	check_network2d$(EXEEXT) check_network3d$(EXEEXT) \
	check_network_log$(EXEEXT) check_virtualknn$(EXEEXT) \
	check_sequence$(EXEEXT) check_stored_proc$(EXEEXT) \
	check_wms$(EXEEXT) check_drop_rename$(EXEEXT) \
	routing_test$(EXEEXT) geojson_test$(EXEEXT) $(am__EXEEXT_1)

@ENABLE_GEOPACKAGE_TRUE@am__append_1 = \
@ENABLE_GEOPACKAGE_TRUE@		check_createBaseTables \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateTilesTable \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateTilesTableMissingSRID \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateTilesZoomLevel \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgInsertEpsgSRID check_gpkgMode \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateFeaturesTable \
................................................................................
check_wfsin_LDADD = $(LDADD)
check_wms_SOURCES = check_wms.c
check_wms_OBJECTS = check_wms.$(OBJEXT)
check_wms_LDADD = $(LDADD)
check_xls_load_SOURCES = check_xls_load.c
check_xls_load_OBJECTS = check_xls_load.$(OBJEXT)
check_xls_load_LDADD = $(LDADD)



geojson_test_SOURCES = geojson_test.c
geojson_test_OBJECTS = geojson_test.$(OBJEXT)
geojson_test_LDADD = $(LDADD)
routing_test_SOURCES = routing_test.c
routing_test_OBJECTS = routing_test.$(OBJEXT)
routing_test_LDADD = $(LDADD)
shape_3d_SOURCES = shape_3d.c
................................................................................
	./$(DEPDIR)/check_virtualtable2.Po \
	./$(DEPDIR)/check_virtualtable3.Po \
	./$(DEPDIR)/check_virtualtable4.Po \
	./$(DEPDIR)/check_virtualtable5.Po \
	./$(DEPDIR)/check_virtualtable6.Po \
	./$(DEPDIR)/check_virtualxpath.Po ./$(DEPDIR)/check_wfsin.Po \
	./$(DEPDIR)/check_wms.Po ./$(DEPDIR)/check_xls_load.Po \

	./$(DEPDIR)/geojson_test.Po ./$(DEPDIR)/routing_test.Po \
	./$(DEPDIR)/shape_3d.Po ./$(DEPDIR)/shape_cp1252.Po \
	./$(DEPDIR)/shape_primitives.Po ./$(DEPDIR)/shape_utf8_1.Po \
	./$(DEPDIR)/shape_utf8_1ex.Po ./$(DEPDIR)/shape_utf8_2.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
	$(AM_CFLAGS) $(CFLAGS)
................................................................................
	check_tempgeom.c check_topology2d.c check_topology3d.c \
	check_toponoface2d.c check_topoplus.c check_toposnap.c \
	check_version.c check_virtual_ovflw.c check_virtualbbox.c \
	check_virtualelem.c check_virtualknn.c check_virtualtable1.c \
	check_virtualtable2.c check_virtualtable3.c \
	check_virtualtable4.c check_virtualtable5.c \
	check_virtualtable6.c check_virtualxpath.c check_wfsin.c \
	check_wms.c check_xls_load.c geojson_test.c routing_test.c \
	shape_3d.c shape_cp1252.c shape_primitives.c shape_utf8_1.c \
	shape_utf8_1ex.c shape_utf8_2.c
DIST_SOURCES = check_add_tile_triggers.c \
	check_add_tile_triggers_bad_table_name.c check_bufovflw.c \
	check_clone_table.c check_control_points.c check_create.c \
	check_createBaseTables.c check_cutter.c check_dbf_load.c \
	check_drop_rename.c check_dxf.c check_endian.c check_exif.c \
	check_exif2.c check_extension.c check_extra_relations_fncts.c \
	check_fdo1.c check_fdo2.c check_fdo3.c check_fdo_bufovflw.c \
................................................................................
	check_tempgeom.c check_topology2d.c check_topology3d.c \
	check_toponoface2d.c check_topoplus.c check_toposnap.c \
	check_version.c check_virtual_ovflw.c check_virtualbbox.c \
	check_virtualelem.c check_virtualknn.c check_virtualtable1.c \
	check_virtualtable2.c check_virtualtable3.c \
	check_virtualtable4.c check_virtualtable5.c \
	check_virtualtable6.c check_virtualxpath.c check_wfsin.c \
	check_wms.c check_xls_load.c geojson_test.c routing_test.c \
	shape_3d.c shape_cp1252.c shape_primitives.c shape_utf8_1.c \
	shape_utf8_1ex.c shape_utf8_2.c
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
	ctags-recursive dvi-recursive html-recursive info-recursive \
	install-data-recursive install-dvi-recursive \
	install-exec-recursive install-html-recursive \
	install-info-recursive install-pdf-recursive \
	install-ps-recursive install-recursive installcheck-recursive \
	installdirs-recursive pdf-recursive ps-recursive \
................................................................................
	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 \
	sqlproc_sample.txt sqlproc_logfile.txt \
	sqlproc_error.txt orbetello.sqlite \
	test.geojson mapconfig.xml mapconfig2.xml

SUBDIRS = sql_stmt_geosadvanced_tests sql_stmt_geos_tests \
	sql_stmt_geos_380 sql_stmt_geos_non380 \
	sql_stmt_libxml2_tests sql_stmt_rtgeom_tests \
	sql_stmt_mathsql_tests sql_stmt_proj_tests \
	sql_stmt_proj492_tests sql_stmt_proj493_tests \
	sql_stmt_proj600security_tests \

	sql_stmt_proj600_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 \
	sql_stmt_gpkg_epsg492_tests sql_stmt_gpkg_epsg493_tests \
	sql_stmt_gpkg_epsg600_tests \
................................................................................
check_wms$(EXEEXT): $(check_wms_OBJECTS) $(check_wms_DEPENDENCIES) $(EXTRA_check_wms_DEPENDENCIES) 
	@rm -f check_wms$(EXEEXT)
	$(AM_V_CCLD)$(LINK) $(check_wms_OBJECTS) $(check_wms_LDADD) $(LIBS)

check_xls_load$(EXEEXT): $(check_xls_load_OBJECTS) $(check_xls_load_DEPENDENCIES) $(EXTRA_check_xls_load_DEPENDENCIES) 
	@rm -f check_xls_load$(EXEEXT)
	$(AM_V_CCLD)$(LINK) $(check_xls_load_OBJECTS) $(check_xls_load_LDADD) $(LIBS)





geojson_test$(EXEEXT): $(geojson_test_OBJECTS) $(geojson_test_DEPENDENCIES) $(EXTRA_geojson_test_DEPENDENCIES) 
	@rm -f geojson_test$(EXEEXT)
	$(AM_V_CCLD)$(LINK) $(geojson_test_OBJECTS) $(geojson_test_LDADD) $(LIBS)

routing_test$(EXEEXT): $(routing_test_OBJECTS) $(routing_test_DEPENDENCIES) $(EXTRA_routing_test_DEPENDENCIES) 
	@rm -f routing_test$(EXEEXT)
................................................................................
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualtable4.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualtable5.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualtable6.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualxpath.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_wfsin.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_wms.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_xls_load.Po@am__quote@ # am--include-marker

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geojson_test.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/routing_test.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_3d.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_cp1252.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_primitives.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_utf8_1.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_utf8_1ex.Po@am__quote@ # am--include-marker
................................................................................
geojson_test.log: geojson_test$(EXEEXT)
	@p='geojson_test$(EXEEXT)'; \
	b='geojson_test'; \
	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
	--log-file $$b.log --trs-file $$b.trs \
	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
	"$$tst" $(AM_TESTS_FD_REDIRECT)







check_createBaseTables.log: check_createBaseTables$(EXEEXT)
	@p='check_createBaseTables$(EXEEXT)'; \
	b='check_createBaseTables'; \
	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
	--log-file $$b.log --trs-file $$b.trs \
	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
	"$$tst" $(AM_TESTS_FD_REDIRECT)
................................................................................
	-rm -f ./$(DEPDIR)/check_virtualtable4.Po
	-rm -f ./$(DEPDIR)/check_virtualtable5.Po
	-rm -f ./$(DEPDIR)/check_virtualtable6.Po
	-rm -f ./$(DEPDIR)/check_virtualxpath.Po
	-rm -f ./$(DEPDIR)/check_wfsin.Po
	-rm -f ./$(DEPDIR)/check_wms.Po
	-rm -f ./$(DEPDIR)/check_xls_load.Po

	-rm -f ./$(DEPDIR)/geojson_test.Po
	-rm -f ./$(DEPDIR)/routing_test.Po
	-rm -f ./$(DEPDIR)/shape_3d.Po
	-rm -f ./$(DEPDIR)/shape_cp1252.Po
	-rm -f ./$(DEPDIR)/shape_primitives.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1ex.Po
................................................................................
	-rm -f ./$(DEPDIR)/check_virtualtable4.Po
	-rm -f ./$(DEPDIR)/check_virtualtable5.Po
	-rm -f ./$(DEPDIR)/check_virtualtable6.Po
	-rm -f ./$(DEPDIR)/check_virtualxpath.Po
	-rm -f ./$(DEPDIR)/check_wfsin.Po
	-rm -f ./$(DEPDIR)/check_wms.Po
	-rm -f ./$(DEPDIR)/check_xls_load.Po

	-rm -f ./$(DEPDIR)/geojson_test.Po
	-rm -f ./$(DEPDIR)/routing_test.Po
	-rm -f ./$(DEPDIR)/shape_3d.Po
	-rm -f ./$(DEPDIR)/shape_cp1252.Po
	-rm -f ./$(DEPDIR)/shape_primitives.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1ex.Po







|
>







 







>
>
>







 







>
|
|
|
|







 







|
|
|







 







|
|
|







 







|











>







 







>
>
>
>







 







>







 







>
>
>
>
>
>
>







 







>







 







>







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
...
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
...
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
...
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
...
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
....
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
....
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
....
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
....
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
....
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
....
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
	check_cutter$(EXEEXT) check_topology2d$(EXEEXT) \
	check_topology3d$(EXEEXT) check_toponoface2d$(EXEEXT) \
	check_topoplus$(EXEEXT) check_toposnap$(EXEEXT) \
	check_network2d$(EXEEXT) check_network3d$(EXEEXT) \
	check_network_log$(EXEEXT) check_virtualknn$(EXEEXT) \
	check_sequence$(EXEEXT) check_stored_proc$(EXEEXT) \
	check_wms$(EXEEXT) check_drop_rename$(EXEEXT) \
	routing_test$(EXEEXT) geojson_test$(EXEEXT) \
	check_zipshp$(EXEEXT) $(am__EXEEXT_1)
@ENABLE_GEOPACKAGE_TRUE@am__append_1 = \
@ENABLE_GEOPACKAGE_TRUE@		check_createBaseTables \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateTilesTable \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateTilesTableMissingSRID \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateTilesZoomLevel \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgInsertEpsgSRID check_gpkgMode \
@ENABLE_GEOPACKAGE_TRUE@		check_gpkgCreateFeaturesTable \
................................................................................
check_wfsin_LDADD = $(LDADD)
check_wms_SOURCES = check_wms.c
check_wms_OBJECTS = check_wms.$(OBJEXT)
check_wms_LDADD = $(LDADD)
check_xls_load_SOURCES = check_xls_load.c
check_xls_load_OBJECTS = check_xls_load.$(OBJEXT)
check_xls_load_LDADD = $(LDADD)
check_zipshp_SOURCES = check_zipshp.c
check_zipshp_OBJECTS = check_zipshp.$(OBJEXT)
check_zipshp_LDADD = $(LDADD)
geojson_test_SOURCES = geojson_test.c
geojson_test_OBJECTS = geojson_test.$(OBJEXT)
geojson_test_LDADD = $(LDADD)
routing_test_SOURCES = routing_test.c
routing_test_OBJECTS = routing_test.$(OBJEXT)
routing_test_LDADD = $(LDADD)
shape_3d_SOURCES = shape_3d.c
................................................................................
	./$(DEPDIR)/check_virtualtable2.Po \
	./$(DEPDIR)/check_virtualtable3.Po \
	./$(DEPDIR)/check_virtualtable4.Po \
	./$(DEPDIR)/check_virtualtable5.Po \
	./$(DEPDIR)/check_virtualtable6.Po \
	./$(DEPDIR)/check_virtualxpath.Po ./$(DEPDIR)/check_wfsin.Po \
	./$(DEPDIR)/check_wms.Po ./$(DEPDIR)/check_xls_load.Po \
	./$(DEPDIR)/check_zipshp.Po ./$(DEPDIR)/geojson_test.Po \
	./$(DEPDIR)/routing_test.Po ./$(DEPDIR)/shape_3d.Po \
	./$(DEPDIR)/shape_cp1252.Po ./$(DEPDIR)/shape_primitives.Po \
	./$(DEPDIR)/shape_utf8_1.Po ./$(DEPDIR)/shape_utf8_1ex.Po \
	./$(DEPDIR)/shape_utf8_2.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
	$(AM_CFLAGS) $(CFLAGS)
................................................................................
	check_tempgeom.c check_topology2d.c check_topology3d.c \
	check_toponoface2d.c check_topoplus.c check_toposnap.c \
	check_version.c check_virtual_ovflw.c check_virtualbbox.c \
	check_virtualelem.c check_virtualknn.c check_virtualtable1.c \
	check_virtualtable2.c check_virtualtable3.c \
	check_virtualtable4.c check_virtualtable5.c \
	check_virtualtable6.c check_virtualxpath.c check_wfsin.c \
	check_wms.c check_xls_load.c check_zipshp.c geojson_test.c \
	routing_test.c shape_3d.c shape_cp1252.c shape_primitives.c \
	shape_utf8_1.c shape_utf8_1ex.c shape_utf8_2.c
DIST_SOURCES = check_add_tile_triggers.c \
	check_add_tile_triggers_bad_table_name.c check_bufovflw.c \
	check_clone_table.c check_control_points.c check_create.c \
	check_createBaseTables.c check_cutter.c check_dbf_load.c \
	check_drop_rename.c check_dxf.c check_endian.c check_exif.c \
	check_exif2.c check_extension.c check_extra_relations_fncts.c \
	check_fdo1.c check_fdo2.c check_fdo3.c check_fdo_bufovflw.c \
................................................................................
	check_tempgeom.c check_topology2d.c check_topology3d.c \
	check_toponoface2d.c check_topoplus.c check_toposnap.c \
	check_version.c check_virtual_ovflw.c check_virtualbbox.c \
	check_virtualelem.c check_virtualknn.c check_virtualtable1.c \
	check_virtualtable2.c check_virtualtable3.c \
	check_virtualtable4.c check_virtualtable5.c \
	check_virtualtable6.c check_virtualxpath.c check_wfsin.c \
	check_wms.c check_xls_load.c check_zipshp.c geojson_test.c \
	routing_test.c shape_3d.c shape_cp1252.c shape_primitives.c \
	shape_utf8_1.c shape_utf8_1ex.c shape_utf8_2.c
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
	ctags-recursive dvi-recursive html-recursive info-recursive \
	install-data-recursive install-dvi-recursive \
	install-exec-recursive install-html-recursive \
	install-info-recursive install-pdf-recursive \
	install-ps-recursive install-recursive installcheck-recursive \
	installdirs-recursive pdf-recursive ps-recursive \
................................................................................
	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 elba.zip \
	Gpx-sample.gpx 000323485.gpx \
	sqlproc_sample.txt sqlproc_logfile.txt \
	sqlproc_error.txt orbetello.sqlite \
	test.geojson mapconfig.xml mapconfig2.xml

SUBDIRS = sql_stmt_geosadvanced_tests sql_stmt_geos_tests \
	sql_stmt_geos_380 sql_stmt_geos_non380 \
	sql_stmt_libxml2_tests sql_stmt_rtgeom_tests \
	sql_stmt_mathsql_tests sql_stmt_proj_tests \
	sql_stmt_proj492_tests sql_stmt_proj493_tests \
	sql_stmt_proj600security_tests \
	sql_stmt_zip_proj6 sql_stmt_minizip \
	sql_stmt_proj600_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 \
	sql_stmt_gpkg_epsg492_tests sql_stmt_gpkg_epsg493_tests \
	sql_stmt_gpkg_epsg600_tests \
................................................................................
check_wms$(EXEEXT): $(check_wms_OBJECTS) $(check_wms_DEPENDENCIES) $(EXTRA_check_wms_DEPENDENCIES) 
	@rm -f check_wms$(EXEEXT)
	$(AM_V_CCLD)$(LINK) $(check_wms_OBJECTS) $(check_wms_LDADD) $(LIBS)

check_xls_load$(EXEEXT): $(check_xls_load_OBJECTS) $(check_xls_load_DEPENDENCIES) $(EXTRA_check_xls_load_DEPENDENCIES) 
	@rm -f check_xls_load$(EXEEXT)
	$(AM_V_CCLD)$(LINK) $(check_xls_load_OBJECTS) $(check_xls_load_LDADD) $(LIBS)

check_zipshp$(EXEEXT): $(check_zipshp_OBJECTS) $(check_zipshp_DEPENDENCIES) $(EXTRA_check_zipshp_DEPENDENCIES) 
	@rm -f check_zipshp$(EXEEXT)
	$(AM_V_CCLD)$(LINK) $(check_zipshp_OBJECTS) $(check_zipshp_LDADD) $(LIBS)

geojson_test$(EXEEXT): $(geojson_test_OBJECTS) $(geojson_test_DEPENDENCIES) $(EXTRA_geojson_test_DEPENDENCIES) 
	@rm -f geojson_test$(EXEEXT)
	$(AM_V_CCLD)$(LINK) $(geojson_test_OBJECTS) $(geojson_test_LDADD) $(LIBS)

routing_test$(EXEEXT): $(routing_test_OBJECTS) $(routing_test_DEPENDENCIES) $(EXTRA_routing_test_DEPENDENCIES) 
	@rm -f routing_test$(EXEEXT)
................................................................................
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualtable4.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualtable5.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualtable6.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_virtualxpath.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_wfsin.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_wms.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_xls_load.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_zipshp.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geojson_test.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/routing_test.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_3d.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_cp1252.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_primitives.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_utf8_1.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_utf8_1ex.Po@am__quote@ # am--include-marker
................................................................................
geojson_test.log: geojson_test$(EXEEXT)
	@p='geojson_test$(EXEEXT)'; \
	b='geojson_test'; \
	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
	--log-file $$b.log --trs-file $$b.trs \
	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
	"$$tst" $(AM_TESTS_FD_REDIRECT)
check_zipshp.log: check_zipshp$(EXEEXT)
	@p='check_zipshp$(EXEEXT)'; \
	b='check_zipshp'; \
	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
	--log-file $$b.log --trs-file $$b.trs \
	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
	"$$tst" $(AM_TESTS_FD_REDIRECT)
check_createBaseTables.log: check_createBaseTables$(EXEEXT)
	@p='check_createBaseTables$(EXEEXT)'; \
	b='check_createBaseTables'; \
	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
	--log-file $$b.log --trs-file $$b.trs \
	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
	"$$tst" $(AM_TESTS_FD_REDIRECT)
................................................................................
	-rm -f ./$(DEPDIR)/check_virtualtable4.Po
	-rm -f ./$(DEPDIR)/check_virtualtable5.Po
	-rm -f ./$(DEPDIR)/check_virtualtable6.Po
	-rm -f ./$(DEPDIR)/check_virtualxpath.Po
	-rm -f ./$(DEPDIR)/check_wfsin.Po
	-rm -f ./$(DEPDIR)/check_wms.Po
	-rm -f ./$(DEPDIR)/check_xls_load.Po
	-rm -f ./$(DEPDIR)/check_zipshp.Po
	-rm -f ./$(DEPDIR)/geojson_test.Po
	-rm -f ./$(DEPDIR)/routing_test.Po
	-rm -f ./$(DEPDIR)/shape_3d.Po
	-rm -f ./$(DEPDIR)/shape_cp1252.Po
	-rm -f ./$(DEPDIR)/shape_primitives.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1ex.Po
................................................................................
	-rm -f ./$(DEPDIR)/check_virtualtable4.Po
	-rm -f ./$(DEPDIR)/check_virtualtable5.Po
	-rm -f ./$(DEPDIR)/check_virtualtable6.Po
	-rm -f ./$(DEPDIR)/check_virtualxpath.Po
	-rm -f ./$(DEPDIR)/check_wfsin.Po
	-rm -f ./$(DEPDIR)/check_wms.Po
	-rm -f ./$(DEPDIR)/check_xls_load.Po
	-rm -f ./$(DEPDIR)/check_zipshp.Po
	-rm -f ./$(DEPDIR)/geojson_test.Po
	-rm -f ./$(DEPDIR)/routing_test.Po
	-rm -f ./$(DEPDIR)/shape_3d.Po
	-rm -f ./$(DEPDIR)/shape_cp1252.Po
	-rm -f ./$(DEPDIR)/shape_primitives.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1.Po
	-rm -f ./$(DEPDIR)/shape_utf8_1ex.Po

Changes to test/check_map_config.c.

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
	return SQLITE_OK;
    return SQLITE_ERROR;
}

#ifdef ENABLE_LIBXML2		/* only if LIBXML2 is supported */
#ifndef OMIT_ICONV		/* only if ICONV is supported */

static unsigned char *
load_blob (const char *path, int *blob_len)
{
/* loading an external image */
    unsigned char *blob;
    int sz = 0;
    int rd;
    FILE *fl = fopen (path, "rb");
    if (!fl)
      {
	  fprintf (stderr, "cannot open \"%s\"\n", path);
	  return NULL;
      }
    if (fseek (fl, 0, SEEK_END) == 0)
	sz = ftell (fl);
    blob = (unsigned char *) malloc (sz);
    *blob_len = sz;
    rewind (fl);
    rd = fread (blob, 1, sz, fl);
    if (rd != sz)
      {
	  fprintf (stderr, "read error \"%s\"\n", path);
	  return NULL;
      }
    fclose (fl);
    return blob;
}

static unsigned char *
load_xml (const char *path, int *len)
{
/* loading an external XML */
    unsigned char *xml;
    int sz = 0;
    int rd;







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







78
79
80
81
82
83
84




























85
86
87
88
89
90
91
	return SQLITE_OK;
    return SQLITE_ERROR;
}

#ifdef ENABLE_LIBXML2		/* only if LIBXML2 is supported */
#ifndef OMIT_ICONV		/* only if ICONV is supported */





























static unsigned char *
load_xml (const char *path, int *len)
{
/* loading an external XML */
    unsigned char *xml;
    int sz = 0;
    int rd;

Changes to test/check_math_funcs.c.

40
41
42
43
44
45
46

47
48
49
50
51
52
53
..
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
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
 
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>


#include "sqlite3.h"
#include "spatialite.h"

static const double double_eps = 0.00000001;

int
................................................................................
    double result;
    sqlite3_int64 result64;

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

    result = math_round (3.4);
    if (abs (result - 3) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for 3.4: %f\n", result);
	  return -1;
      }

    result = math_round (3.6);
    if (abs (result - 4) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for 3.6: %f\n", result);
	  return -2;
      }

    result = math_round (-3.4);
    if (abs (result + 3) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for -3.4: %f\n", result);
	  return -3;
      }

    result = math_round (-3.6);
    if (abs (result + 4) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for -3.6: %f\n", result);
	  return -4;
      }

    result64 = math_llabs ((sqlite3_int64) 26);
    if (result64 != 26)







>







 







|






|






|






|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
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
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
 
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#include "sqlite3.h"
#include "spatialite.h"

static const double double_eps = 0.00000001;

int
................................................................................
    double result;
    sqlite3_int64 result64;

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

    result = math_round (3.4);
    if (fabs (result - 3) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for 3.4: %f\n", result);
	  return -1;
      }

    result = math_round (3.6);
    if (fabs (result - 4) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for 3.6: %f\n", result);
	  return -2;
      }

    result = math_round (-3.4);
    if (fabs (result + 3) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for -3.4: %f\n", result);
	  return -3;
      }

    result = math_round (-3.6);
    if (fabs (result + 4) > double_eps)
      {
	  fprintf (stderr, "bad math_round() result for -3.6: %f\n", result);
	  return -4;
      }

    result64 = math_llabs ((sqlite3_int64) 26);
    if (result64 != 26)

Changes to test/check_relations_fncts.c.

43
44
45
46
47
48
49

50
51
52
53
54
55
56
...
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
....
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
 
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>


#include "config.h"

#include "sqlite3.h"
#include "spatialite.h"
#include "spatialite/gaiageo.h"

................................................................................
	  fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
		   result);
	  returnValue = -33;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint_r (cache, 0, validGeometry);
    if (abs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -62;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint_r (cache, validGeometry, 0);
    if (abs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -63;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint_r (cache, 0, 0);
    if (abs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -64;
	  goto exit;
      }

................................................................................
	  fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
		   result);
	  returnValue = -33;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint (0, validGeometry);
    if (abs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -62;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint (validGeometry, 0);
    if (abs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -63;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint (0, 0);
    if (abs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -64;
	  goto exit;
      }








>







 







|








|








|







 







|








|








|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
....
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
 
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#include "config.h"

#include "sqlite3.h"
#include "spatialite.h"
#include "spatialite/gaiageo.h"

................................................................................
	  fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
		   result);
	  returnValue = -33;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint_r (cache, 0, validGeometry);
    if (fabs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -62;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint_r (cache, validGeometry, 0);
    if (fabs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -63;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint_r (cache, 0, 0);
    if (fabs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -64;
	  goto exit;
      }

................................................................................
	  fprintf (stderr, "bad result at %s:%i: %i\n", __FILE__, __LINE__,
		   result);
	  returnValue = -33;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint (0, validGeometry);
    if (fabs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -62;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint (validGeometry, 0);
    if (fabs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -63;
	  goto exit;
      }

    resultDouble = gaiaLineLocatePoint (0, 0);
    if (fabs (resultDouble - -1.0) > double_eps)
      {
	  fprintf (stderr, "bad result at %s:%i: %f\n", __FILE__, __LINE__,
		   resultDouble);
	  returnValue = -64;
	  goto exit;
      }

Changes to test/check_sql_stmt.h.

600
601
602
603
604
605
606










607
608
609
610
611
612
613
614









615
616
617
618
619
620
621
622
		result =
		    run_subdir_test ("sql_stmt_logfile_tests", conn,
				     load_extension, 0);
		if (result != 0)
		  {
		      return result;
		  }










#ifdef PROJ_NEW			/* only id PROJ.6 is supported */
		result =
		    run_subdir_test ("sql_stmt_proj600security_tests", conn,
				     load_extension, 0);
		if (result != 0)
		  {
		      return result;
		  }









#endif
	    }
      }

    if (legacy)
      {
	  /* skipping Sequence tests in legacy mode */
	  fprintf (stderr,







>
>
>
>
>
>
>
>
>
>








>
>
>
>
>
>
>
>
>
|







600
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
635
636
637
638
639
640
641
		result =
		    run_subdir_test ("sql_stmt_logfile_tests", conn,
				     load_extension, 0);
		if (result != 0)
		  {
		      return result;
		  }
#ifdef ENABLE_MINIZIP	/* only if MINIZIP is enabled */
		result =
		    run_subdir_test ("sql_stmt_minizip", conn,
				     load_extension, 0);
		if (result != 0)
		  {
		      return result;
		  }
#endif

#ifdef PROJ_NEW			/* only id PROJ.6 is supported */
		result =
		    run_subdir_test ("sql_stmt_proj600security_tests", conn,
				     load_extension, 0);
		if (result != 0)
		  {
		      return result;
		  }
#ifdef ENABLE_MINIZIP	/* only if MINIZIP is enabled */
		result =
		    run_subdir_test ("sql_stmt_zip_proj6", conn,
				     load_extension, 0);
		if (result != 0)
		  {
		      return result;
		  }
#endif	/* end MINIZIP */
#endif	/* end PROJ.6 */
	    }
      }

    if (legacy)
      {
	  /* skipping Sequence tests in legacy mode */
	  fprintf (stderr,

Changes to test/check_tempgeom.c.

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
    int retval = 0;
    int ret;
    sqlite3 *handle;
    const char *sql;
    sqlite3_stmt *stmt = NULL;
    char *err_msg = NULL;
    char **results;
    int rows;
    int columns;
    void *cache = spatialite_alloc_connection ();

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

    ret =
	sqlite3_open_v2 (":memory:", &handle,







<
<
<







82
83
84
85
86
87
88



89
90
91
92
93
94
95
{
    int retval = 0;
    int ret;
    sqlite3 *handle;
    const char *sql;
    sqlite3_stmt *stmt = NULL;
    char *err_msg = NULL;



    void *cache = spatialite_alloc_connection ();

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

    ret =
	sqlite3_open_v2 (":memory:", &handle,

Added test/check_zipshp.c.















































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*

 check_zipshp.c -- SpatiaLite Test Case

 Author: Sandro Furieri <a.furieri@lqt.it>

 ------------------------------------------------------------------------------
 
 Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
 The contents of this file are subject to the Mozilla Public License Version
 1.1 (the "License"); you may not use this file except in compliance with
 the License. You may obtain a copy of the License at
 http://www.mozilla.org/MPL/
 
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.

The Original Code is the SpatiaLite library

The Initial Developer of the Original Code is Alessandro Furieri
 
Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved.

Contributor(s):

Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
 
*/

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "config.h"

#include "sqlite3.h"
#include "spatialite.h"

int
main (int argc, char *argv[])
{
    int retcode = 0;

#ifdef ENABLE_MINIZIP	/* only if MINIZIP is enabled */
#ifndef OMIT_ICONV		/* only if ICONV is enabled */
    int ret;
    sqlite3 *handle;
    char *err_msg = NULL;
    void *cache = spatialite_alloc_connection ();
    char *old_SPATIALITE_SECURITY_ENV = NULL;
#ifdef _WIN32
    char *env;
#endif /* not WIN32 */

    old_SPATIALITE_SECURITY_ENV = getenv ("SPATIALITE_SECURITY");
#ifdef _WIN32
    putenv ("SPATIALITE_SECURITY=relaxed");
#else /* not WIN32 */
    setenv ("SPATIALITE_SECURITY", "relaxed", 1);
#endif

    ret =
	sqlite3_open_v2 (":memory:", &handle,
			 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "cannot open \":memory:\" database: %s\n",
		   sqlite3_errmsg (handle));
	  sqlite3_close (handle);
	  return -1;
      }

    spatialite_init_ex (handle, cache, 0);

    ret = sqlite3_exec (handle, "PRAGMA foreign_keys=1", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "PRAGMA foreign_keys=1 error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -2;
      }

    ret =
	sqlite3_exec (handle, "SELECT InitSpatialMetadata(1)", NULL, NULL,
		      &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -3;
      }

/* importing Elba (polygons) from ZipSHP */
    ret =
	sqlite3_exec (handle,
		      "SELECT ImportZipSHP('./elba.zip', 'elba-pg', 'elba_pg', 'CP1252', 32632)",
		      NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "ImportZipSHP() elba-pg error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -5;
      }

/* importing Elba (linestrings) from ZipSHP */
    ret =
	sqlite3_exec (handle,
		      "SELECT ImportZipSHP('./elba.zip', 'elba-ln', 'elba_ln', 'CP1252', 32632)",
		      NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "ImportZipSHP() elba-ln error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -6;
      }

    if (old_SPATIALITE_SECURITY_ENV)
      {
#ifdef _WIN32
	  env =
	      sqlite3_mprintf ("SPATIALITE_SECURITY=%s",
			       old_SPATIALITE_SECURITY_ENV);
	  putenv (env);
	  sqlite3_free (env);
#else /* not WIN32 */
	  setenv ("SPATIALITE_SECURITY", old_SPATIALITE_SECURITY_ENV, 1);
#endif
      }
    else
      {
#ifdef _WIN32
	  putenv ("SPATIALITE_SECURITY=");
#else /* not WIN32 */
	  unsetenv ("SPATIALITE_SECURITY");
#endif
      }
    sqlite3_close (handle);
    spatialite_cleanup_ex (cache);

#endif
#endif /* end MINIZIP conditional */

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

    spatialite_shutdown ();
    return retcode;
}

Added test/elba.zip.

cannot compute difference between binary files

Added test/sql_stmt_minizip/Makefile.am.

























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

EXTRA_DIST = importzipdbf1.testcase \
	importzipdbf2.testcase \
	importzipdbf3.testcase \
	importzipdbf4.testcase \
	importzipdbf5.testcase \
	importzipdbf6.testcase \
	importzipdbf7.testcase \
	importzipdbf8.testcase \
	importzipdbf9.testcase \
	importzipdbf10.testcase \
	importzipdbf11.testcase \
	importzipdbf12.testcase \
	importzipdbf13.testcase \
	importzipdbf14.testcase \
	importzipdbf15.testcase \
	importzipshp1.testcase \
	importzipshp2.testcase \
	importzipshp3.testcase \
	importzipshp4.testcase \
	importzipshp5.testcase \
	importzipshp6.testcase \
	importzipshp7.testcase \
	importzipshp8.testcase \
	importzipshp9.testcase \
	importzipshp10.testcase \
	importzipshp11.testcase \
	importzipshp12.testcase \
	importzipshp13.testcase \
	importzipshp14.testcase \
	importzipshp15.testcase \
	importzipshp16.testcase \
	importzipshp17.testcase \
	importzipshp18.testcase \
	importzipshp19.testcase \
	importzipshp20.testcase \
	importzipshp21.testcase \
	importzipshp22.testcase \
	importzipshp23.testcase \
	importzipshp24.testcase \
	importzipshp25.testcase \
	importzipshp26.testcase \
	zipnumdbf1.testcase \
	zipnumdbf2.testcase \
	zipnumdbf3.testcase \
	zipnumdbf4.testcase \
	zipnumdbf5.testcase \
	zipnumdbf6.testcase \
	zipnumshp1.testcase \
	zipnumshp2.testcase \
	zipnumshp3.testcase \
	zipnumshp4.testcase \
	zipnumshp5.testcase \
	zipnumshp6.testcase \
	zipdbfn1.testcase \
	zipdbfn2.testcase \
	zipdbfn3.testcase \
	zipdbfn4.testcase \
	zipdbfn5.testcase \
	zipdbfn6.testcase \
	zipdbfn7.testcase \
	zipdbfn8.testcase \
	zipdbfn9.testcase \
	zipdbfn10.testcase \
	zipdbfn11.testcase \
	zipshpn1.testcase \
	zipshpn2.testcase \
	zipshpn3.testcase \
	zipshpn4.testcase \
	zipshpn5.testcase \
	zipshpn6.testcase \
	zipshpn7.testcase \
	zipshpn8.testcase \
	zipshpn9.testcase \
	zipshpn10.testcase \
	zipshpn11.testcase

Added test/sql_stmt_minizip/Makefile.in.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2018 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
  if test -z '$(MAKELEVEL)'; then \
    false; \
  elif test -n '$(MAKE_HOST)'; then \
    true; \
  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    true; \
  else \
    false; \
  fi; \
}
am__make_running_with_option = \
  case $${target_option-} in \
      ?) ;; \
      *) echo "am__make_running_with_option: internal error: invalid" \
              "target option '$${target_option-}' specified" >&2; \
         exit 1;; \
  esac; \
  has_opt=no; \
  sane_makeflags=$$MAKEFLAGS; \
  if $(am__is_gnu_make); then \
    sane_makeflags=$$MFLAGS; \
  else \
    case $$MAKEFLAGS in \
      *\\[\ \	]*) \
        bs=\\; \
        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
    esac; \
  fi; \
  skip_next=no; \
  strip_trailopt () \
  { \
    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
  }; \
  for flg in $$sane_makeflags; do \
    test $$skip_next = yes && { skip_next=no; continue; }; \
    case $$flg in \
      *=*|--*) continue;; \
        -*I) strip_trailopt 'I'; skip_next=yes;; \
      -*I?*) strip_trailopt 'I';; \
        -*O) strip_trailopt 'O'; skip_next=yes;; \
      -*O?*) strip_trailopt 'O';; \
        -*l) strip_trailopt 'l'; skip_next=yes;; \
      -*l?*) strip_trailopt 'l';; \
      -[dEDm]) skip_next=yes;; \
      -[JT]) skip_next=yes;; \
    esac; \
    case $$flg in \
      *$$target_option*) has_opt=yes; break;; \
    esac; \
  done; \
  test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = test/sql_stmt_minizip
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
	$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
	$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 = 
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 = 
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
    *) (install-info --version) >/dev/null 2>&1;; \
  esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GEOSCONFIG = @GEOSCONFIG@
GEOS_CFLAGS = @GEOS_CFLAGS@
GEOS_LDFLAGS = @GEOS_LDFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBXML2_CFLAGS = @LIBXML2_CFLAGS@
LIBXML2_LIBS = @LIBXML2_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = importzipdbf1.testcase \
	importzipdbf2.testcase \
	importzipdbf3.testcase \
	importzipdbf4.testcase \
	importzipdbf5.testcase \
	importzipdbf6.testcase \
	importzipdbf7.testcase \
	importzipdbf8.testcase \
	importzipdbf9.testcase \
	importzipdbf10.testcase \
	importzipdbf11.testcase \
	importzipdbf12.testcase \
	importzipdbf13.testcase \
	importzipdbf14.testcase \
	importzipdbf15.testcase \
	importzipshp1.testcase \
	importzipshp2.testcase \
	importzipshp3.testcase \
	importzipshp4.testcase \
	importzipshp5.testcase \
	importzipshp6.testcase \
	importzipshp7.testcase \
	importzipshp8.testcase \
	importzipshp9.testcase \
	importzipshp10.testcase \
	importzipshp11.testcase \
	importzipshp12.testcase \
	importzipshp13.testcase \
	importzipshp14.testcase \
	importzipshp15.testcase \
	importzipshp16.testcase \
	importzipshp17.testcase \
	importzipshp18.testcase \
	importzipshp19.testcase \
	importzipshp20.testcase \
	importzipshp21.testcase \
	importzipshp22.testcase \
	importzipshp23.testcase \
	importzipshp24.testcase \
	importzipshp25.testcase \
	importzipshp26.testcase \
	zipnumdbf1.testcase \
	zipnumdbf2.testcase \
	zipnumdbf3.testcase \
	zipnumdbf4.testcase \
	zipnumdbf5.testcase \
	zipnumdbf6.testcase \
	zipnumshp1.testcase \
	zipnumshp2.testcase \
	zipnumshp3.testcase \
	zipnumshp4.testcase \
	zipnumshp5.testcase \
	zipnumshp6.testcase \
	zipdbfn1.testcase \
	zipdbfn2.testcase \
	zipdbfn3.testcase \
	zipdbfn4.testcase \
	zipdbfn5.testcase \
	zipdbfn6.testcase \
	zipdbfn7.testcase \
	zipdbfn8.testcase \
	zipdbfn9.testcase \
	zipdbfn10.testcase \
	zipdbfn11.testcase \
	zipshpn1.testcase \
	zipshpn2.testcase \
	zipshpn3.testcase \
	zipshpn4.testcase \
	zipshpn5.testcase \
	zipshpn6.testcase \
	zipshpn7.testcase \
	zipshpn8.testcase \
	zipshpn9.testcase \
	zipshpn10.testcase \
	zipshpn11.testcase

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 \
	    *$$dep*) \
	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
	        && { if test -f $@; then exit 0; else break; fi; }; \
	      exit 1;; \
	  esac; \
	done; \
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/sql_stmt_minizip/Makefile'; \
	$(am__cd) $(top_srcdir) && \
	  $(AUTOMAKE) --foreign test/sql_stmt_minizip/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@case '$?' in \
	  *config.status*) \
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
	  *) \
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
	esac;

$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs
tags TAGS:

ctags CTAGS:

cscope cscopelist:


distdir: $(BUILT_SOURCES)
	$(MAKE) $(AM_MAKEFLAGS) distdir-am

distdir-am: $(DISTFILES)
	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	list='$(DISTFILES)'; \
	  dist_files=`for file in $$list; do echo $$file; done | \
	  sed -e "s|^$$srcdirstrip/||;t" \
	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
	case $$dist_files in \
	  */*) $(MKDIR_P) `echo "$$dist_files" | \
			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
			   sort -u` ;; \
	esac; \
	for file in $$dist_files; do \
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
	  if test -d $$d/$$file; then \
	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
	    if test -d "$(distdir)/$$file"; then \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
	  else \
	    test -f "$(distdir)/$$file" \
	    || cp -p $$d/$$file "$(distdir)/$$file" \
	    || exit 1; \
	  fi; \
	done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am

installcheck: installcheck-am
install-strip:
	if test -z '$(STRIP)'; then \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	      install; \
	else \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
	fi
mostlyclean-generic:

clean-generic:

distclean-generic:
	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)

maintainer-clean-generic:
	@echo "This command is intended for maintainers to use"
	@echo "it deletes files that may require special tools to rebuild."
clean: clean-am

clean-am: clean-generic clean-libtool mostlyclean-am

distclean: distclean-am
	-rm -f Makefile
distclean-am: clean-am distclean-generic

dvi: dvi-am

dvi-am:

html: html-am

html-am:

info: info-am

info-am:

install-data-am:

install-dvi: install-dvi-am

install-dvi-am:

install-exec-am:

install-html: install-html-am

install-html-am:

install-info: install-info-am

install-info-am:

install-man:

install-pdf: install-pdf-am

install-pdf-am:

install-ps: install-ps-am

install-ps-am:

installcheck-am:

maintainer-clean: maintainer-clean-am
	-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

mostlyclean: mostlyclean-am

mostlyclean-am: mostlyclean-generic mostlyclean-libtool

pdf: pdf-am

pdf-am:

ps: ps-am

ps-am:

uninstall-am:

.MAKE: install-am install-strip

.PHONY: all all-am check check-am clean clean-generic clean-libtool \
	cscopelist-am ctags-am distclean distclean-generic \
	distclean-libtool distdir dvi dvi-am html html-am info info-am \
	install install-am install-data install-data-am install-dvi \
	install-dvi-am install-exec install-exec-am install-html \
	install-html-am install-info install-info-am install-man \
	install-pdf install-pdf-am install-ps install-ps-am \
	install-strip installcheck installcheck-am installdirs \
	maintainer-clean maintainer-clean-generic mostlyclean \
	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
	tags-am uninstall uninstall-am

.PRECIOUS: Makefile


# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

Added test/sql_stmt_minizip/importzipdbf1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - NULL filename
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', NULL, 'table', 'UTF-8');
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', NULL, 'table', 'UTF-8')
(NULL)

Added test/sql_stmt_minizip/importzipdbf10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - OK colname case
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, 'UPPERCASE');
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, 'UPPERCASE')
(NULL)

Added test/sql_stmt_minizip/importzipdbf11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - OK colname case
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAMECASE');
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAMECASE')
(NULL)

Added test/sql_stmt_minizip/importzipdbf12.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - NULL zipfile
:memory: #use in-memory database
SELECT ImportZipDBF(NULL, 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME');
1 # rows (not including the header row)
1 # columns
ImportZipDBF(NULL, 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME')
(NULL)

Added test/sql_stmt_minizip/importzipdbf13.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - INT zipfile
:memory: #use in-memory database
SELECT ImportZipDBF(1, 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME');
1 # rows (not including the header row)
1 # columns
ImportZipDBF(1, 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME')
(NULL)

Added test/sql_stmt_minizip/importzipdbf14.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - DOUBLE zipfile
:memory: #use in-memory database
SELECT ImportZipDBF(1.3, 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME');
1 # rows (not including the header row)
1 # columns
ImportZipDBF(1.3, 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME')
(NULL)

Added test/sql_stmt_minizip/importzipdbf15.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - BLOB zipfile
:memory: #use in-memory database
SELECT ImportZipDBF(zeroblob(10), 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME');
1 # rows (not including the header row)
1 # columns
ImportZipDBF(zeroblob(10), 'shapefile', 'table', 'UTF-8', 'id', 0, 'SAME')
(NULL)

Added test/sql_stmt_minizip/importzipdbf2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - NULL table
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', NULL, 'UTF-8');
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', NULL, 'UTF-8')
(NULL)

Added test/sql_stmt_minizip/importzipdbf3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - NULL charset
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipdbf4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - NULL pk-column
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipdbf5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - NULL text_dates
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipdbf6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - not existing shapefile
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id');
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id')
(NULL)

Added test/sql_stmt_minizip/importzipdbf7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - existing shapefile
:memory: #use in-memory database
SELECT ImportZipDBF('./elba.zip', 'elba-pg.dbf', 'zipdbftable', 'UTF-8');
1 # rows (not including the header row)
1 # columns
ImportZipDBF('./elba.zip', 'elba-pg.dbf', 'zipdbftable', 'UTF-8')
10

Added test/sql_stmt_minizip/importzipdbf8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - NULL colname case
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipdbf9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipDBF - OK colname case
:memory: #use in-memory database
SELECT ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, 'UPPER');
1 # rows (not including the header row)
1 # columns
ImportZipDBF('test.zip', 'shapefile', 'table', 'UTF-8', 'id', 0, 'UPPER')
(NULL)

Added test/sql_stmt_minizip/importzipshp1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL filename
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', NULL, 'table', 'UTF-8');
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', NULL, 'table', 'UTF-8')
(NULL)

Added test/sql_stmt_minizip/importzipshp10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL compressed
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL spatial_index
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp12.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL text_dates
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp13.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - not existing shapefile
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 1);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 1)
(NULL)

Added test/sql_stmt_minizip/importzipshp14.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - existing shapefile
:memory: #use in-memory database
SELECT ImportZipSHP('./elba.zip', 'elba-pg', 'zipshptable', 'UTF-8', 3003);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('./elba.zip', 'elba-pg', 'zipshptable', 'UTF-8', 3003)
10

Added test/sql_stmt_minizip/importzipshp15.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL colname case
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp16.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - OK colname case
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'UPPER');
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'UPPER')
(NULL)

Added test/sql_stmt_minizip/importzipshp17.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - OK colname case
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'UPPERCASE');
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'UPPERCASE')
(NULL)

Added test/sql_stmt_minizip/importzipshp18.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - OK colname case
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAMECASE');
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAMECASE')
(NULL)

Added test/sql_stmt_minizip/importzipshp19.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - OK colname case - NULL statistics
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL table
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', NULL, 'UTF-8');
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', NULL, 'UTF-8')
(NULL)

Added test/sql_stmt_minizip/importzipshp20.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - OK colname case - OK statistics
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'LOWER', 1);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'LOWER', 1)
(NULL)

Added test/sql_stmt_minizip/importzipshp21.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - OK colname case - OK statistics, NULL verbose
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp22.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - OK colname case - OK statistics, OL verbose
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'LOWER', 1, 1);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'LOWER', 1, 1)
(NULL)

Added test/sql_stmt_minizip/importzipshp23.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL zipfile
:memory: #use in-memory database
SELECT ImportZipSHP(NULL, 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP(NULL, 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp24.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - INT zipfile
:memory: #use in-memory database
SELECT ImportZipSHP(1, 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP(1, 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp25.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - DOUBLE zipfile
:memory: #use in-memory database
SELECT ImportZipSHP(1.3, 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP(1.3, 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp26.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - BLOB zipfile
:memory: #use in-memory database
SELECT ImportZipSHP(zeroblob(10), 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP(zeroblob(10), 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', 1, 1, 1, 0, 'SAME', 1, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL charset
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL srid
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL geo-column
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL geo-column
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL pk-column
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL geometry-tryp
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', NULL)
(NULL)

Added test/sql_stmt_minizip/importzipshp9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
ImportZipSHP - NULL coerce2d
:memory: #use in-memory database
SELECT ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', NULL);
1 # rows (not including the header row)
1 # columns
ImportZipSHP('test.zip', 'shapefile', 'table', 'UTF-8', 4326, 'geom', 'id', 'POINT', NULL)
(NULL)

Added test/sql_stmt_minizip/zipdbfn1.testcase.















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

Added test/sql_stmt_minizip/zipdbfn10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - existing zipfile, invalid index
:memory: #use in-memory database
SELECT Zipfile_DbfN('./elba.zip', 10);
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN('./elba.zip', 10);
(NULL)

Added test/sql_stmt_minizip/zipdbfn11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - existing zipfile, valid index
:memory: #use in-memory database
SELECT Zipfile_DbfN('./elba.zip', 1);
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN('./elba.zip', 1);
elba-ln.dbf

Added test/sql_stmt_minizip/zipdbfn2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - INT zipfile
:memory: #use in-memory database
SELECT Zipfile_DbfN(1, 2);
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN(1, 2);
(NULL)

Added test/sql_stmt_minizip/zipdbfn3.testcase.















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

Added test/sql_stmt_minizip/zipdbfn4.testcase.















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

Added test/sql_stmt_minizip/zipdbfn5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - NULL index
:memory: #use in-memory database
SELECT Zipfile_DbfN('./elba.zip', NULL);
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN('./elba.zip', NULL);
(NULL)

Added test/sql_stmt_minizip/zipdbfn6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - DOUBLE index
:memory: #use in-memory database
SELECT Zipfile_DbfN('./elba.zip', 1.9);
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN('./elba.zip', 1.9);
(NULL)

Added test/sql_stmt_minizip/zipdbfn7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - TEXT index
:memory: #use in-memory database
SELECT Zipfile_DbfN('./elba.zip', 'one');
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN('./elba.zip', 'one');
(NULL)

Added test/sql_stmt_minizip/zipdbfn8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - BLOB index
:memory: #use in-memory database
SELECT Zipfile_DbfN('./elba.zip', zeroblob(4));
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN('./elba.zip', zeroblob(4));
(NULL)

Added test/sql_stmt_minizip/zipdbfn9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_DbfN - non-existing zipfile
:memory: #use in-memory database
SELECT Zipfile_DbfN('./elbazzone.zip', 1);
1 # rows (not including the header row)
1 # columns
Zipfile_DbfN('./elbazzone.zip', 1);
(NULL)

Added test/sql_stmt_minizip/zipnumdbf1.testcase.















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

Added test/sql_stmt_minizip/zipnumdbf2.testcase.















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

Added test/sql_stmt_minizip/zipnumdbf3.testcase.















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

Added test/sql_stmt_minizip/zipnumdbf4.testcase.















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

Added test/sql_stmt_minizip/zipnumdbf5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_NumDBF - non-existing zipfile
:memory: #use in-memory database
SELECT Zipfile_NumDBF('dumb_test-zip');
1 # rows (not including the header row)
1 # columns
Zipfile_NumDBF('dumb_test-zip')
(NULL)

Added test/sql_stmt_minizip/zipnumdbf6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_NumDBF - valid zipfile
:memory: #use in-memory database
SELECT Zipfile_NumDBF('./elba.zip');
1 # rows (not including the header row)
1 # columns
Zipfile_NumDBF('./elba.zip')
2

Added test/sql_stmt_minizip/zipnumshp1.testcase.















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

Added test/sql_stmt_minizip/zipnumshp2.testcase.















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

Added test/sql_stmt_minizip/zipnumshp3.testcase.















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

Added test/sql_stmt_minizip/zipnumshp4.testcase.















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

Added test/sql_stmt_minizip/zipnumshp5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_NumSHP - non-existing zipfile
:memory: #use in-memory database
SELECT Zipfile_NumSHP('dumb_test-zip');
1 # rows (not including the header row)
1 # columns
Zipfile_NumSHP('dumb_test-zip')
(NULL)

Added test/sql_stmt_minizip/zipnumshp6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_NumSHP - valid zipfile
:memory: #use in-memory database
SELECT Zipfile_NumSHP('./elba.zip');
1 # rows (not including the header row)
1 # columns
Zipfile_NumSHP('./elba.zip')
2

Added test/sql_stmt_minizip/zipshpn1.testcase.















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

Added test/sql_stmt_minizip/zipshpn10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - existing zipfile, invalid index
:memory: #use in-memory database
SELECT Zipfile_ShpN('./elba.zip', 10);
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN('./elba.zip', 10);
(NULL)

Added test/sql_stmt_minizip/zipshpn11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - existing zipfile, valid index
:memory: #use in-memory database
SELECT Zipfile_ShpN('./elba.zip', 1);
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN('./elba.zip', 1);
elba-ln

Added test/sql_stmt_minizip/zipshpn2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - INT zipfile
:memory: #use in-memory database
SELECT Zipfile_ShpN(1, 2);
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN(1, 2);
(NULL)

Added test/sql_stmt_minizip/zipshpn3.testcase.















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

Added test/sql_stmt_minizip/zipshpn4.testcase.















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

Added test/sql_stmt_minizip/zipshpn5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - NULL index
:memory: #use in-memory database
SELECT Zipfile_ShpN('./elba.zip', NULL);
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN('./elba.zip', NULL);
(NULL)

Added test/sql_stmt_minizip/zipshpn6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - DOUBLE index
:memory: #use in-memory database
SELECT Zipfile_ShpN('./elba.zip', 1.9);
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN('./elba.zip', 1.9);
(NULL)

Added test/sql_stmt_minizip/zipshpn7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - TEXT index
:memory: #use in-memory database
SELECT Zipfile_ShpN('./elba.zip', 'one');
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN('./elba.zip', 'one');
(NULL)

Added test/sql_stmt_minizip/zipshpn8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - BLOB index
:memory: #use in-memory database
SELECT Zipfile_ShpN('./elba.zip', zeroblob(4));
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN('./elba.zip', zeroblob(4));
(NULL)

Added test/sql_stmt_minizip/zipshpn9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
Zipfile_ShpN - non-existing zipfile
:memory: #use in-memory database
SELECT Zipfile_ShpN('./elbazzone.zip', 1);
1 # rows (not including the header row)
1 # columns
Zipfile_ShpN('./elbazzone.zip', 1);
(NULL)

Changes to test/sql_stmt_tests/Makefile.

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
....
2322
2323
2324
2325
2326
2327
2328






2329
2330
2331
2332
2333
2334
2335
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
LD = /usr/bin/ld -m elf_x86_64
LDFLAGS = 
LIBOBJS = 
LIBS = -lrttopo -lfreexl -lproj -lsqlite3 -lz -lsqlite3  -L/usr/lib64 -lgeos_c
LIBTOOL = $(SHELL) $(top_builddir)/libtool
LIBXML2_CFLAGS = -I/usr/include/libxml2 
LIBXML2_LIBS = -lxml2 
LIPO = 
LN_S = ln -s
LTLIBOBJS = 
MAINT = #
................................................................................
	reflectcoords3.testcase \
	reflectcoords4.testcase \
	reflectcoords5.testcase \
	reflectcoords6.testcase \
	reflectcoords7.testcase \
	reflectcoords8.testcase \
	reflectcoords9.testcase \






	removedupl1.testcase \
	removedupl2.testcase \
	removedupl3.testcase \
	removedupl4.testcase \
	removepoint10.testcase \
	removepoint11.testcase \
	removepoint12.testcase \







|







 







>
>
>
>
>
>







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
....
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
LD = /usr/bin/ld -m elf_x86_64
LDFLAGS = 
LIBOBJS = 
LIBS = -lminizip -lrttopo -lfreexl -lproj -lsqlite3 -lz -lsqlite3  -L/usr/lib64 -lgeos_c
LIBTOOL = $(SHELL) $(top_builddir)/libtool
LIBXML2_CFLAGS = -I/usr/include/libxml2 
LIBXML2_LIBS = -lxml2 
LIPO = 
LN_S = ln -s
LTLIBOBJS = 
MAINT = #
................................................................................
	reflectcoords3.testcase \
	reflectcoords4.testcase \
	reflectcoords5.testcase \
	reflectcoords6.testcase \
	reflectcoords7.testcase \
	reflectcoords8.testcase \
	reflectcoords9.testcase \
	remextrasp1.testcase \
	remextrasp2.testcase \
	remextrasp3.testcase \
	remextrasp4.testcase \
	remextrasp5.testcase \
	remextrasp6.testcase \
	removedupl1.testcase \
	removedupl2.testcase \
	removedupl3.testcase \
	removedupl4.testcase \
	removepoint10.testcase \
	removepoint11.testcase \
	removepoint12.testcase \

Changes to test/sql_stmt_tests/Makefile.am.

2070
2071
2072
2073
2074
2075
2076






2077
2078
2079
2080
2081
2082
2083
	reflectcoords3.testcase \
	reflectcoords4.testcase \
	reflectcoords5.testcase \
	reflectcoords6.testcase \
	reflectcoords7.testcase \
	reflectcoords8.testcase \
	reflectcoords9.testcase \






	removedupl1.testcase \
	removedupl2.testcase \
	removedupl3.testcase \
	removedupl4.testcase \
	removepoint10.testcase \
	removepoint11.testcase \
	removepoint12.testcase \







>
>
>
>
>
>







2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
	reflectcoords3.testcase \
	reflectcoords4.testcase \
	reflectcoords5.testcase \
	reflectcoords6.testcase \
	reflectcoords7.testcase \
	reflectcoords8.testcase \
	reflectcoords9.testcase \
	remextrasp1.testcase \
	remextrasp2.testcase \
	remextrasp3.testcase \
	remextrasp4.testcase \
	remextrasp5.testcase \
	remextrasp6.testcase \
	removedupl1.testcase \
	removedupl2.testcase \
	removedupl3.testcase \
	removedupl4.testcase \
	removepoint10.testcase \
	removepoint11.testcase \
	removepoint12.testcase \

Changes to test/sql_stmt_tests/Makefile.in.

2322
2323
2324
2325
2326
2327
2328






2329
2330
2331
2332
2333
2334
2335
	reflectcoords3.testcase \
	reflectcoords4.testcase \
	reflectcoords5.testcase \
	reflectcoords6.testcase \
	reflectcoords7.testcase \
	reflectcoords8.testcase \
	reflectcoords9.testcase \






	removedupl1.testcase \
	removedupl2.testcase \
	removedupl3.testcase \
	removedupl4.testcase \
	removepoint10.testcase \
	removepoint11.testcase \
	removepoint12.testcase \







>
>
>
>
>
>







2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
	reflectcoords3.testcase \
	reflectcoords4.testcase \
	reflectcoords5.testcase \
	reflectcoords6.testcase \
	reflectcoords7.testcase \
	reflectcoords8.testcase \
	reflectcoords9.testcase \
	remextrasp1.testcase \
	remextrasp2.testcase \
	remextrasp3.testcase \
	remextrasp4.testcase \
	remextrasp5.testcase \
	remextrasp6.testcase \
	removedupl1.testcase \
	removedupl2.testcase \
	removedupl3.testcase \
	removedupl4.testcase \
	removepoint10.testcase \
	removepoint11.testcase \
	removepoint12.testcase \

Added test/sql_stmt_tests/remextrasp1.testcase.















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

Added test/sql_stmt_tests/remextrasp2.testcase.















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

Added test/sql_stmt_tests/remextrasp3.testcase.















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

Added test/sql_stmt_tests/remextrasp4.testcase.















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

Added test/sql_stmt_tests/remextrasp5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RemoveExtraSpaces() - no extra spaces
:memory: #use in-memory database
SELECT RemoveExtraSpaces('this is a text string');
1 # rows (not including the header row)
1 # columns
RemoveExtraSpaces('this is a text string')
this is a text string

Added test/sql_stmt_tests/remextrasp6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RemoveExtraSpaces() - with extra spaces
:memory: #use in-memory database
SELECT RemoveExtraSpaces('this   is		a 	 text  string');
1 # rows (not including the header row)
1 # columns
RemoveExtraSpaces('this   is		a 	 text  string')
this is	a text string

Added test/sql_stmt_zip_proj6/Makefile.am.



























>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13

EXTRA_DIST = zipguessshp1.testcase \
	zipguessshp2.testcase \
	zipguessshp3.testcase \
	zipguessshp4.testcase \
	zipguessshp5.testcase \
	zipguessshp6.testcase \
	zipguessshp7.testcase \
	zipguessshp8.testcase \
	zipguessshp9.testcase \
	zipguessshp10.testcase \
	zipguessshp11.testcase \
	zipguessshp12.testcase

Added test/sql_stmt_zip_proj6/Makefile.in.

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2018 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
  if test -z '$(MAKELEVEL)'; then \
    false; \
  elif test -n '$(MAKE_HOST)'; then \
    true; \
  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    true; \
  else \
    false; \
  fi; \
}
am__make_running_with_option = \
  case $${target_option-} in \
      ?) ;; \
      *) echo "am__make_running_with_option: internal error: invalid" \
              "target option '$${target_option-}' specified" >&2; \
         exit 1;; \
  esac; \
  has_opt=no; \
  sane_makeflags=$$MAKEFLAGS; \
  if $(am__is_gnu_make); then \
    sane_makeflags=$$MFLAGS; \
  else \
    case $$MAKEFLAGS in \
      *\\[\ \	]*) \
        bs=\\; \
        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
    esac; \
  fi; \
  skip_next=no; \
  strip_trailopt () \
  { \
    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
  }; \
  for flg in $$sane_makeflags; do \
    test $$skip_next = yes && { skip_next=no; continue; }; \
    case $$flg in \
      *=*|--*) continue;; \
        -*I) strip_trailopt 'I'; skip_next=yes;; \
      -*I?*) strip_trailopt 'I';; \
        -*O) strip_trailopt 'O'; skip_next=yes;; \
      -*O?*) strip_trailopt 'O';; \
        -*l) strip_trailopt 'l'; skip_next=yes;; \
      -*l?*) strip_trailopt 'l';; \
      -[dEDm]) skip_next=yes;; \
      -[JT]) skip_next=yes;; \
    esac; \
    case $$flg in \
      *$$target_option*) has_opt=yes; break;; \
    esac; \
  done; \
  test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = test/sql_stmt_zip_proj6
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
	$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
	$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 = 
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 = 
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
    *) (install-info --version) >/dev/null 2>&1;; \
  esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GEOSCONFIG = @GEOSCONFIG@
GEOS_CFLAGS = @GEOS_CFLAGS@
GEOS_LDFLAGS = @GEOS_LDFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBXML2_CFLAGS = @LIBXML2_CFLAGS@
LIBXML2_LIBS = @LIBXML2_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = zipguessshp1.testcase \
	zipguessshp2.testcase \
	zipguessshp3.testcase \
	zipguessshp4.testcase \
	zipguessshp5.testcase \
	zipguessshp6.testcase \
	zipguessshp7.testcase \
	zipguessshp8.testcase \
	zipguessshp9.testcase \
	zipguessshp10.testcase \
	zipguessshp11.testcase \
	zipguessshp12.testcase

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 \
	    *$$dep*) \
	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
	        && { if test -f $@; then exit 0; else break; fi; }; \
	      exit 1;; \
	  esac; \
	done; \
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/sql_stmt_zip_proj6/Makefile'; \
	$(am__cd) $(top_srcdir) && \
	  $(AUTOMAKE) --foreign test/sql_stmt_zip_proj6/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@case '$?' in \
	  *config.status*) \
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
	  *) \
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
	esac;

$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs
tags TAGS:

ctags CTAGS:

cscope cscopelist:


distdir: $(BUILT_SOURCES)
	$(MAKE) $(AM_MAKEFLAGS) distdir-am

distdir-am: $(DISTFILES)
	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	list='$(DISTFILES)'; \
	  dist_files=`for file in $$list; do echo $$file; done | \
	  sed -e "s|^$$srcdirstrip/||;t" \
	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
	case $$dist_files in \
	  */*) $(MKDIR_P) `echo "$$dist_files" | \
			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
			   sort -u` ;; \
	esac; \
	for file in $$dist_files; do \
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
	  if test -d $$d/$$file; then \
	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
	    if test -d "$(distdir)/$$file"; then \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
	  else \
	    test -f "$(distdir)/$$file" \
	    || cp -p $$d/$$file "$(distdir)/$$file" \
	    || exit 1; \
	  fi; \
	done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am

installcheck: installcheck-am
install-strip:
	if test -z '$(STRIP)'; then \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	      install; \
	else \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
	fi
mostlyclean-generic:

clean-generic:

distclean-generic:
	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)

maintainer-clean-generic:
	@echo "This command is intended for maintainers to use"
	@echo "it deletes files that may require special tools to rebuild."
clean: clean-am

clean-am: clean-generic clean-libtool mostlyclean-am

distclean: distclean-am
	-rm -f Makefile
distclean-am: clean-am distclean-generic

dvi: dvi-am

dvi-am:

html: html-am

html-am:

info: info-am

info-am:

install-data-am:

install-dvi: install-dvi-am

install-dvi-am:

install-exec-am:

install-html: install-html-am

install-html-am:

install-info: install-info-am

install-info-am:

install-man:

install-pdf: install-pdf-am

install-pdf-am:

install-ps: install-ps-am

install-ps-am:

installcheck-am:

maintainer-clean: maintainer-clean-am
	-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

mostlyclean: mostlyclean-am

mostlyclean-am: mostlyclean-generic mostlyclean-libtool

pdf: pdf-am

pdf-am:

ps: ps-am

ps-am:

uninstall-am:

.MAKE: install-am install-strip

.PHONY: all all-am check check-am clean clean-generic clean-libtool \
	cscopelist-am ctags-am distclean distclean-generic \
	distclean-libtool distdir dvi dvi-am html html-am info info-am \
	install install-am install-data install-data-am install-dvi \
	install-dvi-am install-exec install-exec-am install-html \
	install-html-am install-info install-info-am install-man \
	install-pdf install-pdf-am install-ps install-ps-am \
	install-strip installcheck installcheck-am installdirs \
	maintainer-clean maintainer-clean-generic mostlyclean \
	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
	tags-am uninstall uninstall-am

.PRECIOUS: Makefile


# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

Added test/sql_stmt_zip_proj6/zipguessshp1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - NULL zipfile
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP(NULL, 'elba-ln');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP(NULL, 'elba-ln')
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - non-existing Shp basename
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('./elba.zip', 'unbelievable');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('./elba.zip', 'unbelievable')
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - valid Shp basename non-existing .PRJ
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('./elba.zip', 'elba-ln');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('./elba.zip', 'elba-ln')
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp12.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - valid Shp basename existing .PRJ
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('./elba.zip', 'elba-pg');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('./elba.zip', 'elba-pg')
3003

Added test/sql_stmt_zip_proj6/zipguessshp2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - INT zipfile
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP(2, 'elba-ln');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP(2, 'elba-ln')
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - DOUBLE zipfile
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP(2.3, 'elba-ln');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP(2.3, 'elba-ln')
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - BLOB zipfile
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP(zeroblob(10), 'elba-ln');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP(zeroblob(10), 'elba-ln')
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp5.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - non-existing zipfile
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('fake.zipfile', 'elba-ln');
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('fake.zipfile', 'elba-ln')
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp6.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - NULL Shp basename
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('./elba.zip', NULL);
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('./elba.zip', NULL)
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - INT Shp basename
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('./elba.zip', 1);
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('./elba.zip', 1)
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - DOUBLE Shp basename
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('./elba.zip', 1.7);
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('./elba.zip', 1.7)
(NULL)

Added test/sql_stmt_zip_proj6/zipguessshp9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROJ_GuessSridFromZipSHP() - BLOB Shp basename
:memory: #use in-memory database
SELECT PROJ_GuessSridFromZipSHP('./elba.zip', zeroblob(10));
1 # rows (not including the header row)
1 # columns
PROJ_GuessSridFromZipSHP('./elba.zip', zeroblob(10))
(NULL)