[FEATURE][needs-docs] Show projection bounds in projection widget (#5356)

- Script to pull bounds from EPSG.org Postgres dump
- Add resources/data/world_map.shp for reference
- Show canvas bounds for reference
This commit is contained in:
Nathan Woodrow 2017-10-16 10:40:05 +10:00 committed by GitHub
parent ea95b38509
commit cf241f51ae
17 changed files with 7774 additions and 55 deletions

View File

@ -11,6 +11,7 @@
class QgsProjectionSelectionTreeWidget : QWidget
{
%Docstring
@ -51,6 +52,13 @@ class QgsProjectionSelectionTreeWidget : QWidget
option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.
.. seealso:: showNoProjection()
.. versionadded:: 3.0
%End
void setShowBoundsMap( bool show );
%Docstring
Sets whether to show the bounnds preview map.
.. seealso:: showBoundsMap()
.. versionadded:: 3.0
%End
bool showNoProjection() const;
@ -62,6 +70,14 @@ class QgsProjectionSelectionTreeWidget : QWidget
:rtype: bool
%End
bool showBoundsMap() const;
%Docstring
Returns whether the bounds preview map is shown.
.. versionadded:: 3.0
.. seealso:: setShowBoundsMap()
:rtype: bool
%End
bool hasValidSelection() const;
%Docstring
Returns true if the current selection in the widget is a valid choice. Valid
@ -80,6 +96,21 @@ class QgsProjectionSelectionTreeWidget : QWidget
.. seealso:: crs()
%End
void setPreviewRect( const QgsRectangle &rect );
%Docstring
Sets the initial "preview" rectangle for the bounds overview map.
.. versionadded:: 3.0
.. seealso:: previewRect()
%End
const QgsRectangle previewRect();
%Docstring
The initial "preview" rectangle for the bounds overview map.
.. versionadded:: 3.0
.. seealso:: previewRect()
:rtype: QgsRectangle
%End
void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
%Docstring
filters this widget by the given CRSs

View File

@ -4,6 +4,7 @@ INSTALL(FILES qgis_global_settings.ini
DESTINATION ${QGIS_DATA_DIR})
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY themes DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY data DESTINATION ${QGIS_DATA_DIR}/resources)
IF (WITH_SERVER)
INSTALL(DIRECTORY server DESTINATION ${QGIS_DATA_DIR}/resources)

BIN
resources/data/world_map.dbf Executable file

Binary file not shown.

1
resources/data/world_map.prj Executable file
View File

@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

Binary file not shown.

View File

@ -0,0 +1,885 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis simplifyMaxScale="1" hasScaleBasedVisibilityFlag="0" simplifyDrawingHints="1" version="2.99.0-Master" maxScale="0" simplifyDrawingTol="1" readOnly="0" mincale="1e+8" simplifyLocal="1" simplifyAlgorithm="0">
<renderer-v2 forceraster="0" type="singleSymbol" enableorderby="0" symbollevels="0">
<symbols>
<symbol clip_to_extent="1" type="fill" alpha="1" name="0">
<layer pass="0" enabled="1" class="SimpleFill" locked="0">
<prop k="border_width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="color" v="224,220,202,154"/>
<prop k="joinstyle" v="bevel"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0.26"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="style" v="solid"/>
<data_defined_properties>
<Option type="Map">
<Option value="" type="QString" name="name"/>
<Option name="properties"/>
<Option value="collection" type="QString" name="type"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</symbols>
<rotation/>
<sizescale/>
</renderer-v2>
<customproperties>
<property value="0" key="embeddedWidgets/count"/>
<property key="variableNames"/>
<property key="variableValues"/>
</customproperties>
<blendMode>0</blendMode>
<featureBlendMode>0</featureBlendMode>
<layerOpacity>1</layerOpacity>
<SingleCategoryDiagramRenderer diagramType="Histogram" attributeLegend="1">
<DiagramCategory rotationOffset="270" penAlpha="255" scaleBasedVisibility="0" minimumSize="0" labelPlacementMethod="XHeight" lineSizeScale="3x:0,0,0,0,0,0" diagramOrientation="Up" enabled="0" penColor="#000000" barWidth="5" sizeScale="3x:0,0,0,0,0,0" backgroundColor="#ffffff" scaleDependency="Area" sizeType="MM" backgroundAlpha="255" lineSizeType="MM" maxScaleDenominator="1e+8" minScaleDenominator="0" penWidth="0" width="15" height="15" opacity="1">
<fontProperties description="Cantarell,11,-1,5,50,0,0,0,0,0" style=""/>
</DiagramCategory>
</SingleCategoryDiagramRenderer>
<DiagramLayerSettings zIndex="0" obstacle="0" placement="0" dist="0" showAll="1" priority="0" linePlacementFlags="18">
<properties>
<Option type="Map">
<Option value="" type="QString" name="name"/>
<Option name="properties"/>
<Option value="collection" type="QString" name="type"/>
</Option>
</properties>
</DiagramLayerSettings>
<fieldConfiguration>
<field name="scalerank">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="featurecla">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="LABELRANK">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="SOVEREIGNT">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="SOV_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ADM0_DIF">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="LEVEL">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="TYPE">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ADMIN">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ADM0_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="GEOU_DIF">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="GEOUNIT">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="GU_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="SU_DIF">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="SUBUNIT">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="SU_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="BRK_DIFF">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="NAME">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="NAME_LONG">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="BRK_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="BRK_NAME">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="BRK_GROUP">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ABBREV">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="POSTAL">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="FORMAL_EN">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="FORMAL_FR">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="NOTE_ADM0">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="NOTE_BRK">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="NAME_SORT">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="NAME_ALT">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="MAPCOLOR7">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="MAPCOLOR8">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="MAPCOLOR9">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="MAPCOLOR13">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="POP_EST">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="GDP_MD_EST">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="POP_YEAR">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="LASTCENSUS">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="GDP_YEAR">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ECONOMY">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="INCOME_GRP">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="WIKIPEDIA">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="FIPS_10_">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ISO_A2">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ISO_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ISO_N3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="UN_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="WB_A2">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="WB_A3">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="WOE_ID">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="WOE_ID_EH">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="WOE_NOTE">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ADM0_A3_IS">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ADM0_A3_US">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ADM0_A3_UN">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ADM0_A3_WB">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="CONTINENT">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="REGION_UN">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="SUBREGION">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="REGION_WB">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="NAME_LEN">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="LONG_LEN">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ABBREV_LEN">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="TINY">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="HOMEPART">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
</fieldConfiguration>
<aliases>
<alias index="0" field="scalerank" name=""/>
<alias index="1" field="featurecla" name=""/>
<alias index="2" field="LABELRANK" name=""/>
<alias index="3" field="SOVEREIGNT" name=""/>
<alias index="4" field="SOV_A3" name=""/>
<alias index="5" field="ADM0_DIF" name=""/>
<alias index="6" field="LEVEL" name=""/>
<alias index="7" field="TYPE" name=""/>
<alias index="8" field="ADMIN" name=""/>
<alias index="9" field="ADM0_A3" name=""/>
<alias index="10" field="GEOU_DIF" name=""/>
<alias index="11" field="GEOUNIT" name=""/>
<alias index="12" field="GU_A3" name=""/>
<alias index="13" field="SU_DIF" name=""/>
<alias index="14" field="SUBUNIT" name=""/>
<alias index="15" field="SU_A3" name=""/>
<alias index="16" field="BRK_DIFF" name=""/>
<alias index="17" field="NAME" name=""/>
<alias index="18" field="NAME_LONG" name=""/>
<alias index="19" field="BRK_A3" name=""/>
<alias index="20" field="BRK_NAME" name=""/>
<alias index="21" field="BRK_GROUP" name=""/>
<alias index="22" field="ABBREV" name=""/>
<alias index="23" field="POSTAL" name=""/>
<alias index="24" field="FORMAL_EN" name=""/>
<alias index="25" field="FORMAL_FR" name=""/>
<alias index="26" field="NOTE_ADM0" name=""/>
<alias index="27" field="NOTE_BRK" name=""/>
<alias index="28" field="NAME_SORT" name=""/>
<alias index="29" field="NAME_ALT" name=""/>
<alias index="30" field="MAPCOLOR7" name=""/>
<alias index="31" field="MAPCOLOR8" name=""/>
<alias index="32" field="MAPCOLOR9" name=""/>
<alias index="33" field="MAPCOLOR13" name=""/>
<alias index="34" field="POP_EST" name=""/>
<alias index="35" field="GDP_MD_EST" name=""/>
<alias index="36" field="POP_YEAR" name=""/>
<alias index="37" field="LASTCENSUS" name=""/>
<alias index="38" field="GDP_YEAR" name=""/>
<alias index="39" field="ECONOMY" name=""/>
<alias index="40" field="INCOME_GRP" name=""/>
<alias index="41" field="WIKIPEDIA" name=""/>
<alias index="42" field="FIPS_10_" name=""/>
<alias index="43" field="ISO_A2" name=""/>
<alias index="44" field="ISO_A3" name=""/>
<alias index="45" field="ISO_N3" name=""/>
<alias index="46" field="UN_A3" name=""/>
<alias index="47" field="WB_A2" name=""/>
<alias index="48" field="WB_A3" name=""/>
<alias index="49" field="WOE_ID" name=""/>
<alias index="50" field="WOE_ID_EH" name=""/>
<alias index="51" field="WOE_NOTE" name=""/>
<alias index="52" field="ADM0_A3_IS" name=""/>
<alias index="53" field="ADM0_A3_US" name=""/>
<alias index="54" field="ADM0_A3_UN" name=""/>
<alias index="55" field="ADM0_A3_WB" name=""/>
<alias index="56" field="CONTINENT" name=""/>
<alias index="57" field="REGION_UN" name=""/>
<alias index="58" field="SUBREGION" name=""/>
<alias index="59" field="REGION_WB" name=""/>
<alias index="60" field="NAME_LEN" name=""/>
<alias index="61" field="LONG_LEN" name=""/>
<alias index="62" field="ABBREV_LEN" name=""/>
<alias index="63" field="TINY" name=""/>
<alias index="64" field="HOMEPART" name=""/>
</aliases>
<excludeAttributesWMS/>
<excludeAttributesWFS/>
<defaults>
<default field="scalerank" expression=""/>
<default field="featurecla" expression=""/>
<default field="LABELRANK" expression=""/>
<default field="SOVEREIGNT" expression=""/>
<default field="SOV_A3" expression=""/>
<default field="ADM0_DIF" expression=""/>
<default field="LEVEL" expression=""/>
<default field="TYPE" expression=""/>
<default field="ADMIN" expression=""/>
<default field="ADM0_A3" expression=""/>
<default field="GEOU_DIF" expression=""/>
<default field="GEOUNIT" expression=""/>
<default field="GU_A3" expression=""/>
<default field="SU_DIF" expression=""/>
<default field="SUBUNIT" expression=""/>
<default field="SU_A3" expression=""/>
<default field="BRK_DIFF" expression=""/>
<default field="NAME" expression=""/>
<default field="NAME_LONG" expression=""/>
<default field="BRK_A3" expression=""/>
<default field="BRK_NAME" expression=""/>
<default field="BRK_GROUP" expression=""/>
<default field="ABBREV" expression=""/>
<default field="POSTAL" expression=""/>
<default field="FORMAL_EN" expression=""/>
<default field="FORMAL_FR" expression=""/>
<default field="NOTE_ADM0" expression=""/>
<default field="NOTE_BRK" expression=""/>
<default field="NAME_SORT" expression=""/>
<default field="NAME_ALT" expression=""/>
<default field="MAPCOLOR7" expression=""/>
<default field="MAPCOLOR8" expression=""/>
<default field="MAPCOLOR9" expression=""/>
<default field="MAPCOLOR13" expression=""/>
<default field="POP_EST" expression=""/>
<default field="GDP_MD_EST" expression=""/>
<default field="POP_YEAR" expression=""/>
<default field="LASTCENSUS" expression=""/>
<default field="GDP_YEAR" expression=""/>
<default field="ECONOMY" expression=""/>
<default field="INCOME_GRP" expression=""/>
<default field="WIKIPEDIA" expression=""/>
<default field="FIPS_10_" expression=""/>
<default field="ISO_A2" expression=""/>
<default field="ISO_A3" expression=""/>
<default field="ISO_N3" expression=""/>
<default field="UN_A3" expression=""/>
<default field="WB_A2" expression=""/>
<default field="WB_A3" expression=""/>
<default field="WOE_ID" expression=""/>
<default field="WOE_ID_EH" expression=""/>
<default field="WOE_NOTE" expression=""/>
<default field="ADM0_A3_IS" expression=""/>
<default field="ADM0_A3_US" expression=""/>
<default field="ADM0_A3_UN" expression=""/>
<default field="ADM0_A3_WB" expression=""/>
<default field="CONTINENT" expression=""/>
<default field="REGION_UN" expression=""/>
<default field="SUBREGION" expression=""/>
<default field="REGION_WB" expression=""/>
<default field="NAME_LEN" expression=""/>
<default field="LONG_LEN" expression=""/>
<default field="ABBREV_LEN" expression=""/>
<default field="TINY" expression=""/>
<default field="HOMEPART" expression=""/>
</defaults>
<constraints>
<constraint field="scalerank" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="featurecla" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="LABELRANK" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="SOVEREIGNT" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="SOV_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ADM0_DIF" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="LEVEL" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="TYPE" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ADMIN" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ADM0_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="GEOU_DIF" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="GEOUNIT" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="GU_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="SU_DIF" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="SUBUNIT" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="SU_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="BRK_DIFF" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="NAME" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="NAME_LONG" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="BRK_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="BRK_NAME" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="BRK_GROUP" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ABBREV" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="POSTAL" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="FORMAL_EN" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="FORMAL_FR" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="NOTE_ADM0" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="NOTE_BRK" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="NAME_SORT" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="NAME_ALT" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="MAPCOLOR7" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="MAPCOLOR8" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="MAPCOLOR9" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="MAPCOLOR13" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="POP_EST" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="GDP_MD_EST" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="POP_YEAR" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="LASTCENSUS" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="GDP_YEAR" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ECONOMY" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="INCOME_GRP" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="WIKIPEDIA" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="FIPS_10_" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ISO_A2" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ISO_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ISO_N3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="UN_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="WB_A2" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="WB_A3" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="WOE_ID" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="WOE_ID_EH" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="WOE_NOTE" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ADM0_A3_IS" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ADM0_A3_US" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ADM0_A3_UN" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ADM0_A3_WB" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="CONTINENT" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="REGION_UN" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="SUBREGION" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="REGION_WB" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="NAME_LEN" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="LONG_LEN" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="ABBREV_LEN" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="TINY" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
<constraint field="HOMEPART" constraints="0" unique_strength="0" exp_strength="0" notnull_strength="0"/>
</constraints>
<constraintExpressions>
<constraint field="scalerank" desc="" exp=""/>
<constraint field="featurecla" desc="" exp=""/>
<constraint field="LABELRANK" desc="" exp=""/>
<constraint field="SOVEREIGNT" desc="" exp=""/>
<constraint field="SOV_A3" desc="" exp=""/>
<constraint field="ADM0_DIF" desc="" exp=""/>
<constraint field="LEVEL" desc="" exp=""/>
<constraint field="TYPE" desc="" exp=""/>
<constraint field="ADMIN" desc="" exp=""/>
<constraint field="ADM0_A3" desc="" exp=""/>
<constraint field="GEOU_DIF" desc="" exp=""/>
<constraint field="GEOUNIT" desc="" exp=""/>
<constraint field="GU_A3" desc="" exp=""/>
<constraint field="SU_DIF" desc="" exp=""/>
<constraint field="SUBUNIT" desc="" exp=""/>
<constraint field="SU_A3" desc="" exp=""/>
<constraint field="BRK_DIFF" desc="" exp=""/>
<constraint field="NAME" desc="" exp=""/>
<constraint field="NAME_LONG" desc="" exp=""/>
<constraint field="BRK_A3" desc="" exp=""/>
<constraint field="BRK_NAME" desc="" exp=""/>
<constraint field="BRK_GROUP" desc="" exp=""/>
<constraint field="ABBREV" desc="" exp=""/>
<constraint field="POSTAL" desc="" exp=""/>
<constraint field="FORMAL_EN" desc="" exp=""/>
<constraint field="FORMAL_FR" desc="" exp=""/>
<constraint field="NOTE_ADM0" desc="" exp=""/>
<constraint field="NOTE_BRK" desc="" exp=""/>
<constraint field="NAME_SORT" desc="" exp=""/>
<constraint field="NAME_ALT" desc="" exp=""/>
<constraint field="MAPCOLOR7" desc="" exp=""/>
<constraint field="MAPCOLOR8" desc="" exp=""/>
<constraint field="MAPCOLOR9" desc="" exp=""/>
<constraint field="MAPCOLOR13" desc="" exp=""/>
<constraint field="POP_EST" desc="" exp=""/>
<constraint field="GDP_MD_EST" desc="" exp=""/>
<constraint field="POP_YEAR" desc="" exp=""/>
<constraint field="LASTCENSUS" desc="" exp=""/>
<constraint field="GDP_YEAR" desc="" exp=""/>
<constraint field="ECONOMY" desc="" exp=""/>
<constraint field="INCOME_GRP" desc="" exp=""/>
<constraint field="WIKIPEDIA" desc="" exp=""/>
<constraint field="FIPS_10_" desc="" exp=""/>
<constraint field="ISO_A2" desc="" exp=""/>
<constraint field="ISO_A3" desc="" exp=""/>
<constraint field="ISO_N3" desc="" exp=""/>
<constraint field="UN_A3" desc="" exp=""/>
<constraint field="WB_A2" desc="" exp=""/>
<constraint field="WB_A3" desc="" exp=""/>
<constraint field="WOE_ID" desc="" exp=""/>
<constraint field="WOE_ID_EH" desc="" exp=""/>
<constraint field="WOE_NOTE" desc="" exp=""/>
<constraint field="ADM0_A3_IS" desc="" exp=""/>
<constraint field="ADM0_A3_US" desc="" exp=""/>
<constraint field="ADM0_A3_UN" desc="" exp=""/>
<constraint field="ADM0_A3_WB" desc="" exp=""/>
<constraint field="CONTINENT" desc="" exp=""/>
<constraint field="REGION_UN" desc="" exp=""/>
<constraint field="SUBREGION" desc="" exp=""/>
<constraint field="REGION_WB" desc="" exp=""/>
<constraint field="NAME_LEN" desc="" exp=""/>
<constraint field="LONG_LEN" desc="" exp=""/>
<constraint field="ABBREV_LEN" desc="" exp=""/>
<constraint field="TINY" desc="" exp=""/>
<constraint field="HOMEPART" desc="" exp=""/>
</constraintExpressions>
<attributeactions>
<defaultAction value="{00000000-0000-0000-0000-000000000000}" key="Canvas"/>
</attributeactions>
<attributetableconfig sortOrder="0" actionWidgetStyle="dropDown" sortExpression="">
<columns>
<column type="field" hidden="0" width="-1" name="scalerank"/>
<column type="field" hidden="0" width="-1" name="featurecla"/>
<column type="field" hidden="0" width="-1" name="LABELRANK"/>
<column type="field" hidden="0" width="-1" name="SOVEREIGNT"/>
<column type="field" hidden="0" width="-1" name="SOV_A3"/>
<column type="field" hidden="0" width="-1" name="ADM0_DIF"/>
<column type="field" hidden="0" width="-1" name="LEVEL"/>
<column type="field" hidden="0" width="-1" name="TYPE"/>
<column type="field" hidden="0" width="-1" name="ADMIN"/>
<column type="field" hidden="0" width="-1" name="ADM0_A3"/>
<column type="field" hidden="0" width="-1" name="GEOU_DIF"/>
<column type="field" hidden="0" width="-1" name="GEOUNIT"/>
<column type="field" hidden="0" width="-1" name="GU_A3"/>
<column type="field" hidden="0" width="-1" name="SU_DIF"/>
<column type="field" hidden="0" width="-1" name="SUBUNIT"/>
<column type="field" hidden="0" width="-1" name="SU_A3"/>
<column type="field" hidden="0" width="-1" name="BRK_DIFF"/>
<column type="field" hidden="0" width="-1" name="NAME"/>
<column type="field" hidden="0" width="-1" name="NAME_LONG"/>
<column type="field" hidden="0" width="-1" name="BRK_A3"/>
<column type="field" hidden="0" width="-1" name="BRK_NAME"/>
<column type="field" hidden="0" width="-1" name="BRK_GROUP"/>
<column type="field" hidden="0" width="-1" name="ABBREV"/>
<column type="field" hidden="0" width="-1" name="POSTAL"/>
<column type="field" hidden="0" width="-1" name="FORMAL_EN"/>
<column type="field" hidden="0" width="-1" name="FORMAL_FR"/>
<column type="field" hidden="0" width="-1" name="NOTE_ADM0"/>
<column type="field" hidden="0" width="-1" name="NOTE_BRK"/>
<column type="field" hidden="0" width="-1" name="NAME_SORT"/>
<column type="field" hidden="0" width="-1" name="NAME_ALT"/>
<column type="field" hidden="0" width="-1" name="MAPCOLOR7"/>
<column type="field" hidden="0" width="-1" name="MAPCOLOR8"/>
<column type="field" hidden="0" width="-1" name="MAPCOLOR9"/>
<column type="field" hidden="0" width="-1" name="MAPCOLOR13"/>
<column type="field" hidden="0" width="-1" name="POP_EST"/>
<column type="field" hidden="0" width="-1" name="GDP_MD_EST"/>
<column type="field" hidden="0" width="-1" name="POP_YEAR"/>
<column type="field" hidden="0" width="-1" name="LASTCENSUS"/>
<column type="field" hidden="0" width="-1" name="GDP_YEAR"/>
<column type="field" hidden="0" width="-1" name="ECONOMY"/>
<column type="field" hidden="0" width="-1" name="INCOME_GRP"/>
<column type="field" hidden="0" width="-1" name="WIKIPEDIA"/>
<column type="field" hidden="0" width="-1" name="FIPS_10_"/>
<column type="field" hidden="0" width="-1" name="ISO_A2"/>
<column type="field" hidden="0" width="-1" name="ISO_A3"/>
<column type="field" hidden="0" width="-1" name="ISO_N3"/>
<column type="field" hidden="0" width="-1" name="UN_A3"/>
<column type="field" hidden="0" width="-1" name="WB_A2"/>
<column type="field" hidden="0" width="-1" name="WB_A3"/>
<column type="field" hidden="0" width="-1" name="WOE_ID"/>
<column type="field" hidden="0" width="-1" name="WOE_ID_EH"/>
<column type="field" hidden="0" width="-1" name="WOE_NOTE"/>
<column type="field" hidden="0" width="-1" name="ADM0_A3_IS"/>
<column type="field" hidden="0" width="-1" name="ADM0_A3_US"/>
<column type="field" hidden="0" width="-1" name="ADM0_A3_UN"/>
<column type="field" hidden="0" width="-1" name="ADM0_A3_WB"/>
<column type="field" hidden="0" width="-1" name="CONTINENT"/>
<column type="field" hidden="0" width="-1" name="REGION_UN"/>
<column type="field" hidden="0" width="-1" name="SUBREGION"/>
<column type="field" hidden="0" width="-1" name="REGION_WB"/>
<column type="field" hidden="0" width="-1" name="NAME_LEN"/>
<column type="field" hidden="0" width="-1" name="LONG_LEN"/>
<column type="field" hidden="0" width="-1" name="ABBREV_LEN"/>
<column type="field" hidden="0" width="-1" name="TINY"/>
<column type="field" hidden="0" width="-1" name="HOMEPART"/>
<column type="actions" hidden="1" width="-1"/>
</columns>
</attributetableconfig>
<editform></editform>
<editforminit/>
<editforminitcodesource>0</editforminitcodesource>
<editforminitfilepath></editforminitfilepath>
<editforminitcode><![CDATA[# -*- coding: utf-8 -*-
"""
QGIS forms can have a Python function that is called when the form is
opened.
Use this function to add extra logic to your forms.
Enter the name of the function in the "Python Init function"
field.
An example follows:
"""
from qgis.PyQt.QtWidgets import QWidget
def my_form_open(dialog, layer, feature):
geom = feature.geometry()
control = dialog.findChild(QWidget, "MyLineEdit")
]]></editforminitcode>
<featformsuppress>0</featformsuppress>
<editorlayout>generatedlayout</editorlayout>
<widgets/>
<conditionalstyles>
<rowstyles/>
<fieldstyles/>
</conditionalstyles>
<expressionfields/>
<previewExpression>NAME</previewExpression>
<mapTip></mapTip>
<layerGeometryType>2</layerGeometryType>
</qgis>

BIN
resources/data/world_map.shp Executable file

Binary file not shown.

BIN
resources/data/world_map.shx Executable file

Binary file not shown.

6452
resources/epsg_areas.csv Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

56
scripts/bounds_sync.py Normal file
View File

@ -0,0 +1,56 @@
import os
import sys
import sqlite3 as sqlite
def gen():
db = sqlite.connect(":memory:")
tablesfile = sys.argv[1]
datafiles = sys.argv[2]
with open(os.path.join("data", tablesfile)) as f:
data = f.read()
db.executescript(data)
with open(os.path.join("data", datafiles)) as f:
data = f.read()
data = data.replace("CHR", "Char")
db.executescript(data)
query = """
SELECT crs.coord_ref_sys_code,
area_west_bound_lon,
area_north_bound_lat,
area_east_bound_lon,
area_south_bound_lat
FROM epsg_coordinatereferencesystem crs
JOIN epsg_area area ON crs.area_of_use_code = area.area_code
"""
rows = db.execute(query)
with open("resources/epsg_areas.csv", "w") as f:
f.write("coord_sys_code, west_bound_lon, north_bound_lat, east_bound_lon, south_bound_lat\n")
for row in rows:
csv = ",".join(str(data) for data in row)
f.write('{0}\n'.format(csv))
def usage():
print("""
Generate the epsg_bounds.csv file to support viewing projection areas and bounds checks in QGIS.
Usage:
bounds_sync.py {table dump} {data dump}
bounds_sync.py EPSG_v9_1.mdb_Tables_PostgreSQL.sql EPSG_v9_1.mdb_Data_PostgreSQL.sql
""")
if __name__ == "__main__":
if len(sys.argv) < 3:
usage()
else:
gen()

View File

@ -154,6 +154,28 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
updateGuiForMapUnits( QgsProject::instance()->crs().mapUnits() );
projectionSelector->setCrs( QgsProject::instance()->crs() );
QPolygonF mainCanvasPoly = mapCanvas->mapSettings().visiblePolygon();
QgsGeometry g = QgsGeometry::fromQPolygonF( mainCanvasPoly );
// close polygon
mainCanvasPoly << mainCanvasPoly.at( 0 );
if ( QgsProject::instance()->crs() !=
QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) )
{
// reproject extent
QgsCoordinateTransform ct( QgsProject::instance()->crs(),
QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) );
g = g.densifyByCount( 5 );
try
{
g.transform( ct );
}
catch ( QgsCsException & )
{
}
}
projectionSelector->setPreviewRect( g.boundingBox() );
mMapTileRenderingCheckBox->setChecked( mMapCanvas->mapSettings().testFlag( QgsMapSettings::RenderMapTile ) );
// see end of constructor for updating of projection selector

View File

@ -1857,6 +1857,13 @@ int QgsCoordinateReferenceSystem::syncDatabase()
return -1;
}
QString boundsColumns( "ALTER TABLE tbl_srs ADD west_bound_lon REAL;"
"ALTER TABLE tbl_srs ADD north_bound_lat REAL;"
"ALTER TABLE tbl_srs ADD east_bound_lon REAL;"
"ALTER TABLE tbl_srs ADD south_bound_lat REAL;" );
sqlite3_exec( database, boundsColumns.toUtf8(), nullptr, nullptr, nullptr );
// fix up database, if not done already //
if ( sqlite3_exec( database, "alter table tbl_srs add noupdate boolean", nullptr, nullptr, nullptr ) == SQLITE_OK )
( void )sqlite3_exec( database, "update tbl_srs set noupdate=(auth_name='EPSG' and auth_id in (5513,5514,5221,2065,102067,4156,4818))", nullptr, nullptr, nullptr );
@ -2103,6 +2110,58 @@ int QgsCoordinateReferenceSystem::syncDatabase()
sqlite3_finalize( select );
#endif
QFile csv( QgsApplication::pkgDataPath() + "/resources/epsg_areas.csv" );
if ( !csv.open( QIODevice::ReadOnly ) )
{
return false;
}
QTextStream lines( &csv );
QString header = lines.readLine();
for ( ;; )
{
QString line = lines.readLine();
if ( line.isNull() )
break;
if ( line.startsWith( '#' ) )
{
continue;
}
const QStringList data = line.split( ',' );
if ( data[0] == QStringListIterator( "None" ) )
continue;
double west_bound_lon = data[1].toDouble();
double north_bound_lat = data[2].toDouble();
double east_bound_lon = data[3].toDouble();
double south_bound_lat = data[4].toDouble();
sql = QStringLiteral( "UPDATE tbl_srs "
"SET west_bound_lon=%1, "
"north_bound_lat=%2, "
"east_bound_lon=%3, "
"south_bound_lat=%4 "
"WHERE auth_name='EPSG' AND auth_id=%5" )
.arg( west_bound_lon )
.arg( north_bound_lat )
.arg( east_bound_lon )
.arg( south_bound_lat )
.arg( data[0] );
if ( sqlite3_exec( database, sql.toUtf8(), nullptr, nullptr, &errMsg ) != SQLITE_OK )
{
qCritical( "Could not execute: %s [%s/%s]\n",
sql.toLocal8Bit().constData(),
sqlite3_errmsg( database ),
errMsg ? errMsg : "(unknown error)" );
if ( errMsg )
sqlite3_free( errMsg );
errors++;
}
}
pj_ctx_free( pContext );
if ( sqlite3_exec( database, "COMMIT", nullptr, nullptr, nullptr ) != SQLITE_OK )

