PostGIS  2.2.7dev-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 495 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 assert_all_results_found(), lwcollection_same(), LWGEOM_same(), test_lwgeom_force_clockwise(), test_lwgeom_node(), and test_lwgeom_same().

496 {
497  LWDEBUGF(2, "lwgeom_same(%s, %s) called",
498  lwtype_name(lwgeom1->type),
499  lwtype_name(lwgeom2->type));
500 
501  if ( lwgeom1->type != lwgeom2->type )
502  {
503  LWDEBUG(3, " type differ");
504 
505  return LW_FALSE;
506  }
507 
508  if ( FLAGS_GET_ZM(lwgeom1->flags) != FLAGS_GET_ZM(lwgeom2->flags) )
509  {
510  LWDEBUG(3, " ZM flags differ");
511 
512  return LW_FALSE;
513  }
514 
515  /* Check boxes if both already computed */
516  if ( lwgeom1->bbox && lwgeom2->bbox )
517  {
518  /*lwnotice("bbox1:%p, bbox2:%p", lwgeom1->bbox, lwgeom2->bbox);*/
519  if ( ! gbox_same(lwgeom1->bbox, lwgeom2->bbox) )
520  {
521  LWDEBUG(3, " bounding boxes differ");
522 
523  return LW_FALSE;
524  }
525  }
526 
527  /* geoms have same type, invoke type-specific function */
528  switch (lwgeom1->type)
529  {
530  case POINTTYPE:
531  return lwpoint_same((LWPOINT *)lwgeom1,
532  (LWPOINT *)lwgeom2);
533  case LINETYPE:
534  return lwline_same((LWLINE *)lwgeom1,
535  (LWLINE *)lwgeom2);
536  case POLYGONTYPE:
537  return lwpoly_same((LWPOLY *)lwgeom1,
538  (LWPOLY *)lwgeom2);
539  case TRIANGLETYPE:
540  return lwtriangle_same((LWTRIANGLE *)lwgeom1,
541  (LWTRIANGLE *)lwgeom2);
542  case CIRCSTRINGTYPE:
543  return lwcircstring_same((LWCIRCSTRING *)lwgeom1,
544  (LWCIRCSTRING *)lwgeom2);
545  case MULTIPOINTTYPE:
546  case MULTILINETYPE:
547  case MULTIPOLYGONTYPE:
548  case MULTICURVETYPE:
549  case MULTISURFACETYPE:
550  case COMPOUNDTYPE:
551  case CURVEPOLYTYPE:
553  case TINTYPE:
554  case COLLECTIONTYPE:
555  return lwcollection_same((LWCOLLECTION *)lwgeom1,
556  (LWCOLLECTION *)lwgeom2);
557  default:
558  lwerror("lwgeom_same: unsupported geometry type: %s",
559  lwtype_name(lwgeom1->type));
560  return LW_FALSE;
561  }
562 
563 }
#define LINETYPE
Definition: liblwgeom.h:71
GBOX * bbox
Definition: liblwgeom.h:382
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:233
#define MULTICURVETYPE
Definition: liblwgeom.h:80
#define POLYGONTYPE
Definition: liblwgeom.h:72
uint8_t flags
Definition: liblwgeom.h:381
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:137
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
#define TRIANGLETYPE
Definition: liblwgeom.h:83
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
Definition: lwcollection.c:248
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
Definition: lwcircstring.c:125
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
Definition: lwtriangle.c:114
#define LW_FALSE
Definition: liblwgeom.h:62
#define TINTYPE
Definition: liblwgeom.h:84
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
Definition: g_box.c:141
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
Definition: lwpoly.c:234
char lwline_same(const LWLINE *p1, const LWLINE *p2)
Definition: lwline.c:143
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76

Here is the call graph for this function:

Here is the caller graph for this function: