Skip to content

Commit

Permalink
fix feature missing data
Browse files Browse the repository at this point in the history
  • Loading branch information
mkumbobeaty committed Nov 17, 2024
1 parent 421d64f commit cce800d
Showing 1 changed file with 75 additions and 68 deletions.
143 changes: 75 additions & 68 deletions src/engines/Cesium/Feature/Resource/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const attachStyle = (
const point = hasAppearance(layer, entity, ["marker", "point"]);
const billboard = hasAppearance(layer, entity, ["marker", "billboard"]);
const label = hasAppearance(layer, entity, ["marker", "label"]);
if (point || billboard || label) {
if (entity.point || entity.billboard || entity.label) {
const position = entity.position?.getValue(currentTime);
const coordinates = [position?.x ?? 0, position?.y ?? 0, position?.z ?? 0];
const feature: Feature = {
Expand Down Expand Up @@ -168,10 +168,10 @@ export const attachStyle = (
name: "show",
...(computedFeature?.marker?.style
? {
override:
computedFeature?.marker?.style === "point" &&
(computedFeature?.marker.show ?? true),
}
override:
computedFeature?.marker?.style === "point" &&
(computedFeature?.marker.show ?? true),
}
: {}),
},
pixelSize: {
Expand Down Expand Up @@ -207,10 +207,10 @@ export const attachStyle = (
name: "show",
...(computedFeature?.marker?.style
? {
override:
computedFeature?.marker?.style === "image" &&
(computedFeature?.marker.show ?? true),
}
override:
computedFeature?.marker?.style === "image" &&
(computedFeature?.marker.show ?? true),
}
: {}),
},
image: {
Expand Down Expand Up @@ -261,7 +261,7 @@ export const attachStyle = (
return [feature, computedFeature];
}

if (hasAppearance(layer, entity, ["polyline", "polyline"])) {
if (entity.polyline) {
const entityPosition = entity.position?.getValue(currentTime);
const positions = entity.polyline?.positions?.getValue(currentTime) as Cartesian3[];
const coordinates = positions?.map(position => [
Expand Down Expand Up @@ -290,35 +290,40 @@ export const attachStyle = (
if (!computedFeature) {
return;
}
attachProperties(entity, computedFeature, ["polyline", "polyline"], {
show: {
name: "show",
default: true,
},
width: {
name: "strokeWidth",
},
material: {
name: "strokeColor",
type: "color",
},
shadows: {
name: "shadows",
type: "shadows",
},
clampToGround: {
name: "clampToGround",
},
});
if (hasAppearance(layer, entity, ["polyline", "polyline"])) {
attachProperties(entity, computedFeature, ["polyline", "polyline"], {
show: {
name: "show",
default: true,
},
width: {
name: "strokeWidth",
},
material: {
name: "strokeColor",
type: "color",
},
shadows: {
name: "shadows",
type: "shadows",
},
clampToGround: {
name: "clampToGround",
},
});
}
return [feature, computedFeature];
}

if (hasAppearance(layer, entity, ["polygon", "polygon"])) {
if (entity.polygon) {
const entityPosition = entity.position?.getValue(currentTime);
const hierarchy = entity.polygon?.hierarchy?.getValue(currentTime) as PolygonHierarchy;
const coordinates = hierarchy?.holes?.map(hole =>
hole.positions.map(position => [position?.x ?? 0, position?.y ?? 0, position?.z ?? 0]),
);
const coordinates: any = hierarchy?.positions?.map(position => [
position?.x ?? 0,
position?.y ?? 0,
position?.z ?? 0,
]);

const feature: Feature = {
type: "feature",
id: makeFeatureId(entity),
Expand All @@ -340,40 +345,42 @@ export const attachStyle = (
if (!computedFeature) {
return;
}
attachProperties(entity, computedFeature, ["polygon", "polygon"], {
show: {
name: "show",
default: true,
},
fill: {
name: "fill",
},
material: {
name: "fillColor",
type: "color",
},
outline: {
name: "stroke",
},
outlineColor: {
name: "strokeColor",
type: "color",
},
outlineWidth: {
name: "strokeWidth",
},
shadows: {
name: "shadows",
type: "shadows",
},
heightReference: {
name: "heightReference",
type: "heightReference",
},
extrudedHeight: {
name: "extrudedHeight",
},
});
if (hasAppearance(layer, entity, ["polygon", "polygon"])) {
attachProperties(entity, computedFeature, ["polygon", "polygon"], {
show: {
name: "show",
default: true,
},
fill: {
name: "fill",
},
material: {
name: "fillColor",
type: "color",
},
outline: {
name: "stroke",
},
outlineColor: {
name: "strokeColor",
type: "color",
},
outlineWidth: {
name: "strokeWidth",
},
shadows: {
name: "shadows",
type: "shadows",
},
heightReference: {
name: "heightReference",
type: "heightReference",
},
extrudedHeight: {
name: "extrudedHeight",
},
});
}
return [feature, computedFeature];
}
};

0 comments on commit cce800d

Please sign in to comment.