Upgrading to GitLab 12.5.4.

Commit 5eaf1af6 authored by Abhijith Sheheer's avatar Abhijith Sheheer

New upstream version 1.11.6

parent 036b4ce8
This diff is collapsed.
{
"name": "d3-geo",
"version": "1.11.3",
"version": "1.11.6",
"description": "Shapes and calculators for spherical coordinates.",
"keywords": [
"d3",
......
......@@ -32,6 +32,9 @@ var boundsStream = {
else if (deltaSum > epsilon) phi1 = 90;
else if (deltaSum < -epsilon) phi0 = -90;
range[0] = lambda0, range[1] = lambda1;
},
sphere: function() {
lambda0 = -(lambda1 = 180), phi0 = -(phi1 = 90);
}
};
......
import {default as polygonContains} from "./polygonContains";
import {default as distance} from "./distance";
import {epsilon, radians} from "./math";
import {epsilon2, radians} from "./math";
var containsObjectType = {
Feature: function(object, point) {
......@@ -59,10 +59,23 @@ function containsPoint(coordinates, point) {
}
function containsLine(coordinates, point) {
var ab = distance(coordinates[0], coordinates[1]),
ao = distance(coordinates[0], point),
ob = distance(point, coordinates[1]);
return ao + ob <= ab + epsilon;
var ao, bo, ab;
for (var i = 0, n = coordinates.length; i < n; i++) {
bo = distance(coordinates[i], point);
if (bo === 0) return true;
if (i > 0) {
ab = distance(coordinates[i], coordinates[i - 1]);
if (
ab > 0 &&
ao <= ab &&
bo <= ab &&
(ao + bo - ab) * (1 - Math.pow((ao - bo) / ab, 2)) < epsilon2 * ab
)
return true;
}
ao = bo;
}
return false;
}
function containsPolygon(coordinates, point) {
......
import adder from "./adder";
import {cartesian, cartesianCross, cartesianNormalizeInPlace} from "./cartesian";
import {asin, atan2, cos, epsilon, halfPi, pi, quarterPi, sin, tau} from "./math";
import {abs, asin, atan2, cos, epsilon, halfPi, pi, quarterPi, sign, sin, tau} from "./math";
var sum = adder();
function longitude(point) {
if (abs(point[0]) <= pi)
return point[0];
else
return sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);
}
export default function(polygon, point) {
var lambda = point[0],
var lambda = longitude(point),
phi = point[1],
sinPhi = sin(phi),
normal = [sin(lambda), -cos(lambda), 0],
......@@ -22,14 +29,14 @@ export default function(polygon, point) {
var ring,
m,
point0 = ring[m - 1],
lambda0 = point0[0],
lambda0 = longitude(point0),
phi0 = point0[1] / 2 + quarterPi,
sinPhi0 = sin(phi0),
cosPhi0 = cos(phi0);
for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
var point1 = ring[j],
lambda1 = point1[0],
lambda1 = longitude(point1),
phi1 = point1[1] / 2 + quarterPi,
sinPhi1 = sin(phi1),
cosPhi1 = cos(phi1),
......
......@@ -255,6 +255,13 @@ tape("bounds: Polygon - ring", function(test) {
test.end();
});
tape("bounds: Sphere", function(test) {
test.deepEqual(d3.geoBounds({
type: "Sphere"
}), [[-180, -90], [180, 90]]);
test.end();
});
tape("bounds: NestedCollection", function(test) {
test.deepEqual(d3.geoBounds({
type: "FeatureCollection",
......
......@@ -31,6 +31,35 @@ tape("a LineString contains any point on the Great Circle path", function(test)
test.end();
});
tape("a LineString with 2+ points contains those points", function(test) {
var points = [[0, 0], [1,2], [3, 4], [5, 6]];
var feature = {type: "LineString", coordinates: points};
points.forEach(point => {
test.equal(d3.geoContains(feature, point), true);
});
test.end();
});
tape("a LineString contains epsilon-distant points", function(test) {
var epsilon = 1e-6;
var line = [[0, 0], [0, 10], [10, 10], [10, 0]];
var points = [[0, 5], [epsilon * 1, 5], [0, epsilon], [epsilon * 1, epsilon]];
points.forEach(point => {
test.true(d3.geoContains({type:"LineString", coordinates: line}, point));
});
test.end();
});
tape("a LineString does not contain 10*epsilon-distant points", function(test) {
var epsilon = 1e-6;
var line = [[0, 0], [0, 10], [10, 10], [10, 0]];
var points = [[epsilon * 10, 5], [epsilon * 10, epsilon]];
points.forEach(point => {
test.false(d3.geoContains({type:"LineString", coordinates: line}, point));
});
test.end();
});
tape("a MultiLineString contains any point on one of its components", function(test) {
test.equal(d3.geoContains({type: "MultiLineString", coordinates: [[[0, 0], [1,2]], [[2, 3], [4,5]]]}, [2, 3]), true);
test.equal(d3.geoContains({type: "MultiLineString", coordinates: [[[0, 0], [1,2]], [[2, 3], [4,5]]]}, [5, 6]), false);
......@@ -113,3 +142,4 @@ tape("null contains nothing", function(test) {
test.equal(d3.geoContains(null, [0, 0]), false);
test.end();
});
......@@ -30,6 +30,14 @@ rollup.rollup({input: "src/polygonContains.js"})
test.end();
});
tape("geoPolygonContains wraps longitudes", function(test) {
var polygon = d3_geo.geoCircle().center([300, 0])().coordinates;
test.equal(polygonContains(polygon, [300, 0]), 1);
test.equal(polygonContains(polygon, [-60, 0]), 1);
test.equal(polygonContains(polygon, [-420, 0]), 1);
test.end();
});
tape("geoPolygonContains(southPole, point) returns the expected value", function(test) {
var polygon = [[[-60, -80], [60, -80], [180, -80], [-60, -80]]];
test.equal(polygonContains(polygon, [0, 0]), 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment