Skip to content

Commit

Permalink
Merge pull request MobilityDB#370 from estebanzimanyi/alpha3
Browse files Browse the repository at this point in the history
Improve error handling
  • Loading branch information
mschoema authored Aug 28, 2023
2 parents aa94b65 + 169e975 commit 874abb6
Show file tree
Hide file tree
Showing 133 changed files with 8,076 additions and 4,961 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ These projects push the boundaries of MobilityDB and connect it with the Postgre

* [MobilityDB-AWS](https://github.com/MobilityDB/MobilityDB-AWS): MobilityDB on Amazon Web Services
* [MobilityDB-Azure](https://github.com/MobilityDB/MobilityDB-Azure): MobilityDB on Azure
* [MobilityDB-GCP](https://github.com/MobilityDB/MobilityDB-GCP): MobilityDB on Google Cloud Platform

### Visualization

Expand Down
1 change: 0 additions & 1 deletion meos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ set(PROJECT_OBJECTS "$<TARGET_OBJECTS:general>")
set(PROJECT_OBJECTS ${PROJECT_OBJECTS} "$<TARGET_OBJECTS:point>")
if(MEOS)
set(PROJECT_OBJECTS ${PROJECT_OBJECTS} "$<TARGET_OBJECTS:general_meos>")
set(PROJECT_OBJECTS ${PROJECT_OBJECTS} "$<TARGET_OBJECTS:point_meos>")
endif()
if(NPOINT)
message(STATUS "Including network points")
Expand Down
4 changes: 2 additions & 2 deletions meos/examples/01_meos_hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
* @endcode
*/

#include <stdio.h> /* for printf */
#include <stdio.h> /* for printf */
#include <stdlib.h> /* for free */
/* Include the MEOS API header */
#include <meos.h>

int main()
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Input temporal points in WKT format */
char *inst_wkt = "POINT(1 1)@2000-01-01";
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/02_meos_read_ais.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize('UTC');
meos_initialize('UTC', NULL);

/* You may substitute the full file path in the first argument of fopen */
FILE *file = fopen("aisinput.csv", "r");
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/03_meos_assemble_ais.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize("UTC");
meos_initialize("UTC", NULL);

/* Get start time */
clock_t t;
Expand Down
4 changes: 2 additions & 2 deletions meos/examples/03_meos_assemble_berlinmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Get start time */
clock_t t;
Expand Down Expand Up @@ -151,7 +151,7 @@ int main(void)
/* Transform the string representing the timestamp into a timestamp value */
rec.t = pg_timestamp_in(timestamp_buffer, -1);
/* Transform the string representing the trip into a temporal value */
TInstant *inst = tgeompointinst_make(rec.point, rec.t);
TInstant *inst = tpointinst_make(rec.point, rec.t);

if (read == 6)
{
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/04_meos_store_ais.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ main(int argc, char **argv)
***************************************************************************/

/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* You may substitute the full file path in the first argument of fopen */
FILE *file = fopen("aisinput.csv", "r");
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/04_meos_stream_ais.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ main(int argc, char **argv)
***************************************************************************/

/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* You may substitute the full file path in the first argument of fopen */
FILE *file = fopen("aisinput.csv", "r");
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/04_meos_stream_file_ais.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ main(int argc, char **argv)
***************************************************************************/

/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* You may substitute the full file path in the first argument of fopen */
FILE *fileIn = fopen("aisinput.csv", "r");
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/05_meos_disassemble_berlinmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int main(void)
int curr_inst[MAX_NO_TRIPS];

/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* You may substitute the full file path in the first argument of fopen */
FILE *file = fopen("trips.csv", "r");
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/06_meos_clip_berlinmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ matrix_print(double distance[NO_VEHICLES + 1][NO_COMMUNES + 3],
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Read communes file */
read_communes();
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/07_meos_tile_berlinmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int main(void)
int i, j, k;

/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Compute the spatial tiles for trips */
int no_rows, no_cols, *no_cells;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/08_meos_simplify_berlinmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main(void)
int i = 0, j;

/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Substitute the full file path in the first argument of fopen */
FILE *file = fopen("trips.csv", "r");
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/09_meos_aggregate_berlinmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(void)
char trip_buffer[MAX_LENGTH_TRIP];

/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* You may substitute the full file path in the first argument of fopen */
FILE *file = fopen("trips.csv", "r");
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_assemble_ais_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize("UTC");
meos_initialize("UTC", NULL);

/* Get start time */
clock_t t;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_assemble_tfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Get start time */
clock_t tm;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_assemble_tpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Get start time */
clock_t time;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_assemble_ttext.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Get start time */
clock_t tm;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_expand_ais.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize("UTC");
meos_initialize("UTC", NULL);

/* Get start time */
clock_t t;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_expand_floatspanset.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize("");
meos_initialize("", NULL);

/* Get start time */
clock_t t;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_expand_intspan.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize("");
meos_initialize("", NULL);

/* Get start time */
clock_t t;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_expand_textset.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef struct
int main(void)
{
/* Initialize MEOS */
meos_initialize("");
meos_initialize("", NULL);

/* Get start time */
clock_t t;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_expand_tfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Get start time */
clock_t tm;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_expand_tpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Get start time */
clock_t time;
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_expand_ttext.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
int main(void)
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Get start time */
clock_t tm;
Expand Down
10 changes: 5 additions & 5 deletions meos/examples/meos_geos_clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
static void
geos_message_handler(const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vprintf (fmt, ap);
va_end(ap);
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}

int main()
{
/* Initialize MEOS */
meos_initialize(NULL);
meos_initialize(NULL, NULL);

/* Send notice and error messages to our stdout handler */
initGEOS(geos_message_handler, geos_message_handler);
Expand Down
8 changes: 4 additions & 4 deletions meos/examples/meos_gserialized_inout.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
int main()
{
/* Initialize MEOS */
meos_initialize();
meos_initialize(NULL, NULL);

/* Input geometries in WKT format */
char *point_wkt = "POINT(1 1)";
Expand Down Expand Up @@ -104,9 +104,9 @@ int main()
char *polygon_hexwkb = gserialized_as_hexwkb(polygon, "XDR");

/* Revert generated GeoJSON strings into geometries */
GSERIALIZED *point3 = gserialized_from_hexewkb(point_hexwkb);
GSERIALIZED *linestring3 = gserialized_from_hexewkb(linestring_hexwkb);
GSERIALIZED *polygon3 = gserialized_from_hexewkb(polygon_hexwkb);
GSERIALIZED *point3 = geometry_from_hexewkb(point_hexwkb);
GSERIALIZED *linestring3 = geometry_from_hexewkb(linestring_hexwkb);
GSERIALIZED *polygon3 = geometry_from_hexewkb(polygon_hexwkb);

/* Ensure that the reverted types are equal to the original ones */
if (! pgis_gserialized_same(point, point3))
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/meos_tpointseq_make.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main()
TimestampTz times[MAX_COUNT];

/* Initialize MEOS */
meos_initialize();
meos_initialize(NULL, NULL);

for (int i = 0; i < 4; i++)
times[i] = pg_timestamptz_in(times_str[i], -1);
Expand Down
77 changes: 77 additions & 0 deletions meos/include/general/error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*****************************************************************************
*
* This MobilityDB code is provided under The PostgreSQL License.
* Copyright (c) 2016-2023, Université libre de Bruxelles and MobilityDB
* contributors
*
* MobilityDB includes portions of PostGIS version 3 source code released
* under the GNU General Public License (GPLv2 or later).
* Copyright (c) 2001-2023, PostGIS contributors
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without a written
* agreement is hereby granted, provided that the above copyright notice and
* this paragraph and the following two paragraphs appear in all copies.
*
* IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
* EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
* AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*****************************************************************************/

/**
* @file
* @brief Error handling.
*/

/* C */
#include <errno.h>
/* MEOS */
#include <meos.h>

typedef enum
{
MEOS_SUCCESS = 0, // Successful operation

MEOS_ERR_INTERNAL_ERROR = 1, // Unspecified internal error
MEOS_ERR_INTERNAL_TYPE_ERROR = 2, // Internal type error
MEOS_ERR_VALUE_OUT_OF_RANGE = 3, // Internal out of range error
MEOS_ERR_DIVISION_BY_ZERO = 4, // Internal division by zero error
MEOS_ERR_MEMORY_ALLOC_ERROR = 5, // Internal malloc error
MEOS_ERR_AGGREGATION_ERROR = 6, // Internal aggregation error
MEOS_ERR_DIRECTORY_ERROR = 7, // Internal directory error
MEOS_ERR_FILE_ERROR = 8, // Internal file error

MEOS_ERR_INVALID_ARG = 10, // Invalid argument
MEOS_ERR_INVALID_ARG_TYPE = 11, // Invalid argument type
MEOS_ERR_INVALID_ARG_VALUE = 12, // Invalid argument value

MEOS_ERR_MFJSON_INPUT = 20, // MFJSON input error
MEOS_ERR_MFJSON_OUTPUT = 21, // MFJSON output error
MEOS_ERR_TEXT_INPUT = 22, // Text input error
MEOS_ERR_TEXT_OUTPUT = 23, // Text output error
MEOS_ERR_WKB_INPUT = 24, // WKB input error
MEOS_ERR_WKB_OUTPUT = 25, // WKB output error
MEOS_ERR_GEOJSON_INPUT = 26, // GEOJSON input error
MEOS_ERR_GEOJSON_OUTPUT = 27, // GEOJSON output error

} errorCode;

extern void meos_error(int errlevel, int errcode, char *format, ...);

/* Set or read error level */

extern int mobdb_errno(void);
extern int mobdb_errno_set(int err);
extern int mobdb_errno_restore(int err);
extern int mobdb_errno_reset(void);

/*****************************************************************************/
Loading

0 comments on commit 874abb6

Please sign in to comment.