Search code examples
openlayers

OpenLayers Curve Geometry not working as expected


I'm trying to create a curved line between two features using OpenLayers 2.10. I'm afraid I may have found a bug, or I simply don't understand what the curve geometry does.

The OpenLayers docs say: "A Curve is a MultiPoint, whose points are assumed to be connected. To this end, we provide a 'getLength()' function, which iterates through the points, summing the distances between them." OK, so far so good...

var curve = new OpenLayers.Feature.Vector(
  new OpenLayers.Geometry.Curve([point1, point2, point3]), null, style
);
layer.addFeatures([curve]);

If I replace Curve with LineString, LinearRing, or Multipoint, the features are rendered as expected. But when I use Curve, precisely squat is rendered on the map. Even worse, calling the geometry's getLength method "works", in the sense that I get a sane answer that gets scales with the distance between the points. I don't know if the answer is correct, but OL certainly has created an internal representation of the curve.

I've tested in Chrome and Firefox on Linux and Windows, and the results are always the same.

Nor have I been able to find a single working example of the Curve geometry. If you someone has one, that would be extrememly useful.

Note that I asked about a similar question about curved lines on StackOverflow, but that was about how to generate "curved" well known text from multiple linestring segments, generated on the server.


Solution

  • Despite evidence to the contrary (being told I should use the curve geometry instead of generating curved segements server-side, and the aforementioned documentation on the curve geometry) no drawing method for the curve geometry exists. So you can create features with the curve geometry all you want, but they won't actually render. Dang. I also asked in IRC, and got this response from Chris Schmidt:

    crschmidt: I do not believe that OpenLayers supports curves.

    crschmidt: I wouldn't try to use such a class, if it exists.