-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Processing - Always reproject the extent to 4326 when fetching parame…
…ters
- Loading branch information
Showing
6 changed files
with
87 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,7 @@ processing-doc: | |
|
||
code-doc: | ||
cd .docker && ./code_doc.sh | ||
|
||
lint: | ||
flake8 | ||
pylint --rcfile=setup.cfg ./QuickOSM |
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,25 +1,18 @@ | ||
"""Processing algorithm for building a query.""" | ||
|
||
__copyright__ = 'Copyright 2021, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = '[email protected]' | ||
|
||
from typing import Dict | ||
|
||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm | ||
from qgis.core import ( | ||
QgsCoordinateReferenceSystem, | ||
QgsCoordinateTransform, | ||
QgsProcessingAlgorithm, | ||
QgsProcessingOutputString, | ||
QgsProject, | ||
) | ||
from qgis.core import QgsProcessingAlgorithm, QgsProcessingOutputString | ||
|
||
from QuickOSM.core.query_factory import QueryFactory | ||
from QuickOSM.core.query_preparation import QueryPreparation | ||
from QuickOSM.definitions.osm import QueryLanguage | ||
from QuickOSM.qgis_plugin_tools.tools.i18n import tr | ||
|
||
__copyright__ = 'Copyright 2021, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = '[email protected]' | ||
|
||
from QuickOSM.quick_osm_processing.build_input import ( | ||
BuildBasedAroundAreaQuery, | ||
BuildBasedExtentQuery, | ||
|
@@ -86,7 +79,7 @@ def build_query(self) -> Dict[str, str]: | |
query_preparation = QueryPreparation( | ||
raw_query, | ||
area=self.area, | ||
extent=self.extent, | ||
extent=self.extent, # It must be already in 4326 when fetching parameters | ||
overpass=self.server | ||
) | ||
raw_query = query_preparation.prepare_query() | ||
|
@@ -177,11 +170,4 @@ def processAlgorithm(self, parameters, context, feedback) -> Dict[str, str]: | |
self.feedback = feedback | ||
self.fetch_based_parameters(parameters, context) | ||
|
||
crs = self.parameterAsExtentCrs(parameters, self.EXTENT, context) | ||
|
||
crs_4326 = QgsCoordinateReferenceSystem(4326) | ||
transform = QgsCoordinateTransform( | ||
crs, crs_4326, QgsProject.instance()) | ||
self.extent = transform.transform(self.extent) | ||
|
||
return self.build_query() |
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,22 +1,15 @@ | ||
"""Generate a raw query.""" | ||
|
||
__copyright__ = 'Copyright 2021, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = '[email protected]' | ||
|
||
from typing import Dict | ||
|
||
from qgis.core import ( | ||
QgsCoordinateReferenceSystem, | ||
QgsCoordinateTransform, | ||
QgsProcessingAlgorithm, | ||
QgsProcessingOutputString, | ||
QgsProject, | ||
) | ||
from qgis.core import QgsProcessingAlgorithm, QgsProcessingOutputString | ||
|
||
from QuickOSM.core.query_preparation import QueryPreparation | ||
from QuickOSM.qgis_plugin_tools.tools.i18n import tr | ||
|
||
__copyright__ = 'Copyright 2021, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = '[email protected]' | ||
|
||
from QuickOSM.quick_osm_processing.build_input import BuildRaw | ||
|
||
|
||
|
@@ -70,16 +63,11 @@ def processAlgorithm(self, parameters, context, feedback) -> Dict[str, str]: | |
self.feedback = feedback | ||
self.fetch_based_parameters(parameters, context) | ||
|
||
crs_4326 = QgsCoordinateReferenceSystem(4326) | ||
transform = QgsCoordinateTransform( | ||
self.crs, crs_4326, QgsProject.instance()) | ||
self.extent = transform.transform(self.extent) | ||
|
||
self.feedback.pushInfo('Prepare the url.') | ||
|
||
query_preparation = QueryPreparation( | ||
self.query, | ||
extent=self.extent, | ||
extent=self.extent, # It should be in 4326 already in this stage | ||
area=self.area, | ||
overpass=self.server | ||
) | ||
|
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,17 +1,19 @@ | ||
"""Set up the parameters for the processing algorithms.""" | ||
|
||
__copyright__ = 'Copyright 2021, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = '[email protected]' | ||
|
||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm | ||
from qgis.core import ( | ||
QgsCoordinateReferenceSystem, | ||
QgsCoordinateTransform, | ||
QgsProcessingParameterDefinition, | ||
QgsProcessingParameterExtent, | ||
QgsProcessingParameterNumber, | ||
QgsProcessingParameterString, | ||
) | ||
|
||
__copyright__ = 'Copyright 2021, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = '[email protected]' | ||
|
||
from QuickOSM.core.utilities.tools import get_setting | ||
from QuickOSM.definitions.osm import QueryType | ||
from QuickOSM.definitions.overpass import OVERPASS_SERVERS | ||
|
@@ -30,6 +32,7 @@ def __init__(self): | |
self.feedback = None | ||
self.area = None | ||
self.extent = None | ||
self.extent_crs = None | ||
self.server = None | ||
self.timeout = None | ||
|
||
|
@@ -74,14 +77,20 @@ def __init__(self): | |
"""Constructor""" | ||
super().__init__() | ||
self.query = None | ||
self.crs = None | ||
|
||
def fetch_based_parameters(self, parameters, context): | ||
"""Get the parameters.""" | ||
super().fetch_based_parameters(parameters, context) | ||
self.query = self.parameterAsString(parameters, self.QUERY, context) | ||
self.extent = self.parameterAsExtent(parameters, self.EXTENT, context) | ||
self.crs = self.parameterAsExtentCrs(parameters, self.EXTENT, context) | ||
self.extent_crs = self.parameterAsExtentCrs(parameters, self.EXTENT, context) | ||
|
||
# Always transform to 4326 | ||
crs_4326 = QgsCoordinateReferenceSystem(4326) | ||
transform = QgsCoordinateTransform(self.extent_crs, crs_4326, context.project()) | ||
self.extent = transform.transform(self.extent) | ||
self.extent_crs = crs_4326 | ||
|
||
self.area = self.parameterAsString(parameters, self.AREA, context) | ||
|
||
def add_top_parameters(self): | ||
|
@@ -241,12 +250,18 @@ def fetch_based_parameters(self, parameters, context): | |
"""Get the parameters.""" | ||
super().fetch_based_parameters(parameters, context) | ||
self.extent = self.parameterAsExtent(parameters, self.EXTENT, context) | ||
self.extent_crs = self.parameterAsExtentCrs(parameters, self.EXTENT, context) | ||
|
||
# Always transform to 4326 | ||
crs_4326 = QgsCoordinateReferenceSystem(4326) | ||
transform = QgsCoordinateTransform(self.extent_crs, crs_4326, context.project()) | ||
self.extent = transform.transform(self.extent) | ||
self.extent_crs = crs_4326 | ||
|
||
def add_top_parameters(self): | ||
"""Set up the parameter.""" | ||
super().add_top_parameters() | ||
|
||
param = QgsProcessingParameterExtent(self.EXTENT, tr('Extent'), optional=False) | ||
help_string = tr('The extent as a rectangle to use when building the query.') | ||
param.setHelp(help_string) | ||
param.setHelp(tr('The extent as a rectangle to use when building the query.')) | ||
self.addParameter(param) |
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