View File

@ -20,6 +20,11 @@
#include "qgscoordinatereferencesystem.h"
#include "qgsmessagelog.h"
#include "qgssettings.h"
#include "qgsrectangle.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgsmaptoolpan.h"
#include "qgsvertexmarker.h"
//qt includes
#include <QFileInfo>
@ -31,6 +36,7 @@ QgsProjectionSelectionTreeWidget::QgsProjectionSelectionTreeWidget( QWidget *par
: QWidget( parent )
{
setupUi( this );
connect( lstCoordinateSystems, &QTreeWidget::itemDoubleClicked, this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_itemDoubleClicked );
connect( lstRecent, &QTreeWidget::itemDoubleClicked, this, &QgsProjectionSelectionTreeWidget::lstRecent_itemDoubleClicked );
connect( lstCoordinateSystems, &QTreeWidget::currentItemChanged, this, &QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged );
@ -38,6 +44,29 @@ QgsProjectionSelectionTreeWidget::QgsProjectionSelectionTreeWidget( QWidget *par
connect( cbxHideDeprecated, &QCheckBox::stateChanged, this, &QgsProjectionSelectionTreeWidget::cbxHideDeprecated_stateChanged );
connect( leSearch, &QgsFilterLineEdit::textChanged, this, &QgsProjectionSelectionTreeWidget::leSearch_textChanged );
mPreviewBand = new QgsRubberBand( mAreaCanvas, QgsWkbTypes::PolygonGeometry );
mPreviewBand->setWidth( 4 );
mPreviewBand2 = new QgsRubberBand( mAreaCanvas, QgsWkbTypes::PolygonGeometry );
mPreviewBand2->setWidth( 4 );
QColor rectColor = QColor( 185, 84, 210, 60 );
mPreviewBand2->setColor( rectColor );
mVertexMarker = new QgsVertexMarker( mAreaCanvas );
mVertexMarker->setIconType( QgsVertexMarker::ICON_CROSS );
mVertexMarker->setColor( Qt::magenta );
mVertexMarker->setPenWidth( 3 );
QgsCoordinateReferenceSystem srs( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
mAreaCanvas->setDestinationCrs( srs );
QString layerPath = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/world_map.shp" );
mLayers << new QgsVectorLayer( layerPath );
mAreaCanvas->setLayers( mLayers );
mAreaCanvas->setMapTool( new QgsMapToolPan( mAreaCanvas ) );
mAreaCanvas->setVisible( mShowMap );
if ( QDialog *dlg = qobject_cast<QDialog *>( parent ) )
{
// mark selected projection for push to front if parent dialog is accepted
@ -70,6 +99,11 @@ QgsProjectionSelectionTreeWidget::QgsProjectionSelectionTreeWidget( QWidget *par
QgsProjectionSelectionTreeWidget::~QgsProjectionSelectionTreeWidget()
{
qDeleteAll( mLayers );
delete mPreviewBand;
delete mPreviewBand2;
delete mVertexMarker;
if ( !mPushProjectionToFront )
{
return;
@ -281,6 +315,20 @@ void QgsProjectionSelectionTreeWidget::setCrs( const QgsCoordinateReferenceSyste
}
}
void QgsProjectionSelectionTreeWidget::setPreviewRect( QgsRectangle rect )
{
mPreviewRect = rect;
mPreviewBand2->setToGeometry( QgsGeometry::fromRect( mPreviewRect ), nullptr );
mPreviewBand2->show();
mVertexMarker->setCenter( rect.center() );
mVertexMarker->show();
}
QgsRectangle QgsProjectionSelectionTreeWidget::previewRect()
{
return mPreviewRect;
}
// Returns the whole proj4 string for the selected projection node
QString QgsProjectionSelectionTreeWidget::selectedProj4String()
{
@ -439,11 +487,23 @@ void QgsProjectionSelectionTreeWidget::setShowNoProjection( bool show )
mCheckBoxNoProjection->setHidden( !show );
}
void QgsProjectionSelectionTreeWidget::setShowBoundsMap( bool show )
{
mShowMap = show;
mAreaCanvas->setVisible( show );
}
bool QgsProjectionSelectionTreeWidget::showNoProjection() const
{
return !mCheckBoxNoProjection->isHidden();
}
bool QgsProjectionSelectionTreeWidget::showBoundsMap() const
{
return mShowMap;
}
bool QgsProjectionSelectionTreeWidget::hasValidSelection() const
{
QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
@ -710,8 +770,8 @@ void QgsProjectionSelectionTreeWidget::lstCoordinateSystems_currentItemChanged(
// Found a real CRS
emit crsSelected();
teProjection->setText( selectedProj4String() );
teSelected->setText( selectedName() );
updateBoundsPreview();
QList<QTreeWidgetItem *> nodes = lstRecent->findItems( current->text( QgisCrsIdColumn ), Qt::MatchExactly, QgisCrsIdColumn );
if ( !nodes.isEmpty() )
@ -957,6 +1017,67 @@ long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch( const QString &sql
return srsId;
}
void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
{
sqlite3 *database = nullptr;
const char *tail = nullptr;
sqlite3_stmt *stmt = nullptr;
QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
return;
int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
if ( result )
{
QgsDebugMsg( QString( "Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
//no need for assert because user db may not have been created yet
return;
}
QString sql = QStringLiteral( "select west_bound_lon, north_bound_lat, east_bound_lon, south_bound_lat from tbl_srs "
"where srs_id=%2" )
.arg( lvi->text( QgisCrsIdColumn ) );
result = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
if ( result == SQLITE_OK )
{
if ( sqlite3_step( stmt ) == SQLITE_ROW )
{
double west = sqlite3_column_double( stmt, 0 );
double north = sqlite3_column_double( stmt, 1 );
double east = sqlite3_column_double( stmt, 2 );
double south = sqlite3_column_double( stmt, 3 );
QgsRectangle rect( west, north, east, south );
if ( !rect.isEmpty() )
{
mPreviewBand->setToGeometry( QgsGeometry::fromRect( rect ), nullptr );
mPreviewBand->setColor( QColor( 255, 0, 0, 65 ) );
mAreaCanvas->setExtent( rect );
mPreviewBand->show();
mAreaCanvas->zoomOut();
QString extentString = tr( "Extent: %1" ).arg( rect.toString( 2 ) );
QString proj4String = tr( "Proj4: %1" ).arg( selectedProj4String() );
teProjection->setText( extentString + "\n" + proj4String );
}
else
{
mPreviewBand->hide();
mAreaCanvas->zoomToFullExtent();
QString extentString = tr( "Extent: Extent not known" );
QString proj4String = tr( "Proj4: %1" ).arg( selectedProj4String() );
teProjection->setText( extentString + "\n" + proj4String );
}
}
}
// close the sqlite3 statement
sqlite3_finalize( stmt );
sqlite3_close( database );
}
QStringList QgsProjectionSelectionTreeWidget::authorities()
{
sqlite3 *database = nullptr;

View File

@ -20,6 +20,8 @@
#include "qgis_gui.h"
#include "qgscoordinatereferencesystem.h"
class QgsVertexMarker;
class QResizeEvent;
/**
@ -64,6 +66,13 @@ class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::
*/
void setShowNoProjection( bool show );
/**
* Sets whether to show the bounnds preview map.
* \see showBoundsMap()
* \since QGIS 3.0
*/
void setShowBoundsMap( bool show );
/**
* Returns whether the "no/invalid" projection option is shown. If this
* option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.
@ -72,6 +81,13 @@ class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::
*/
bool showNoProjection() const;
/**
* Returns whether the bounds preview map is shown.
* \since QGIS 3.0
* \see setShowBoundsMap()
*/
bool showBoundsMap() const;
/**
* Returns true if the current selection in the widget is a valid choice. Valid
* selections include any projection and also the "no/invalid projection" option
@ -89,6 +105,20 @@ class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::
*/
void setCrs( const QgsCoordinateReferenceSystem &crs );
/**
* Sets the initial "preview" rectangle for the bounds overview map.
* \since QGIS 3.0
* \see previewRect()
*/
void setPreviewRect( const QgsRectangle &rect );
/**
* The initial "preview" rectangle for the bounds overview map.
* \since QGIS 3.0
* \see previewRect()
*/
const QgsRectangle previewRect();
/**
* \brief filters this widget by the given CRSs
*
@ -251,8 +281,20 @@ class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::
//! Hide deprecated CRSes
void hideDeprecated( QTreeWidgetItem *item );
QgsRubberBand *mPreviewBand;
QgsRubberBand *mPreviewBand2;
QgsVertexMarker *mVertexMarker;
bool mShowMap = true;
QList<QgsMapLayer *> mLayers;
QgsRectangle mPreviewRect;
private slots:
//! get list of authorities
void updateBoundsPreview();
QStringList authorities();
//! Apply projection on double-click

View File

@ -26,6 +26,7 @@ QgsProjectionSelectionWidget::QgsProjectionSelectionWidget( QWidget *parent )
{
mDialog = new QgsProjectionSelectionDialog( this );
QHBoxLayout *layout = new QHBoxLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
layout->setSpacing( 0 );

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<height>635</height>
<width>578</width>
<height>654</height>
</rect>
</property>
<property name="sizePolicy">
@ -57,33 +57,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFilterLineEdit" name="leSearch"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Recently used coordinate reference systems</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
@ -245,34 +218,104 @@
</widget>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextEdit" name="teProjection">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFilterLineEdit" name="leSearch"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>90</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoBulletList</set>
</property>
<property name="readOnly">
<bool>true</bool>
<property name="text">
<string>Recently used coordinate reference systems</string>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QTextEdit" name="teProjection">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoBulletList</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QgsMapCanvas" name="mAreaCanvas" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>117</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777214</width>
<height>16777215</height>
</size>
</property>
<zorder>mExtentsLabel</zorder>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -295,6 +338,12 @@
<extends>QLineEdit</extends>
<header>qgsfilterlineedit.h</header>
</customwidget>
<customwidget>
<class>QgsMapCanvas</class>
<extends>QWidget</extends>
<header>qgsmapcanvas.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leSearch</tabstop>
@ -302,7 +351,6 @@
<tabstop>cbxHideDeprecated</tabstop>
<tabstop>lstCoordinateSystems</tabstop>
<tabstop>teSelected</tabstop>
<tabstop>teProjection</tabstop>
</tabstops>
<resources/>
<connections/>