Add spatial reference inside geometry in EsriFormat

As mentioned on issue 6992, EsriFormat was adding the spatial reference
outside the geometry, failing to insert data via the Arcgis rest API.
The spatial reference should be inside the geometry.
This commit is contained in:
Joao Gouveia
2017-07-10 10:24:04 +02:00
parent 4a0f97ac6a
commit 2be40953a8
+6 -6
View File
@@ -623,6 +623,12 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function(
if (geometry) { if (geometry) {
object['geometry'] = object['geometry'] =
ol.format.EsriJSON.writeGeometry_(geometry, opt_options); ol.format.EsriJSON.writeGeometry_(geometry, opt_options);
if (opt_options && opt_options.featureProjection) {
object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({
wkid: ol.proj.get(
opt_options.featureProjection).getCode().split(':').pop()
});
}
} }
var properties = feature.getProperties(); var properties = feature.getProperties();
delete properties[feature.getGeometryName()]; delete properties[feature.getGeometryName()];
@@ -631,12 +637,6 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function(
} else { } else {
object['attributes'] = {}; object['attributes'] = {};
} }
if (opt_options && opt_options.featureProjection) {
object['spatialReference'] = /** @type {EsriJSONCRS} */({
wkid: ol.proj.get(
opt_options.featureProjection).getCode().split(':').pop()
});
}
return object; return object;
}; };