PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_GEOS_getPointN()

GEOSGeometry * LWGEOM_GEOS_getPointN ( const GEOSGeometry *  g_in,
uint32_t  n 
)

Definition at line 46 of file liblwgeom/lwgeom_geos_clean.c.

References lwcollection_make_geos_friendly(), lwline_make_geos_friendly(), lwpoly_make_geos_friendly(), and ring_make_geos_friendly().

Referenced by LWGEOM_GEOS_nodeLines().

47 {
48  uint32_t dims;
49  const GEOSCoordSequence* seq_in;
50  GEOSCoordSeq seq_out;
51  double val;
52  uint32_t sz;
53  int gn;
54  GEOSGeometry* ret;
55 
56  switch ( GEOSGeomTypeId(g_in) )
57  {
58  case GEOS_MULTIPOINT:
59  case GEOS_MULTILINESTRING:
60  case GEOS_MULTIPOLYGON:
61  case GEOS_GEOMETRYCOLLECTION:
62  {
63  for (gn=0; gn<GEOSGetNumGeometries(g_in); ++gn)
64  {
65  const GEOSGeometry* g = GEOSGetGeometryN(g_in, gn);
66  ret = LWGEOM_GEOS_getPointN(g,n);
67  if ( ret ) return ret;
68  }
69  break;
70  }
71 
72  case GEOS_POLYGON:
73  {
74  ret = LWGEOM_GEOS_getPointN(GEOSGetExteriorRing(g_in), n);
75  if ( ret ) return ret;
76  for (gn=0; gn<GEOSGetNumInteriorRings(g_in); ++gn)
77  {
78  const GEOSGeometry* g = GEOSGetInteriorRingN(g_in, gn);
79  ret = LWGEOM_GEOS_getPointN(g, n);
80  if ( ret ) return ret;
81  }
82  break;
83  }
84 
85  case GEOS_POINT:
86  case GEOS_LINESTRING:
87  case GEOS_LINEARRING:
88  break;
89 
90  }
91 
92  seq_in = GEOSGeom_getCoordSeq(g_in);
93  if ( ! seq_in ) return NULL;
94  if ( ! GEOSCoordSeq_getSize(seq_in, &sz) ) return NULL;
95  if ( ! sz ) return NULL;
96 
97  if ( ! GEOSCoordSeq_getDimensions(seq_in, &dims) ) return NULL;
98 
99  seq_out = GEOSCoordSeq_create(1, dims);
100  if ( ! seq_out ) return NULL;
101 
102  if ( ! GEOSCoordSeq_getX(seq_in, n, &val) ) return NULL;
103  if ( ! GEOSCoordSeq_setX(seq_out, n, val) ) return NULL;
104  if ( ! GEOSCoordSeq_getY(seq_in, n, &val) ) return NULL;
105  if ( ! GEOSCoordSeq_setY(seq_out, n, val) ) return NULL;
106  if ( dims > 2 )
107  {
108  if ( ! GEOSCoordSeq_getZ(seq_in, n, &val) ) return NULL;
109  if ( ! GEOSCoordSeq_setZ(seq_out, n, val) ) return NULL;
110  }
111 
112  return GEOSGeom_createPoint(seq_out);
113 }
unsigned int uint32_t
Definition: uthash.h:78
GEOSGeometry * LWGEOM_GEOS_getPointN(const GEOSGeometry *, uint32_t)
Here is the call graph for this function:
Here is the caller graph for this function: