[Featureserver] How to save polylines/linestrings from OL?

Frederik Ramm frederik at remote.org
Mon Oct 13 20:04:49 EDT 2008


Hi,

    I've been using OpenLayers for a while and am now starting to play 
with FeatureServer.

I have two layers in OpenLayers, each with one Polyline on it. I want
to save this full picture to FeatureServer. I generate an array 
containing the two polylines from the two layers:

var feature_array = new Array();
feature_array.push(first_layer.features[0]);
feature_array.push(second_layer.features[0]);

and let this run through OpenLayer's GeoJSON formatter, yielding:

{"type":"FeatureCollection","features":[{"type":"Feature","id":"OpenLayers.Feature.Vector_429","properties":{},"geometry":{"type":"LineString","coordinates":[[946549.6300834444,6275193.970668824],[946534.0453547356,6275193.970668824],[946531.8189649201,6275173.60840275],[946371.5188982,6275046.345351336],[946337.009856059,6275002.227940855],[946163.3514504456,6274818.973470214],[946072.0694680078,6274812.186343908]]}},{"type":"Feature","id":"OpenLayers.Feature.Vector_456","properties":{},"geometry":{"type":"LineString","coordinates":[[946550.0753614076,6275195.83721234],[946550.6284395837,6275198.850473554],[946545.9565402488,6275200.842944701],[946547.6374645595,6275161.2553185765],[946527.655615965,6275159.100318105],[946502.9315570632,6275149.818550694],[946456.5001974597,6275115.016255822],[946350.2346115634,6274999.156698926],[946289.9328434088,6274939.802198524],[946174.0937813055,6274819.397665788],[946110.8309146966,6274812.932927536],[946072.4274498615,6274811.742776
886],[946072.4034264801,6274813.543768735]]}}]}

If I try to save this to FeatureServer, I get an error message about the 
geometry type "LineString" that was created by OpenLayers:

Unable to determine bounding box for feature with geometry LineString

(this is from Feature.py). I then modified Feature.py to also accept 
LineString instead of Line, but then the same problem occurs again in 
the storage backends:

An error occurred: Couldn't create WKT from geometry of type LineString 
({u'type': u'LineString', u'coordinates': ... ). Only Point, Line, 
Polygon are supported.

(this is from the SQLite backend but I have verified that neither does 
the PostGIS backend support the a GeoJSON type of "Linestring").

Somehow this must work - http://featureserver.org/demo.html perfectly
manages to upload polylines! So where is my mistake? (My FeatureServer 
installation is a few months old but I have confirmed that current SVN 
versions don't expect to receive LineString either. I'm using OpenLayers 
directly from http://openlayers.org/api/OpenLayers.js.)

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00'09" E008°23'33"



More information about the Featureserver mailing list