Opened 9 years ago

Closed 9 years ago

#3366 closed enhancement (fixed)

Provide mechanism in liblwgeom to iterate over all points in a geometry

Reported by: dbaston Owned by: dbaston
Priority: medium Milestone: PostGIS 2.3.0
Component: postgis Version: master
Keywords: Cc:

Description

Currently, this capability is only available at the database level through ST_DumpPoints. A set of iterator functions was developed for the WIP fix for #2996, but could be applied independent of that ticket.

Change History (12)

comment:1 by strk, 9 years ago

+1

comment:2 by robe, 9 years ago

+1 go for it.

comment:3 by robe, 9 years ago

Owner: changed from pramsey to dbaston

comment:4 by dbaston, 9 years ago

Only question then is what to call it….I had gone with LWITERATOR initially, but that's not terribly descriptive. LWPOINTITERATOR is hard to read. I was sticking with all-caps & no underscores to try and match the style of existing types. Any preferences on this?

comment:5 by strk, 9 years ago

I've no problems with LWPOINTITERATOR. Would it need to be dimension-aware ? Ie: LWPOINT2DITERATOR, LWPOINT3DMITERATOR, …

comment:6 by dbaston, 9 years ago

We only need one version of the iterator, but we could have multiple versions of these two functions:

int lwiterator_next(LWITERATOR* s, POINT4D* p);
int lwiterator_peek(LWITERATOR* s, POINT4D* p);

Or we could (as I've done so far) provide only 4D points, and let the user convert them as they wish.

comment:7 by strk, 9 years ago

is mutating iteration supported ?

comment:8 by dbaston, 9 years ago

No, I wasn't envisioning that.

comment:9 by strk, 9 years ago

I've been feeling the need for that doing github.com/strk/fineltra (similar to what st_transform does)

comment:10 by dbaston, 9 years ago

It looks like we could supply an updated POINT4D* to ptarray_set_point4d, which can pull out the correct components from it (as appropriate for the point type). The question then is how to provide the updated POINT4D* ?

What are your thoughts on something like this?

lwpointiterator_modify_next(LWPOINTITERATOR* s, POINT4D*);

I guess a client would use this in conjunction with the peek and has_next functions to mutate the geometry.

comment:11 by strk, 9 years ago

lwpointiterator_modify_next(LWPOINTITERATOR* s, POINT4D*) sounds good to me.

comment:12 by dbaston, 9 years ago

Resolution: fixed
Status: newclosed

(In [14400]) add LWPOINTITERATOR (closes #3366)

Note: See TracTickets for help on using tickets.