tl;dr;
Is it possible for MapServer to read GeoJSON file and serve it as a layer
Yes, the below requests use a GeoJSON input (taken from my example comment).
MapServer WFS output in GeoJSON with GeoJSON as input
MapServer WFS output in GML with GeoJSON as input
For configuring input you need in your map file LAYER:
CONNECTION "data/ows.json"
CONNECTIONTYPE OGR
For layer projection I used:
PROJECTION
# https://mapserver.org/mapfile/projection.html#projection
# The following syntax may be used in LAYERs that are OGR connections, shapefile layers or raster layers:
AUTO
END
I also have:
CLASSITEM "Status_1"
LABELITEM "Status_1"
METADATA
"GML_FEATUREID" "fid"
"GML_INCLUDE_ITEMS" "all"
"GML_TYPES" "auto"
"OWS_TITLE" "Energy generation status (2016)"
END
STATUS ON
TYPE POINT
and for outputting GeoJSON as part of a WFS, irrespective of what the input vector data is, you need something like:
MAP
OUTPUTFORMAT
NAME "JSON"
DRIVER "OGR/GEOJSON"
EXTENSION "json"
FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "LCO:COORDINATE_PRECISION=8"
FORMATOPTION "LCO:DESCRIPTION=This should be GeoJSON 2008; the projection may not be in CRS:84, but if not, there should be a crs: member telling you what projection has been used"
FORMATOPTION "LCO:NATIVE_DATA=YES"
FORMATOPTION "LCO:WRITE_BBOX=YES"
FORMATOPTION "STORAGE=stream"
MIMETYPE "application/json; subtype=geojson"
END
WEB
METADATA
"OWS_ABSTRACT" "This is a test web service"
"OWS_ACCESSCONSTRAINTS" ""
"WFS_enable_request" "*"
"OWS_FEES" "none"
"OWS_KEYWORDLIST" "test,testing,123"
"OWS_SERVICE_ONLINERESOURCE" ""
"OWS_TITLE" "Testing capabilities"
"WFS_GETFEATURE_FORMATLIST" "JSON"
END
END
LAYER
# your input vector data
END
...
END
and serve it as a layer
~ certainly MapServer can serve GeoJSON, it doesn't have to be the input, as a WFS output ~ here's an example ogc2.bgs.ac.uk/cgi-bin/UGA_ARGI/… Input in this example is a postgresql database