-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add load river command and use triggers (#226)
* add load river command * use pg triggers * use pg triggers * use pg triggers * use pg triggers * use pg triggers * use pg triggers * use pg triggers * use pg triggers * use pg triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * use internal triggers * fix command * lint
- Loading branch information
Showing
27 changed files
with
277 additions
and
134 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
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 |
---|---|---|
|
@@ -20,7 +20,6 @@ services: | |
|
||
web: | ||
image: georiviere:latest | ||
user: $UID:$GID | ||
build: | ||
context: . | ||
target: dev | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,19 @@ | ||
from geotrek.altimetry.models import AltimetryMixin as BaseAltimetryMixin | ||
|
||
from georiviere.functions import ElevationInfos, Length3D | ||
from geotrek.common.mixins import TimeStampedModelMixin | ||
|
||
|
||
class AltimetryMixin(BaseAltimetryMixin): | ||
class Meta: | ||
abstract = True | ||
def refresh(self): | ||
# Update object's computed values (reload from database) | ||
if self.pk: | ||
fromdb = self.__class__.objects.get(pk=self.pk) | ||
BaseAltimetryMixin.reload(self, fromdb) | ||
TimeStampedModelMixin.reload(self, fromdb) | ||
return self | ||
|
||
def save(self, *args, **kwargs): | ||
super().save(*args, **kwargs) | ||
elevation_infos = self._meta.model.objects.filter(pk=self.pk) \ | ||
.annotate(infos=ElevationInfos('geom')).first().infos | ||
draped_geom = elevation_infos.get('draped') | ||
self.geom_3d = draped_geom | ||
self.slope = elevation_infos.get('slope') | ||
self.min_elevation = elevation_infos.get('min_elevation') | ||
self.max_elevation = elevation_infos.get('max_elevation') | ||
self.ascent = elevation_infos.get('positive_gain') | ||
self.descent = elevation_infos.get('negative_gain') | ||
compute_results = self._meta.model.objects.filter(pk=self.pk) \ | ||
.annotate(length_3d=Length3D(draped_geom)).first() | ||
self.length = compute_results.length_3d | ||
super().save(force_insert=False, | ||
update_fields=[ | ||
'geom_3d', | ||
'slope', | ||
'min_elevation', | ||
'max_elevation', | ||
'ascent', | ||
'descent', | ||
'length' | ||
]) | ||
self.refresh() | ||
|
||
class Meta: | ||
abstract = True |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TRIGGER description_morphology_10_elevation | ||
BEFORE INSERT OR UPDATE OF geom ON description_morphology | ||
FOR EACH ROW EXECUTE PROCEDURE elevation(); | ||
|
||
CREATE TRIGGER description_status_10_elevation | ||
BEFORE INSERT OR UPDATE OF geom ON description_status | ||
FOR EACH ROW EXECUTE PROCEDURE elevation(); | ||
|
||
CREATE TRIGGER description_land_10_elevation | ||
BEFORE INSERT OR UPDATE OF geom ON description_land | ||
FOR EACH ROW EXECUTE PROCEDURE elevation(); | ||
|
||
CREATE TRIGGER description_usage_10_elevation | ||
BEFORE INSERT OR UPDATE OF geom ON description_usage | ||
FOR EACH ROW EXECUTE PROCEDURE elevation(); |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE description_morphology ALTER COLUMN full_edge_height SET DEFAULT 0.0; | ||
ALTER TABLE description_morphology ALTER COLUMN full_edge_width SET DEFAULT 0.0; | ||
ALTER TABLE description_morphology ALTER COLUMN description SET DEFAULT ''; |
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.