PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 575 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, and LWGEOM::type.

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

576 {
577  LWDEBUGF(2, "lwgeom_same(%s, %s) called",
578  lwtype_name(lwgeom1->type),
579  lwtype_name(lwgeom2->type));
580 
581  if ( lwgeom1->type != lwgeom2->type )
582  {
583  LWDEBUG(3, " type differ");
584 
585  return LW_FALSE;
586  }
587 
588  if ( FLAGS_GET_ZM(lwgeom1->flags) != FLAGS_GET_ZM(lwgeom2->flags) )
589  {
590  LWDEBUG(3, " ZM flags differ");
591 
592  return LW_FALSE;
593  }
594 
595  /* Check boxes if both already computed */
596  if ( lwgeom1->bbox && lwgeom2->bbox )
597  {
598  /*lwnotice("bbox1:%p, bbox2:%p", lwgeom1->bbox, lwgeom2->bbox);*/
599  if ( ! gbox_same(lwgeom1->bbox, lwgeom2->bbox) )
600  {
601  LWDEBUG(3, " bounding boxes differ");
602 
603  return LW_FALSE;
604  }
605  }
606 
607  /* geoms have same type, invoke type-specific function */
608  switch (lwgeom1->type)
609  {
610  case POINTTYPE:
611  return lwpoint_same((LWPOINT *)lwgeom1,
612  (LWPOINT *)lwgeom2);
613  case LINETYPE:
614  return lwline_same((LWLINE *)lwgeom1,
615  (LWLINE *)lwgeom2);
616  case POLYGONTYPE:
617  return lwpoly_same((LWPOLY *)lwgeom1,
618  (LWPOLY *)lwgeom2);
619  case TRIANGLETYPE:
620  return lwtriangle_same((LWTRIANGLE *)lwgeom1,
621  (LWTRIANGLE *)lwgeom2);
622  case CIRCSTRINGTYPE:
623  return lwcircstring_same((LWCIRCSTRING *)lwgeom1,
624  (LWCIRCSTRING *)lwgeom2);
625  case MULTIPOINTTYPE:
626  case MULTILINETYPE:
627  case MULTIPOLYGONTYPE:
628  case MULTICURVETYPE:
629  case MULTISURFACETYPE:
630  case COMPOUNDTYPE:
631  case CURVEPOLYTYPE:
633  case TINTYPE:
634  case COLLECTIONTYPE:
635  return lwcollection_same((LWCOLLECTION *)lwgeom1,
636  (LWCOLLECTION *)lwgeom2);
637  default:
638  lwerror("lwgeom_same: unsupported geometry type: %s",
639  lwtype_name(lwgeom1->type));
640  return LW_FALSE;
641  }
642 
643 }
#define LINETYPE
Definition: liblwgeom.h:85
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
Definition: lwtriangle.c:126
GBOX * bbox
Definition: liblwgeom.h:397
#define MULTICURVETYPE
Definition: liblwgeom.h:94
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:264
#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
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
Definition: lwcollection.c:264
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define LW_FALSE
Definition: liblwgeom.h:76
#define TINTYPE
Definition: liblwgeom.h:98
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
char lwline_same(const LWLINE *p1, const LWLINE *p2)
Definition: lwline.c:150
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
Definition: lwcircstring.c:131
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:171
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
Definition: lwpoly.c:337

Here is the call graph for this function:

Here is the caller graph for this function: