1

I am using Leaflet to work with the map. I have a WMS server: L.tileLayer.wms.

function setWMSLayer(theme) {
    if (!theme.includes("SeaChart_")) theme = "SeaChart_" + theme;
    const url = `http://${FLASK_HOST}/cgi-bin/mapserv?map=/var/www/s57demo/data/map/${theme}.map`;
    wmsLocal.setUrl(url);
    wmsLocal.setParams({
        layers: theme
    });
}

const wmsLocal = L.tileLayer.wms('', {
    noWrap: false
});

It uploads .map files with the configuration of my map layers. Each .map file looks something like this:

MAP
    NAME SeaChart_DAY_BLACKBACK
    SIZE 1000 1000
    UNITS dd
    EXTENT -180 -90 180 90
    MAXSIZE 32768
    # CONFIG "MS_OPENLAYERS_JS_URL" "http://localhost/LocalOpenLayers/OpenLayers-ms60.js"
    CONFIG "MS_ERRORFILE" "/tmp/SeaChart_DAY_BLACKBACK.log"
    DEBUG 5
    CONFIG "ON_MISSING_DATA" "LOG"
    #RESOLUTION 96
    #DEFRESOLUTION 96

    PROJECTION
         'init=epsg:4326'
    END

    IMAGETYPE png
    FONTSET './fonts/fontset.lst'
    SYMBOLSET "./symbols/symbols-day.map"
    OUTPUTFORMAT
        NAME 'AGG'
        DRIVER AGG/PNG
        IMAGEMODE RGB
    END

    SHAPEPATH "../chart"

    WEB
        IMAGEPATH '/tmp/'
        IMAGEURL '/tmp/'

        METADATA
          "ows_enable_request"   "*"
          'ows_title'           'SeaChart_DAY_BLACKBACK'
          # 'ows_onlineresource'  'http://localhost/cgi-bin/mapserv.fcgi?map=/app/output/map/SeaChart_DAY_BLACKBACK.map&'
          "wms_srs" "EPSG:4326 EPSG:3857 EPSG:2950 EPSG:2949 EPSG:32188 EPSG:32187 EPSG:42403 EPSG:3857 EPSG:3979"
          "wfs_srs" "EPSG:4326 EPSG:3857 EPSG:2950 EPSG:2949 EPSG:32188 EPSG:32187 EPSG:42403 EPSG:3857 EPSG:3979"
          "labelcache_map_edge_buffer" "10"
          "wms_bbox_extended" "true"
        END
    END

    #
    #   Dummy layer to create a layer group for the color mode
    #
    LAYER
        NAME "DAY_BLACKBACK"
        GROUP "default"
        TYPE POINT
        TRANSFORM FALSE
        STATUS ON
        FEATURE
            POINTS 1 1 END
        END
    END

    #INCLUDE_GSHHS_HERE

END # Map

I use MapServer to load map tiles at this path - http://${FLASK_HOST}/cgi-bin/mapserv?map=/var/www/s57demo/data/map/${theme}.map.

Leaflet uses 3857 by default.

I want to understand how I can switch the coordinate system. I understand that I can use the proj4.js and proj4leaflet.js plugins. I use them and understand how they work. But I'm not clear on how exactly I can switch my coordinate system. Additionally, I have my .map files, which also have their own projection parameters:

PROJECTION
    'init=epsg:4326'
END

I have read a lot of information on the internet about this, but everywhere the information is different and unclear to me. Can someone explain the most important points so that I understand how I can change the coordinate system?

6
  • 1
    Perhaps this link could help: stackoverflow.com/questions/57894197/…
    – Geo
    Commented Jul 30 at 13:58
  • You mean customize your own coordinate system? I just would like to use proj4.js and proj4leaflet.js plugins to switch to any EPSG. Only I don't understand how to do it specifically in my case)
    – bobr
    Commented Jul 30 at 14:13
  • 1
    For EPSG:4326 you don't need proj4.js. It's built in Leaflet. Just specify it as crs option when creating map with L.map method.
    – TomazicM
    Commented Jul 30 at 14:33
  • Yeah, I realize that. Lealfet has several built-in coordinate systems. But my goal is to switch also to EPSGs that Leaflet doesn't have.
    – bobr
    Commented Jul 30 at 14:38
  • There is no general rule, it depends on CRS and WMS. You can start here: gis.stackexchange.com/questions/307634/…
    – TomazicM
    Commented Jul 30 at 20:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.