Apologies in advance if I have overlooked the documentation where this is clear.

I'd like to create a line on my map reflecting a series of points in time order. I can do the dots themselves just fine, but it's not clear how to get that set of points rendered as the vertices of a polyline.

Am I required to create a little mini-module to do so? I am willing, but it seems tantalizingly like there should be a less code-intensive way.

Thanks in advance. This is a remarkable module. Good stuff.

Comments

tmcw’s picture

How are you drawing the dots? If you're using the OpenLayers CCK module's input to do it, then you should be able to enable line input and draw lines. Otherwise, if you're doing geotaxonomy or lat/lon input, there isn't a clear-cut way to do this, unfortunately, although a behavior would likely be possible that connects the dots.

Cayenne’s picture

Ah, I see.

Yes, I was just using the simple lat/lon method from the tutorial.

And I see that the WKT input method is just that, so I'll need to mess with the behavior, I guess, since I want to connect the dots between various datapoints, up to a given time.

This is for yacht race tracking.

davideads’s picture

Just a note: OpenLayers supports line segments. It does NOT support encoded polylines (see http://openlayers.org/pipermail/dev/2009-February/004393.html).

Cayenne’s picture

Wow. that seems really surprising. I don't think it's consistent with what else I have read and seen demonstrated with Openlayers, and seems like a bad thing to leave out. I will continue to investigate...

tmcw’s picture

I'm assuming that Mr. Schmidt's opposition to polylines is based on the facts that

  • The encoding scheme is based on given facts about the Google Maps API and its layers, assumptions that are not universally true in OpenLayers-land. It's also not really a standard that anyone can point to
  • It's rather easy to implement a polyline decoder that works with OpenLayers, and not necessary to implement it in the core project.
seanberto’s picture

If I understand the thread correctly, this is something that Loubabe (Lev Tsypin) and I are going to be working on. We are planning on using the Node Queue module to allow a site visitor to create an ordered list of flagged nodes that they want to visit as part of a walking tour. We hope to use a view of these flagged nodes (sorted by the node queue order) as the sort for displaying a polyline on an OpenLayers map. We'll be exploring this more in the next few weeks.

Cayenne’s picture

That's grreat!

Working with unDrupalled OpenLayers, I have made a nice little page that displays a random polyline across the Pacific Ocean, which is what I want.
If it is at all possible for you to make your project slightly more generic, so that the output of a View, or even just calls to a table, can feed the polyline, that'd be really slick.

Pseudo code

SELECT name, lat, lon, date, comment FROM positions
GROUP BY name
ORDER BY date

Or something like that. But as long as we are agnostic about how the ordered view of nodes got created (and I want to include 70 paths in one map) I am happy.

davideads’s picture

@Cayenne and @Seanberto -- dunno if you got my contact emails, but "connecting the dots" is rather easy. As of today, I also have code written to make a curvy line.

Cayenne’s picture

I did not get your contact email. Also, it appears that openlayers.org itself is DOWN today and has been intermittent the last couple. I wish I had DL'd the js.

EDIT: Site back up, but still. a little troubling....

tmcw’s picture

Cayenne: the OSGEO server has been going up and down recently, as I've heard on #openlayers (on irc.freenode.org). I think it was just dev.openlayers.org, but, who knows. This is a separate project.

mattcasey’s picture

If you guys have any scripts to share, can I get in?

I am currently trying to do this - my client is traveling across country and will update his position for each blog post. I want to draw a line following his path, plus one special 'temporary' line segment projecting the next location (which may be an unpublished node, or have some special field checked?)

Great module - Thanks!

tmcw’s picture

Er, it strikes me as odd to do this on the PHP level and reaching back even to the database level - why not just output points to the map and use a custom behavior to re-write them as a line segment? That'd be much less gnarly and much more reusable.

davideads’s picture

Reaching back to the database level makes no sense, but using PHP to generate the line segments has its place.

I don't think doing it in PHP is necessarily less reusable if the PHP is written sanely, and it keeps the CPU cycles required to create the segments on the server (where the layer can also be cached, so that you can compute once and use many times). It seems to me it really comes down to where you have the cycles to spare. On my project, doing it server side is a no-brainer -- it is dramatically faster without caching, and we have a very powerful server infrastructure to drive the site.

davideads’s picture

Also, my last comment applies to complex features (like curved lines). For drawing a straight line segment between points on the map which require no attributes or other fancy processing, a behavior is definitely the way to go.

tmcw’s picture

Huh? Bezier-curved lines are usually generated in OpenLayers, just using Geometry.Curve, rather than on the server side, which would make the data transfer larger. Anyway, if you've got a working solution, go for it.

zzolo’s picture

Status: Active » Closed (works as designed)

Closing as this seems to be resolved, and just a discussion on implementation details. Feel free to continue the discussion if needed.

davideads’s picture

Wow, I sure got sidetracked by work and travel from this one -- here's a comment on my implementation and why I'm trying to do it this way. Maybe I'm off base...

I'm not using Geometry.Curve because I would a) need to calculate the intermediary points to draw the curve through in Javascript, which seems like needless computation by the client and b) Geometry.Curve isn't a cubic bezier curve. Given how little layer data (on my project, building curve-y lines server side adds 5-10k to the size of the layer data transferred. In an environment where most users will have direct fiber connections to their desktops, I don't think that's exactly a deal breaker).

Because of this, and because of the advantages of a cubic bezier in terms of control over the curve itself, to my mind it still makes sense to generate the curved features server side. I can make control points dependent on metadata associated with map points (i.e. network delay between two physical locations compared to a baseline measurement) and easily change curvature, etc by varying the angle and location of the control points.

See http://trac.openlayers.org/ticket/619 and http://trac.openlayers.org/ticket/1715

leo82’s picture

Hi seanberto,

any help on how do you achieve that?

leo82’s picture

Status: Closed (works as designed) » Active
ken-g’s picture

Issue summary: View changes
Status: Active » Closed (outdated)