Skip to content

Metadata values are ignored when loading COG from URL #83

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

Open
NoamRa opened this issue Aug 28, 2023 · 3 comments · May be fixed by #96
Open

Metadata values are ignored when loading COG from URL #83

NoamRa opened this issue Aug 28, 2023 · 3 comments · May be fixed by #96

Comments

@NoamRa
Copy link

NoamRa commented Aug 28, 2023

Describe the bug
When loading a COG from URL, metadata values are not used. This might be intentional, but there is nothing in the documentation indicate that that's the case.

To Reproduce
Steps to reproduce the behavior:

  • Add break point in GeoRaster's constructor
  • Call parseGeoraster(https://path.to/cog.tiff, { projection: "example" })

Expected behavior
Metadata is expected to be used. When parseGeoraster's input is an ArrayBuffer, it is used.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • Version: 116

Additional context
I see that there are other types of inputs where metadata is not passed as well.

@DanielJDufour
Copy link
Member

Hi, @NoamRa . I'm terribly sorry about the late reply. This is an important issue that you bring up and is certainly something that should be addressed. I'm a bit tight on time at the moment, so a solution might take some time. Would you be interested in submitting a PR?

Otherwise, I think an interim solution would be to over-ride the values after they are returned by parseGeoRaster, so that:

const georaster = await parseGeoraster(url);
georaster.projection = 3857; // or whatever projection

Also, are you needing to override the projection field with a standard EPSG code or a custom projection via PROJ4 String
or WKT? I'm asking because if you are trying custom projections, I can prioritize adding custom projection support to the other family of libraries that work with georaster, as well.

Thank you.

@Truffula
Copy link

I've noticed a similar issue with other construction methods; if I pass in a file that doesn't have embedded projection type in a Blob format, it fails (beginning here with base64 encoded version of the tiff):

const blob = new Blob([
  Uint8Array.from(atob(tiffString), (c) => c.charCodeAt(0)),
]);
const georaster = await window.parseGeoraster(
  blob,
  { projection: 4326 }
);

but the same data wrapped in an ArrayBuffer is fine:

const tiffArray = Uint8Array.from(atob(tiffString), (c) => c.charCodeAt(0));
const buffer = new ArrayBuffer(tiffArray.length);
const view = new Uint8Array(buffer);
view.set(tiffArray);
const georaster = await window.parseGeoraster(
  buffer,
  { projection: 4326 }
);

I think in all of these cases, setting this._metadata = metadata; should solve the issue.

Truffula pushed a commit to Truffula/georaster that referenced this issue Apr 28, 2025
Truffula pushed a commit to Truffula/georaster that referenced this issue Apr 29, 2025
@Truffula
Copy link

Raised PR #96 to fix

@Truffula Truffula linked a pull request Apr 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants