MapServer is a better GIS Engine than GeoServer (I. exploration of technical scheme)

Time:2022-5-31

Recently, I have made a comparison between MapServer and GeoServer. To be honest, if I want to do secondary development, I must be based on MapServer. If I just use it simply, I must first choose GeoServer. MapServer is based on C language and CGI mode. It is easy to wrap in other languages.

The main reason why MapServer is not well known to the public is that it has no visual operation interface, and its official website is difficult to use and read.

So in the future, I will invest in building a GIS Service Engine Based on MapServer. Of course, I may charge a fee, but the price will be very low.

Reference information:

MapServer official website

Ms4w version: 4.0.5

Ms4w download address

(the compilation process of MapServer is complicated. This time, we will not introduce the compilation process. Instead, we will directly use the relevant packages in the compiled ms4w to download the zip archive with data. Ms4w is the only compiled version of MapServer that can be maintained and used on windows. It is mainly based on Apache to implement CGI. In addition, it also integrates GDAL, proj and other GIS professional libraries.)

Ms4w_ 4.0.5 Zip unzipped file structure:

MapServer is a better GIS Engine than GeoServer (I. exploration of technical scheme)

Experimental environment: windows10

Node JS version:10.17.0

Node JS framework:EGG2.2.1

Research process:

By 1.30 in the evening, I was almost blind and finally found the key to the problem.

Some key points:

Unzip ms4w_ 4.0.5 Zip

Copy the contents of the ms4w\apache\cgi bin folder to your desired location

Copy the contents of the ms4w\apps\local-demo folder to your desired location

Modify local demo / local The contents of the map are as follows (mainly to comment out some things that will report errors, such as symbolset, fontset, project, imagepath, imageurl, font, etc.):

/*
 Description:  Simple map to display on MS4W localhost ( http://127.0.0.1 )
               Also configured for WMS service, and includes GeoJSON output
 Data source:  NaturalEarth dataset, in SpatiaLite format.
 Other notes:  Open this mapfile in Notepad++, and use the color syntax file
               from https://ms4w.com/trac/wiki/Notepad++MapServerStyle
 Author:       Jeff McKenna, GatewayGeo, [email protected]
 Last updated: 2020-11-24
*/
 
MAP
NAME "local-demo"
STATUS ON
SIZE 600 400
# SYMBOLSET "../etc/symbols.txt"
EXTENT -180 -90 180 90
UNITS DD
SHAPEPATH "./data"
IMAGECOLOR 255 255 255
# FONTSET "../etc/fonts.txt"
# PROJECTION
#   "init=epsg:4326"
# END  

WEB
  IMAGEPATH "/temp/"
  IMAGEURL "/temp/"
  METADATA
    "wms_title"             "MS4W Demo WMS Server"
    "wms_abstract"          "This demonstration server was setup by GatewayGeo (https://gatewaygeomatics.com/) and is powered by MS4W (https://ms4w.com/)."      
    "wms_onlineresource"    "http://127.0.0.1/cgi-bin/mapserv.exe?map=/ms4w/apps/local-demo/local.map"
    "wms_service_onlineresource" "https://gatewaygeomatics.com/"    
    "wms_contactperson"     "Jeff McKenna" 
    "wms_contactorganization" "GatewayGeo"
    "wms_contactposition"   "President"
    "wms_contactelectronicmailaddress" "[email protected]"
    "wms_srs"               "EPSG:4326 EPSG:3857 EPSG:4269"
    "wms_getfeatureinfo_formatlist" "text/plain,text/html,application/json,application/vnd.ogc.gml,gml"
    "wms_enable_request"    "*"
  END
END

OUTPUTFORMAT
  NAME "png"
  DRIVER AGG/PNG
  MIMETYPE "image/png"
  IMAGEMODE RGB
  EXTENSION "png"
  FORMATOPTION "GAMMA=0.75"
END

OUTPUTFORMAT
  NAME "application/json"
  DRIVER "OGR/GEOJSON"
  MIMETYPE "application/json"
  FORMATOPTION "FORM=SIMPLE"
  FORMATOPTION "STORAGE=memory"
END

/* Ocean */
LAYER
  NAME "ocean"
  METADATA
    "wms_title" "Ocean"
    "wms_include_items" "all"
    "gml_include_items" "all"
    "gml_featureid"     "ogc_fid"   
  END
  TYPE POLYGON
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "demo.db"
  DATA "ocean"
  # PROJECTION
  #   "init=epsg:4326"
  # END 
  CLASS
    NAME "Ocean"
    STYLE
      COLOR 134 204 249
    END
  END
  TEMPLATE "ttt.html"
END # layer

