Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 57 additions & 69 deletions examples/layers/JSONLayers/Ortho.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,123 +16,111 @@
"tileMatrixSetLimits": {
"2": {
"minTileRow": 0,
"maxTileRow": 4,
"maxTileRow": 3,
"minTileCol": 0,
"maxTileCol": 4
},
"3": {
"minTileRow": 0,
"maxTileRow": 8,
"maxTileRow": 7,
"minTileCol": 0,
"maxTileCol": 8
},
"4": {
"minTileRow": 0,
"maxTileRow": 16,
"minTileRow": 1,
"maxTileRow": 14,
"minTileCol": 0,
"maxTileCol": 16
"maxTileCol": 15
},
"5": {
"minTileRow": 0,
"maxTileRow": 32,
"minTileRow": 3,
"maxTileRow": 28,
"minTileCol": 0,
"maxTileCol": 32
"maxTileCol": 31
},
"6": {
"minTileRow": 1,
"maxTileRow": 64,
"minTileRow": 7,
"maxTileRow": 56,
"minTileCol": 0,
"maxTileCol": 64
"maxTileCol": 63
},
"7": {
"minTileRow": 3,
"maxTileRow": 128,
"minTileRow": 14,
"maxTileRow": 113,
"minTileCol": 0,
"maxTileCol": 128
"maxTileCol": 127
},
"8": {
"minTileRow": 7,
"maxTileRow": 256,
"minTileRow": 28,
"maxTileRow": 227,
"minTileCol": 0,
"maxTileCol": 256
"maxTileCol": 255
},
"9": {
"minTileRow": 15,
"maxTileRow": 512,
"minTileRow": 57,
"maxTileRow": 454,
"minTileCol": 0,
"maxTileCol": 512
"maxTileCol": 511
},
"10": {
"minTileRow": 31,
"maxTileRow": 1024,
"minTileRow": 114,
"maxTileRow": 909,
"minTileCol": 0,
"maxTileCol": 1024
"maxTileCol": 1023
},
"11": {
"minTileRow": 62,
"maxTileRow": 2048,
"minTileRow": 229,
"maxTileRow": 1818,
"minTileCol": 0,
"maxTileCol": 2048
"maxTileCol": 2047
},
"12": {
"minTileRow": 125,
"maxTileRow": 4096,
"minTileRow": 459,
"maxTileRow": 3636,
"minTileCol": 0,
"maxTileCol": 4096
"maxTileCol": 4095
},
"13": {
"minTileRow": 2739,
"maxTileRow": 4628,
"minTileCol": 41,
"maxTileCol": 7917
"minTileRow": 919,
"maxTileRow": 7272,
"minTileCol": 0,
"maxTileCol": 8191
},
"14": {
"minTileRow": 5478,
"maxTileRow": 9256,
"minTileCol": 82,
"maxTileCol": 15835
"minTileRow": 1839,
"maxTileRow": 14544,
"minTileCol": 0,
"maxTileCol": 16383
},
"15": {
"minTileRow": 10956,
"maxTileRow": 18513,
"minTileCol": 165,
"maxTileCol": 31670
"minTileRow": 3678,
"maxTileRow": 29089,
"minTileCol": 0,
"maxTileCol": 32767
},
"16": {
"minTileRow": 21912,
"maxTileRow": 37026,
"minTileCol": 330,
"maxTileCol": 63341
"minTileRow": 7357,
"maxTileRow": 58178,
"minTileCol": 0,
"maxTileCol": 65535
},
"17": {
"minTileRow": 43825,
"maxTileRow": 74052,
"minTileCol": 660,
"maxTileCol": 126683
"minTileRow": 14714,
"maxTileRow": 116357,
"minTileCol": 0,
"maxTileCol": 131071
},
"18": {
"minTileRow": 87648,
"maxTileRow": 148111,
"minTileCol": 1312,
"maxTileCol": 253375
"minTileRow": 29428,
"maxTileRow": 232715,
"minTileCol": 0,
"maxTileCol": 262143
},
"19": {
"minTileRow": 175296,
"maxTileRow": 294063,
"minTileCol": 170144,
"maxTileCol": 343487
},
"20": {
"minTileRow": 357008,
"maxTileRow": 384687,
"minTileCol": 524400,
"maxTileCol": 540927
},
"21": {
"minTileRow": 714032,
"maxTileRow": 768783,
"minTileCol": 1048816,
"maxTileCol": 1081775
"minTileRow": 58856,
"maxTileRow": 465431,
"minTileCol": 0,
"maxTileCol": 524287
}
}
}
Expand Down
38 changes: 33 additions & 5 deletions packages/Geographic/src/Extent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,21 @@ class Extent {
return Extent.intersectsExtent(this, extent);
}

/**
* Tests whether two extents intersect.
*
* This method checks if the geographic extents `extentA` and `extentB`
* overlap. If their coordinate reference systems (CRS) differ, `extentB`
* is reprojected into the CRS of `extentA` before performing the test.
*
* Extents that touch at an edge or a corner aren't treated as intersecting.
*
* @param extentA - The reference extent.
* @param extentB - The extent to test against.
*
* @returns `true` if the extents intersect, `false` otherwise.
*/
static intersectsExtent(extentA: Extent, extentB: Extent) {
// TODO don't work when is on limit
const other = extentB.crs == extentA.crs ? extentB : extentB.as(extentA.crs, _extent);
return !(extentA.west >= other.east ||
extentA.east <= other.west ||
Expand All @@ -310,16 +323,29 @@ class Extent {

/**
* Returns the intersection of this extent with another one.
* @param extent - extent to intersect
*
* This method computes the overlapping region between this extent and
* another extent. If their coordinate reference systems (CRS) differ,
* the other extent is reprojected into the CRS of this extent before
* performing the intersection.
*
*
* @param extent - The extent to intersect with this one.
* @param target - The target extent to store the result. If not provided,
* a new extent will be created.
*
* @returns The intersection extent
* (may be empty if extents do not intersect).
*/
intersect(extent: Extent) {
intersect(extent: Extent, target = new Extent(this.crs)) {
if (!this.intersectsExtent(extent)) {
return new Extent(this.crs);
return target;
}
if (extent.crs != this.crs) {
extent = extent.as(this.crs, _extent);
}
return new Extent(this.crs,

return target.set(
Math.max(this.west, extent.west),
Math.min(this.east, extent.east),
Math.max(this.south, extent.south),
Expand Down Expand Up @@ -432,6 +458,8 @@ class Extent {
this.north = north;
}
}

return this;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions packages/Geographic/test/unit/extent.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ describe('Extent', function () {
assert.ok(withValues.intersectsExtent(inter));
});

it('intersectsExtent should return false when extents touch at edges -------', () => {
const a = new Extent('EPSG:4326', 0, 10, 0, 10);
const b = new Extent('EPSG:4326', 10, 20, 0, 10);

assert.strictEqual(Extent.intersectsExtent(a, b), false);
});

it('intersectsExtent should return false when extents touch at corners', () => {
const a = new Extent('EPSG:4326', 0, 10, 0, 10);
const b = new Extent('EPSG:4326', 10, 20, 10, 20);

assert.strictEqual(Extent.intersectsExtent(a, b), false);
});

it('should intersect like expected', function () {
const withValues = new Extent('EPSG:4326', minX, maxX, minY, maxY);
const extent = new Extent('EPSG:4326', minX + 1, maxX - 1, maxY - 1, maxY + 2);
Expand Down
2 changes: 1 addition & 1 deletion packages/Main/src/Core/Picking.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export default {
pickObjectsAt(view, viewCoords, radius, object, target = []) {
// Raycaster use NDC coordinate
view.viewToNormalizedCoords(viewCoords, normalized);
if (radius < 0) {
if (radius === 0) {
raycaster.setFromCamera(normalized, view.camera3D);

const intersects = raycaster.intersectObject(object, true);
Expand Down
Loading
Loading