[File] Advice on writing magic entry for SOSI map format?

Petter Reinholdtsen pere at hungry.com
Fri May 3 19:56:50 UTC 2019


Here is an improved draft to recognize SOSI files.  Still not sure how
to verify the file end with ".SLUTT", optionally with line endings (\n
or \r\n).  Also have no idea how to handle BOM at the start of the file,
except by failing to recognize files with a BOM at the start. :)


#------------------------------------------------------------------------------
# $File: $
# SOSI
# Summary: Systematic Organization of Spatial Information
# Long description: Norwegian text based map format
# File extension: .sos
# Full name:    Petter Reinholdtsen (pere at hungry.com)
# Reference: https://en.wikipedia.org/wiki/SOSI
#
# Example SOSI files available from
# https://trac.osgeo.org/gdal/ticket/3638
# https://nedlasting.geonorge.no/geonorge/Basisdata/N50Kartdata/SOSI/
# https://nedlasting.geonorge.no/geonorge/Samferdsel/Elveg/SOSI/
#
# Start with ".HODE" and end with ".SLUTT", might have BOM at the
# start and following ".HODE" near the start there is "\n..TEGNSETT "
# followed by the charset and "\n" or "\r\n", as well as
# "\n..SOSI-VERSJON " followed by the format version and "\n" or
# "\r\n".

0       string  .HODE           SOSI map data
>5      search  \n..SOSI-VERSJON
>>&1	string	x		\b, version %s
>5      search  \n..TEGNSETT
>>&1	string	x		\b, charset %s
!:mime application/vnd.sosi
!:ext sos
#-7      string  \n.SLUTT
#-8      string  \n.SLUTT\n
#-9      string  \n.SLUTT\r\n

-- 
Happy hacking
Petter Reinholdtsen


More information about the File mailing list