Skip to content

Commit 82e8ae3

Browse files
authored
Merge pull request #967 from geographika/mssql
Update mssql plugin page to mention CONFIG file
2 parents 0ec6fd2 + 549cb9a commit 82e8ae3

File tree

2 files changed

+48
-39
lines changed

2 files changed

+48
-39
lines changed

conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class WKTLexer(RegexLexer):
398398
r'LEFT|LINE|LL|LOCAL|LR|MEDIUM|METERS|MILES|MITER|MULTIPLE|MYGIS|MYSQL|NONE|'
399399
r'NORMAL|OFF|OGR|ON|ONE-TO-ONE|ONE-TO-MANY|ORACLESPATIAL|'
400400
r'PERCENTAGES|PIXMAP|PIXELS|POINT|POLYGON|POSTGIS|POSTGRESQL|'
401-
r'PLUGIN|QUERY|RASTER|RIGHT|ROUND|SDE|SELECTED|SIMPLE|SINGLE|'
401+
r'QUERY|RASTER|RIGHT|ROUND|SDE|SELECTED|SIMPLE|SINGLE|'
402402
r'SMALL|SQUARE|TINY|TRIANGLE|TRUE|TRUETYPE|UC|UL|UNION|UR|UV_ANGLE|UV_MINUS_ANGLE|UV_LENGTH|UV_LENGTH_2|UVRASTER|VECTOR|'
403403
r'WFS|WMS|ALPHA|'
404404
r'GIF|JPEG|JPG|PNG|WBMP|SWF|PDF|GTIFF|PC256|RGB|RGBA|INT16|FLOAT32|GD|'
@@ -424,7 +424,7 @@ class WKTLexer(RegexLexer):
424424
r'MINLENGTH|MINSIZE|MINSUBDIVIDE|MINTEMPLATE|MINWIDTH|NAME|OFFSET|OFFSITE|'
425425
r'OPACITY|OUTLINECOLOR|OUTLINEWIDTH|OUTPUTFORMAT|OVERLAYBACKGROUNDCOLOR|'
426426
r'OVERLAYCOLOR|OVERLAYMAXSIZE|OVERLAYMINSIZE|OVERLAYOUTLINECOLOR|'
427-
r'OVERLAYSIZE|OVERLAYSYMBOL|PARTIALS|PATTERN|POINTS|POLAROFFSET|POSITION|POSTLABELCACHE|'
427+
r'OVERLAYSIZE|OVERLAYSYMBOL|PARTIALS|PATTERN|PLUGIN|PLUGINS|POINTS|POLAROFFSET|POSITION|POSTLABELCACHE|'
428428
r'PRIORITY|PROCESSING|PROJECTION|QUERYFORMAT|QUERYMAP|RASTERLABEL|REFERENCE|REGION|'
429429
r'RELATIVETO|REQUIRES|RESOLUTION|SCALE|SCALEDENOM|SCALETOKEN|SHADOWCOLOR|SHADOWSIZE|'
430430
r'SHAPEPATH|SIZE|SIZEUNITS|STATUS|STYLE|STYLEITEM|SYMBOL|SYMBOLSCALE|'

en/input/vector/mssql.txt

+46-37
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MSSQL
1313
:Contact: jmckenna at gatewaygeomatics.com
1414
:Author: Seth Girvin
1515
:Contact: sethg at geographika.co.uk
16-
:Last Updated: 2021-05-05
16+
:Last Updated: 2024-09-22
1717

1818
.. contents::
1919
:depth: 4
@@ -32,17 +32,17 @@ columns, which is compiled as a plugin ("msplugin_mssql2008.dll").
3232

3333
More Information:
3434

35-
* `OGR MSSQL Spatial driver page <https://gdal.org/drivers/vector/mssqlspatial.html>`__ (describes the OGR MSSQL support)
36-
* `ogr2ogr application <https://gdal.org/programs/ogr2ogr.html>`__ (describes the ogr2ogr commandline application)
35+
* `OGR MSSQL Spatial driver page <https://gdal.org/en/latest/drivers/vector/mssqlspatial.html>`__ (describes the OGR MSSQL support)
36+
* `ogr2ogr application <https://gdal.org/en/latest/programs/ogr2ogr.html>`__ (describes the ogr2ogr commandline application)
3737
* :ref:`vector` (MapServer Vector Data Access Guide)
3838

3939
Creating Spatial Data Tables in MSSQL
4040
=====================================
4141

4242
There are several ways to create spatial data tables in MSSQL. You can easily upload existing data to an MSSQL
43-
table by using the `ogr2ogr <https://gdal.org/programs/ogr2ogr.html>`__
44-
commandline tool and the OGR's `MSSQL Spatial driver
45-
<https://gdal.org/drivers/vector/mssqlspatial.html>`__. Here is an example that uploads
43+
table by using the `ogr2ogr <https://gdal.org/en/latest/programs/ogr2ogr.html>`__
44+
command line tool and the OGR's `MSSQL Spatial driver
45+
<https://gdal.org/en/latest/drivers/vector/mssqlspatial.html>`__. Here is an example that uploads
4646
a shapefile (province.shp) into an MSSQL instance:
4747

4848
::
@@ -69,28 +69,28 @@ examples:
6969

7070
Server=55.55.55.55\SQLEXPRESS,1433;uid=a_user;pwd=a_password;
7171
database=a_database;Integrated Security=True
72-
72+
7373
If you don't specify Driver in the connection string, it uses the "SQL Server" driver (sqlsrv32.dll)
7474
which was last updated in 2010. To use a newer driver you can specify this in the connection string:
7575

7676
::
7777

7878
driver={ODBC Driver 17 for SQL Server};server=55.55.55.55\SQLEXPRESS,1433;uid=a_user;pwd=a_password;
7979
database=a_database;Integrated Security=False
80-
81-
The "SQL Server Native Client" drivers are also supported.
8280

83-
81+
The "SQL Server Native Client" drivers are also supported.
82+
83+
8484
OPTION 1: Connect Through OGR
8585
-----------------------------
8686

8787
GDAL/OGR (and therefore MapServer) can read spatial tables in MSSQL 2008 through the
88-
`MSSQLSpatial driver <https://gdal.org/drivers/vector/mssqlspatial.html>`__.
88+
`MSSQLSpatial driver <https://gdal.org/en/latest/drivers/vector/mssqlspatial.html>`__.
8989

9090
Verify Local Support for MSSQLSpatial
9191
*************************************
9292

93-
Use the command *ogrinfo --formats* to verify that your local GDAL is built with support for MSSQL;
93+
Use the command ``ogrinfo --formats`` to verify that your local GDAL is built with support for MSSQL;
9494
the response should contain "MSSQLSpatial" such as:
9595

9696
::
@@ -102,23 +102,23 @@ the response should contain "MSSQLSpatial" such as:
102102
...
103103
-> "MSSQLSpatial" (read/write)
104104
...
105-
105+
106106
Test OGR Connection Parameters
107107
******************************
108108

109-
Use the *ogrinfo* commandline utility to test your connection through the MSSQLSpatial driver, such as:
109+
Use the *ogrinfo* command line utility to test your connection through the MSSQLSpatial driver, such as:
110110

111111
::
112112

113113
ogrinfo "MSSQL:server=.\SQLEXPRESS;database=geo;trusted_connection=yes" province -summary
114-
114+
115115
Create MapServer Layer using CONNECTIONTYPE OGR
116116
***********************************************
117117

118118
Your layer should contain a CONNECTIONTYPE OGR statement, as well as a CONNECTION.
119119
The connection should also contact a "tables=" parameter, and also the name of the
120120
geometry column in brackets. You do not need to specify the DATA parameter unless you
121-
define an sql select statement starting with the 'WHERE' keyword. For example:
121+
define an SQL select statement starting with the 'WHERE' keyword. For example:
122122

123123
.. code-block:: mapfile
124124

@@ -142,9 +142,9 @@ define an sql select statement starting with the 'WHERE' keyword. For example:
142142
END
143143
PROCESSING 'CLOSE_CONNECTION=DEFER'
144144
END # layer
145-
146145

147-
.. NOTE::
146+
.. note::
147+
148148
The usual CONNECTIONTYPE terms 'using unique' and 'using srid' are not meaningful
149149
for the OGR driver in this case, as these parameters are automatically retrieved
150150
from the 'geometry_columns' metadata table.
@@ -154,6 +154,22 @@ define an sql select statement starting with the 'WHERE' keyword. For example:
154154
OPTION 2: Connect Through MapServer Plugin
155155
------------------------------------------
156156

157+
As of MapServer 8.0 plugins can only be used when referenced in the MapServer :ref:`CONFIG <config>`
158+
file. The ``PLUGINS`` section needs to contain a key - a name for the driver, and a the path to the DLL.
159+
For example:
160+
161+
.. code-block:: mapfile
162+
163+
CONFIG
164+
...
165+
PLUGINS
166+
"mssql" "C:\MapServer\bin\ms\plugins\mssql2008\msplugin_mssql2008.dll"
167+
END
168+
...
169+
170+
The key ``mssql`` can then be used in any Mapfiles to refer to this DLL. Controlling which DLLs are loaded by MapServer
171+
in the ``CONFIG`` file prevents Mapfiles from loading potentially dangerous DLLs.
172+
157173
Create MapServer Layer
158174
**********************
159175

