Opened 17 years ago

Closed 15 years ago

#24 closed enhancement (wontfix)

Enhancement: containsVertex function

Reported by: mtnclimb Owned by:
Priority: low Milestone: PostGIS 1.5.0
Component: postgis Version:
Keywords: Cc:

Description (last modified by robe)

A containsVertex function might be a useful addition.

int containsVertex(Geometry geom, double x, double y)

I geom contains a vertex with location (x,y), returns the index of that vertex. Otherwise returns -1. For geometrys which contain more than one coordinate sequence, the index is the cumulative index over all coordinate sequences.

This can be implemented as a fast linear scan of all vertices in the geometry.

Change History (6)

comment:1 by kneufeld, 17 years ago

Agreed, esp. if one is doing linear referencing or edit a single point in a geometry.

or int ST_ContainsPoint(Geometry geom, Geometry point) or int ST_ContainsCoordinate(Geometry geom, Geometry point)

Though I think the cumulative index part could get confusing. We could restrict the use to LineStrings only.

comment:2 by pramsey, 17 years ago

What about multi-line strings? Behavior?

comment:3 by mtnclimb, 17 years ago

One idea is to use the cumulative index idea. So for a ML:

g = MULTILINESTRING((0 0, 1 1) (1 1, 2 2))

ST_ContainsPoint(g, pt(0,0)) = 0 ST_ContainsPoint(g, pt(1,1)) = 1 1st one found is returned ST_ContainsPoint(g, pt(2,2)) = 3 2nd linestring has indexes 2, 3

Another is to return a pair (lineIndex, ptIndex) - but this might make for more complicated code in the caller.

comment:4 by kneufeld, 17 years ago

<i>(No comment was entered for this change.)</i>

comment:5 by robe, 16 years ago

Description: modified (diff)
Milestone: 2.0

comment:6 by pramsey, 15 years ago

Resolution: wontfix
Status: newclosed

Two year old, no movement, retiring until someone decides to love this ticket.

Note: See TracTickets for help on using tickets.