PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ LWGEOM_GEOS_getPointN()

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

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

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