PostGIS  2.3.8dev-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 508 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_lwgeom_force_clockwise(), test_lwgeom_node(), and test_lwgeom_same().

509 {
510  LWDEBUGF(2, "lwgeom_same(%s, %s) called",
511  lwtype_name(lwgeom1->type),
512  lwtype_name(lwgeom2->type));
513 
514  if ( lwgeom1->type != lwgeom2->type )
515  {
516  LWDEBUG(3, " type differ");
517 
518  return LW_FALSE;
519  }
520 
521  if ( FLAGS_GET_ZM(lwgeom1->flags) != FLAGS_GET_ZM(lwgeom2->flags) )
522  {
523  LWDEBUG(3, " ZM flags differ");
524 
525  return LW_FALSE;
526  }
527 
528  /* Check boxes if both already computed */
529  if ( lwgeom1->bbox && lwgeom2->bbox )
530  {
531  /*lwnotice("bbox1:%p, bbox2:%p", lwgeom1->bbox, lwgeom2->bbox);*/
532  if ( ! gbox_same(lwgeom1->bbox, lwgeom2->bbox) )
533  {
534  LWDEBUG(3, " bounding boxes differ");
535 
536  return LW_FALSE;
537  }
538  }
539 
540  /* geoms have same type, invoke type-specific function */
541  switch (lwgeom1->type)
542  {
543  case POINTTYPE:
544  return lwpoint_same((LWPOINT *)lwgeom1,
545  (LWPOINT *)lwgeom2);
546  case LINETYPE:
547  return lwline_same((LWLINE *)lwgeom1,
548  (LWLINE *)lwgeom2);
549  case POLYGONTYPE:
550  return lwpoly_same((LWPOLY *)lwgeom1,
551  (LWPOLY *)lwgeom2);
552  case TRIANGLETYPE:
553  return lwtriangle_same((LWTRIANGLE *)lwgeom1,
554  (LWTRIANGLE *)lwgeom2);
555  case CIRCSTRINGTYPE:
556  return lwcircstring_same((LWCIRCSTRING *)lwgeom1,
557  (LWCIRCSTRING *)lwgeom2);
558  case MULTIPOINTTYPE:
559  case MULTILINETYPE:
560  case MULTIPOLYGONTYPE:
561  case MULTICURVETYPE:
562  case MULTISURFACETYPE:
563  case COMPOUNDTYPE:
564  case CURVEPOLYTYPE:
566  case TINTYPE:
567  case COLLECTIONTYPE:
568  return lwcollection_same((LWCOLLECTION *)lwgeom1,
569  (LWCOLLECTION *)lwgeom2);
570  default:
571  lwerror("lwgeom_same: unsupported geometry type: %s",
572  lwtype_name(lwgeom1->type));
573  return LW_FALSE;
574  }
575 
576 }
#define LINETYPE
Definition: liblwgeom.h:85
GBOX * bbox
Definition: liblwgeom.h:397
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:246
#define MULTICURVETYPE
Definition: liblwgeom.h:94
uint8_t type
Definition: liblwgeom.h:502
#define POLYGONTYPE
Definition: liblwgeom.h:86
uint8_t flags
Definition: liblwgeom.h:396
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:152
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
Definition: lwcollection.c:261
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
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:127
#define LW_FALSE
Definition: liblwgeom.h:76
#define TINTYPE
Definition: liblwgeom.h:98
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:88
#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:307
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:102
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: