Page Properties | ||||||
---|---|---|---|---|---|---|
| ||||||
|
...
If Python 3.9 is not already installed:
download Python 3.9 from https://www.python.org/ftp/python/3.9.11/python-3.9.11-amd64.exe
right-click on the downloaded .exe file and ‘Run as Admin’ to install
Choose Custom Installation
When prompted for an install location, install to C:/Python39
Open the Windows command prompt and navigate to a suitable folder (normally
D:/Astun/Tools
)Run
C:/Python39/python -m venv mapsource-ogc
in that folder to create a Python virtual environment - this will keep the Python installation separate from other installations on the machineA
mapsource-ogc
folder will have been created inAstun/Tools
, with aScripts
folder below itIn the command prompt,
cd
to themapsource-ogc
folder, navigate to theScripts
folder, and runactivate.bat
to activate the environmentThe command prompt will now have a prefix
(mapsource-ogc)
to show that you are in the virtual environmentMake sure you are running a recent (18+) version of
pip
by runningpip install --upgrade pip
. To check which version of pip you are running, run the commandpip --version
Download the latest version wheel file (currently 1.5.9 10 -
mapsource_ogc-1.5.910-py2.py3-none-any.whl
) from the Astun FTP site (https://download.astuntechnology.com/public/ ) and place it in the new folder that has been created for the virtual environment (e.g.D:/Astun/Tools/mapsource-ogc
)Install the script in the virtual environment by running
pip install mapsource_ogc-1.5.810-py2.py3-none-any.whl --force-reinstall
, (using the correct file name for the current version)
...
Symbol definitions must be held in the symbols (.sym) file, not inline in the .map file - this should be implemented before the script is run. In addition. if the map file directly references a symbol that has an external file reference, such as in the code below, the reference will fail.
Code Block SYMBOL NAME "tree" TYPE PIXMAP IMAGE "D:/mapserver/shared/symbols/Legend/landuse_deciduous_green.png" END
SYMBOL elements in the .map file must have their values quoted, otherwise, the conversion will fail:
SYMBOL "circle"
notSYMBOL circle
A double backslash in the map file (for example IMAGEPATH "D:\mapserver\tmp\\" ) will cause the script to fail - this should be changed to a double slash before the script is run (IMAGEPATH "D:/mapserver/tmp//" )
A style which retrieves colour values from query will cause the script to fail. For example:
Code Block LAYER NAME "planning.mk_solid" STATUS OFF TYPE POLYGON INCLUDE "sdw.inc" DATA "wkb_geometry from (select *,replace (rgb_colour,',',' ') as mapservercolour from planning.mk_solid) as foo using unique ogc_fid using srid=27700" TOLERANCEUNITS PIXELS VALIDATION qstring '.' END OPACITY 50 CLASS NAME "" STYLE COLOR [mapservercolour] WIDTH 0 END END END
In the above example, we can see that the COLOR parameter is taking its value from the
[mapservercolour]
attribute. This configuration will produce the following error:Code Block File "D:\Astun\Tools\mapsource-ogc\lib\site-packages\maputils\xml_to_sld.py", line 45, in <genexpr> return "#" + "".join("{:02X}".format(int(a)) for a in colors) ValueError: invalid literal for int() with base 10: '['
The mapfile should be edited to amend this approach.
Known script issues
These issues are known, and will be fixed in a later version of the script.
If SQL in the .map file contains an escaped quote character, for example
where \"CaseFullRef\"
the backslash escape character is not currently removed, and so the layer will fail - this will need to be manually fixed in the Map Source, either in the SQL editor in Studio, or in the Map Source XML itself, so that the text readswhere "CaseFullRef"
If the SQL in the .map file contains a test for not null values
is not null
the test is incorrectly translated to!= null
in the generated Map Source - this will need to be manually reverted in the Map Source, either in the SQL editor in Studio, or in the Map Source XML itself
Other issues
These issues may cause layers to fail or be incorrectly converted - they can be fixed manually in the Map Source post conversion.
Queries containing an apostrophe in a text string (e.g. value='Children’s Centres') are correctly converted but iShare reports an error.
Some pattern-matching regular expression rules are not being correctly converted,
If Fields are specified in the Field List for a Layer but are not present in the database, the Layer will fail. Likewise, Fields used in expressions must be in a Field List.
If in Field Settings, Add link to field is checked, but Link using is not set, when the layer is converted to a Standard Layer, it fails to display.
If there is no ‘fallback’ class in the SLD, i.e. if only rules for specific values are set, MapServer creates a filter with incorrect syntax for any values with parentheses, so these values are omitted from the data returned. The fix is to add a fallback rule.
Labels for Point styles may be incorrectly placed, and in some cases, the Point style is not showing. The fix is to delete the SLD from the Advanced tab and recreate the Style – the color settings are retained, normally only the Label attribute setting is needed.
Having a
select
statement using double quotes for its query will cause MapServer to fail to draw the layers. For example:DATA "wkb_geometry from (select *, trim
("path_type")as footpath_type from landscape.public_row) as foo using unique ogc_fid using srid=27700"
the above will produce the following error in the MapServer logs:Code Block [Wed Jan 25 14:30:01 2023].739000 loadLayer(): Unknown identifier. Parsing error near (path_type):(line 2829)
In that case, removing the double quotes from the DATA attribute and replacing them with single will resolve the issue:DATA 'wkb_geometry from (select *, trim("path_type") as footpath_type from landscape.public_row) as foo using unique ogc_fid using srid=27700'
It is worth checking the rendering order of your layers after the conversion and rearranging it using Studio. Have in mind that for the Classic Layers, the rendering order is coming from the map file while for the OGC Layers, the order is coming from the Map Source.