PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_same()

char lwgeom_same ( const LWGEOM lwgeom1,
const LWGEOM lwgeom2 
)

geom1 same as geom2 iff

  • have same type
    • have same # objects
  • have same bvol
  • each object in geom1 has a corresponding object in geom2 (see above)
    Parameters
    lwgeom1
    lwgeom2

Definition at line 544 of file lwgeom.c.

References LWGEOM::bbox, CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LWGEOM::flags, FLAGS_GET_ZM, gbox_same(), LINETYPE, LW_FALSE, lwcircstring_same(), lwcollection_same(), LWDEBUG, LWDEBUGF, lwerror(), lwline_same(), lwpoint_same(), lwpoly_same(), lwtriangle_same(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, LWGEOM::type, and LWCOLLECTION::type.

Referenced by assert_all_results_found(), lwcollection_same(), LWGEOM_same(), test_lwcurve_linearize(), test_lwgeom_force_clockwise(), test_lwgeom_node(), and test_lwgeom_same().

545 {
546  LWDEBUGF(2, "lwgeom_same(%s, %s) called",
547  lwtype_name(lwgeom1->type),
548  lwtype_name(lwgeom2->type));
549 
550  if ( lwgeom1->type != lwgeom2->type )
551  {
552  LWDEBUG(3, " type differ");
553 
554  return LW_FALSE;
555  }
556 
557  if ( FLAGS_GET_ZM(lwgeom1->flags) != FLAGS_GET_ZM(lwgeom2->flags) )
558  {
559  LWDEBUG(3, " ZM flags differ");
560 
561  return LW_FALSE;
562  }
563 
564  /* Check boxes if both already computed */
565  if ( lwgeom1->bbox && lwgeom2->bbox )
566  {
567  /*lwnotice("bbox1:%p, bbox2:%p", lwgeom1->bbox, lwgeom2->bbox);*/
568  if ( ! gbox_same(lwgeom1->bbox, lwgeom2->bbox) )
569  {
570  LWDEBUG(3, " bounding boxes differ");
571 
572  return LW_FALSE;
573  }
574  }
575 
576  /* geoms have same type, invoke type-specific function */
577  switch (lwgeom1->type)
578  {
579  case POINTTYPE:
580  return lwpoint_same((LWPOINT *)lwgeom1,
581  (LWPOINT *)lwgeom2);
582  case LINETYPE:
583  return lwline_same((LWLINE *)lwgeom1,
584  (LWLINE *)lwgeom2);
585  case POLYGONTYPE:
586  return lwpoly_same((LWPOLY *)lwgeom1,
587  (LWPOLY *)lwgeom2);
588  case TRIANGLETYPE:
589  return lwtriangle_same((LWTRIANGLE *)lwgeom1,
590  (LWTRIANGLE *)lwgeom2);
591  case CIRCSTRINGTYPE:
592  return lwcircstring_same((LWCIRCSTRING *)lwgeom1,
593  (LWCIRCSTRING *)lwgeom2);
594  case MULTIPOINTTYPE:
595  case MULTILINETYPE:
596  case MULTIPOLYGONTYPE:
597  case MULTICURVETYPE:
598  case MULTISURFACETYPE:
599  case COMPOUNDTYPE:
600  case CURVEPOLYTYPE:
602  case TINTYPE:
603  case COLLECTIONTYPE:
604  return lwcollection_same((LWCOLLECTION *)lwgeom1,
605  (LWCOLLECTION *)lwgeom2);
606  default:
607  lwerror("lwgeom_same: unsupported geometry type: %s",
608  lwtype_name(lwgeom1->type));
609  return LW_FALSE;
610  }
611 
612 }
#define LINETYPE
Definition: liblwgeom.h:86
GBOX * bbox
Definition: liblwgeom.h:398
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:264
#define MULTICURVETYPE
Definition: liblwgeom.h:95
uint8_t type
Definition: liblwgeom.h:503
#define POLYGONTYPE
Definition: liblwgeom.h:87
uint8_t flags
Definition: liblwgeom.h:397
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
Definition: lwcollection.c:262
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
Definition: lwcircstring.c:138
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
Definition: lwtriangle.c:133
#define LW_FALSE
Definition: liblwgeom.h:77
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
Definition: g_box.c:176
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
Definition: lwpoly.c:347
char lwline_same(const LWLINE *p1, const LWLINE *p2)
Definition: lwline.c:156
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: