-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Typescript definitions #59
base: master
Are you sure you want to change the base?
Conversation
@@ -43,7 +46,7 @@ | |||
"dependencies": { | |||
"cross-fetch": "^3.0.4", | |||
"georaster-to-canvas": "0.2.0", | |||
"geotiff": "1.0.0-beta.13", | |||
"geotiff": "file://../geotiff", |
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.
errant commit, this needs to be removed before merging
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.
Left some small comments. Awesome you included a test/types.ts
!
/** defines the new raster image to generate as a window in the source raster image. Resolution (cell size) is determined from this */ | ||
export interface WindowOptions { | ||
/** left side of the image window in pixel coordinates */ | ||
left: number |
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.
do these need commas or semicolons at the end of the lines?
* If the window options do not align exactly with the source image then a new | ||
* one is generated using the resampleMethod. The best available overview will | ||
* also be used if they are available. */ | ||
getValues?: (options: WindowOptions) => Promise<TypedArray[][]>; |
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.
I think it returns a 3D array like [band][row][column], so should be Promise<TypedArray[][][]>
* also be used if they are available. */ | ||
getValues?: (options: WindowOptions) => Promise<TypedArray[][]>; | ||
/** experimental! returns a canvas picture of the data. */ | ||
toCanvas: (options: { height?: number; width?: number }) => ImageData |
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.
This function basically calls https://github.com/GeoTIFF/georaster-to-canvas/blob/master/index.js. It returns the canvas created by document.createElement("CANVAS");
here. Is there a way to specify an HTML Canvas Element with TypeScript?
toCanvas: (options: { height?: number; width?: number }) => ImageData | ||
} | ||
|
||
export type GeorasterMetadata = Pick< |
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.
I haven't used Pick
before. So will this include xmax
and ymin
as optional arguments?
Hey. I saw this nifty line in https://github.com/geotiffjs/geotiff.js/pull/253/files: |
Hi @DanielJDufour , thank you for this great library. I am experiencing an issue with using this library with typescript, as it is a requirement for georaster for leaflet. Error: I would appreciate any solution to this. Thanks! |
Got rid of the error by creating a new file |
Hi, @jeafreezy . Great to hear you are making use of GeoRasterLayer. I think you might be able to solve your problems by creating a declarations.d.ts file and adding a line that says I also wanted to apologize for taking so long with reviewing this PR. I want to say that adding types is definitely a priority for me. Unfortunately, I find myself trying to push a new major georaster upgrade across the goal line (improved accuracy and support for .asc, .jpg, .png, .prj, .wld). As soon as I'm done with that, I promise types will get more attention. Basically, I'm afraid if I lose focus on the new major georaster upgrade, it will be another several years till it happens. I hope that makes sense. And I really am sorry for the inconvenience and frustration this causes. |
Hi @DanielJDufour , thank you for the hint! It worked very well. Wish you the best in pushing the major upgrade! |
Goal - add Typescript definitions.
Details:
parseGeoraster() method and the
Georaster` object it returns.Testing: