-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reproject any projection coords #18
- Loading branch information
Showing
13 changed files
with
734 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/TIFFImageryProvider/src/TIFFImageryProviderTilingScheme.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
Cartesian2, | ||
Cartographic, | ||
Math as CMath, | ||
Rectangle, | ||
WebMercatorTilingScheme, | ||
} from 'cesium'; | ||
|
||
import { | ||
Cartesian3, | ||
Ellipsoid, | ||
} from 'cesium'; | ||
|
||
class TIFFImageryProviderTilingScheme extends WebMercatorTilingScheme { | ||
constructor(options?: { | ||
ellipsoid?: Ellipsoid; | ||
numberOfLevelZeroTilesX?: number; | ||
numberOfLevelZeroTilesY?: number; | ||
rectangleSouthwestInMeters?: Cartesian2; | ||
rectangleNortheastInMeters?: Cartesian2; | ||
project?: (pos: number[]) => number[]; | ||
unproject?: (pos: number[]) => number[]; | ||
}) { | ||
super(options); | ||
|
||
const { project, unproject } = options; | ||
if (project) { | ||
// @ts-ignore | ||
this._projection.project = function (cartographic: Cartographic) { | ||
const [x, y] = unproject([cartographic.longitude, cartographic.latitude].map(CMath.toDegrees)) | ||
const z = cartographic.height; | ||
return new Cartesian3(x, y, z); | ||
}; | ||
} | ||
if (unproject) { | ||
// @ts-ignore | ||
this._projection.unproject = function (cartesian: Cartesian3) { | ||
const [longitude, latitude] = project([cartesian.x, cartesian.y]).map(CMath.toRadians) | ||
const height = cartesian.z; | ||
return new Cartographic(longitude, latitude, height); | ||
}; | ||
} | ||
|
||
const southwest = this.projection.unproject( | ||
options.rectangleSouthwestInMeters as any | ||
); | ||
const northeast = this.projection.unproject( | ||
options.rectangleNortheastInMeters as any | ||
); | ||
// @ts-ignore | ||
this._rectangle = new Rectangle( | ||
southwest.longitude, | ||
southwest.latitude, | ||
northeast.longitude, | ||
northeast.latitude | ||
); | ||
} | ||
} | ||
|
||
export default TIFFImageryProviderTilingScheme; |
Oops, something went wrong.