Skip to content

Commit

Permalink
Merge pull request #31 from yanxj0/master
Browse files Browse the repository at this point in the history
fix(primitive-geojson):修复多孔polygon显示问题
  • Loading branch information
hongfaqiu authored Nov 25, 2024
2 parents 5dd49de + 5dcb1af commit 5fab45c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
17 changes: 9 additions & 8 deletions packages/primitive-geojson/src/GeoJsonLayer-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,20 @@ export function createPolygon(
}
const properties = geoJson.properties ?? {};

const positions = coordinatesArrayToCartesianArray(
coordinates[0],
crsFunction,
);
const cartesian3Coords = coordinates.map((it) => coordinatesArrayToCartesianArray(
it,
crsFunction
));
geoJsonLayer.addPolygon({
type: 'Polygon',
positions,
type: "Polygon",
positions: cartesian3Coords[0],
holes: cartesian3Coords.slice(1),
style: {
material: options.fill,
outlineColor: options.stroke,
outlineWidth: options.strokeWidth,
outlineWidth: options.strokeWidth
},
properties,
properties
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/primitive-geojson/src/GeoJsonPrimitiveLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ export class GeoJsonPrimitiveLayer extends BasicGraphicLayer {
}

addPolygon(item: PolygonPrimitiveItem) {
const { positions, style } = item;
const { positions, style, holes } = item;
const id = this._generateId();

const geometry = new PolygonGeometry({
polygonHierarchy: new PolygonHierarchy(positions),
polygonHierarchy: new PolygonHierarchy(positions, holes.map(hole => new PolygonHierarchy(hole))),
vertexFormat: PerInstanceColorAppearance.VERTEX_FORMAT,
extrudedHeight: style?.extrudedHeight,
arcType: ArcType.RHUMB,
Expand Down
1 change: 1 addition & 0 deletions packages/primitive-geojson/src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export type LabelPrimitiveItem = {
export type PolygonPrimitiveItem = {
type: 'Polygon';
positions: Cartesian3[];
holes: Cartesian3[][];
style?: {
material?: Color;
/**The distance in meters between the polygon and the ellipsoid surface. */
Expand Down

0 comments on commit 5fab45c

Please sign in to comment.