Skip to content

Commit

Permalink
Improve naming for npoint functions and files (MobilityDB#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanzimanyi authored Oct 8, 2024
1 parent 2aaeaa9 commit d57fa08
Show file tree
Hide file tree
Showing 44 changed files with 369 additions and 378 deletions.
2 changes: 1 addition & 1 deletion meos/examples/03_berlinmod_assemble.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int main(void)
/* Transform the string representing the date into a date value */
rec.day = pg_date_in(date_buffer);
/* Transform the string representing the trip into a temporal value */
rec.point = pgis_geometry_in(point_buffer, -1);
rec.point = geom_in(point_buffer, -1);
/* 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 */
Expand Down
4 changes: 2 additions & 2 deletions meos/examples/06_berlinmod_clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int read_communes(void)
&communes[no_records].id, communes[no_records].name,
&communes[no_records].population, geo_buffer);
/* Transform the string representing the geometry into a geometry value */
communes[no_records++].geom = pgis_geometry_in(geo_buffer, -1);
communes[no_records++].geom = geom_in(geo_buffer, -1);

if (read != 4 && !feof(file))
{
Expand Down Expand Up @@ -173,7 +173,7 @@ int read_brussels_region(void)
int read = fscanf(file, "%100[^,],%100000[^\n]\n", brussels_region.name,
geo_buffer);
/* Transform the string representing the geometry into a geometry value */
brussels_region.geom = pgis_geometry_in(geo_buffer, -1);
brussels_region.geom = geom_in(geo_buffer, -1);

if (read != 2 && !feof(file))
{
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/07_berlinmod_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int main(void)
int no_speed_tiles, no_trip_tiles;
STBox *trip_extent =
stbox_in("SRID=3857;STBOX X((473212.810151,6578740.528027),(499152.544688,6607165.513683))");
GSERIALIZED *sorigin = pgis_geometry_in("Point(0 0)", -1);
GSERIALIZED *sorigin = geom_in("Point(0 0)", -1);
STBox *trip_tiles = stbox_space_tiles(trip_extent, 5e3, 5e3, 0, sorigin,
true, &no_trip_tiles);
/* Compute the (value and time) tiles for speed of trips */
Expand Down
18 changes: 9 additions & 9 deletions meos/examples/geo_inout.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ int main()
char *polygon_wkt = "Polygon((1 1,1 2,2 2,2 1,1 1))";

/* Read WKT into geometries */
GSERIALIZED *point = pgis_geometry_in(point_wkt, -1);
GSERIALIZED *linestring = pgis_geometry_in(linestring_wkt, -1);
GSERIALIZED *polygon = pgis_geometry_in(polygon_wkt, -1);
GSERIALIZED *point = geom_in(point_wkt, -1);
GSERIALIZED *linestring = geom_in(linestring_wkt, -1);
GSERIALIZED *polygon = geom_in(polygon_wkt, -1);

/* Convert geometries to WKT */
char *point_text = geo_as_text(point, 6);
char *linestring_text = geo_as_text(linestring, 6);
char *polygon_text = geo_as_text(polygon, 6);

/* Revert generated WKT strings into geometries */
GSERIALIZED *point1 = pgis_geometry_in(point_text, -1);
GSERIALIZED *linestring1 = pgis_geometry_in(linestring_text, -1);
GSERIALIZED *polygon1 = pgis_geometry_in(polygon_text, -1);
GSERIALIZED *point1 = geom_in(point_text, -1);
GSERIALIZED *linestring1 = geom_in(linestring_text, -1);
GSERIALIZED *polygon1 = geom_in(polygon_text, -1);

/* Ensure that the reverted types are equal to the original ones */
if (! geo_same(point, point1))
Expand Down Expand Up @@ -105,9 +105,9 @@ int main()
char *polygon_hexwkb = geo_as_hexewkb(polygon, "XDR");

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

/* Ensure that the reverted types are equal to the original ones */
if (! geo_same(point, point3))
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/stbox_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(void)
/* Initialize values for tiling */
STBox *box = stbox_in("STBOX XT(((1,1),(10,10)),[2020-03-01, 2020-03-10])");
Interval *interv = pg_interval_in("5 days", -1);
GSERIALIZED *sorigin = pgis_geometry_in("Point(0 0 0)", -1);
GSERIALIZED *sorigin = geom_in("Point(0 0 0)", -1);
TimestampTz torigin = pg_timestamptz_in("2020-03-01", -1);

/* Perform tiling */
Expand Down
2 changes: 1 addition & 1 deletion meos/examples/tpoint_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(void)

Temporal *tpoint = tgeompoint_in("[Point(1 1)@2020-03-01, Point(10 10)@2020-03-10]");
Interval *interv = pg_interval_in("2 days", -1);
GSERIALIZED *sorigin = pgis_geometry_in("Point(0 0 0)", -1);
GSERIALIZED *sorigin = geom_in("Point(0 0 0)", -1);
TimestampTz torigin = pg_timestamptz_in("2020-03-01", -1);

bool spacesplit = true; /* Set this parameter to enable/disable space split */
Expand Down
4 changes: 3 additions & 1 deletion meos/include/general/type_round.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
#include <postgres.h>
/* MEOS */
#include <meos.h>
#include "npoint/tnpoint_static.h"
#if NPOINT
#include "npoint/npoint.h"
#endif /* NPOINT */

/*****************************************************************************/

Expand Down
11 changes: 5 additions & 6 deletions meos/include/meos.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,15 @@ extern char *geo_as_ewkt(const GSERIALIZED *gs, int precision);
extern char *geo_as_geojson(const GSERIALIZED *gs, int option, int precision, const char *srs);
extern char *geo_as_hexewkb(const GSERIALIZED *gs, const char *endian);
extern char *geo_as_text(const GSERIALIZED *gs, int precision);
extern GSERIALIZED *geo_from_text(char *wkt, int srid);
extern GSERIALIZED *geo_from_ewkb(const uint8_t *wkb, size_t wkb_size, int32 srid);
extern GSERIALIZED *geo_from_geojson(const char *geojson);
extern char *geo_out(const GSERIALIZED *gs);
extern bool geo_same(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern GSERIALIZED *geography_from_hexewkb(const char *wkt);
extern GSERIALIZED *geography_from_text(char *wkt, int srid);
extern GSERIALIZED *geometry_from_hexewkb(const char *wkt);
extern GSERIALIZED *geometry_from_text(char *wkt, int srid);
extern GSERIALIZED *pgis_geography_in(char *str, int32 typmod);
extern GSERIALIZED *pgis_geometry_in(char *str, int32 typmod);
extern GSERIALIZED *geog_from_hexewkb(const char *wkt);
extern GSERIALIZED *geog_in(char *str, int32 typmod);
extern GSERIALIZED *geom_from_hexewkb(const char *wkt);
extern GSERIALIZED *geom_in(char *str, int32 typmod);

/*===========================================================================*
* Functions for set and span types
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions meos/include/npoint/tnpoint_distance.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
#include <postgres.h>
/* MEOS */
#include "general/temporal.h"
#include "npoint/tnpoint_static.h"
#include "npoint/npoint.h"

/*****************************************************************************/

extern Datum npoint_distance(Datum np1, Datum np2);
extern Datum datum_npoint_distance(Datum np1, Datum np2);
extern Temporal *distance_tnpoint_point(const Temporal *temp,
const GSERIALIZED *gs);
extern Temporal *distance_tnpoint_npoint(const Temporal *temp,
Expand Down
2 changes: 1 addition & 1 deletion meos/include/npoint/tnpoint_spatialfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <postgres.h>
/* MEOS */
#include "general/temporal.h"
#include "npoint/tnpoint_static.h"
#include "npoint/npoint.h"

/*****************************************************************************/

Expand Down
2 changes: 1 addition & 1 deletion meos/include/npoint/tnpoint_tempspatialrels.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <postgres.h>
/* MEOS */
#include "general/temporal.h"
#include "npoint/tnpoint_static.h"
#include "npoint/npoint.h"

/*****************************************************************************/

Expand Down
74 changes: 37 additions & 37 deletions meos/include/point/pgis_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

/* Functions borrowed from lwgeom_pg.c */

extern GSERIALIZED* geometry_serialize(LWGEOM *lwgeom);
extern GSERIALIZED* geography_serialize(LWGEOM *lwgeom);
extern GSERIALIZED* geom_serialize(LWGEOM *lwgeom);
extern GSERIALIZED* geog_serialize(LWGEOM *lwgeom);

/* Functions adapted from lwgeom_box.c */

Expand All @@ -62,64 +62,64 @@ extern LWGEOM *box3d_to_lwgeom(BOX3D *box);

/* Functions adapted from lwgeom_functions_basic.c */

/* The implementation of this function changed in PostGIS version 3.2 */
extern double geo_perimeter(const GSERIALIZED *gs);
extern GSERIALIZED *geometry_boundary(const GSERIALIZED *gs);
extern GSERIALIZED *geo_shortestline2d(const GSERIALIZED *gs1,
extern double geom_perimeter(const GSERIALIZED *gs);
extern GSERIALIZED *geom_boundary(const GSERIALIZED *gs);
extern GSERIALIZED *geom_shortestline2d(const GSERIALIZED *gs1,
const GSERIALIZED *s2);
extern GSERIALIZED *geometry_shortestline3d(const GSERIALIZED *gs1,
extern GSERIALIZED *geom_shortestline3d(const GSERIALIZED *gs1,
const GSERIALIZED *s2);
extern double geo_distance(const GSERIALIZED *gs1,
const GSERIALIZED *gs2);
extern double geometry_3Ddistance(const GSERIALIZED *gs1,
const GSERIALIZED *gs2);
extern bool geometry_3Dintersects(const GSERIALIZED *gs1,
const GSERIALIZED *gs2);
extern bool geometry_dwithin2d(const GSERIALIZED *gs1,
const GSERIALIZED *gs2, double tolerance);
extern bool geometry_dwithin3d(const GSERIALIZED *gs1,
const GSERIALIZED *gs2, double tolerance);
extern bool geo_relate_pattern(const GSERIALIZED *gs1,
const GSERIALIZED *gs2, char *patt);
extern double geom_distance2d(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern double geom_distance3d(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern bool geom_intersects3d(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern bool geom_dwithin2d(const GSERIALIZED *gs1, const GSERIALIZED *gs2,
double tolerance);
extern bool geom_dwithin3d(const GSERIALIZED *gs1, const GSERIALIZED *gs2,
double tolerance);
extern bool geom_relate_pattern(const GSERIALIZED *gs1, const GSERIALIZED *gs2,
char *patt);
extern GSERIALIZED *geo_reverse(const GSERIALIZED *geom);
extern bool gserialized_azimuth(GSERIALIZED *gs1, GSERIALIZED *gs2,
extern bool geom_azimuth(const GSERIALIZED *gs1, const GSERIALIZED *gs2,
double *result);

/* Functions adapted from lwgeom_geos.c */

extern GEOSGeometry *POSTGIS2GEOS(const GSERIALIZED *pglwgeom);
extern GSERIALIZED *GEOS2POSTGIS(GEOSGeom geom, char want3d);

extern bool geometry_spatialrel(const GSERIALIZED *gs1,
const GSERIALIZED *gs2, spatialRel rel);
extern GSERIALIZED *geometry_intersection(const GSERIALIZED *gs1,
extern bool geom_spatialrel(const GSERIALIZED *gs1, const GSERIALIZED *gs2,
spatialRel rel);
extern bool geom_intersects2d(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern bool geom_contains(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern bool geom_covers(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern bool geom_touches(const GSERIALIZED *gs1, const GSERIALIZED *gs2);
extern GSERIALIZED *geom_intersection2d(const GSERIALIZED *gs1,
const GSERIALIZED *gs2);
extern GSERIALIZED *geometry_array_union(GSERIALIZED **gsarr, int nelems);
extern GSERIALIZED *geometry_buffer(const GSERIALIZED *gs, double size,
extern GSERIALIZED *geom_array_union(GSERIALIZED **gsarr, int nelems);
extern GSERIALIZED *geom_buffer(const GSERIALIZED *gs, double size,
char *params);
extern GSERIALIZED *geometry_convex_hull(const GSERIALIZED *gs);
extern GSERIALIZED *geom_convex_hull(const GSERIALIZED *gs);

/* Functions adapted from geography_measurement.c */

extern double pgis_geography_area(const GSERIALIZED *g, bool use_spheroid);
extern double pgis_geography_perimeter(const GSERIALIZED *g, bool use_spheroid);
extern double pgis_geography_length(const GSERIALIZED *g, bool use_spheroid);
extern bool pgis_geography_dwithin(const GSERIALIZED *g1, GSERIALIZED *g2,
extern double geog_area(const GSERIALIZED *gs, bool use_spheroid);
extern double geog_perimeter(const GSERIALIZED *gs, bool use_spheroid);
extern double geog_length(const GSERIALIZED *gs, bool use_spheroid);
extern bool geog_dwithin(const GSERIALIZED *gs1, const GSERIALIZED *gs2,
double tolerance, bool use_spheroid);
extern double pgis_geography_distance(const GSERIALIZED *g1,
const GSERIALIZED *g2);
extern bool geog_intersects(const GSERIALIZED *gs1, const GSERIALIZED *gs2,
bool use_spheroid);
extern double geog_distance(const GSERIALIZED *g1, const GSERIALIZED *g2);

/* Functions adapted from geography_inout.c */

extern GSERIALIZED *gserialized_geog_from_geom(GSERIALIZED *geom);
extern GSERIALIZED *gserialized_geom_from_geog(GSERIALIZED *geog);
extern GSERIALIZED *geog_from_geom(GSERIALIZED *geom);
extern GSERIALIZED *geom_from_geog(GSERIALIZED *geog);

/* Functions adapted from lwgeom_functions_analytic.c */

extern GSERIALIZED *linestring_line_interpolate_point(GSERIALIZED *gser,
extern GSERIALIZED *line_interpolate_point(GSERIALIZED *gs,
double distance_fraction, char repeat);
extern GSERIALIZED *linestring_substring(GSERIALIZED *geom, double from,
double to);
extern GSERIALIZED *line_substring(GSERIALIZED *gs, double from, double to);

/* Functions adapted from lwgeom_lrs.c */

Expand Down
12 changes: 6 additions & 6 deletions meos/include/point/tpoint_spatialfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ extern Datum datum_transform(Datum value, Datum srid);

extern datum_func2 distance_fn(int16 flags);
extern datum_func2 pt_distance_fn(int16 flags);
extern Datum geom_distance2d(Datum geom1, Datum geom2);
extern Datum geom_distance3d(Datum geom1, Datum geom2);
extern Datum geog_distance(Datum geog1, Datum geog2);
extern Datum pt_distance2d(Datum geom1, Datum geom2);
extern Datum pt_distance3d(Datum geom1, Datum geom2);
extern Datum geom_intersection2d(Datum geom1, Datum geom2);
extern Datum datum_geom_distance2d(Datum geom1, Datum geom2);
extern Datum datum_geom_distance3d(Datum geom1, Datum geom2);
extern Datum datum_geog_distance(Datum geog1, Datum geog2);
extern Datum datum_pt_distance2d(Datum geom1, Datum geom2);
extern Datum datum_pt_distance3d(Datum geom1, Datum geom2);
extern Datum datum_geom_intersection2d(Datum geom1, Datum geom2);

/* Parameter tests */

Expand Down
24 changes: 12 additions & 12 deletions meos/include/point/tpoint_spatialrels.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@

/*****************************************************************************/

extern Datum geom_contains(Datum geom1, Datum geom2);
extern Datum geom_covers(Datum geom1, Datum geom2);
extern Datum geom_disjoint2d(Datum geom1, Datum geom2);
extern Datum geom_disjoint3d(Datum geom1, Datum geom2);
extern Datum geog_disjoint(Datum geog1, Datum geog2);
extern Datum geom_intersects2d(Datum geom1, Datum geom2);
extern Datum geom_intersects3d(Datum geom1, Datum geom2);
extern Datum geog_intersects(Datum geog1, Datum geog2);
extern Datum geom_touches(Datum geom1, Datum geom2);
extern Datum geom_dwithin2d(Datum geom1, Datum geom2, Datum dist);
extern Datum geom_dwithin3d(Datum geom1, Datum geom2, Datum dist);
extern Datum geog_dwithin(Datum geog1, Datum geog2, Datum dist);
extern Datum datum_geom_contains(Datum geom1, Datum geom2);
extern Datum datum_geom_covers(Datum geom1, Datum geom2);
extern Datum datum_geom_disjoint2d(Datum geom1, Datum geom2);
extern Datum datum_geom_disjoint3d(Datum geom1, Datum geom2);
extern Datum datum_geog_disjoint(Datum geog1, Datum geog2);
extern Datum datum_geom_intersects2d(Datum geom1, Datum geom2);
extern Datum datum_geom_intersects3d(Datum geom1, Datum geom2);
extern Datum datum_geog_intersects(Datum geog1, Datum geog2);
extern Datum datum_geom_touches(Datum geom1, Datum geom2);
extern Datum datum_geom_dwithin2d(Datum geom1, Datum geom2, Datum dist);
extern Datum datum_geom_dwithin3d(Datum geom1, Datum geom2, Datum dist);
extern Datum datum_geog_dwithin(Datum geog1, Datum geog2, Datum dist);

extern datum_func2 get_disjoint_fn_gs(int16 flags1, uint8_t flags2);
extern datum_func2 get_intersects_fn_gs(int16 flags1, uint8_t flags2);
Expand Down
2 changes: 1 addition & 1 deletion meos/src/general/temporal_compops.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "general/type_util.h"
#include "point/tpoint_spatialfuncs.h"
#if NPOINT
#include "npoint/tnpoint_static.h"
#include "npoint/npoint.h"
#endif

/*****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion meos/src/general/temporal_modif.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
#include "general/type_util.h"
#include "point/tpoint_parser.h"
#include "point/tpoint_spatialfuncs.h"
#include "npoint/tnpoint_distance.h"
#if NPOINT
#include "npoint/tnpoint_distance.h"
#include "npoint/tnpoint_spatialfuncs.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion meos/src/general/tsequenceset.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ datum_distance(Datum value1, Datum value2, meosType type, int16 flags)
}
#if NPOINT
else if (type == T_NPOINT)
return DatumGetFloat8(npoint_distance(value1, value2));
return DatumGetFloat8(datum_npoint_distance(value1, value2));
#endif
meos_error(ERROR, MEOS_ERR_INTERNAL_TYPE_ERROR,
"Unknown types for distance between values: %s", meostype_name(type));
Expand Down
2 changes: 1 addition & 1 deletion meos/src/general/type_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "point/stbox.h"
#include "point/tpoint_spatialfuncs.h"
#if NPOINT
#include "npoint/tnpoint_static.h"
#include "npoint/npoint.h"
#endif /* NPOINT */

/*****************************************************************************/
Expand Down
6 changes: 3 additions & 3 deletions meos/src/general/type_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "general/span.h"
#include "point/tpoint_spatialfuncs.h"
#if NPOINT
#include "npoint/tnpoint_static.h"
#include "npoint/npoint.h"
#include "npoint/tnpoint_parser.h"
#endif
#if POSE
Expand Down Expand Up @@ -893,15 +893,15 @@ basetype_in(const char *str, meosType type,
}
case T_GEOMETRY:
{
GSERIALIZED *gs = pgis_geometry_in((char *) str, -1);
GSERIALIZED *gs = geom_in((char *) str, -1);
if (! gs)
return false;
*result = PointerGetDatum(gs);
return true;
}
case T_GEOGRAPHY:
{
GSERIALIZED *gs = pgis_geography_in((char *) str, -1);
GSERIALIZED *gs = geog_in((char *) str, -1);
if (! gs)
return false;
*result = PointerGetDatum(gs);
Expand Down
Loading

0 comments on commit d57fa08

Please sign in to comment.