@@ -167,32 +183,32 @@ configured to access MSSQL as follows:
167183
TYPE POLYGON
168184
STATUS DEFAULT
169185
CONNECTIONTYPE PLUGIN
170-
PLUGIN "msplugin_mssql2008.dll"
186+
PLUGIN "mssql"
171187
CONNECTION "Server=.\MSSQLSERVER2008;Database=Maps;Integrated Security=true"
172188
DATA "ogr_geometry from rivers USING UNIQUE ogr_fid USING SRID=4326"
173189
...
174190
END
175191

176192
The DATA parameter is used to perform the SQL select statement to
177-
access your table in MSSQL. The geometry column is required in the
178-
select statement; in the above example the ogr_geometry column is the
193+
access your table in MSSQL. The geometry column is required in the
194+
select statement; in the above example the ``ogr_geometry`` column is the
179195
geometry column in the rivers table. The table should also have an
180-
unique column (ogr_fid) which is provided for random access to the
196+
unique column (``ogr_fid``) which is provided for random access to the
181197
features in the feature query operations.
182198

183199
The DATA section should also contain the spatial reference id (SRID)
184200
of the features in the data table The SRID is used when specifying the
185201
search shapes during the intersect operations which should match with
186202
the SRID of the features otherwise no features are returned in a
187-
particular query. if you omit specifying the SRID value in the DATA
203+
particular query. If you omit specifying the SRID value in the DATA
188204
section the diver will use SRID=0 when defining the search shapes.
189205

190206
Selecting the Type of the Geometry Column
191207
*****************************************
192208

193209
For the geometry columns MSSQL supports 2 data types: "geometry" and
194-
"geography". By default the driver considers the type of the geometry
195-
column is "geometry". In case if the type of the geometry column is
210+
"geography". By default the driver considers the type of the geometry
211+
column is "geometry". In case if the type of the geometry column is
196212
"geography" we must specify the data type in the DATA section
197213
explicitly, like::
198214

@@ -205,19 +221,14 @@ On Windows platforms the DLLs needed by the program are searched for
205221
in the following order:
206222

207223
1) The directory from which the application loaded.
208-
209224
2) The current directory.
210-
211225
3) The system directory. Use the `GetSystemDirectory
212226
<http://msdn.microsoft.com/en-us/library/ms724373.aspx>`__ function
213227
to get the path of this directory.
214-
215228
4) The 16-bit system directory.
216-
217229
5) The Windows directory. Use the `GetWindowsDirectory
218230
<http://msdn.microsoft.com/en-us/library/ms724454.aspx>`__ function
219231
to get the path of this directory.
220-
221232
6) The directories that are listed in the PATH environment variable.
222233

223234
Binaries Containing the MSSQL Plugin
@@ -226,7 +237,7 @@ Binaries Containing the MSSQL Plugin
226237
Currently the following binary distributions contain
227238
msplugin_mssql2008.dll:
228239

229-
- `GISInternals <http://www.gisinternals.com>`__
240+
- `GISInternals <https://www.gisinternals.com/>`__
230241
- `MS4W <https://ms4w.com>`__
231242

232243
Using Spatial Indexes
@@ -237,16 +248,14 @@ be created to the geometry column which could easily be done with the
237248
OGR MSSQL Spatial driver like::
238249

239250
ogrinfo -sql "create spatial index on rivers"
240-
"MSSQL:server=.\MSSQLSERVER2008;database=Maps;
241-
Integrated Security=true"
242-
251+
"MSSQL:server=.\MSSQLSERVER2008;database=Maps;Integrated Security=true;"
252+
243253
In general we can safely rely on the query optimizer to select the
244-
most appropriate index in the sql query operations. In some cases -
254+
most appropriate index in the SQL query operations. In some cases -
245255
however - we should force the optimizer to use the spatial index by
246256
specifying the index hint in the DATA section like::
247257

248-
DATA "ogr_geometry from rivers using index ogr_geometry_sidx
249-
USING UNIQUE ogr_fid USING SRID=4326"
258+
DATA "ogr_geometry from rivers using index ogr_geometry_sidx USING UNIQUE ogr_fid USING SRID=4326"
250259

251260
Layer Processing Options
252261
------------------------

0 commit comments

Comments
 (0)