In addition to points, the geoRSS format also supports lines, polygons, boxes and circles (http://georss.org/simple)

It would be cool to support lines, polygons and boxes with geofield (circles might be out of scope as there is no representation for them in geofield).

Thanks for the awesome module!

Comments

mfb’s picture

Status: Active » Needs work

I could use some help with this one. So far I committed a georss:box option, this was easy as each geofield item gives me a bounding box as well as the centroid. Note: please test this, if you get a chance. I didn't yet verify that this works correctly :)

I see that each item has a geo_type property which might be point, linestring or polygon. So my thinking is I could also add a georss geometry formatter, which would render whatever georss geometry element is appropriate for the given geofield item. Does geofield give me a means to easily parse the WKT into latitude/longitude pairs that I could use for georss?

phayes’s picture

Assigned: Unassigned » phayes

HI mfb,

OK cool, I'll assign it to me and I'll see if I can get it to work.

phayes’s picture

So I've added support for geoRSS directly to GeoPHP (https://github.com/phayes/geoPHP). This is a utility library that geofield uses. So you should be able to get automatic point, line, and polygon support by doing the following:

$geom = geoPHP::load($wkt_from_geofield,'wkt');
$georss_string = $geom->out('georss','georss');

Easy! However, this is currently sitting in the master (development) branch of the geoPHP library. We should wait a while until it winds it's way though a normal release before supporting it.

mfb’s picture

  1. You have a typo, $output .= when $output hasn't already been defined causes a PHP notice.
  2. I was expecting to just get the value, because Drupal puts the element name and value (and attributes) into separate elements of an array for each RSS element. If you return the string in XML format then I will need to parse it to extract the element name and value.
phayes’s picture

Hi mfb,

Can you explain to me what you mean when you say that you would like to get "just the value". Can you give me an example? Thanks!

mfb’s picture

For a polygon I was expecting to get a string like 10 30 20 10 40 20 40 40 10 30 instead I get <georss:polygon>10 30 20 10 40 20 40 40 10 30</georss:polygon> So I have to parse the XML to extract the element name and value. It's a bit hackish, but works..

phayes’s picture

mfb,

Ah, I see the issue. This is tricky since for geoPHP library it makes sense to output the whole XML string, but I can see why you would not want it. The two options I see are:

1. Parse the output (kinda messy but works).

2. Look at this code: https://github.com/phayes/geoPHP/blob/master/lib/adapters/GeoRSS.class.php, and then re-implement the same logic in Drupal, but leave out the tags. This is likely the better solution.

A related issue that we might run into is that geofield can store, in a single delta, geometries such as MULTIPOLYGON and MULITIPOINT, which are compound geometries. georss doesn't have a concept for these things - geoPHP just outputs multiple georss tags wrapped in a single <georss:where> tag to hold them all. If you are not ingesting the strings whole-sale we will want to think about how to do this.

phayes’s picture

P.S - since you don't care about going from GeoRSS to geometry, the code you are interested in the above link starts at line 164 (geometryToGeoRSS method).

mfb’s picture

Status: Needs work » Fixed

I've not seen compound geometries used in GeoRSS, so I'm not convinced we need it..

Marking this fixed as it now supports lines, polygons and boxes.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.