I would write a bash script that starts with using ogrinfo.
Extract all relevant information from ogrinfo with sed, awk and similar tools.
Print the mapfile content of the fly from the bash script with a lot of printf
commands
Quick method in my opinion!
Here is a small extract from an example I did a couple of weeks ago:
#!/bin/sh
#
# Argument parsing depending on your needs.
#
# eg. KML_FILE is set from argument 1
# MAPFILE is argument 2
#
# Process EXTENT for the mapfile
#
shopt -s lastpipe
ogrinfo -ro $KML_FILE -al \
| grep Extent | egrep -o '[0-9.]+' | readarray BBOX
minx=`echo ${BBOX[0]} | tr -d '\n'`
miny=`echo ${BBOX[1]} | tr -d '\n'`
maxx=`echo ${BBOX[2]} | tr -d '\n'`
maxy=`echo ${BBOX[3]} | tr -d '\n'`
#
# Print header part of mapfile
#
printf "MAP\n" > ${MAPFILE}.map
printf " NAME %s\n" "$MAPFILE" >> ${MAPFILE}.map
printf " SIZE 1000 1000\n" >> ${MAPFILE}.map
printf " UNITS dd\n" >> ${MAPFILE}.map
printf " EXTENT %s %s %s %s\n" "${minx} ${miny} ${maxx} ${maxy}" >>
${MAPFILE}.map
….
…and the rest of the mapfile in the same manner.
/Lars S.
From: [email protected]
[mailto:[email protected]] On Behalf Of alok mathur
Sent: den 10 mars 2015 12:15
To: [email protected]
Subject: [mapserver-users] Best Practice
Hi ,
Could any one suggest me to how to create .map file from KML file. Are any
tools available.
My requirement is to take KML file as input create .map file corresponding to
that KML and provide changes on map so that it reflects on the fly.
--
Alok Mathur
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users