@reearth/core 0.0.5-beta.0 → 0.0.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -50,12 +50,6 @@ test("attachProperties()", () => {
|
|
|
50
50
|
outlineWidth: 100,
|
|
51
51
|
outlineColor: "blue",
|
|
52
52
|
});
|
|
53
|
-
expect(mockEntity.properties.reearth_originalProperties).toEqual({
|
|
54
|
-
polygon: {
|
|
55
|
-
material: toColor("blue"),
|
|
56
|
-
outlineWidth: 100,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
53
|
|
|
60
54
|
// Computed feature should not be changed.
|
|
61
55
|
expect(mockComputedFeature).toEqual({
|
|
@@ -64,29 +64,26 @@ export function attachProperties<
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const tag = getTag(entity);
|
|
67
|
+
const originalProperties = tag?.originalProperties || {};
|
|
68
|
+
const isUpdatedInLastUpdate = originalProperties[appearanceName];
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
overrideOriginalProperties(
|
|
70
|
-
entity,
|
|
71
|
-
tag,
|
|
72
|
-
propertyName,
|
|
73
|
-
Object.keys(propertyMap).reduce(
|
|
74
|
-
(r, k) => {
|
|
75
|
-
r[k] = (property as any)[k];
|
|
76
|
-
return r;
|
|
77
|
-
},
|
|
78
|
-
{} as Record<string, any>,
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
|
|
70
|
+
let isUpdated = false;
|
|
82
71
|
Object.entries(propertyMap).forEach(([entityPropertyKey, appearancePropertyKey]) => {
|
|
83
72
|
const appearanceKeyName = appearancePropertyKey.name;
|
|
84
73
|
const appearanceKeyType = appearancePropertyKey.type as AppearancePropertyKeyType;
|
|
85
74
|
|
|
86
75
|
let value =
|
|
87
76
|
appearancePropertyKey.override ??
|
|
88
|
-
(computedFeature?.[appearanceName] as any)?.[appearanceKeyName]
|
|
89
|
-
|
|
77
|
+
(computedFeature?.[appearanceName] as any)?.[appearanceKeyName];
|
|
78
|
+
const isDefaultUsed = value == null && !!appearancePropertyKey.default;
|
|
79
|
+
value = value == null ? appearancePropertyKey.default : value;
|
|
80
|
+
|
|
81
|
+
if ((value == null || isDefaultUsed) && !isUpdatedInLastUpdate) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
isUpdated = true;
|
|
86
|
+
|
|
90
87
|
switch (appearanceKeyType) {
|
|
91
88
|
case "color":
|
|
92
89
|
value = toColor(value);
|
|
@@ -98,9 +95,14 @@ export function attachProperties<
|
|
|
98
95
|
value = heightReference(value);
|
|
99
96
|
}
|
|
100
97
|
|
|
98
|
+
if (value === (entity[propertyName] as any)[entityPropertyKey]) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
101
102
|
(entity[propertyName] as any)[entityPropertyKey] =
|
|
102
103
|
value ?? (property as any)[entityPropertyKey];
|
|
103
104
|
});
|
|
105
|
+
overrideOriginalProperties(entity, tag, appearanceName, isUpdated);
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
const hasAppearance = <
|
|
@@ -111,7 +113,7 @@ const hasAppearance = <
|
|
|
111
113
|
entity: Entity,
|
|
112
114
|
namePair: [appearanceName: AName, propertyName: PName],
|
|
113
115
|
): boolean => {
|
|
114
|
-
return !!(extractSimpleLayer(layer)?.[namePair[0]]
|
|
116
|
+
return !!(extractSimpleLayer(layer)?.[namePair[0]] && entity[namePair[1]]);
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
export const makeFeatureId = (e: Entity) => String(e.id);
|