Stave, you are right. Thank you very much! I add [shpxy precision="6"] then the ''coordinates" output correctely. <br><br><div class="gmail_quote">在 2012年4月18日 上午2:58,Lime, Steve D (DNR) <span dir="ltr"><<a href="mailto:Steve.Lime@state.mn.us">Steve.Lime@state.mn.us</a>></span>写道:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So the problem with the coordinates is they are truncated or ??? Not having the spec handy what would the correct output be? There are<br>
several arguments to the shpxy tag that will probably be of help. For example you might add:<br>
<br>
[shpxy precision="6"]<br>
<br>
Steve<br>
<div><div class="h5"><br>
-----Original Message-----<br>
From: <a href="mailto:mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</a> [mailto:<a href="mailto:mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</a>] On Behalf Of Li Quansheng<br>
Sent: Tuesday, April 17, 2012 11:18 AM<br>
To: <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
Subject: [mapserver-users] mapserver 5.6 CGI output GeoJSON format<br>
<br>
hi guys,<br>
I installed FGS 5.6.3 on my VM to do some studying, these days I want to add WFS layer to my applyaction via openlayers, and I want to do some WFS query to output GeoJSON, I do my best, now,there is one problem I can't figure out.<br>
my mapfile: (mapserver 5.6)<br>
....<br>
OUTPUTFORMAT<br>
NAME "geojson"<br>
DRIVER "TEMPLATE"<br>
MIMETYPE "application/json; subtype=geojson"<br>
FORMATOPTION "FILE=xj1JSON.tmpl"<br>
END<br>
...<br>
METADATA<br>
'ows_title' 'XJ-MAP' #OWS (OGC Web Services)<br>
'ows_onlineresource'<br>
'<a href="http://192.168.207.100/cgi-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map" target="_blank">http://192.168.207.100/cgi-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map</a>'<br>
'ows_srs' 'EPSG:4326'<br>
'wms_tile' 'xjmap'<br>
'wms_onlineresource'<br>
'<a href="http://192.168.207.100/cgi-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map" target="_blank">http://192.168.207.100/cgi-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map</a>'<br>
'wms_srs' 'EPSG:4326 EPSG:900913'<br>
"wfs_title" "xjmap"<br>
"wfs_onlineresource"<br>
"<a href="http://192.168.207.100/cgin-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map&" target="_blank">http://192.168.207.100/cgin-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map&</a>"<br>
"wfs_srs" "EPSG:4326 EPSG:900913" ## Recommended<br>
"wfs_abstract" "xjmap WFS service." ## Recommended<br>
"wfs_enable_request" "*" # necessary,"*" enables all requests<br>
"wfs_encoding" "UTF-8"<br>
END<br>
....<br>
LAYER<br>
NAME 'tielu'<br>
TYPE LINE<br>
DUMP true<br>
TEMPLATE fooOnlyForWMSGetFeatureInfo<br>
EXTENT 70.409351 33.963843 99.420299 49.549665 CONNECTIONTYPE postgis<br>
CONNECTION "host=localhost dbname=xj1 user=xxx password=xxx"<br>
PROCESSING "CLOSE_CONNECTION=DEFER"<br>
DATA "the_geom from tielu"<br>
METADATA<br>
'ows_title' 'tielu'<br>
"wfs_title" "tielu" ##REQUIRED<br>
"wfs_srs" "EPSG:4326" ## REQUIRED<br>
"wfs_featureid" "gid"<br>
#"wfs_getfeature_formatlist" "geojson" # mapserver 6.0 support<br>
"gml_include_items" "all" ## Optional (serves all attributes for layer)<br>
"gml_featureid" "gid" ## REQUIRED<br>
"wfs_enable_request" "*"<br>
END<br>
STATUS OFF<br>
TRANSPARENCY 100<br>
PROJECTION<br>
'proj=longlat'<br>
'datum=WGS84'<br>
'no_defs'<br>
END<br>
CLASS<br>
NAME 'tielu'<br>
STYLE<br>
WIDTH 0.91<br>
COLOR 164 229 51<br>
END<br>
END<br>
END<br>
....<br>
the GeoJson outputformat template file xj1JSON.tmpl // mapserver template [resultset layer=tielu] {<br>
"type": "FeatureCollection",<br>
"features": [<br>
[feature limit=-1 feature trimlast=","]<br>
{<br>
"type": "Feature",<br>
"id": "[gid]",<br>
"geometry": {<br>
"type": "MultiLineString",<br>
"coordinates": [<br>
"coordinates": [[[shpxy]]]<br>
]<br>
},<br>
"properties": {<br>
"gid": "[gid]",<br>
"type": "[type]",<br>
"name": "[name]"<br>
}<br>
},<br>
[/feature]<br>
]<br>
}<br>
[/resultset]<br>
<br>
I want to output the "tielu" multiline layer , I can success execute the http request, <a href="http://192.168.207.100/cgi-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map&layer=tielu&mode=nquery&qformat=geojson" target="_blank">http://192.168.207.100/cgi-bin/mapserv?map=/opt/fgs/www/htdocs/xj1/xj1.map&layer=tielu&mode=nquery&qformat=geojson</a><br>
, It seemed that all the GeoJSON output is perfect except the output coordinates of the colum the_geom.<br>
the output is as flowings:<br>
{<br>
"type": "FeatureCollection",<br>
"features": [<br>
{<br>
"type": "Feature",<br>
"id": "1",<br>
"geometry": {<br>
"type": "MultiLineString",<br>
"coordinates": [<br>
"coordinates": [[84,42 84,42 84,42 84,42 83,42 83,42 83,42 83,42<br>
83,42 83,42]] //there is sth wrong here!<br>
]<br>
},<br>
"properties": {<br>
"gid": "1",<br>
"type": "70",<br>
"name": "name111"<br>
}<br>
},<br>
....<br>
]<br>
}<br>
I think sth wrong in my template file about "coordinates":<br>
[[[shpxy]]], I do many google searching,try my best to correct the file,I try<br>
"coordinates": [[LONG], [LAT]] etc,<br>
, but I failed, Could anyone give me some advice, thank you very much!<br>
</div></div>_______________________________________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
<br>
<br>
</blockquote></div><br>