Ejemplo n.º 1
0
int main( int argc, char **argv )
{
	Options::init( argc, argv );
	std::srand( time( 0 ) );
	if ( options->daemon() ) {
		if ( daemon( 0, 0 ) < 0 ) {
			std::cerr << "Error in daemon(): " << strerror( errno ) << ".\n";
		}
	}

	if ( !all_registered() )
		open_connections();
	Server serv;
	return serv.exec();
}
int
main (int argc, char *argv[])
{
    sqlite3 *handle_in = NULL;
    sqlite3 *handle_out = NULL;
    void *cache_in = NULL;
    void *cache_out = NULL;
    const char *path_origin;
    const char *path_destination;
    int ret;
    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

    do_unlink_all ();

/* converting from SpatiaLite v4 to GPKG */
    ret = system ("cp ./gpkg_test.sqlite copy-gpkg_test.sqlite");
    if (ret != 0)
      {
	  fprintf (stderr, "cannot copy gpkg_test.sqlite database\n");
	  return -1;
      }
    path_origin = "./copy-gpkg_test.sqlite";
    path_destination = "./out1.gpkg";
    cache_in = spatialite_alloc_connection ();
    cache_out = spatialite_alloc_connection ();
    if (!open_connections
	(path_origin, path_destination, cache_in, cache_out, &handle_in,
	 &handle_out))
      {
	  do_unlink_all ();
	  return -1;
      }
    if (!gaiaSpatialite2GPKG
	(handle_in, path_origin, handle_out, path_destination))
      {
	  do_unlink_all ();
	  return -1;
      }
    sqlite3_close (handle_in);
    sqlite3_close (handle_out);
    spatialite_cleanup_ex (cache_in);
    spatialite_cleanup_ex (cache_out);

/* converting from GPKG to SpatiaLite */
    path_origin = "./out1.gpkg";
    path_destination = "./out1.sqlite";
    cache_in = spatialite_alloc_connection ();
    cache_out = spatialite_alloc_connection ();
    if (!open_connections
	(path_origin, path_destination, cache_in, cache_out, &handle_in,
	 &handle_out))
      {
	  do_unlink_all ();
	  return -1;
      }
    if (!gaiaGPKG2Spatialite
	(handle_in, path_origin, handle_out, path_destination))
      {
	  do_unlink_all ();
	  return -1;
      }
    sqlite3_close (handle_in);
    sqlite3_close (handle_out);
    spatialite_cleanup_ex (cache_in);
    spatialite_cleanup_ex (cache_out);

/* converting from SpatiaLite v3 to GPKG */
    ret =
	system ("cp ./test-legacy-3.0.1.sqlite copy-test-legacy-3.0.1.sqlite");
    if (ret != 0)
      {
	  do_unlink_all ();
	  fprintf (stderr, "cannot copy test-legacy-3.0.1.sqlite database\n");
	  return -1;
      }
    if (!do_load_legacy ("./copy-test-legacy-3.0.1.sqlite"))
      {
	  do_unlink_all ();
	  return -1;
      }
    path_origin = "./copy-test-legacy-3.0.1.sqlite";
    path_destination = "./out2.sqlite";
    cache_in = spatialite_alloc_connection ();
    cache_out = spatialite_alloc_connection ();
    if (!open_connections
	(path_origin, path_destination, cache_in, cache_out, &handle_in,
	 &handle_out))
      {
	  do_unlink_all ();
	  return -1;
      }
    if (!gaiaSpatialite2GPKG
	(handle_in, path_origin, handle_out, path_destination))
      {
	  do_unlink_all ();
	  return -1;
      }
    sqlite3_close (handle_in);
    sqlite3_close (handle_out);
    spatialite_cleanup_ex (cache_in);
    spatialite_cleanup_ex (cache_out);

    do_unlink_all ();
    return 0;
}