[OpenLayers-Users] Projection missing GeoJSON.write and GML.write

Maxime Phaneuf maxime.phaneuf at usherbrooke.ca
Thu Mar 18 12:42:44 EDT 2010


Hi guys

I'm developing a web service where it will be possible to export each vector
layer to GML, GeoJSON, Shapefile...

So, I have a vector layer defined this way:
	traverseHaughton = new OpenLayers.Layer.Vector("Haughton Traverses", {
		strategies: [new OpenLayers.Strategy.BBOX(), saveStrategyTraverse],
		styleMap: vectorStyleMap,
		protocol: new OpenLayers.Protocol.WFS({
			version:       "1.0.0",
			url:           "http://***:8080/geoserver/wfs?",
			featureType:   "traverse_haughton",
			srsName:       "EPSG:26916",
			featurePrefix: "topp",
			geometryName:  "the_geom"
		})
	});

As you can see, the projection is EPSG:26916, which is also defined for the
map object.

The problem is when I'm using the .write() function. Even though a
projection is defined, it does not translate into the GML or GeoJSON.

GeoJSON example:
var geojson = new OpenLayers.Format.GeoJSON();
geojson.externalProjection = map.projection;
geojson.internalProjection = map.getProjectionObject();
var ingeoj = geojson.write(layer.features);	

ingeoj = 
"{"type":"FeatureCollection","features":[{"type":"Feature","id":"line_haughton.100934661","properties":{"id":"1","name":"2","notes":"344"},"geometry":{"type":"MultiLineString","coordinates":[[[422336.53759006,8363423.4713272],[422626.89012912,8362411.92054595],[422336.53759006,8361400.3697647]]]}},{"type":"Feature","id":"line_haughton.101521704","properties":{"id":"1","name":"2","notes":"3"},"geometry":{"type":"MultiLineString","coordinates":[[[423722.73680883,8367984.8160542],[425034.00634008,8366186.5035542],[425914.4301682,8366898.3355855]]]}}]}"

There is no CRS property. The same thing is happening with GML. I think this
is causing me problem when I try to use GDAL/OGR on server side.

Do any of you know how to add the projection information into a GML of
GeoJSON created by openlayers?

Thanks
Maxime


-- 
View this message in context: http://n2.nabble.com/Projection-missing-GeoJSON-write-and-GML-write-tp4757646p4757646.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list