Hi
I have a Web mapping app built with OL 2.13.1
Vector data is read in from a database source as WKT. I have to transform from
a source projection to a map projection once read into a vector feature, before
adding to a vector layer, and then transform back to the source projection when
writing out new features or edits back to the database.
My WKT format is defined as:
var wkt_format = new OpenLayers.Format.WKT();
I read my features as:
featgeom = wkt_format.read(crds);
if (srcsrs != mapsrs) {
featgeom.geometry.transform(srcproj,mapproj);
}
This works fine.
On writing I get a problem when I clone a feature, reproject it and then try to
write out the WKT:
var wkt_out;
if (srcsrs != mapsrs) {
var geometry = feature.geometry.clone();
geometry.transform(mapproj, srcproj);
wkt_out = wkt_format.write(geometry);
}
else {
wkt_out = wkt_format.write(feature);
}
I get an error:
'CLASS_NAME' is null or not an object
WKT.js
Looking in WKT.js it appears the clone is not copying the type of geometry?
/**
* Method: extractGeometry
* Entry point to construct the WKT for a single Geometry object.
*
* Parameters:
* geometry - {<OpenLayers.Geometry.Geometry>}
*
* Returns:
* {String} A WKT string of representing the geometry
*/
extractGeometry: function(geometry) {
var type = geometry.CLASS_NAME.split('.')[2].toLowerCase();
if (!this.extract[type]) {
return null;
}
if (this.internalProjection && this.externalProjection) {
geometry = geometry.clone();
geometry.transform(this.internalProjection,
this.externalProjection);
}
var wktType = type == 'collection' ? 'GEOMETRYCOLLECTION' :
type.toUpperCase();
var data = wktType + '(' + this.extract[type].apply(this, [geometry]) +
')';
return data;
}
Any clues how to solve this?
Many thanks,
Robert Sanson
This email and any attachments are confidential and intended solely for the
addressee(s). If you are not the intended recipient, please notify us
immediately and then delete this email from your system.
This message has been scanned for Malware and Viruses by Websense Hosted
Security.
www.websense.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users