PostGIS  2.5.7dev-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 582 of file lwgeom.c.

583 {
584  LWDEBUGF(2, "lwgeom_same(%s, %s) called",
585  lwtype_name(lwgeom1->type),
586  lwtype_name(lwgeom2->type));
587 
588  if ( lwgeom1->type != lwgeom2->type )
589  {
590  LWDEBUG(3, " type differ");
591 
592  return LW_FALSE;
593  }
594 
595  if ( FLAGS_GET_ZM(lwgeom1->flags) != FLAGS_GET_ZM(lwgeom2->flags) )
596  {
597  LWDEBUG(3, " ZM flags differ");
598 
599  return LW_FALSE;
600  }
601 
602  /* Check boxes if both already computed */
603  if ( lwgeom1->bbox && lwgeom2->bbox )
604  {
605  /*lwnotice("bbox1:%p, bbox2:%p", lwgeom1->bbox, lwgeom2->bbox);*/
606  if ( ! gbox_same(lwgeom1->bbox, lwgeom2->bbox) )
607  {
608  LWDEBUG(3, " bounding boxes differ");
609 
610  return LW_FALSE;
611  }
612  }
613 
614  /* geoms have same type, invoke type-specific function */
615  switch (lwgeom1->type)
616  {
617  case POINTTYPE:
618  return lwpoint_same((LWPOINT *)lwgeom1,
619  (LWPOINT *)lwgeom2);
620  case LINETYPE:
621  return lwline_same((LWLINE *)lwgeom1,
622  (LWLINE *)lwgeom2);
623  case POLYGONTYPE:
624  return lwpoly_same((LWPOLY *)lwgeom1,
625  (LWPOLY *)lwgeom2);
626  case TRIANGLETYPE:
627  return lwtriangle_same((LWTRIANGLE *)lwgeom1,
628  (LWTRIANGLE *)lwgeom2);
629  case CIRCSTRINGTYPE:
630  return lwcircstring_same((LWCIRCSTRING *)lwgeom1,
631  (LWCIRCSTRING *)lwgeom2);
632  case MULTIPOINTTYPE:
633  case MULTILINETYPE:
634  case MULTIPOLYGONTYPE:
635  case MULTICURVETYPE:
636  case MULTISURFACETYPE:
637  case COMPOUNDTYPE:
638  case CURVEPOLYTYPE:
640  case TINTYPE:
641  case COLLECTIONTYPE:
642  return lwcollection_same((LWCOLLECTION *)lwgeom1,
643  (LWCOLLECTION *)lwgeom2);
644  default:
645  lwerror("lwgeom_same: unsupported geometry type: %s",
646  lwtype_name(lwgeom1->type));
647  return LW_FALSE;
648  }
649 
650 }
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
Definition: g_box.c:171
#define LW_FALSE
Definition: liblwgeom.h:77
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define TRIANGLETYPE
Definition: liblwgeom.h:98
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
Definition: lwcollection.c:278
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
Definition: lwtriangle.c:126
char lwline_same(const LWLINE *p1, const LWLINE *p2)
Definition: lwline.c:150
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
Definition: lwpoly.c:339
char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
Definition: lwcircstring.c:131
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:264
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint8_t type
Definition: liblwgeom.h:506
uint8_t type
Definition: liblwgeom.h:399
GBOX * bbox
Definition: liblwgeom.h:401
uint8_t flags
Definition: liblwgeom.h:400

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 LWPOINT::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().

Here is the call graph for this function:
Here is the caller graph for this function: