Creating an object that stores properties only when needed in BaseObject class

This commit is contained in:
Michał Zielański
2020-06-15 13:00:26 +02:00
parent 323a472fbb
commit 0e8f0034ab
7 changed files with 103 additions and 58 deletions
+6 -2
View File
@@ -199,6 +199,11 @@ class EsriJSON extends JSONFeature {
writeFeatureObject(feature, opt_options) {
opt_options = this.adaptOptions(opt_options);
const object = {};
if (!feature.hasProperties()) {
object['attributes'] = {};
return object;
}
const properties = feature.getProperties();
const geometry = feature.getGeometry();
if (geometry) {
object['geometry'] = writeGeometry(geometry, opt_options);
@@ -214,9 +219,8 @@ class EsriJSON extends JSONFeature {
),
});
}
delete properties[feature.getGeometryName()];
}
const properties = feature.getProperties();
delete properties[feature.getGeometryName()];
if (!isEmpty(properties)) {
object['attributes'] = properties;
} else {