Skip to content
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

Implement geo upload #47

Open
wants to merge 247 commits into
base: master
Choose a base branch
from
Open

Implement geo upload #47

wants to merge 247 commits into from

Conversation

mtiessen1175
Copy link
Collaborator

@mtiessen1175 mtiessen1175 commented Nov 30, 2023

references #44

Implement the structure for the upload mechanism in the volume-edit view. Allow the upload of both - browsing layers and context layers - i.e. upload of geoTIFF and (iFDO) metadata, linkage of WMS.

  • Additional layers can be added in the volume edit view
  • An additional layer can be a georeferenced file (geoTIFF) or a link to a WMS source
    • geoTIFF upload done (but should be tested more thoroughly by adding more example .tif files, e.g. a geoTIFF using the ModelTransformationTag. Corresponding code implemented here. Update: Tests fully cover this case; see commits cafb808 and bb6b2c6)
    • WMS
  • Layers can be ordered in the volume edit view
  • Each layer can either be a "browsing layer" (Geospatial browsing visualisation #44) or a "context layer" or both
  • The filter-map shows all configured "browsing" layers
  • Option to upload the full image extent as metadata (also from iFDO, see Geospatial context fusion display #45)

associated PR's:

Base automatically changed from browsing_vis to master December 8, 2023 14:43
@mzur
Copy link
Member

mzur commented Oct 23, 2024

This is most certainly due to the transformation error in the proj4php package, as discussed #47 (comment).

Did you find the overlay? Where do I have to look? 😃

Yes, I created a normalization of the color-band (as geoTIFF's often contain more color-information that can be set/adjusted manually by the user). So the #47 (comment) solution for now was to normalize the color-band to 0 - 255 in case it differs from that range (see code).

I saw that but I expected this to produce something else than the black/white image. There is no 0-255 range in the tiled image, just 0 and 255.

@mtiessen1175
Copy link
Collaborator Author

Did you find the overlay? Where do I have to look? 😃

Ahh, yeah it is a fairly small example-TIFF! The coordinates in EPSG:3857 are: -325165.2, 7779955.1 (Loch Davan close to Dinnet, Scotland)

I saw that but I expected this to produce something else than the black/white image. There is no 0-255 range in the tiled image, just 0 and 255.

I see, so I should check what goes wrong in the normalization.

@mtiessen1175
Copy link
Collaborator Author

I saw that but I expected this to produce something else than the black/white image. There is no 0-255 range in the tiled image, just 0 and 255.

I see, so I should check what goes wrong in the normalization.

The formula used for image normalization should be working. It seems that the derived min- and max-values from libvips are not providing the correct min/max colour-band values as I expected them to be (i.e. they are different to what I see in the QGIS colour settings). Moreover, I tested with two different geoTIFF's and surprisingly the min/max of the two geoTIFF's were identical (min: -3.4028230607371E+38, max: 162.15870666504).
So I need to find a different approach to get the min/max colour-value information from the image.

@mzur
Copy link
Member

mzur commented Oct 31, 2024

You should try it with the Vips CLI too. If this does not show the expected values you can ask in the Vips repo. The maintainer is extremely responsive and helpful if you provide a good description of the problem and an example file.

@mtiessen1175
Copy link
Collaborator Author

You should try it with the Vips CLI too. If this does not show the expected values you can ask in the Vips repo. The maintainer is extremely responsive and helpful if you provide a good description of the problem and an example file.

I tried with the CLI and get the correct max() value but an incorrect min(). This must be due to the NoData values of the geoTIFF images (the black frame around the geoTIFF when converting it to an image). So the min() always returns this value (e.g. -99999) instead of the desired min-value (e.g. -4123.31).

@mzur
Copy link
Member

mzur commented Nov 5, 2024

(please use @mzur, otherwise I don't get notified of activity here)

If this can be fixed by creating the geoTIFF in any other way then we could add an explanation to the manual and just expect geoTIFFs with the correct format. Then there is no need for special handling of edge cases (for now).

@mzur
Copy link
Member

mzur commented Nov 6, 2024

I tested the WMS now and it works fine.

I noticed an error on the geo map of a volume (not the map in the filter modal). When I open the label trees tab there, it says Error in event handler for "sidebar.toggle": "TypeError: this.map is undefined".

@mtiessen1175
Copy link
Collaborator Author

@mzur,

If this can be fixed by creating the geoTIFF in any other way then we could add an explanation to the manual and just expect geoTIFFs with the correct format. Then there is no need for special handling of edge cases (for now).

I've implemented the color normalization such that NoData values of -99999 will get excluded in order to calculate the true min (see conversation on libvips discussion). I therefore would add an excerpt to the manual stating that color-band normalization should either be done beforehand or the NoData values of the geoTIFF should be set to -99999 in order to be handled correctly by BIIGLE.

@mzur
Copy link
Member

mzur commented Nov 12, 2024

Sounds good 👍

@mtiessen1175
Copy link
Collaborator Author

@mzur,

I noticed an error on the geo map of a volume (not the map in the filter modal). When I open the label trees tab there, it says Error in event handler for "sidebar.toggle": "TypeError: this.map is undefined".

That's fixed now.

When I upload a GeoTIFF, I get JS errors (see below). The upload seems to succeed, though.

14:31:59.876 [Vue warn]: $listeners is readonly.

found in

---> <Portal>
       <Tab>
         <Tabs>
           <Root> volumes.js:3924:15 

Regarding the latter, I tried to find where the warning is coming from by debugging the code, but I couldn't figure out what causes it. It is still unclear to me...

  1. where the readonly is allegedly violated and
  2. to what kind of object the attributes refer to

I looked into the whole upload process of the geoTIFF files, comprised of:

and

commenting lines step by step to see where the warning stems from, but it's still not obvious to me. Do you have any idea or instinct what could cause such warning?

@mzur
Copy link
Member

mzur commented Dec 3, 2024

The error came from the Portal component which is used by the uiv Tab. The portal imports Vue but since biigle/geo compiles it's own JS package, this was a separate Vue instance than the one of biigle/core, which caused the error. To fix this, biigle/geo now uses the Tab and Tabs components exported from biigle/core, which use the correct Vue instance.

The issue is described here: LinusBorg/portal-vue#201

@mtiessen1175
Copy link
Collaborator Author

The error came from the Portal component which is used by the uiv Tab. The portal imports Vue but since biigle/geo compiles it's own JS package, this was a separate Vue instance than the one of biigle/core, which caused the error. To fix this, biigle/geo now uses the Tab and Tabs components exported from biigle/core, which use the correct Vue instance.

The issue is described here: LinusBorg/portal-vue#201

Thanks for the help and clarification on this issue! 👍

@mtiessen1175 mtiessen1175 requested a review from mzur December 4, 2024 12:24
@@ -46,7 +42,7 @@ export default {
data.append('volumeId', this.volumeId);
geoApi.saveWebMap({id: this.volumeId}, data)
.then(this.handleSuccess, this.handleError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently get a 500 server error if the WMS URL is invalid.

  1. The 500 error should not occur. instead it should return a 422 validation error.
  2. Even if a 500 occurs, an error message should be shown in the UI.

@@ -104,7 +104,7 @@ protected function getVipsImage($path)
*/
protected function imageNormalization($vipsImage, $min, $max)
{
// band intensity normalization x' = (x - $min * (255 / ($max - $min))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still get only black&white tiles.

BIIGLE:
image

QGIS:
image

Is this because of the "incorrect" preprocessing of the TIFF we talked about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the position is also not 100% correct but I guess this is the error we talked about and which can't be fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This produces undesired console output from processing actual files. Maybe this can be mocked?

Comment on lines +31 to +34
$table->foreign('volume_id')
->references('id')
->on('volumes')
->onDelete('cascade');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need an event handler/observer that deletes the geo overlay files when the whole volume or project is deleted.

@@ -40,10 +40,14 @@ public function boot(Modules $modules, Router $router)
'viewMixins' => [
'imagesIndex',
'manualTutorial',
'manualVolumes',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not manualVolumes mixin location on the manual index page. It can be added in biigle/core#725, though.

There is also the volume-map manual article. The description of the geo filter there is no longer correct.

Comment on lines +55 to +57
$router->get('geo-overlays/{id}/file', [
'uses' => 'GeoOverlayController@showFile',
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

Comment on lines +14 to +30
$faker = \Faker\Factory::create();
$model = new GeoOverlay;
$model->name = $faker->company();
$model->volume_id = VolumeTest::create()->id;
$model->type = 'geotiff';
$model->browsing_layer = false;
$model->context_layer = false;
$model->layer_index = null;
$model->attrs = [
'top_left_lng' => $faker->randomFloat(),
'top_left_lat' => $faker->randomFloat(),
'bottom_right_lng' => $faker->randomFloat(),
'bottom_right_lat' => $faker->randomFloat(),
'width' => $faker->randomNumber(),
'height' => $faker->randomNumber()
];
$model->save();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better define a factory for the model.

Comment on lines +79 to +81
$model = self::createGeotiffOverlay();
$model->volume->delete();
$this->assertNull($model->fresh());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also test if the overlay files are removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are quite slow because they process actual files. Maybe this can also be mocked (e.g. implement a method "read exif" that returns static data in the test without opening an actual file)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that this test does not actually send HTTP requests!

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 this pull request may close these issues.

Geospatial browsing visualisation
2 participants