Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zmiao committed Mar 20, 2020
1 parent 11541e3 commit 73be374
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/within.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function perp(v1, v2) {

// check if p1 and p2 are in different sides of line segment q1->q2
function twoSided(p1, p2, q1, q2) {
// q1->p1 (x1, y1), q1->p2 (x2, y2), q2->q1 (x3, y3)
// q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)
const x1 = p1[0] - q1[0];
const y1 = p1[1] - q1[1];
const x2 = p2[0] - q1[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"expression": ["within", {
"type": "Polygon",
"coordinates": [[[-185.0, 60.0], [175.0, 60.0], [175.0, 65.0], [-185.0, 65.0], [-185.0, 60.0]]]
}],
"inputs": [[{
"zoom": 0,
"canonicalID": {
"z": 0,
"x": 0,
"y": 0
}
}, {
"geometry": {
"type": "LineString",
"coordinates": [[-183, 61], [-179, 62]]
}
}], [{
"zoom": 0,
"canonicalID": {
"z": 0,
"x": 0,
"y": 0
}
}, {
"geometry": {
"type": "LineString",
"coordinates": [[-183, 61], [181, 63]]
}
}], [{
"zoom": 0,
"canonicalID": {
"z": 0,
"x": 0,
"y": 0
}
}, {
"geometry": {
"type": "LineString",
"coordinates": [[-183, 62], [55, 63.5]]
}
}]],
"expected": {
"compiled": {
"type": "boolean",
"isFeatureConstant": false,
"isZoomConstant": true,
"result": "success"
},
"outputs": [true, false, true],
"serialized": ["within", {
"coordinates": [[[-185.0, 60.0], [175.0, 60.0], [175.0, 65.0], [-185.0, 65.0], [-185.0, 60.0]]],
"type": "Polygon"
}]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"expression": ["within", {
"type": "Polygon",
"coordinates": [[[-360.0, 60.0], [0.0, 60.0], [0.0, 65.0], [-360.0, 65.0], [-360.0, 60.0]]]
}],
"inputs": [[{
"zoom": 0,
"canonicalID": {
"z": 0,
"x": 0,
"y": 0
}
}, {
"geometry": {
"type": "Point",
"coordinates": [-183, 61]
}
}], [{
"zoom": 0,
"canonicalID": {
"z": 0,
"x": 0,
"y": 0
}
}, {
"geometry": {
"type": "Point",
"coordinates": [-361, 61]
}
}], [{
"zoom": 0,
"canonicalID": {
"z": 0,
"x": 0,
"y": 0
}
}, {
"geometry": {
"type": "Point",
"coordinates": [183, 62]
}
}], [{
"zoom": 0,
"canonicalID": {
"z": 0,
"x": 0,
"y": 0
}
}, {
"geometry": {
"type": "Point",
"coordinates": [55, 62]
}
}]],
"expected": {
"compiled": {
"type": "boolean",
"isFeatureConstant": false,
"isZoomConstant": true,
"result": "success"
},
"outputs": [true, true, true, true],
"serialized": ["within", {
"coordinates": [[[-360.0, 60.0], [0.0, 60.0], [0.0, 65.0], [-360.0, 65.0], [-360.0, 60.0]]],
"type": "Polygon"
}]
}
}

0 comments on commit 73be374

Please sign in to comment.