-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adapt to schema 230 (implicit CRS) #428
Merged
margrietpalm
merged 6 commits into
margriet_implicit_crs
from
margriet_424_adapt_to_schema_230
Dec 24, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ebb2ceb
Change CRS in all tests to 28892
margrietpalm 1bd9129
Disable RasterHasMatchingEPSGCheck (should be fixed in ticket 414)
margrietpalm 5857b60
Fix linting issues
margrietpalm d2d3b5b
Remove geo_query and use explicit queries instead now transformations…
margrietpalm 0c4d6ff
Remove mention on removed transformation from docstring of Connection…
margrietpalm 3c3e8f8
Update changes
margrietpalm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from dataclasses import dataclass | ||
from typing import List, Literal, NamedTuple | ||
|
||
from geoalchemy2.functions import ST_Distance, ST_Length | ||
from sqlalchemy import ( | ||
and_, | ||
case, | ||
|
@@ -19,7 +20,6 @@ | |
|
||
from .base import BaseCheck, CheckLevel | ||
from .cross_section_definitions import cross_section_configuration_for_record | ||
from .geo_query import distance, length, transform | ||
|
||
|
||
class CorrectAggregationSettingsExist(BaseCheck): | ||
|
@@ -290,7 +290,7 @@ def get_invalid(self, session): | |
self.to_check(session) | ||
.join(start_node, start_node.id == self.start_node) | ||
.join(end_node, end_node.id == self.end_node) | ||
.filter(distance(start_node.geom, end_node.geom) < self.min_distance) | ||
.filter(ST_Distance(start_node.geom, end_node.geom) < self.min_distance) | ||
) | ||
return list(q.with_session(session).all()) | ||
|
||
|
@@ -324,7 +324,7 @@ def get_invalid(self, session: Session) -> List[NamedTuple]: | |
f"""SELECT * | ||
FROM connection_node AS cn1, connection_node AS cn2 | ||
WHERE | ||
distance(cn1.geom, cn2.geom, 1) < :min_distance | ||
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. The third argument, use_ellipsoid, is only suported for long/lat coordinates and will return None's for projected. Because from now on only projected should be allowed, this argument is removed. |
||
distance(cn1.geom, cn2.geom) < :min_distance | ||
AND cn1.ROWID != cn2.ROWID | ||
AND cn2.ROWID IN ( | ||
SELECT ROWID | ||
|
@@ -548,10 +548,10 @@ def get_invalid(self, session: Session) -> List[NamedTuple]: | |
linestring = models.Channel.geom | ||
tol = self.min_distance | ||
breach_point = func.Line_Locate_Point( | ||
transform(linestring), transform(func.ST_PointN(self.column, 1)) | ||
linestring, func.ST_PointN(self.column, 1) | ||
) | ||
dist_1 = breach_point * length(linestring) | ||
dist_2 = (1 - breach_point) * length(linestring) | ||
dist_1 = breach_point * ST_Length(linestring) | ||
dist_2 = (1 - breach_point) * ST_Length(linestring) | ||
return ( | ||
self.to_check(session) | ||
.join(models.Channel, self.table.c.channel_id == models.Channel.id) | ||
|
@@ -577,10 +577,8 @@ def get_invalid(self, session: Session) -> List[NamedTuple]: | |
|
||
# First fetch the position of each potential breach per channel | ||
def get_position(point, linestring): | ||
breach_point = func.Line_Locate_Point( | ||
transform(linestring), transform(func.ST_PointN(point, 1)) | ||
) | ||
return (breach_point * length(linestring)).label("position") | ||
breach_point = func.Line_Locate_Point(linestring, func.ST_PointN(point, 1)) | ||
return (breach_point * ST_Length(linestring)).label("position") | ||
|
||
potential_breaches = sorted( | ||
session.query(self.table, get_position(self.column, models.Channel.geom)) | ||
|
@@ -776,7 +774,7 @@ def get_invalid(self, session: Session) -> List[NamedTuple]: | |
self.table.c.id, | ||
self.table.c.area, | ||
self.table.c.geom, | ||
func.ST_Area(transform(self.table.c.geom)).label("calculated_area"), | ||
func.ST_Area(self.table.c.geom).label("calculated_area"), | ||
).subquery() | ||
return ( | ||
session.query(all_results) | ||
|
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Removed these convenience functions because transformations are no longer needed when all geometries are in the same CRS and they are all projected and in meters. Keeping them is confusing imho and I prefer to directly use the geoalchemy functions.