-
Notifications
You must be signed in to change notification settings - Fork 1
Implement geo upload #47
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
base: master
Are you sure you want to change the base?
Changes from 247 commits
2bcd8f1
95f256d
a22e711
16384a7
b2ffaa0
b87f144
7423087
17971e7
812c679
59037c5
0bdcede
9a6e582
f610d9c
20dd573
dac2b90
eeec97d
4c275d0
4b7db07
c8357cd
b625dd9
9962c3f
e204d41
fcce5e7
00e7763
f0a4534
e9a926e
7f8fcf9
595afc2
3314db6
2e75f7b
0bdd8b3
cb36b79
8f5fbe2
3b95d67
5d0fe0a
315bf5f
b6bece4
4dced87
09021a3
7183b3a
2f3aad2
e1b886e
f84424f
76414ed
c98ba36
334c055
4456838
52ac92e
18cc1f5
92fda9d
bccb8f8
2e5375e
45cce08
23e2303
0004396
4433927
1b29c3a
0430626
3b5a053
9344032
94026c9
14c860e
5068124
1bdd326
6cb855a
709dd35
a5377d2
b418cdf
6e93fa5
4286ddf
c4b77ec
b088e30
3fde9e3
01f15bb
17158dc
d138785
1e058c5
2ea490d
2f00871
ed23e26
95cda2d
6eddc05
eb61721
7d6e60d
22fff4a
4d4a955
418fb0f
03b1671
9f7a998
3875e27
6262cf9
fec0e71
4104659
f02ca5c
f0fcdb1
4882b68
8c5fa95
3b2ca76
1e403c5
f4fc9a9
05438e6
e25d866
35d91d8
9a9306c
198c930
a88482a
4f168c3
3853945
726c649
cae81ee
7f44d6c
635e389
8dab21a
c122b1a
e884aac
af3f3a7
7394749
4f8ea8d
833e2a2
c7e8d8c
46e46cc
c49dc8c
9cfc300
d47dbe7
7b0d50c
ff6e8a7
fc1cdb8
c0a7c1e
acf2f38
246d839
87c32a6
b7ac7e7
adfa120
ae8620d
cb7b480
e88a630
a9d4a0b
5b294dc
d972cdc
61ecf6f
7f4b1a7
cbf1442
4dedfa9
d052b3b
61b8ea2
5f3cca7
aaf2237
131a9cc
e08882c
b6b1a0c
8175665
5fa0e0f
0b50064
beb1f61
bd420aa
4500fb0
5c46347
88910df
1cc80f7
13cf3b4
5c2e399
dafbbb9
d7abc11
d0bc924
a291654
9acd9ca
e45ad44
e8730e8
65e7d5a
4ecda53
59892eb
c3ef007
f0d164e
7654a07
644b930
bb2b791
2279818
3aefd31
bac8d09
7201227
816201c
6b657ef
bd402e5
887693b
5b0e3aa
4477abf
170a6e7
7d3d670
be13391
ced9e91
7057537
62e7279
e5ed3d3
d4bb956
e7ebfa9
5b7c9dc
789f7cd
bf82222
a08a6ab
dc52f9f
235cfcb
7e2cf63
5479281
b8e2bfb
ce4cbcd
ee74db1
59251f0
91a80df
b902e54
7f50560
871f9e6
c288d49
527ad00
45d0920
4afe9ea
d0895a6
4c1035a
4a69c1c
b1aee4a
eae3d61
cc1f192
a58cacb
96a29b7
002fa63
e674b2d
fe7e4ec
7251ef5
ce25ce0
cf30104
3cd6a28
ce66e66
910f7ce
33bcd4c
6518f59
8ebd72c
7036586
ab0d58f
ade2258
838bf69
81384fa
623831c
1871f3c
393e864
c7509ed
1ede709
a719500
c0e5fd1
dcf5eca
981463b
b965a7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| namespace Biigle\Modules\Geo\Console\Commands; | ||
|
|
||
| use Biigle\Modules\Geo\GeoServiceProvider as ServiceProvider; | ||
| use Illuminate\Console\Command; | ||
|
|
||
| class Config extends Command | ||
| { | ||
| /** | ||
| * The console command name. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $name = 'geo:config'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $description = 'Publish the config file for this module'; | ||
|
|
||
| /** | ||
| * Execute the command. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function handle() | ||
| { | ||
| $this->call('vendor:publish', [ | ||
| '--provider' => ServiceProvider::class, | ||
| '--tag' => ['config'], | ||
| '--force' => true, | ||
| ]); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| class AddGeoOverlaysTable extends Migration | ||
| { | ||
| /** | ||
| * Run the migrations. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function up() | ||
| { | ||
| /* | ||
| | A geo overlay is an image that can be placed on a world map. This can be a | ||
| | bathymetric map of the area where a specific volume was recorded. Geo overlays | ||
| | can be uploaded by volume admins and are displayed on the volume geo view. | ||
| | Each overlay consists of an image and the geospatial information where the | ||
| | image should be displayed on the world map. While the input format can vary | ||
| | the geospatial information will always be converted to the latitude and | ||
| | longitude of the top left and bottom right corners of the image in WGS 84 | ||
| | (EPSG:4326). | ||
| */ | ||
| Schema::create('geo_overlays', function (Blueprint $table) { | ||
| $table->increments('id'); | ||
| // A short description of the overlay. | ||
| $table->string('name', 512); | ||
| $table->integer('volume_id')->unsigned()->index(); | ||
| $table->foreign('volume_id') | ||
| ->references('id') | ||
| ->on('volumes') | ||
| ->onDelete('cascade'); | ||
| $table->string('type', 10)->nullable(); | ||
| $table->boolean('browsing_layer')->default(0); | ||
| $table->boolean('context_layer')->default(0); | ||
| // the position of the overlay (can be set by the user) in case of mutliple uploaded overlays in the same volume | ||
| $table->integer('layer_index')->nullable(); | ||
| // follwoing attributes are possible in attrs-column: | ||
| // if(type == 'geotiff'): 'top_left_lat', 'top_left_lng', 'bottom_right_lat', 'bottom_right_lng', 'width', 'height' | ||
| // if(type == 'webmap'): 'url', 'layers' | ||
| $table->json('attrs')->default('{}'); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Reverse the migrations. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function down() | ||
| { | ||
| Schema::drop('geo_overlays'); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| <?php | ||
|
|
||
| namespace Biigle\Modules\Geo; | ||
|
|
||
| use Illuminate\Database\Eloquent\Model; | ||
| use Illuminate\Http\UploadedFile; | ||
| use Biigle\Volume; | ||
| use Illuminate\Database\Eloquent\Casts\AsArrayObject; | ||
| use Illuminate\Database\Eloquent\Casts\Attribute; | ||
| use Storage; | ||
|
|
||
| class GeoOverlay extends Model | ||
| { | ||
| /** | ||
| * Don't maintain timestamps for this model. | ||
| * | ||
| * @var bool | ||
| */ | ||
| public $timestamps = false; | ||
|
|
||
| /** | ||
| * The attributes hidden in the model's JSON form. | ||
| * | ||
| * @var array | ||
| */ | ||
| protected $hidden = [ | ||
| 'volume_id', | ||
| ]; | ||
|
|
||
| protected $fillable = [ | ||
| 'browsing_layer', | ||
| 'context_layer', | ||
| 'layer_index', | ||
| 'type', | ||
| 'attrs->url', | ||
| 'attrs->layers', | ||
| 'attrs->top_left_lng', | ||
| 'attrs->top_left_lat', | ||
| 'attrs->bottom_right_lng', | ||
| 'attrs->bottom_right_lat' | ||
| ]; | ||
|
|
||
| /** | ||
| * The attributes that should be casted to native types. | ||
| * | ||
| * @var array | ||
| */ | ||
| protected $casts = [ | ||
| 'attrs' => 'array', | ||
| 'attrs->layers' => 'array' | ||
| ]; | ||
|
|
||
|
|
||
| /** | ||
| * Getter for the attrs json column | ||
| */ | ||
| protected function attrs(): Attribute { | ||
|
|
||
| return Attribute::make( | ||
| get: function (mixed $value): array { | ||
| $value = json_decode($value, true); | ||
| $float_array = ['top_left_lng', 'top_left_lat', 'bottom_right_lng', 'bottom_right_lat']; | ||
|
|
||
| foreach($value as $entry) { | ||
| if (in_array($entry, $float_array)) { | ||
| $value[$entry] = floatval($value[$entry]); | ||
| } | ||
| } | ||
|
|
||
| return $value; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * The "booting" method of the model. | ||
| * | ||
| * @return void | ||
| */ | ||
| protected static function boot() | ||
| { | ||
| parent::boot(); | ||
|
|
||
| // Delete the overlay image file when the model is deleted. | ||
| static::deleting(function ($overlay) { | ||
| Storage::disk(config('geo.tiles.overlay_storage_disk'))->deleteDirectory($overlay->id); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * The volume, this overlay belongs to. | ||
| * | ||
| * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
| */ | ||
| public function volume() | ||
| { | ||
| return $this->belongsTo(Volume::class); | ||
| } | ||
|
|
||
| /** | ||
| * Get the local path to the overlay image file. | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getPathAttribute() | ||
| { | ||
| return "{$this->id}/{$this->id}_original.tif"; | ||
| } | ||
|
|
||
| /** | ||
| * Store the uploaded image file of the geo overlay. | ||
| * | ||
| * @param UploadedFile $file | ||
| */ | ||
| public function storeFile(UploadedFile $file) | ||
| { | ||
| Storage::disk(config('geo.tiles.overlay_storage_disk')) | ||
| ->putFileAs($this->id, $file, "{$this->id}_original.tif"); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,14 @@ public function boot(Modules $modules, Router $router) | |
| 'viewMixins' => [ | ||
| 'imagesIndex', | ||
| 'manualTutorial', | ||
| 'manualVolumes', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is not There is also the |
||
| 'volumesSidebar', | ||
| 'volumesScripts', | ||
| 'projectsShowTabs', | ||
| 'volumesStyles' | ||
| 'volumesStyles', | ||
| 'volumesEditRight', | ||
| 'volumesEditScripts', | ||
| 'volumesEditStyles' | ||
| ], | ||
| 'apidoc' => [__DIR__.'/Http/Controllers/Api/'], | ||
| ]); | ||
|
|
@@ -56,10 +60,18 @@ public function boot(Modules $modules, Router $router) | |
| */ | ||
| public function register() | ||
| { | ||
| $this->mergeConfigFrom(__DIR__.'/config/geo.php', 'geo'); | ||
|
|
||
| $this->app->singleton('command.geo.publish', function ($app) { | ||
| return new \Biigle\Modules\Geo\Console\Commands\Publish(); | ||
| }); | ||
| $this->commands('command.geo.publish'); | ||
|
|
||
|
|
||
| $this->app->singleton('command.geo.config', function ($app) { | ||
| return new \Biigle\Modules\Geo\Console\Commands\Config(); | ||
| }); | ||
| $this->commands('command.geo.config'); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -71,6 +83,7 @@ public function provides() | |
| { | ||
| return [ | ||
| 'command.geo.publish', | ||
| 'command.geo.config', | ||
| ]; | ||
| } | ||
| } | ||
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.
We need an event handler/observer that deletes the geo overlay files when the whole volume or project is deleted.