PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_GEOS_getPointN()

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

Definition at line 56 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().

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