-
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: add fromUrl, support [email protected]+ #11
- Loading branch information
Showing
6 changed files
with
221 additions
and
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,22 +35,30 @@ import TIFFImageryProvider from 'tiff-imagery-provider'; | |
|
||
const cesiumViewer = new Viewer("cesiumContainer"); | ||
|
||
const provider = new TIFFImageryProvider({ | ||
const provider = await TIFFImageryProvider.fromUrl({ | ||
url: 'https://oin-hotosm.s3.amazonaws.com/56f9b5a963ebf4bc00074e70/0/56f9c2d42b67227a79b4faec.tif', | ||
}); | ||
|
||
cesiumViewer.imageryLayers.addImageryProvider(provider); | ||
``` | ||
|
||
You can also use the New keyword to create a new TIFFimageryProvider, which was deprecated after [email protected]+ | ||
|
||
```ts | ||
const provider = new TIFFImageryProvider({ | ||
url: YOUR_TIFF_URL, | ||
}); | ||
provider.readyPromise.then(() => { | ||
cesiumViewer.imageryLayers.addImageryProvider(provider); | ||
}) | ||
|
||
``` | ||
|
||
If TIFF's projection is not EPSG:4326, you can pass the ``projFunc`` to handle the projection | ||
|
||
```ts | ||
import proj4 from 'proj4'; | ||
|
||
new TIFFImageryProvider({ | ||
url: YOUR_TIFF_URL, | ||
TIFFImageryProvider.fromUrl(YOUR_TIFF_URL, { | ||
projFunc: (code) => { | ||
if (code === 32760) { | ||
proj4.defs("EPSG:32760", "+proj=utm +zone=60 +south +datum=WGS84 +units=m +no_defs +type=crs"); | ||
|
@@ -64,8 +72,7 @@ Band calculation | |
|
||
```ts | ||
// NDVI | ||
new TIFFImageryProvider({ | ||
url: YOUR_TIFF_URL, | ||
TIFFImageryProvider.fromUrl(YOUR_TIFF_URL, { | ||
renderOptions: { | ||
single: { | ||
colorScale: 'rainbow', | ||
|
@@ -93,7 +100,8 @@ class TIFFImageryProvider { | |
} | ||
|
||
interface TIFFImageryProviderOptions { | ||
url: string | File | Blob; | ||
/** Deprecated */ | ||
url?: string | File | Blob; | ||
requestOptions?: { | ||
/** defaults to false */ | ||
forceXHR?: boolean; | ||
|
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 |
---|---|---|
|
@@ -35,22 +35,31 @@ import TIFFImageryProvider from 'tiff-imagery-provider'; | |
|
||
const cesiumViewer = new Viewer("cesiumContainer"); | ||
|
||
const provider = new TIFFImageryProvider({ | ||
const provider = await TIFFImageryProvider.fromUrl({ | ||
url: 'https://oin-hotosm.s3.amazonaws.com/56f9b5a963ebf4bc00074e70/0/56f9c2d42b67227a79b4faec.tif', | ||
}); | ||
|
||
cesiumViewer.imageryLayers.addImageryProvider(provider); | ||
|
||
``` | ||
|
||
也可以使用New关键字新建一个TIFFimageryProvider,但是在[email protected]+之后被弃用 | ||
|
||
```ts | ||
const provider = new TIFFImageryProvider({ | ||
url: YOUR_TIFF_URL, | ||
}); | ||
provider.readyPromise.then(() => { | ||
cesiumViewer.imageryLayers.addImageryProvider(provider); | ||
}) | ||
|
||
``` | ||
|
||
如果TIFF的投影不是EPSG:4326,您可以传递``projFunc``来处理投影 | ||
如果 TIFF 的投影不是 EPSG:4326,你可以通过 ``projFunc`` 来处理投影 | ||
|
||
```ts | ||
import proj4 from 'proj4'; | ||
|
||
new TIFFImageryProvider({ | ||
url: YOUR_TIFF_URL, | ||
TIFFImageryProvider.fromUrl(YOUR_TIFF_URL, { | ||
projFunc: (code) => { | ||
if (code === 32760) { | ||
proj4.defs("EPSG:32760", "+proj=utm +zone=60 +south +datum=WGS84 +units=m +no_defs +type=crs"); | ||
|
@@ -64,8 +73,7 @@ new TIFFImageryProvider({ | |
|
||
```ts | ||
// NDVI | ||
new TIFFImageryProvider({ | ||
url: YOUR_TIFF_URL, | ||
TIFFImageryProvider.fromUrl(YOUR_TIFF_URL, { | ||
renderOptions: { | ||
single: { | ||
colorScale: 'rainbow', | ||
|
@@ -93,7 +101,8 @@ class TIFFImageryProvider { | |
} | ||
|
||
interface TIFFImageryProviderOptions { | ||
url: string | File | Blob; | ||
/** 已弃用 */ | ||
url?: string | File | Blob; | ||
requestOptions?: { | ||
/** 默认 false */ | ||
forceXHR?: boolean; | ||
|
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
Oops, something went wrong.
8ce6a81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
tiff-imagery-provider-example – ./
tiff-imagery-provider-example-git-main-hongfaqiu.vercel.app
tiff-imagery-provider-example.vercel.app
tiff-imagery-provider-example-hongfaqiu.vercel.app