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

452 {
453  LWDEBUGF(2, "lwgeom_same(%s, %s) called",
454  lwtype_name(lwgeom1->type),
455  lwtype_name(lwgeom2->type));
456 
457  if ( lwgeom1->type != lwgeom2->type )
458  {
459  LWDEBUG(3, " type differ");
460 
461  return LW_FALSE;
462  }
463 
464  if ( FLAGS_GET_ZM(lwgeom1->flags) != FLAGS_GET_ZM(lwgeom2->flags) )
465  {
466  LWDEBUG(3, " ZM flags differ");
467 
468  return LW_FALSE;
469  }
470 
471  /* Check boxes if both already computed */
472  if ( lwgeom1->bbox && lwgeom2->bbox )
473  {
474  /*lwnotice("bbox1:%p, bbox2:%p", lwgeom1->bbox, lwgeom2->bbox);*/
475  if ( ! gbox_same(lwgeom1->bbox, lwgeom2->bbox) )
476  {
477  LWDEBUG(3, " bounding boxes differ");
478 
479  return LW_FALSE;
480  }
481  }
482 
483  /* geoms have same type, invoke type-specific function */
484  switch (lwgeom1->type)
485  {
486  case POINTTYPE:
487  return lwpoint_same((LWPOINT *)lwgeom1,
488  (LWPOINT *)lwgeom2);
489  case LINETYPE:
490  return lwline_same((LWLINE *)lwgeom1,
491  (LWLINE *)lwgeom2);
492  case POLYGONTYPE:
493  return lwpoly_same((LWPOLY *)lwgeom1,
494  (LWPOLY *)lwgeom2);
495  case TRIANGLETYPE:
496  return lwtriangle_same((LWTRIANGLE *)lwgeom1,
497  (LWTRIANGLE *)lwgeom2);
498  case CIRCSTRINGTYPE:
499  return lwcircstring_same((LWCIRCSTRING *)lwgeom1,
500  (LWCIRCSTRING *)lwgeom2);
501  case MULTIPOINTTYPE:
502  case MULTILINETYPE:
503  case MULTIPOLYGONTYPE:
504  case MULTICURVETYPE:
505  case MULTISURFACETYPE:
506  case COMPOUNDTYPE:
507  case CURVEPOLYTYPE:
509  case TINTYPE:
510  case COLLECTIONTYPE:
511  return lwcollection_same((LWCOLLECTION *)lwgeom1,
512  (LWCOLLECTION *)lwgeom2);
513  default:
514  lwerror("lwgeom_same: unsupported geometry type: %s",
515  lwtype_name(lwgeom1->type));
516  return LW_FALSE;
517  }
518 
519 }
#define LINETYPE
Definition: liblwgeom.h:61
GBOX * bbox
Definition: liblwgeom.h:354
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:231
#define MULTICURVETYPE
Definition: liblwgeom.h:70
#define POLYGONTYPE
Definition: liblwgeom.h:62
uint8_t flags
Definition: liblwgeom.h:353
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:119
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
Definition: lwcollection.c:238
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
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:52
#define TINTYPE
Definition: liblwgeom.h:74
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
#define MULTILINETYPE
Definition: liblwgeom.h:64
#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:139
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
Definition: lwpoly.c:229
char lwline_same(const LWLINE *p1, const LWLINE *p2)
Definition: lwline.c:142
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: