Skip to content

Commit

Permalink
Polygon tesselation fix (visgl#2659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Feb 8, 2019
1 parent 56c6071 commit 3c4ab91
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class PolygonTesselator extends Tesselator {
*/
if (holeIndices) {
for (let j = 0; j < holeIndices.length; j++) {
vertexValid[vertexStart + holeIndices[j] - 1] = 0;
vertexValid[vertexStart + holeIndices[j] / positionSize - 1] = 0;
}
}
vertexValid[vertexStart + geometrySize - 1] = 0;
Expand Down
30 changes: 30 additions & 0 deletions test/modules/layers/polygon-tesselation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,36 @@ test('PolygonTesselator#constructor', t => {
t.end();
});

test('PolygonTesselator#tesselation', t => {
const tesselator = new PolygonTesselator({
data: [
{
polygon: [[1, 1], [2, 2], [3, 0], [1, 1]],
name: 'simple loop'
},
{
polygon: [[[0, 0], [2, 0], [2, 2], [0, 2]], [[0.5, 0.5], [1, 0.5], [0.5, 1]]],
name: 'with 1 hole'
}
],
getGeometry: d => d.polygon,
positionFormat: 'XY'
});

t.deepEquals(
tesselator.get('indices'),
[1, 3, 2, 4, 12, 11, 10, 12, 4, 5, 6, 7, 7, 4, 11, 10, 4, 5, 5, 7, 11, 11, 10, 5],
'returned correct indices'
);
t.deepEquals(
tesselator.get('vertexValid'),
[1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0],
'returned correct vertexValid'
);

t.end();
});

test('PolygonTesselator#methods', t => {
TEST_DATA.forEach(testData => {
t.comment(`Polygon data: ${testData.title}`);
Expand Down
Binary file modified test/render/golden-images/geojson-extruded-lnglat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 19 additions & 9 deletions test/render/test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,6 @@ export const TEST_CASES = [
lineWidthScale: 10,
lineWidthMinPixels: 1,
pickable: true,
coordinateSystem: COORDINATE_SYSTEM.LNGLAT_DEPRECATED,
fp64: true,
lightSettings: LIGHT_SETTINGS
})
],
Expand All @@ -627,21 +625,33 @@ export const TEST_CASES = [
{
name: 'geojson-extruded-lnglat',
viewState: {
latitude: 37.751537058389985,
longitude: -122.42694203247012,
zoom: 11.5,
latitude: 37.78,
longitude: -122.45,
zoom: 12,
pitch: 0,
bearing: 0
},
layers: [
new GeoJsonLayer({
id: 'geojson-extruded-lnglat',
data: dataSamples.choropleths,
getElevation: f => ((f.properties.ZIP_CODE * 10) % 127) * 10,
getFillColor: f => [0, 100, (f.properties.ZIP_CODE * 55) % 255],
getLineColor: f => [200, 0, 80],
data: dataSamples.geojson,
extruded: true,
wireframe: true,
getRadius: f => MARKER_SIZE_MAP[f.properties['marker-size']],
getFillColor: f => {
const color = parseColor(f.properties.fill || f.properties['marker-color']);
const opacity = (f.properties['fill-opacity'] || 1) * 255;
return setOpacity(color, opacity);
},
getLineColor: f => {
const color = parseColor(f.properties.stroke);
const opacity = (f.properties['stroke-opacity'] || 1) * 255;
return setOpacity(color, opacity);
},
getLineWidth: f => f.properties['stroke-width'],
getElevation: f => 500,
lineWidthScale: 10,
lineWidthMinPixels: 1,
pickable: true,
lightSettings: LIGHT_SETTINGS
})
Expand Down

0 comments on commit 3c4ab91

Please sign in to comment.