/* Countries */
LAYER
  NAME "countries"
  METADATA
    "wms_title"         "World Countries"
    "wms_include_items" "all"
    "gml_include_items" "all"
    "gml_featureid"     "ogc_fid"
  END
  TYPE POLYGON
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "demo.db"
  DATA "countries"
  # PROJECTION
  #   "init=epsg:4326"
  # END
  LABELITEM "name"
  CLASS
    NAME "World Countries"
    STYLE
      COLOR 200 200 200
      OUTLINECOLOR 0 0 0
      WIDTH 0.1
    END
    LABEL
      # FONT sans
      TYPE truetype
      POSITION AUTO     
      PARTIALS FALSE
      BUFFER 5
      SIZE 5 
      COLOR 75 75 75
      MINFEATURESIZE 10
    END     
  END
  TEMPLATE "ttt.html"  
END # layer

/* Lakes */
LAYER
  NAME "lakes"
  METADATA
    "wms_title" "World Lakes"
    "wms_include_items" "all"
    "gml_include_items" "all"
    "gml_featureid"     "ogc_fid"   
  END
  TYPE POLYGON
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "demo.db"
  DATA "lakes"
  # PROJECTION
  #   "init=epsg:4326"
  # END 
  CLASS
    NAME "Lakes"
    STYLE
      COLOR 153 204 255
    END
  END
  TEMPLATE "ttt.html"  
END # layer

/* Ocean labels */
LAYER
  NAME "ocean-labels"
  METADATA
    "wms_title" "Ocean Labels"
    "wms_include_items" "all"
    "gml_include_items" "all"
    "gml_featureid"     "ogc_fid"   
  END
  TYPE POLYGON
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "demo.db"
  DATA "marine_region_poly"
  # PROJECTION
  #   "init=epsg:4326"
  # END
  LABELITEM "name"
  CLASS
    NAME "Ocean Labels"
    LABEL
      COLOR  75 75 75
      # FONT sans-italic
      TYPE truetype
      SIZE 5
      POSITION AUTO      
      PARTIALS FALSE
      BUFFER 5
    END
    #MAXSCALEDENOM 50000000
  END
  TEMPLATE "ttt.html"  
END # layer

/* Places */
LAYER
  NAME "places"
  METADATA
    "wms_title" "Populated Places"
    "wms_include_items" "all"
    "gml_include_items" "all"
    "gml_featureid"     "ogc_fid"   
  END
  TYPE POINT
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "demo.db"
  DATA "places"
  # PROJECTION
  #   "init=epsg:4326"
  # END
  LABELITEM "name"
  CLASS
    NAME "Populated Places"
    SYMBOL "square"
    SIZE 4
    COLOR 150 150 150
    LABEL
      COLOR  75 75 75
      # FONT sans
      TYPE truetype
      SIZE 5
      POSITION AUTO      
      PARTIALS FALSE
      BUFFER 5
    END
    MAXSCALEDENOM 50000000
  END
  TEMPLATE "ttt.html"  
END # layer

END # Map File

Get sample URL request parameters:

Start ms4w and the browser opens:http://localhost/

Open F12, drag the default map, and get the request address in the network:

http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/local-demo/local.map&layers=ocean%20countries%20lakes%20ocean-labels%20places&mode=map&map_imagetype=png&mapext=-85.980848625+-78.768824625+94.319751375+41.431575375&imgext=-85.980848625+-78.768824625+94.319751375+41.431575375&map_size=600+400&imgx=300&imgy=200&imgxy=600+400

MapServer is a better GIS Engine than GeoServer (I. exploration of technical scheme)

If you need to make the coordinate system conversion without error, modify the following configuration. Font font is the same

Configure the coordinate system conversion parameters (it seems that you have forgotten whether this configuration is added in the.Map file or changed elsewhere. It is estimated that it is added by yourself)

CONFIG “PROJ_LIB” “D:\software\nginx-1.13.4\proj\nad”

Modify the request parameters and use the local command line to execute and output to the local file (to execute using CMD, you cannot use PowerShell, the reason is unknown). The command is as follows:

.\mapserv.exe -nh QUERY_STRING=”map=../mapconfig/local-demo/local.map&layers=ocean%20countries%20lakes%20ocean-labels%20places&mode=map&map_imagetype=png&mapext=75.2755005+24.56595675+120.3506505+54.61605675&imgext=75.2755005+24.56595675+120.3506505+54.61605675&map_size=600+400&imgx=300&imgy=200&imgxy=600+400″ >test.png

Add -nh to the local output to prevent the HTTP request header from being written to the file, resulting in the file being unreadable.

Epsg:4326 should be lowercase. It is case sensitive.

Local disk generated test Png picture, which can be opened, indicates that the test is successful.

Through comparison, it is found that the speed of outputting PNG files by MapServer is about three times that of MapServer in the case of 3million data.

How to use it systematically is a big problem.

GIS Engine Development

Recently, I packaged a GIS Engine with MapServer as an alternative to GeoServer, which is suitable for small and micro enterprises and individual users. Download address:

Mapserver-server.zip

Decompression password: 2234. I will improve it as planned in the future, and strive to be lightweight, easy to use, stable, high-performance and open source.

At the same time, I will provide services at a low price and sell the source code at a low price to ensure daily expenses.

Original address